//#---------------------------------------------------------- //# * Initialize //#---------------------------------------------------------- public UI_BattleGroup(Game_Group group, int fieldX, int fieldY) { _group = group; FIELD_X = fieldX; FIELD_Y = fieldY; Index = MinIndex; }
//#---------------------------------------------------------- //# * Can Add Reinforcements //#---------------------------------------------------------- public bool CanAddReinforcements(Game_Group group, int row) { foreach (int gridY in group.RowsWithUnits) { if (IsStartingRowOccupied(row + gridY, group.IsPlayerOwned)) return false; } return true; }
//#====================================================================================== //#---------------------------------------------------------- //# * Add Reinforcements //#---------------------------------------------------------- public void AddReinforcements(Game_Group group, int row) { // iterate through units in group and add each one foreach (Point2DEx pt in group.GetUnitPts()) { if (group.UnitIDs[pt.X, pt.Y] == -1) continue; // if grid doesn't contain a unit, next int offsetX = (group.IsPlayerOwned ? REINFORCEMENT_WIDTH - 1 - group.RightMostUnit + pt.X : ENEMY_REINFORCEMENT_START_X - group.LeftMostUnit + pt.X); int offsetY = row + pt.Y; _units[offsetX, offsetY] = group.CreateBattleUnit(pt.X, pt.Y); } }
//#---------------------------------------------------------- //# * Can Send Group //#---------------------------------------------------------- public override bool CanSendGroup(Game_Group group, int row) { if (_tick < _tickSendScript[_currentScript]) return false; // if not time yet if (!base.CanSendGroup(group, row)) return false; return true; }
//#---------------------------------------------------------- //# * Can Send Group //#---------------------------------------------------------- public virtual bool CanSendGroup(Game_Group group, int row) { if (group.PointValue > ReinforcementPts) return false; // enough points if (!_field.CanAddReinforcements(group, row)) return false; // can place on field return true; }
//#---------------------------------------------------------- //# * Send Group //#---------------------------------------------------------- public void SendGroup(Game_Group group, int row) { _field.AddReinforcements(group, row); ReinforcementPts -= group.PointValue; }
//#---------------------------------------------------------- //# * Initialize //#---------------------------------------------------------- public Game_BattleUnit(Data_Unit unit, Game_Group group, bool playerOwned, bool isVeteran = false) : base(unit, playerOwned, isVeteran) { _color = group.Color; }
public Game_Group Clone() { Game_Group clone = new Game_Group(_index, IsPlayerOwned); foreach (Point2DEx pt in GetUnitPts()) clone.UnitIDs[pt.X, pt.Y] = UnitIDs[pt.X, pt.Y]; return clone; }