public void setupHomebase(ref DataPool worldData, bool ai) { homebase = new Homebase(ref worldData, ai); ship = new Ship(ref worldData); trainingRegime = new List <ManagerProtocol.FacilityShortcut>(); setupTrainingRegime(); }
public void Check(Homebase h) //Homebase check for what vehicle needs to be built { if (h.BuildMiners == true && h.MiningTarget.GoldCount != 0) { MinerDesire = GetMinerDesireability(h) * MoneyToSpend(h, 'M'); } FighterDesire = GetFighterDesireability(h) * MoneyToSpend(h, 'F'); }
void Start() { inventory = new Inventory(); // FIXME: change from hardcoded to something better homebase = new Homebase(world.GetTileAt(world.Width - 1, (world.Height - 1) / 2)); //Debug.Log(homebase.tile.X +"_"+ homebase.tile.Y); PlaceHomebase(homebase); }
void Start() { gameOverPanel = transform.FindChild("GameOverPanel").GetComponent<CanvasGroup>(); player = FindObjectOfType<Player>(); homeBase = FindObjectOfType<Homebase>(); levelManager = FindObjectOfType<LevelManager>(); GUIItems = GameObject.FindGameObjectsWithTag("GUIItem"); }
// Start is called before the first frame update private void Awake() { if (Instance != null) { DestroyImmediate(gameObject); return; } Instance = this; DontDestroyOnLoad(gameObject); }
private float GetMinerDesireability(Homebase h) //Determine if a new miner needs to be built or not { float CurrentRatio = h.Miners.Count / h.MaxMiners; //Maintain a suitable ratio of miners to a max and wether fighters should be built if (CurrentRatio > 0.9) { return(0); } else if (CurrentRatio <= 0.7f) { return(1); } return(1 - CurrentRatio); //Get a desire based upon the remaining amount required; }
// Start is called before the first frame update void Initialise() { //Get references to components to speed up access AttachedVehicle = GetComponentInParent <Vehicle>(); SB = GetComponentInParent <SteeringBehaviours>(); AttachedVehicle.Parent = this; Homebase[] HBLIST = FindObjectsOfType <Homebase>(); if (HBLIST[0].Team != Team) { EnemyBase = HBLIST[0]; } CurrentState = new ScanState(); }
private float MoneyToSpend(Homebase h, char Type) //M is Miner, F is fighter { switch (Type) //Check which type needs to be built and determine if the required resources are available { case 'M': if (h.StoredResources >= h.MinerCost) { return(1); } break; case 'F': if (h.StoredResources >= h.FighterCost) { return(1); } break; } return(0); }
public override void Execute(StateObject s) { Homebase h = (Homebase)s; DesireabilityBrain Brain = new DesireabilityBrain(); if (h.Miners.Count == h.MaxMiners) //Put limits on whether these units can be built currently { h.BuildMiners = false; } else if (h.Miners.Count < h.MaxMiners) { h.BuildMiners = true; } if (h.Fighters.Count == h.MaxFighters) { h.BuildMiners = false; } else if (h.Fighters.Count < h.MaxFighters) { h.BuildMiners = true; } Brain.Check(h); //Based on the above conditions build units if the funds are available if (Brain.MinerDesire != 0 && Brain.MinerDesire > Brain.FighterDesire && h.BuildMiners == true) //Spawn the appropriate vehicle if it is currently desirable { h.SpawnMiner(); h.StoredResources -= h.MinerCost; } else if (Brain.FighterDesire != 0) { h.SpawnFighter(); h.StoredResources -= h.FighterCost; } }
private float GetFighterDesireability(Homebase h) //Decide if a fighter should be built currently { float CurrentRatio = h.Fighters.Count / h.MaxFighters; return(1 - CurrentRatio); //Get a desire based upon the remaining amount }
void PlaceHomebase(Homebase hb) { world.PlaceImmovable("Homebase", hb.tile); }
public Manager(JSONObject json) : base(JSONTemplates.ToVector2Int(json.GetField("age")), json.GetField("firstname").str, json.GetField("lastname").str, (int)json.GetField("townindex").i, (int)json.GetField("weight").i) { preference = (BoxerClass.Type)Enum.Parse(typeof(BoxerClass.Type), json.GetField("preference").str); boxerIndex = (int)json.GetField("boxerindex").i; record = new Record(json.GetField("record")); atSea = json.GetField("atsea").b; atTournament = json.GetField("attournament").b; homebase = new Homebase(json.GetField("homebase")); ship = new Ship(json.GetField("ship")); finance = new FinanceProtocol(json.GetField("finance")); currentBoxerELO = json.GetField("boxerelo").f; currentManagerELO = json.GetField("managerelo").f; tournamentCount = (int)json.GetField("tournamentsattended").i; tournamentPriority = (int)json.GetField("priority").i; currentRanking = (TournamentProtocol.Level)Enum.Parse(typeof(TournamentProtocol.Level), json.GetField("rank").str); trainingRegime = new List <ManagerProtocol.FacilityShortcut>(); foreach (JSONObject r in json.GetField("trainingregime").list) { trainingRegime.Add((ManagerProtocol.FacilityShortcut)Enum.Parse(typeof(ManagerProtocol.FacilityShortcut), r.str)); } archivedBoxerELO = new List <float>(); foreach (JSONObject r in json.GetField("archivedboxerelo").list) { archivedBoxerELO.Add(r.f); } archivedManagerELO = new List <float>(); foreach (JSONObject r in json.GetField("archivedmanagerelo").list) { archivedManagerELO.Add(r.f); } previousOpponents = new List <int>(); foreach (JSONObject r in json.GetField("previousopponents").list) { previousOpponents.Add((int)r.i); } consumables = new List <Consumable>(); foreach (JSONObject r in json.GetField("consumables").list) { consumables.Add(new Consumable(r)); } arms = new List <Arm>(); foreach (JSONObject r in json.GetField("arms").list) { arms.Add(new Arm(r)); } legs = new List <Legs>(); foreach (JSONObject r in json.GetField("legs").list) { legs.Add(new Legs(r)); } implants = new List <Implant>(); foreach (JSONObject r in json.GetField("implants").list) { implants.Add(new Implant(r)); } }