public IEnumerator UnitPreventsFurtherMovement() { MapIndex startTilePos = new MapIndex(1, 1); m_combatUnit.SetCurrentTile(m_mapGrid.GetTile(startTilePos)); Assert.True(m_mapGrid.GetTile(startTilePos).transform.childCount == 1); m_combatUnit.SetMovementLeft(0); m_player.SelectUnit(startTilePos); m_player.SelectUnit(new MapIndex(1, 10)); m_player.TurnStart(); m_player.TurnEnd(); Tile tile = m_combatUnit.GetCurrentTile(); Player player2 = GameObject.Instantiate(m_playerPrefab).GetComponent <Player>(); player2.Initialize(1, Color.blue, m_mapGrid); player2.SetResourceAmount("Gold", 10000); player2.AddUnitToPlayer(m_combatUnitPrefab, m_combatUnit.GetPath()[m_combatUnit.GetPath().Count - 1].GetTileID()); m_player.TurnStart(); m_player.TurnEnd(); Assert.True(tile == m_combatUnit.GetCurrentTile()); GameObject.Destroy(player2.gameObject); yield return(true); }
public void ProcessTurn() { //We attack the unit until it is killed evenif it means chasing it accross the map. if (m_targetObj != null && m_targetObj.tag == "CombatUnit") { Unit targetUnit = m_targetObj.GetComponent <Unit>(); Tile targetTile = targetUnit.GetCurrentTile(); m_unit.SetPath(m_playerAI.m_mapGrid.CreatePath(m_unit.GetCurrentTile(), targetTile, m_unit), targetTile); m_targetTile = targetTile; } else { switch (m_playerAI.GetUnitTactic()) { case UnitTactic.Attack: AttackCity(); break; case UnitTactic.Defend: DefendCity(); break; case UnitTactic.None: //We defend a city even if we do not have a tactic as there is nothing else to do. DefendCity(); break; default: break; } } }
public IEnumerator SettlerAndCombatInSameTile() { GameObject combatUnitPrefab = Resources.Load <GameObject>("Prefabs/UnitPrefabs/Scout"); m_player.AddUnitToPlayer(combatUnitPrefab, m_settlerUnit.GetCurrentTile().GetTileID()); CombatUnit combatUnit = m_player.GetUnits()[m_player.GetUnits().Count - 1].GetComponent <CombatUnit>(); Assert.True(m_settlerUnit.GetCurrentTile() == combatUnit.GetCurrentTile()); yield return(null); }