public void Combat_setupbattle() { Sector location = new Sector(sys, new System.Drawing.Point()); Empire emp = new Empire(); MockCombatant combatant = new MockCombatant(emp); testComObj = new MockCombatObject(combatant, new PointXd(), new PointXd(), 42, "SHP"); spinrate = new Compass(5, false); testComObj.maxRotate = spinrate; testComObj.cmbt_accel = new PointXd(0, 0, 0); testComObj.maxfowardThrust = 100; testComObj.maxStrafeThrust = (Fix16)0; testComObj.cmbt_mass = 100; ICombatant[] combatants = new ICombatant[] { combatant }; foreach (ISpaceObject ispobj in (combatants)) { location.Place(ispobj); } battle = new Battle_Space(location); battle.StartNodes.Add(testComObj); }
public void SlideObject(CombatObject targetObject) { Vector2 prevPos = targetObject.prevPos; Vector2 posDif = targetObject.pos - prevPos; if (Mathf.Abs(posDif.y) > Mathf.Abs(posDif.x)) { posDif.x = 0; } else if (Mathf.Abs(posDif.y) < Mathf.Abs(posDif.x)) { posDif.y = 0; } if (posDif.y != 0) { posDif.y /= Mathf.Abs(posDif.y); } if (posDif.x != 0) { posDif.x /= Mathf.Abs(posDif.x); } Vector2Int EndPos = targetObject.pos + new Vector2Int((int)posDif.x, (int)posDif.y); List <Vector2Int> potentialGridOccupations = targetObject.PotentialGridOccupation(EndPos); if (targetObject.AttemptPush(potentialGridOccupations, (int)posDif.x, (int)posDif.y, targetObject.LastMoveSpeed, 0)) { targetObject.MoveCharacterExecute(EndPos, targetObject.LastMoveSpeed, targetObject.LastMoveSpeed, CombatExecutor.characterGrid); } }
public static bool CanIMoveToTile(Vector2Int pos, CombatObject traveler) { int height_difference = CombatExecutor.gridHeight[pos.x, pos.y] - CombatExecutor.gridHeight[traveler.pos.x, traveler.pos.y]; if (height_difference > traveler.MaxJumpHeight || !isTravelTypeCompatible(pos, traveler)) { return(false); } return(true); }
public static bool isTravelTypeCompatible(Vector2Int pos, CombatObject traveler) { BlockTemplate block_info = CombatExecutor.blockGrid[pos.x, pos.y].GetComponent <BlockTemplate>(); if ((block_info.Walkable && traveler.CanWalk) || (block_info.Swimable && traveler.CanSwim) || (block_info.Flyable && traveler.CanFly)) { return(true); } return(false); }
public static bool isTravelTypeCompatibleList(List <Vector2Int> positions, CombatObject traveler) { foreach (Vector2Int pos in positions) { if (!isTravelTypeCompatible(pos, traveler)) { return(false); } } return(true); }
public bool AttemptPush(List <Vector2Int> pushTargets, int HorChange, int VerChange, float Speed, int pushStrength) { List <FighterClass> charactersToPush = new List <FighterClass>(); List <CombatObject> objectsToPush = new List <CombatObject>(); foreach (Vector2Int pushTarget in pushTargets) { if (!BattleMapProcesses.isThisOnTheGrid(pushTarget)) { return(false); } if (CombatExecutor.characterGrid[pushTarget.x, pushTarget.y] != null) { FighterClass characterToPush = CombatExecutor.characterGrid[pushTarget.x, pushTarget.y].GetComponent <FighterClass>(); if (!CombatExecutor.characterGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>().PushObjectCheck(HorChange, VerChange, Speed, pushStrength - 1)) { return(false); } if (!charactersToPush.Contains(characterToPush)) { objectsToPush.Add(characterToPush); } } if (CombatExecutor.objectGrid[pushTarget.x, pushTarget.y] != null) { if (!CombatExecutor.objectGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>().Passable) { CombatObject objectToPush = CombatExecutor.objectGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>(); if (!CombatExecutor.objectGrid[pushTarget.x, pushTarget.y].GetComponent <CombatObject>().PushObjectCheck(HorChange, VerChange, Speed, pushStrength - 1)) { return(false); } if (!objectsToPush.Contains(objectToPush)) { objectsToPush.Add(objectToPush); } } } } foreach (CombatObject characterToPush in charactersToPush) { characterToPush.MoveCharacterExecute(new Vector2Int(characterToPush.pos.x + HorChange, characterToPush.pos.y + VerChange), Speed, Speed, CombatExecutor.characterGrid); } foreach (CombatObject objectToPush in objectsToPush) { objectToPush.MoveCharacterExecute(new Vector2Int(objectToPush.pos.x + HorChange, objectToPush.pos.y + VerChange), Speed, Speed, CombatExecutor.objectGrid); } return(true); }
public void Combat_ReplayTest02() { setupEnvironment1(); battle.Start(); battle.Resolve(); CombatObject battlecomobj = battle.CombatObjects.ToArray()[0]; PointXd loc1 = new PointXd(battlecomobj.cmbt_loc); long diceit1 = battlecomobj.getDice().Iteration; int numenemies1 = battlecomobj.empire.ownships.Count(); battle.SetUpPieces(); //this should be replay setup now. PointXd loc2 = new PointXd(battlecomobj.cmbt_loc); long diceit2 = battlecomobj.getDice().Iteration; int numenemies2 = battlecomobj.empire.ownships.Count(); Assert.AreEqual(true, battle.IsReplay); Assert.AreNotEqual(loc1, loc2); Assert.AreNotEqual(diceit1, diceit2); Assert.AreNotEqual(numenemies1, numenemies2); }
public void SlideObject(CombatObject targetObject) { }