public SpawnUnitPlan(PlayerManager player, AntTypes type) { this.Player = player; this.PlanType = PlanTypes.CreateUnit; this.isLarva = type == AntTypes.Larva; this.Ants = new AntSwarm(player, type, 1); this.Delay = isLarva ? 2 : 1; }
public int GetFreeAnts(AntTypes type) { if (AntsInNest.ContainsKey(type)) { return(AntsInNest[type]); } else { return(0); } }
//sends ants from nest to the field public void ToTheField(AntTypes type, int quantity) { if (HasFreeAnts(type, quantity)) { AntsInNest[type] -= quantity; var swarm = new AntSwarm(Owner, type, quantity); AntsOnFields.Add(swarm); OnCompositionChanged?.Invoke(); } }
//adds ants from nowhere to the nest public void AntIncome(AntTypes type, int quantity) { if (AntsInNest.ContainsKey(type)) { AntsInNest[type] += quantity; } else { AntsInNest.Add(type, quantity); } FixOvergrow(); OnCompositionChanged?.Invoke(); }
public static IAnts GetAnts(object pars, AntTypes type) { switch (type) { case AntTypes.Rectangle: if (mRectangular == null) mRectangular = new RectAnts(); Point[] points = (Point[])pars; mRectangular.Start = points[0]; mRectangular.End = points[1]; return mRectangular; default: return null; } }
public void Add(AntTypes type, int quantity) { if (Ants.ContainsKey(type)) { Ants[type] += quantity; } else { Ants.Add(type, quantity); } AntCount += quantity; RecalcSpeed(); OnCompositionChanged?.Invoke(this); }
//removes ants from the nest to nowhere public void AntDecline(AntTypes type, int quantity) { if (AntsInNest.ContainsKey(type)) { AntsInNest[type] -= quantity; if (AntsInNest[type] < 0) { AntsInNest[type] = 0; } OnCompositionChanged?.Invoke(); } }
public void Remove(AntTypes type, int quantity) { if (Ants.ContainsKey(type)) { Ants[type] = Mathf.Max(Ants[type] - quantity, 0); AntCount = 0; foreach (var amount in Ants.Values) { AntCount += amount; } RecalcSpeed(); OnCompositionChanged?.Invoke(this); } }
/// <summary> /// Returns the ant of the specified type /// </summary> /// <param name="pars"></param> /// <param name="type"></param> /// <returns></returns> public static IAnts GetAnts(object pars, AntTypes type) { switch (type) { case AntTypes.Rectangle: if (mRectangular == null) { mRectangular = new RectAnts(); } Point[] points = (Point[])pars; mRectangular.Start = points[0]; mRectangular.End = points[1]; return(mRectangular); default: return(null); } }
public AntSwarm(PlayerManager owner, AntTypes type) : this(owner, type, 0) { }
public AntSwarm(PlayerManager owner, AntTypes type, int quantity) : this(owner) { _ants.Add(type, quantity); AntCount = quantity; RecalcSpeed(); }
public bool HasPlaceForAnts(AntTypes type, int quantity) { return(AntMaxCapacity[type] - GetFreeAnts(type) >= quantity); }
public bool HasFreeAnts(AntTypes type, int amount) { return(GetFreeAnts(type) >= amount); }
public NestAntCountData(AntTypes type, int count) { this.type.value = type.ToString().Localized(); this.count.value = count; this.max.value = GameplayManager.Instance.Player.Anter.AntMaxCapacity[type]; }