Commented resource and some little changes
This commit is contained in:
@@ -145,7 +145,7 @@ namespace NPlanet
|
||||
oPlanetModelClone.OrbitAngle = this.OrbitAngle;
|
||||
|
||||
// Complex datatypes need deep copy
|
||||
oPlanetModelClone.Resous = this.Resous.clone();
|
||||
oPlanetModelClone.Resous = this.Resous.Clone();
|
||||
// Deep clone missing, building not implemented yet
|
||||
oPlanetModelClone.Buildings = new List<NBuilding.IBuilding>();
|
||||
oPlanetModelClone.Position = new Vector3(this.Position.x, this.Position.y, 0);
|
||||
|
||||
@@ -17,8 +17,6 @@ public class GameManager : MonoBehaviour
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
* Clock reference, clock counts seconds until new day and calls @see UpdateGame() at new day
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PlayerValues
|
||||
{
|
||||
this.ID = id;
|
||||
|
||||
Resous = newResous.clone();
|
||||
Resous = newResous.Clone();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
8
Space4x/Assets/Scripts/Resource/Model.meta
Normal file
8
Space4x/Assets/Scripts/Resource/Model.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44a393b8b1d635f448bafe5ad2f4eb05
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
121
Space4x/Assets/Scripts/Resource/Model/Resources.cs
Normal file
121
Space4x/Assets/Scripts/Resource/Model/Resources.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Resource.Model
|
||||
*/
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NResources
|
||||
{
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class administrates resource values. Used by planet and player.
|
||||
*/
|
||||
public class Resources
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
/**
|
||||
* Money property of a player or planet.
|
||||
*/
|
||||
public int Money { get; set; }
|
||||
|
||||
/**
|
||||
* Science property of a player or planet.
|
||||
*/
|
||||
public int Science { get; set; }
|
||||
|
||||
/**
|
||||
* Power property of a player or planet.
|
||||
*/
|
||||
public int Power { get; set; }
|
||||
|
||||
/**
|
||||
* Food property of a player or planet.
|
||||
*/
|
||||
public int Food { get; set; }
|
||||
|
||||
/**
|
||||
* IndustrialCapacity property of a player or planet.
|
||||
*/
|
||||
public int IndustrialCapacity { get; set; }
|
||||
|
||||
/**
|
||||
* Population property of a player or planet.
|
||||
*/
|
||||
public int Population { get; set; }
|
||||
|
||||
/**
|
||||
* ActualFood property of a player or planet.
|
||||
*/
|
||||
public int ActualFood { get; set; }
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Creates resources with all values defined with 0.
|
||||
*/
|
||||
public Resources()
|
||||
{
|
||||
Money = 0;
|
||||
Science = 0;
|
||||
Power = 0;
|
||||
Food = 0;
|
||||
IndustrialCapacity = 0;
|
||||
Population = 0;
|
||||
ActualFood = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates resources with random values, indicated by startRange and endRange.
|
||||
*
|
||||
* @param startRange, minimum value a resource can have (included).
|
||||
* @param endRange, maximum value a resource can have (included because in function 1 is added).
|
||||
*/
|
||||
public Resources(int startRange, int endRange)
|
||||
{
|
||||
System.Random random = new System.Random();
|
||||
|
||||
endRange++;
|
||||
Money = random.Next(startRange, endRange);
|
||||
Science = random.Next(startRange, endRange);
|
||||
Power = random.Next(startRange, endRange);
|
||||
Food = random.Next(startRange, endRange);
|
||||
IndustrialCapacity = random.Next(startRange, endRange);
|
||||
|
||||
Population = 0;
|
||||
ActualFood = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones this object and returns clone.
|
||||
*/
|
||||
public Resources Clone()
|
||||
{
|
||||
Resources oClonedResources = new Resources();
|
||||
|
||||
oClonedResources.Money = this.Money;
|
||||
oClonedResources.Science = this.Science;
|
||||
oClonedResources.Power = this.Power;
|
||||
oClonedResources.Food = this.Food;
|
||||
oClonedResources.IndustrialCapacity = this.IndustrialCapacity;
|
||||
oClonedResources.Population = this.Population;
|
||||
oClonedResources.ActualFood = this.ActualFood;
|
||||
|
||||
return oClonedResources;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ResourceViewScript : MonoBehaviour
|
||||
{
|
||||
public Text FoodNumberText;
|
||||
public Text IndustryNumberText;
|
||||
public Text WealthNumberText;
|
||||
public Text ScienceNumberText;
|
||||
public Text MilitaryNumberText;
|
||||
public Text PopulationNumberText;
|
||||
public Text ActualFoodNumberText;
|
||||
|
||||
private GameModel oGameModel;
|
||||
|
||||
public void SetGameModel(GameModel oGameModel)
|
||||
{
|
||||
// Set own game model
|
||||
this.oGameModel = oGameModel;
|
||||
}
|
||||
|
||||
public void DailyUpdateView()
|
||||
{
|
||||
FoodNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Food.ToString();
|
||||
IndustryNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.IndustrialCapacity.ToString();
|
||||
WealthNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Money.ToString();
|
||||
ScienceNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Science.ToString();
|
||||
MilitaryNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Power.ToString();
|
||||
PopulationNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Population.ToString();
|
||||
ActualFoodNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.ActualFood.ToString();
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NResources
|
||||
{
|
||||
public class Resources
|
||||
{
|
||||
public int Money { get; set; }
|
||||
public int Science { get; set; }
|
||||
public int Power { get; set; }
|
||||
public int Food { get; set; }
|
||||
public int IndustrialCapacity { get; set; }
|
||||
public int Population { get; set; }
|
||||
public int ActualFood { get; set; }
|
||||
|
||||
public Resources()
|
||||
{
|
||||
Money = 0;
|
||||
Science = 0;
|
||||
Power = 0;
|
||||
Food = 0;
|
||||
IndustrialCapacity = 0;
|
||||
Population = 0;
|
||||
ActualFood = 0;
|
||||
}
|
||||
|
||||
public Resources(int startRange, int endRange)
|
||||
{
|
||||
System.Random random = new System.Random();
|
||||
|
||||
endRange++;
|
||||
Money = random.Next(startRange, endRange);
|
||||
Science = random.Next(startRange, endRange);
|
||||
Power = random.Next(startRange, endRange);
|
||||
Food = random.Next(startRange, endRange);
|
||||
IndustrialCapacity = random.Next(startRange, endRange);
|
||||
|
||||
Population = 0;
|
||||
ActualFood = 0;
|
||||
}
|
||||
|
||||
private Resources(int money, int science, int power, int food, int iC, int population, int actualFood)
|
||||
{
|
||||
this.Money = money;
|
||||
this.Science = science;
|
||||
this.Power = power;
|
||||
this.Food = food;
|
||||
this.IndustrialCapacity = iC;
|
||||
this.Population = population;
|
||||
this.ActualFood = actualFood;
|
||||
}
|
||||
|
||||
public Resources clone()
|
||||
{
|
||||
return new Resources(this.Money, this.Science, this.Power, this.Food, this.IndustrialCapacity, this.Population, this.ActualFood);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Space4x/Assets/Scripts/Resource/View.meta
Normal file
8
Space4x/Assets/Scripts/Resource/View.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f488def07a202240bdcaedbef822eaf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
96
Space4x/Assets/Scripts/Resource/View/ResourceViewScript.cs
Normal file
96
Space4x/Assets/Scripts/Resource/View/ResourceViewScript.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Resource.Model
|
||||
*/
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class administrates resources view of player info.
|
||||
*/
|
||||
public class ResourceViewScript : MonoBehaviour
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
/**
|
||||
* Reference to text of food at player info.
|
||||
*/
|
||||
public Text FoodNumberText;
|
||||
|
||||
/**
|
||||
* Reference to text of industrial capacity at player info.
|
||||
*/
|
||||
public Text IndustryNumberText;
|
||||
|
||||
/**
|
||||
* Reference to text of wealth at player info.
|
||||
*/
|
||||
public Text WealthNumberText;
|
||||
|
||||
/**
|
||||
* Reference to text of science at player info.
|
||||
*/
|
||||
public Text ScienceNumberText;
|
||||
|
||||
/**
|
||||
* Reference to text of military power at player info.
|
||||
*/
|
||||
public Text MilitaryNumberText;
|
||||
|
||||
/**
|
||||
* Reference to text of population at player info.
|
||||
*/
|
||||
public Text PopulationNumberText;
|
||||
|
||||
/**
|
||||
* Reference to text of actual food at player info.
|
||||
*/
|
||||
public Text ActualFoodNumberText;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
/**
|
||||
* Reference for game model.
|
||||
*/
|
||||
private GameModel oGameModel;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Sets game model reference.
|
||||
*
|
||||
* @param oGameModel, reference to game model.
|
||||
*/
|
||||
public void SetGameModel(GameModel oGameModel)
|
||||
{
|
||||
// Set own game model
|
||||
this.oGameModel = oGameModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called every day and updates the player info by fetching data from player resources.
|
||||
*/
|
||||
public void DailyUpdateView()
|
||||
{
|
||||
FoodNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Food.ToString();
|
||||
IndustryNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.IndustrialCapacity.ToString();
|
||||
WealthNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Money.ToString();
|
||||
ScienceNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Science.ToString();
|
||||
MilitaryNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Power.ToString();
|
||||
PopulationNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.Population.ToString();
|
||||
ActualFoodNumberText.text = oGameModel.PlayerModel.GetPlayerManagers()[0].PlayerAttributes.Resous.ActualFood.ToString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
}
|
||||
Reference in New Issue
Block a user