diff --git a/Space4x/Assets/Scripts/Galaxy/Controller/GalaxyController.cs b/Space4x/Assets/Scripts/Galaxy/Controller/GalaxyController.cs
index fa3a373..552af82 100644
--- a/Space4x/Assets/Scripts/Galaxy/Controller/GalaxyController.cs
+++ b/Space4x/Assets/Scripts/Galaxy/Controller/GalaxyController.cs
@@ -1,16 +1,49 @@
+/**
+ * @file
+ *
+ * @author Aaron Moser
+ *
+ * @package Assets.Scripts.Galaxy.Controller
+ */
namespace NGalaxy
{
+ /**
+ * @section DESCRIPTION
+ *
+ * @todo Class cares about communication of galaxy view and model.
+ *
+ * At the moment just instantiates a street system of solar systems at galaxy model and lets view display it.
+ */
public class GalaxyController
{
- private NGalaxy.GalaxyModelBuilder oGalaxyModelBuilder;
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Public values
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Private values
+
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Public functions
+
+ /**
+ * Constructor of galaxy controller, creates at the moment only a street solar system.
+ *
+ * @todo Add different maps to lobby, which players can choose from. Add parameter to this constructor that describes what kind of map was chosen.
+ *
+ * @param oGalaxyModel, reference to galaxy model.
+ * @param oGalaxyView, reference to galaxy view.
+ */
public GalaxyController(GalaxyModel oGalaxyModel, GalaxyViewScript oGalaxyView)
{
- oGalaxyModelBuilder = new NGalaxy.GalaxyModelBuilder();
+ NGalaxy.GalaxyModelBuilder oGalaxyModelBuilder = new NGalaxy.GalaxyModelBuilder();
+ // Create street solar system
oGalaxyModel.SolarSystemModels = oGalaxyModelBuilder.BuildStreetSystem(oGalaxyModel.SolarSystemCount);
oGalaxyView.DisplaySolarSystems();
}
+
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Private functions
}
}
\ No newline at end of file
diff --git a/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModel.cs b/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModel.cs
index 7f15da0..81fc584 100644
--- a/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModel.cs
+++ b/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModel.cs
@@ -1,16 +1,56 @@
+/**
+ * @file
+ *
+ * @author Aaron Moser
+ *
+ * @package Assets.Scripts.Galaxy.Model
+ */
namespace NGalaxy
{
+ /**
+ * @section DESCRIPTION
+ *
+ * Class containing definition of galaxy model.
+ * Galaxy model consists of solar system models.
+ */
public class GalaxyModel
{
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Public values
+
+ /**
+ * Count of solar system at galaxy.
+ */
public int SolarSystemCount;
+ /**
+ * Array with references to solar system models.
+ */
public SolarSystemModel[] SolarSystemModels;
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Private values
+
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Public functions
+
+ /**
+ * Constructor of galaxy model, sets only count of solar systems
+ */
public GalaxyModel()
{
this.SolarSystemCount = NewGameDataManager.Instance.NumberOfSolarSystems;
}
+ /**
+ * Searches for planet indicated by unique iPlanetID at the solar systems.
+ *
+ * @todo throw Exception if planet was not found, because this sholdn't be possible and returning null is not good.
+ *
+ * @param PlanetID, unique id of a planet to search for.
+ *
+ * @return Planet indicated by PlanetID or null if planet not found.
+ */
public NPlanet.PlanetModel FindPlanet(int PlanetID)
{
NPlanet.PlanetModel oPlanetToReturn = null;
@@ -27,6 +67,13 @@ namespace NGalaxy
return oPlanetToReturn;
}
+ /**
+ * Returns sum of industrial capacity of a solar system which belongs to the player indicated by iPlayerID.
+ *
+ * @param iPlayerID, id of player to check the amount of industrial capacity.
+ *
+ * @return Sum of industrial capacity of the player.
+ */
public int GetIndustrialCapacityOfSolarSystems(int iPlayerID)
{
int iIndustrialCapacitySum = 0;
@@ -37,6 +84,13 @@ namespace NGalaxy
return iIndustrialCapacitySum;
}
+ /**
+ * Returns sum of money of a solar system which belongs to the player indicated by iPlayerID.
+ *
+ * @param iPlayerID, id of player to check the amount of money.
+ *
+ * @return Sum of money of the player.
+ */
public int GetMoneyOfSolarSystems(int iPlayerID)
{
int iMoneySum = 0;
@@ -47,6 +101,13 @@ namespace NGalaxy
return iMoneySum;
}
+ /**
+ * Returns sum of science of a solar system which belongs to the player indicated by iPlayerID.
+ *
+ * @param iPlayerID, id of player to check the amount of science.
+ *
+ * @return Sum of science of the player.
+ */
public int GetScienceOfSolarSystems(int iPlayerID)
{
int iScienceSum = 0;
@@ -57,6 +118,13 @@ namespace NGalaxy
return iScienceSum;
}
+ /**
+ * Returns sum of power of a solar system which belongs to the player indicated by iPlayerID.
+ *
+ * @param iPlayerID, id of player to check the amount of power.
+ *
+ * @return Sum of power of the player.
+ */
public int GetPowerOfSolarSystems(int iPlayerID)
{
int iPowerSum = 0;
@@ -67,6 +135,13 @@ namespace NGalaxy
return iPowerSum;
}
+ /**
+ * Returns sum of food of a solar system which belongs to the player indicated by iPlayerID.
+ *
+ * @param iPlayerID, id of player to check the amount of food.
+ *
+ * @return Sum of food of the player.
+ */
public int GetFoodOfSolarSystems(int iPlayerID, int iFoodTechLevel)
{
int iFoodSum = 0;
@@ -77,6 +152,13 @@ namespace NGalaxy
return iFoodSum;
}
+ /**
+ * Returns sum of population of a solar system which belongs to the player indicated by iPlayerID.
+ *
+ * @param iPlayerID, id of player to check the amount of population.
+ *
+ * @return Sum of population of the player.
+ */
public int GetPopulationOfSolarSystems(int iPlayerID)
{
int iPopulationSum = 0;
@@ -87,6 +169,13 @@ namespace NGalaxy
return iPopulationSum;
}
+ /**
+ * Returns sum of actual food of a solar system which belongs to the player indicated by iPlayerID.
+ *
+ * @param iPlayerID, id of player to check the amount of actual food.
+ *
+ * @return Sum of actual food of the player.
+ */
public int GetActualFoodOfSolarSystems(int iPlayerID)
{
int iActualFoodSum = 0;
diff --git a/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModelBuilder.cs b/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModelBuilder.cs
index f11c17e..e723354 100644
--- a/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModelBuilder.cs
+++ b/Space4x/Assets/Scripts/Galaxy/Model/GalaxyModelBuilder.cs
@@ -1,13 +1,29 @@
+/**
+ * @file
+ *
+ * @author Aaron Moser
+ *
+ * @package Assets.Scripts.Galaxy.Model
+ */
using UnityEngine;
namespace NGalaxy
{
+ /**
+ * @section DESCRIPTION
+ *
+ * Class has functionality to build different galaxy layouts, instantiating solar systems and setting their positions
+ */
public class GalaxyModelBuilder
{
/**
+ * Builds street of solar systems at galaxy canvas.
+ *
+ * @todo split functionality of positioning information and other unrelated values.
*
- * @param iCountOfSolarSystems
- * @return SolarSystemModel[] models of solarsystem
+ * @param iCountOfSolarSystems, number of solar systems to create.
+ *
+ * @return SolarSystemModel[] models of solar systems, containing information of street system.
*/
public SolarSystemModel[] BuildStreetSystem(int iCountOfSolarSystems)
{
@@ -71,7 +87,9 @@ namespace NGalaxy
return SolarSystemModels;
}
- //TODO
+ /**
+ * @todo Build custom solar system
+ */
private void BuildSolarSystems(int iCountOfSolarSystems, int iCountOfPlayers, int[,] aaiPlayerArea)
{
int iNumberOfDistinctSolarSystems = iCountOfSolarSystems / iCountOfPlayers;
@@ -111,7 +129,9 @@ namespace NGalaxy
// Insert distinct planets and clones into each players area so each player has the same amount of resources
}
- //TODO
+ /**
+ * @todo Build custom solar system
+ */
private void Build4PlayerGalaxy(int iCountOfSolarSystems, int iCountOfPlayers)
{
// Depending on players divide grid so each player has one area.
diff --git a/Space4x/Assets/Scripts/Galaxy/Model/SolarSystemBuildHelper.cs b/Space4x/Assets/Scripts/Galaxy/Model/SolarSystemBuildHelper.cs
index a6b6086..107af64 100644
--- a/Space4x/Assets/Scripts/Galaxy/Model/SolarSystemBuildHelper.cs
+++ b/Space4x/Assets/Scripts/Galaxy/Model/SolarSystemBuildHelper.cs
@@ -1,11 +1,34 @@
+/**
+ * @file
+ *
+ * @author Aaron Moser
+ *
+ * @package Assets.Scripts.Galaxy.Model
+ */
using UnityEngine;
+/**
+ * @section DESCRIPTION
+ *
+ * Class supposed to help solar system builder with generating random maps, creating a two dimensional array of this class.
+ * Array should be like a grid at the galaxy canvas.
+ */
public class SolarSystemBuildHelper
{
+ /**
+ * Position at screen
+ */
public Vector2 Position;
+ /**
+ * True if this field is already occupied, so to roll another value to set the next solar system to.
+ */
public bool Occupied;
+ /**
+ * Constructor initializes position with 0, 0 and Occupied with false.
+ *
+ */
public SolarSystemBuildHelper()
{
Position = new Vector2(0, 0);
diff --git a/Space4x/Assets/Scripts/Galaxy/SolarSystem/Events/SolarSystemEventArgs.cs b/Space4x/Assets/Scripts/Galaxy/SolarSystem/Events/SolarSystemEventArgs.cs
index f77bac7..ac28344 100644
--- a/Space4x/Assets/Scripts/Galaxy/SolarSystem/Events/SolarSystemEventArgs.cs
+++ b/Space4x/Assets/Scripts/Galaxy/SolarSystem/Events/SolarSystemEventArgs.cs
@@ -10,15 +10,22 @@ namespace NSolarSystem
/**
* @section DESCRIPTION
*
- * Class .
+ * Class describes event arguments, which occur at galaxy level.
+ * If a solar system at galaxy view is clicked, this arguments are used to overhand the unique id of the solar system clicked.
*/
public class SolarSystemEventArgs
{
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
+ /**
+ * Property eSolarSystemEvent, describes the event occured @see ESolarSystemEvent.
+ */
public ESolarSystemEvent eSolarSystemEvent { get; set; }
+ /**
+ * Property SolarSystemID, unique id of clicked solar system.
+ */
public int SolarSystemID { get; set; }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -27,6 +34,12 @@ namespace NSolarSystem
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
+ /**
+ * Constructor of solar system event arguments. Sets attributes of this.
+ *
+ * @param eSolarSystemEvent, event that occured (at the moment only one event solar system clicked possible).
+ * @param iSolarSystemID, unique id of solar system clicked.
+ */
public SolarSystemEventArgs(ESolarSystemEvent eSolarSystemEvent, int iSolarSystemID)
{
this.eSolarSystemEvent = eSolarSystemEvent;
diff --git a/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewScript.cs b/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewScript.cs
index 55b3f17..5f1dc7c 100644
--- a/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewScript.cs
+++ b/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewScript.cs
@@ -1,40 +1,101 @@
+/**
+ * @file
+ *
+ * @author Aaron Moser
+ * @author Mohamad Kadou
+ *
+ * @package Assets.Scripts.Galaxy.View
+ */
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+/**
+ * @section DESCRIPTION
+ *
+ * Class cares about the galaxy view, the events, that can only occur on its level and the display of the solar system view bodies.
+ */
public class GalaxyViewScript : MonoBehaviour
{
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Public values
+
+ /**
+ * View game object of solar system level.
+ *
+ * InvisibleObjectsCanvas.GameView.GalaxyView.SolarSystemView
+ */
public SolarSystemViewScript oSolarSystemView;
+ /**
+ * Canvas reference containing galaxy ui.
+ *
+ * GalaxyCanvas
+ */
public GameObject GalaxyCanvas;
+ /**
+ * Canvas reference containing solar system ui.
+ *
+ * SolarSystemCanvas
+ */
public GameObject SolarSystemCanvas;
+ /**
+ * Canvas reference containing galaxy bodies ui.
+ *
+ * GalaxyCanvas.GalaxyBodysCanvas
+ */
public Canvas GalaxyBodysCanvas;
+ /**
+ * Reference to galaxy view spawner game object.
+ *
+ * GalaxyCanvas.GalaxyBodysCanvas.GalaxyViewSpawner
+ */
public GalaxyViewSpawnerScript GalaxyViewSpawner;
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Private values
+
+ /**
+ * Array for references to solar system views which will be instantiated @see DisplaySolarSystems().
+ */
private SolarSystemViewBody[] SolarSystemViewBodies;
+ /**
+ * Reference to a game model, set @see SetGameModel(GameModel oGameModel)
+ */
private GameModel oGameModel;
- ///
- /// Lets spawner instantiate solarsystemviewbodies.
- ///
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Public functions
+
+ /**
+ * Lets spawner instantiate solar system view bodies.
+ * Afterwards sets values of them.
+ * Also adds event listeners on click.
+ */
public void DisplaySolarSystems()
{
SolarSystemViewBodies = GalaxyViewSpawner.SpawnSolarSystems(oGameModel.GalaxyModel.SolarSystemCount);
+ SolarSystemModel[] aoSolarSystemModels = oGameModel.GalaxyModel.SolarSystemModels;
+
for (int i = 0; i < SolarSystemViewBodies.Length; i++)
{
- SolarSystemViewBodies[i].SolarSystemSprite = oGameModel.GalaxyModel.SolarSystemModels[i].SolarSystemSprite;
+ // Set solar system sprite
+ SolarSystemViewBodies[i].SolarSystemSprite = aoSolarSystemModels[i].SolarSystemSprite;
+ // Set position related attributes
SolarSystemViewBodies[i].transform.SetParent(GalaxyBodysCanvas.transform, false);
- SolarSystemViewBodies[i].transform.position = oGameModel.GalaxyModel.SolarSystemModels[i].Position;
+ SolarSystemViewBodies[i].transform.position = aoSolarSystemModels[i].Position;
SolarSystemViewBodies[i].transform.localScale = new Vector3(1, 1, 1);
- SolarSystemViewBodies[i].ID = oGameModel.GalaxyModel.SolarSystemModels[i].SolarSystemID;
+ // Set unique solar system id
+ SolarSystemViewBodies[i].ID = aoSolarSystemModels[i].SolarSystemID;
+ // Add event listeners, on click
int ID = SolarSystemViewBodies[i].ID;
SolarSystemViewBodies[i].onClick.AddListener(() => DisplaySolarSystem(ID));
SolarSystemViewBodies[i].onClick.AddListener(() => SetSolarSystemCanvasActive());
@@ -42,21 +103,11 @@ public class GalaxyViewScript : MonoBehaviour
}
}
- private void SetSolarSystemCanvasActive()
- {
- SolarSystemCanvas.SetActive(true);
- }
-
- private void SetGalaxyCanvasInactive()
- {
- GalaxyCanvas.SetActive(false);
- }
-
- private void DisplaySolarSystem(int iSolarSystemID)
- {
- NSolarSystem.SolarSystemController.SolarSystemPressedEvent(this, new NSolarSystem.SolarSystemEventArgs(ESolarSystemEvent.SolarSystemClicked, iSolarSystemID));
- }
-
+ /**
+ * Sets game model reference of this and children.
+ *
+ * @param oGameModel, reference to game model.
+ */
public void SetGameModel(GameModel oGameModel)
{
// Set own game model
@@ -65,4 +116,35 @@ public class GalaxyViewScript : MonoBehaviour
// Set sub views game model
oSolarSystemView.SetGameModel(oGameModel);
}
+
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ // Private functions
+
+ /**
+ * Sets solar system canvas active.
+ */
+ private void SetSolarSystemCanvasActive()
+ {
+ SolarSystemCanvas.SetActive(true);
+ }
+
+ /**
+ * Sets galaxy canvas inactive.
+ */
+ private void SetGalaxyCanvasInactive()
+ {
+ GalaxyCanvas.SetActive(false);
+ }
+
+ /**
+ * Triggers event of solar system controller, that solar system with unique id iSolarSystemID was clicked.
+ */
+ private void DisplaySolarSystem(int iSolarSystemID)
+ {
+ NSolarSystem.SolarSystemEventArgs oSolarSystemWasClickedWithID = new NSolarSystem.SolarSystemEventArgs(ESolarSystemEvent.SolarSystemClicked, iSolarSystemID);
+
+ NSolarSystem.SolarSystemController.SolarSystemPressedEvent(this, oSolarSystemWasClickedWithID);
+ }
+
+
}
diff --git a/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewSpawnerScript.cs b/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewSpawnerScript.cs
index 7943402..7ca1971 100644
--- a/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewSpawnerScript.cs
+++ b/Space4x/Assets/Scripts/Galaxy/View/GalaxyViewSpawnerScript.cs
@@ -1,19 +1,36 @@
+/**
+ * @file
+ *
+ * @author Mohamad Kadou
+ * @author Aaron Moser
+ *
+ * @package Assets.Scripts.Galaxy.View
+ */
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+/**
+ * @section DESCRIPTION
+ *
+ * Class contains functionality to instantiate a number of solar system view body prefabs.
+ */
public class GalaxyViewSpawnerScript : MonoBehaviour
{
- ///
- /// Prefab to instantiate.
- ///
+ /**
+ * Prefab reference to instantiate.
+ *
+ * Assets.PreFabs.SolarSystem
+ */
public SolarSystemViewBody SolarSystemViewBodyPrefab;
- ///
- /// Instantiates iCountOfSolarSystems PlanetViewBodies and returns the array reference.
- ///
- ///
- ///
+ /**
+ * Instantiates iCountOfSolarSystems PlanetViewBodies and returns the array reference.
+ *
+ * @param iCountOfSolarSystems, count of solar systems to instantiate.
+ *
+ * @return Array with solar system bodies references, which were instantiated.
+ */
public SolarSystemViewBody[] SpawnSolarSystems(int iCountOfSolarSystems)
{
SolarSystemViewBody[] aoSolarSystemViewBodies = new SolarSystemViewBody[iCountOfSolarSystems];