Exemplo n.º 1
0
 public void TearDown()
 {
     UnitTestsUtil.TearDownGameTest(ref game, ref map, ref players, ref gui);
     foreach (var unit in units)
     {
         if (unit != null)
         {
             Object.Destroy(unit.gameObject);
         }
     }
 }
Exemplo n.º 2
0
    public void SaveLoadTest()
    {
        // set up a game state
        Game.HumanPlayersCount = new List <int> {
            0, 1, 0, 1
        };
        game.Initialize();
        Game.HumanPlayersCount    = null;
        map.sectors[0].Unit       = InitUnit(2);
        map.sectors[0].Unit.Owner = players[2];
        map.sectors[0].Unit.LevelUp();
        map.sectors[0].Unit.LevelUp();
        int unitLevel = map.sectors[0].Unit.Level;

        map.sectors[0].Owner = players[2];
        map.sectors[1].Owner = players[1];

        // test saving
        SerializableGame memento = game.SaveToMemento();

        // clear game
        UnitTestsUtil.TearDownGameTest(ref game, ref map, ref players, ref gui);
        // re-init game to make it *fresh*
        UnitTestsUtil.SetupGameTest(out game, out map, out players, out gui);
        // test loading
        game.RestoreFromMemento(memento);

        // test if game restored properly
        Assert.That(players[0].IsHuman);
        Assert.That(players[1].IsHuman, Is.False);
        Assert.That(players[2].IsHuman);
        Assert.That(players[3].IsHuman, Is.False);
        Assert.That(map.sectors[0].Unit, Is.Not.Null);
        Assert.That(map.sectors[0].Unit.Owner, Is.EqualTo(players[2]));
        Assert.That(map.sectors[0].Unit.Level, Is.EqualTo(unitLevel));
        Assert.That(map.sectors[1].Owner, Is.EqualTo(players[1]));
    }
Exemplo n.º 3
0
 public void TearDown()
 {
     UnitTestsUtil.TearDownGameTest(ref game, ref map, ref players, ref gui);
 }