123 lines
4.4 KiB
C#
123 lines
4.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.UI;
|
|
using UnityEngine;
|
|
|
|
public class PlayerManager
|
|
{
|
|
// Contains all star systems of player
|
|
//private List<GameObject> starSystems = new List<GameObject>();
|
|
|
|
// Contains all fleets of player
|
|
//private List<GameObject> fleets = new List<GameObject>();
|
|
|
|
private ScienceManager _scienceManager;
|
|
public static int PlayerID = 1;
|
|
|
|
public int ScienceAcumulated; // this int has to be moved to player manager later
|
|
|
|
public enum PlayerColor
|
|
{
|
|
None,
|
|
Red,
|
|
Blue,
|
|
Green,
|
|
Yellow
|
|
}
|
|
|
|
public PlayerColor PlayerColor2
|
|
{
|
|
get
|
|
{
|
|
return _playerColor;
|
|
}
|
|
set
|
|
{
|
|
_playerColor = value;
|
|
}
|
|
}
|
|
|
|
private PlayerColor _playerColor;
|
|
|
|
|
|
// Player values
|
|
public PlayerValues PlayerAttributes
|
|
{
|
|
get
|
|
{
|
|
if (_playerAttributes == null)
|
|
{
|
|
_playerAttributes = new PlayerValues();
|
|
}
|
|
return new PlayerValues();
|
|
}
|
|
set
|
|
{
|
|
_playerAttributes = value;
|
|
}
|
|
}
|
|
|
|
public PlayerValues _playerAttributes;
|
|
|
|
public PlayerManager(ScienceManager sm)
|
|
{
|
|
this._scienceManager = sm;
|
|
this._playerAttributes = new PlayerValues();
|
|
this._playerAttributes.id = PlayerID;
|
|
PlayerID++;
|
|
}
|
|
|
|
// Called by clock over game manager, once per day
|
|
public void simulateDay()
|
|
{
|
|
if (GameManager.SolarSystems != null)
|
|
{
|
|
for (int i = 0; i < GameUI.PlayersNumber; i++)
|
|
{
|
|
if (GameManager.SolarSystems[i].GetComponent<SolarSystemManager>() != null)
|
|
{
|
|
int playerID = this._playerAttributes.id;
|
|
_scienceManager.UpdateScience(this._playerAttributes.science);
|
|
this._playerAttributes.science = _scienceManager.PublicScienceAcumulated;
|
|
|
|
this._playerAttributes.industrialCapacity += GameManager.SolarSystems[i].GetComponent<SolarSystemManager>().GetIndustrialCapacity(playerID) * _scienceManager.techs[0].Level;
|
|
this._playerAttributes.money += GameManager.SolarSystems[i].GetComponent<SolarSystemManager>().GetMoney(playerID) * _scienceManager.techs[1].Level;
|
|
this._playerAttributes.science += GameManager.SolarSystems[i].GetComponent<SolarSystemManager>().GetScience(playerID) * _scienceManager.techs[2].Level;
|
|
|
|
GameManager.SolarSystems[i].GetComponent<SolarSystemManager>().UpdateFood(playerID, _scienceManager.techs[3].Level);
|
|
this._playerAttributes.food += GameManager.SolarSystems[i].GetComponent<SolarSystemManager>().GetFood(playerID);
|
|
this._playerAttributes.population += GameManager.SolarSystems[i].GetComponent<SolarSystemManager>().GetPopulation(playerID);
|
|
this._playerAttributes.actualFood += GameManager.SolarSystems[i].GetComponent<SolarSystemManager>().GetActualFood(playerID);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
//if (starSystems != null)
|
|
//{
|
|
// Add resources for each part of each starSystem which belongs to this player
|
|
//foreach (var starSystem in starSystems)
|
|
//{
|
|
// int playerID = this._playerAttributes.id;
|
|
// // StarSystem.getComponent<Script>().getMoney();
|
|
// this._playerAttributes.money += (1 + ScienceManager.repeatableWealth) * ((StarSystem)starSystem).getMoney(playerID);
|
|
|
|
// this._playerAttributes.science += ((StarSystem)starSystem).getScience(playerID);
|
|
// this._playerAttributes.power += ((StarSystem)starSystem).getPower(playerID);
|
|
// this._playerAttributes.food += ((StarSystem)starSystem).getFood(playerID);
|
|
// this._playerAttributes.industrialCapacity += ((StarSystem)starSystem).getIC(playerID);
|
|
//this._playerAttributes.science += 5 * _scienceManager.techs[2].Level;
|
|
//_scienceManager.UpdateScience(this._playerAttributes.science);
|
|
//this._playerAttributes.science = _scienceManager.PublicScienceAcumulated;
|
|
|
|
}
|
|
|
|
// Deletes overhanded referrence from fleets list
|
|
// If not null
|
|
//public void deleteFleet(ref GameObject fleet)
|
|
//{
|
|
// this.fleets.Remove(fleet);
|
|
//}
|
|
}
|