public static bool CheckExecutable(PlayerManager player, AbCellData target, AntSwarm swarm) { return(player.Anter.HasFreeAnts(swarm) && swarm.AntCount > 0 && player.Anter.CalculateFightPower(swarm) >= 3 && MapManager.Instance.GetPath(player.Nest, target).Count > 0); }
public static bool CheckExecutable(PlayerManager player, AbCellData data, AntSwarm ants) { return(player.Anter.HasFreeAnts(ants) && player.Anter.CalculateFightPower(ants) > 0 && !(data as EnviromentCellData).IsOccupied && (data as EnviromentCellData).IsBugged); }
public override void Reset(AbCellData data) { base.Reset(data); this.Data = data as NestCellData; UpdateInfo(); }
public ScoutPlan(PlayerManager player, AbCellData target, AntSwarm swarm) { this.Player = player; this.PlanType = PlanTypes.Scout; this.TargetCell = target; this.Ants = swarm; this.Delay = 1; this.Ants.Position = Player.Nest; }
public GatherPlan(PlayerManager player, AbCellData target, AntSwarm ants) { this.Player = player; this.PlanType = PlanTypes.Gather; this.Ants = ants; this.TargetCell = target; this.Delay = 1; this.Ants.Position = Player.Nest; }
public override void UpdateInfo(AbCellData data = null) { if (data != null && data != this.Data) { return; } avatarColor.value = new Color32(56, 10, 10, 255); state.value = (GameplayManager.Instance.Player.Nest == this.Data) ? "Your".Localized() : "Enemy".Localized(); value.value = "Nest".Localized(); }
public void OnCellClick(AbCellData cellData) { if (cellData is NestCellData) { var data = cellData as NestCellData; //todo: get player? if (data == GameplayManager.Instance.Player.Nest) { MapManager.Instance.Hide(); WindowManagerUT.Instance.OpenNewPanel <NestPanel>(); } else { // enemy nest. attack options. } } else { var data = cellData as EnviromentCellData; if (data.IsAllyArmy) { if (selectedSwarm != data.Occupant) { UpdatePath(false); selectedSwarm = data.Occupant; UpdatePath(true); return; } } if (selectedSwarm != null) { var selectedPlan = GameplayManager.Instance.Player.Planer.Plans.Find(x => x.Ants == selectedSwarm); if (selectedPlan != null && selectedPlan.TargetCell == data) { UpdatePath(false); selectedPlan.Cancel(); return; } } UpdatePath(false); if (!data.isExplored) { //show gather popup var types = new List <AntTypes> { AntTypes.Worker, AntTypes.Gatherer, AntTypes.Builder, AntTypes.Warrior, AntTypes.Scout, AntTypes.Stopper, }; if (GameplayManager.Instance.Player.Planer.CheckCell(data)) { var actionPanel = WindowManagerUT.Instance.OpenNewPanel <ForageActionPanel>(WindowCloseModes.CloseNothing); System.Func <AntSwarm, bool> check = (s) => { return(ScoutPlan.CheckExecutable(GameplayManager.Instance.Player, cellData, s)); }; actionPanel.SetParameters(types, AntTypes.Worker, 3, check); actionPanel.OnSend = (swarm => { var plan = new ScoutPlan(GameplayManager.Instance.Player, data, swarm); GameplayManager.Instance.Player.Planer.TryToAddPlan(plan); }); } } else if (data.IsEmpty) { //show smth like "you can't do a shit here" message } else if (data.IsAllyArmy) { //show ally popup; } else if (data.IsEnemyArmy) { //show enemy popup; } else if (data.IsGatherable) { //show gather popup var types = new List <AntTypes> { AntTypes.Worker, AntTypes.Gatherer, AntTypes.Builder, AntTypes.Warrior, AntTypes.Scout, AntTypes.Stopper, }; if (GameplayManager.Instance.Player.Planer.CheckCell(data)) { var actionPanel = WindowManagerUT.Instance.OpenNewPanel <ForageActionPanel>(WindowCloseModes.CloseNothing); System.Func <AntSwarm, bool> check = (s) => { return(GatherPlan.CheckExecutable(GameplayManager.Instance.Player, s)); }; actionPanel.SetParameters(types, AntTypes.Worker, 10, check); actionPanel.OnSend = (swarm => { var plan = new GatherPlan(GameplayManager.Instance.Player, data, swarm); GameplayManager.Instance.Player.Planer.TryToAddPlan(plan); }); } } else if (data.IsBugged) { //show fight popup var types = new List <AntTypes> { AntTypes.Warrior, AntTypes.Scout, AntTypes.Stopper, }; if (GameplayManager.Instance.Player.Planer.CheckCell(data)) { var actionPanel = WindowManagerUT.Instance.OpenNewPanel <ForageActionPanel>(WindowCloseModes.CloseNothing); System.Func <AntSwarm, bool> check = (s) => { return(HuntPlan.CheckExecutable(GameplayManager.Instance.Player, data, s)); }; actionPanel.SetParameters(types, AntTypes.Warrior, 5, check); actionPanel.OnSend = (swarm => { var plan = new HuntPlan(GameplayManager.Instance.Player, data, swarm); GameplayManager.Instance.Player.Planer.TryToAddPlan(plan); }); } } } }
public abstract void UpdateInfo(AbCellData data = null);
public virtual void Reset(AbCellData data) { Data = data; }
public override void UpdateInfo(AbCellData data = null) { if (data != null && data != this.Data) { return; } if (this.Data.isExplored) { if (Data.IsBugged) { avatarColor.value = new Color32(200, 39, 39, 255); state.value = Data.Bug.ToString().Localized(); value.value = "Count".Localized() + ": " + Data.BugCount; } else if (Data.IsGatherable) { switch (Data.Source.Type) { case SourceTypes.FlimsyMeat: state.value = "Meat".Localized(); value.value = Data.Source.Residual.ToString(); avatarColor.value = new Color32(210, 210, 5, 255); break; case SourceTypes.FlimsyFruit: state.value = "Fruits".Localized(); value.value = Data.Source.Residual.ToString(); avatarColor.value = new Color32(17, 97, 17, 255); break; case SourceTypes.SolidMeat: state.value = "Meat".Localized(); value.value = "[" + (Data.Source.Size - Data.Source.Gathered) + "/" + Data.Source.Size + "]"; avatarColor.value = new Color32(236, 150, 10, 255); break; case SourceTypes.SolidFruit: state.value = "Fruits".Localized(); value.value = "[" + (Data.Source.Size - Data.Source.Gathered) + "/" + Data.Source.Size + "]"; avatarColor.value = new Color32(30, 200, 30, 255); break; default: break; } } else { avatarColor.value = Color.white; state.value = "Empty".Localized(); value.value = string.Empty; } } else { avatarColor.value = new Color32(200, 200, 200, 255); state.value = "Explore".Localized(); value.value = string.Empty; } }
public List <Vector3Int> GetPath(AbCellData start, AbCellData finish) { var path = AStar.FindPath(start, finish).ConvertAll <Vector3Int>(x => x.FieldPosition); return(path); }
public bool CheckCell(AbCellData cell) { return(cell == null || !Plans.Exists(x => x.TargetCell == cell && x.TargetCell != x.Player.Nest)); }