Commented resource and some little changes

This commit is contained in:
Aaron Moser
2023-07-23 11:43:54 +02:00
parent e1754673fb
commit 3ef4abc67f
16 changed files with 3686 additions and 6970 deletions

View File

@@ -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);

View File

@@ -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
*/

View File

@@ -57,7 +57,7 @@ public class PlayerValues
{
this.ID = id;
Resous = newResous.clone();
Resous = newResous.Clone();
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 44a393b8b1d635f448bafe5ad2f4eb05
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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
}
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7f488def07a202240bdcaedbef822eaf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -320,8 +320,8 @@ MonoBehaviour:
y: 0
width: 393
height: 947
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 20}
m_Panes:
- {fileID: 20}
@@ -466,7 +466,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: ecf9ffff
m_ExpandedIDs: fef9ffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -1154,7 +1154,7 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/Scripts/Research/View
- Assets/Scripts/Research/Model
m_Globs: []
m_OriginalText:
m_ImportLogFlags: 0
@@ -1162,16 +1162,16 @@ MonoBehaviour:
m_ViewMode: 1
m_StartGridSize: 42
m_LastFolders:
- Assets/Scripts/Research/View
- Assets/Scripts/Research/Model
m_LastFoldersGridSize: 42
m_LastProjectPath: C:\Users\Soot\source\repos\Space4xUeberarbeitet\Space4x
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 493}
m_SelectedIDs: b6740000
m_LastClickedID: 29878
m_ExpandedIDs: 00000000be720000c0720000c2720000c4720000c6720000c8720000ca720000cc7200007674000000ca9a3b
m_SelectedIDs: b2740000
m_LastClickedID: 29874
m_ExpandedIDs: 00000000bc720000be720000c0720000c2720000c4720000c6720000c8720000ca72000074740000b674000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -1199,7 +1199,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 00000000be720000c0720000c2720000c4720000c6720000c8720000ca720000cc720000
m_ExpandedIDs: 00000000bc720000be720000c0720000c2720000c4720000c6720000c8720000ca720000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: