Example #1
0
    public IEnumerator TestYear_Next2Turns_2401Expected()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9981");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(3));

        GameController gameController = GameObject.Find("GameController").GetComponent <GameController>();

        gameController.NextTurn();
        yield return(new WaitForSeconds(3));

        gameController.NextTurn();
        yield return(new WaitForSeconds(3));

        Assert.AreEqual(gameController.year, 2401);
    }
Example #2
0
    public IEnumerator TestLoadScene_NetworkManager_NonNullObjectExpected()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9994");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        Assert.IsNotNull(serverNetworkManager);
    }
Example #3
0
    public IEnumerator TestLoadScene_GameAppFillterLocalWithPort9994_LocalHostWithPort9995Expected()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9994");

        var expectedDictionary = new Dictionary <string, string>()
        {
            { "ServerAddress", "127.0.0.1" },
            { "ServerPort", "9994" }
        };

        CollectionAssert.IsSubsetOf((ICollection)expectedDictionary, (ICollection)gameApp.Parameters);
    }
Example #4
0
    public void Join()
    {
        gameApp.PersistAllParameters("JoinGameScene");

        ClientNetworkManager clientNetworkManager = GameObject.Find("ClientNetworkManager").GetComponent <ClientNetworkManager>();

        clientNetworkManager.SetupClient();
    }
Example #5
0
    public IEnumerator TestLoadSceneNewGameScene()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        if (!SceneManager.GetActiveScene().name.Equals("MainMenuScene"))
        {
            Assert.Fail();
        }

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        if (initializer == null)
        {
            Assert.Fail();
        }

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameMapScene"))
        {
            Assert.Fail();
        }


        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9999");

        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameScene"))
        {
            Assert.Fail();
        }

        /*if (gameApp == null)
         * {
         *  Debug.Log("I did find you");
         * }
         * else
         * {
         *  Debug.Log("I found you");
         * }*/

        yield return(null);
    }
Example #6
0
    /*
     *   After "Join" button in "JoinGameScene"
     *   Setup server address and port, start client
     */
    public void SetupClient()
    {
        Debug.Log("SetupClient");

        try
        {
            // persists config data from menu scene
            gameApp.PersistAllParameters("JoinGameScene");

            this.networkAddress = gameApp.GetAndRemoveInputField("ServerAddress");
            this.networkPort    = int.Parse(gameApp.GetAndRemoveInputField("ServerPort"));

            // uncomment for testing
            //this.networkAddress = "127.0.0.1";
            //this.networkPort = 7777;
            this.StartClient();
        } catch (Exception e)
        {
            Debug.Log("SetupClient error: " + e.Message);
            errorInfoPanel.Show("SetupClient error: " + e.Message);
            return;
        }
    }
Example #7
0
    public IEnumerator TestFire_2WarShips_2ShipsFighting()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(1));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(1));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9999");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(1));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(1));

        GameController gameController     = GameObject.Find("GameController").GetComponent <GameController>();
        GameObject     gameObjectKorriban = GameObject.Find("Korriban");
        GameObject     gameObjectWarShip  = Resources.Load("Object/Warship", typeof(GameObject)) as GameObject;
        Planet         Korriban           = gameObjectKorriban.GetComponent <Planet>();

        gameController.GetCurrentPlayer().minerals   = 100;
        gameController.GetCurrentPlayer().population = 100;
        gameController.GetCurrentPlayer().solarPower = 100;
        EventManager.selectionManager.SelectedObject = gameObjectKorriban;
        yield return(new WaitForSeconds(1));

        gameController.BuildSpaceship(gameObjectWarShip);
        yield return(new WaitForSeconds(1));

        GameObject gameObjectWarshipSpaceShip1 = GameObject.Find("Warship(Clone)");
        Warship    warShip1 = gameObjectWarshipSpaceShip1.GetComponent <Warship>();

        gameController.GetCurrentPlayer().engines = 100;
        warShip1.actionPoints = 100;
        gameController.GetCurrentPlayer().attack = 100;

        gameController.NextTurn();
        yield return(new WaitForSeconds(1));

        gameController.GetCurrentPlayer().minerals   = 100;
        gameController.GetCurrentPlayer().population = 100;
        gameController.GetCurrentPlayer().solarPower = 100;
        GameObject noVa = GameObject.Find("Nova");

        EventManager.selectionManager.SelectedObject = noVa;
        yield return(new WaitForSeconds(1));

        gameController.BuildSpaceship(gameObjectWarShip);
        yield return(new WaitForSeconds(1));

        GameObject gameObjectWarshipSpaceShip2 = GameObject.Find("Warship(Clone)");
        Warship    warShip2 = gameObjectWarshipSpaceShip2.GetComponent <Warship>();

        gameController.NextTurn();
        yield return(new WaitForSeconds(1));

        HexGrid grid = (GameObject.Find("HexGrid").GetComponent <HexGrid>());

        EventManager.selectionManager.SelectedObject = gameObjectWarshipSpaceShip1;
        yield return(new WaitForSeconds(1));

        HexCoordinates des = new HexCoordinates(warShip2.Coordinates.X - 1, warShip2.Coordinates.Z);

        grid.TouchCell(des);
        yield return(new WaitForSeconds(10));

        EventManager.selectionManager.TargetObject = gameObjectWarshipSpaceShip2;
        yield return(new WaitForSeconds(1));

        gameController.Attack();
        yield return(new WaitForSeconds(2));

        Assert.IsTrue(gameObjectWarshipSpaceShip2 == null);
    }
Example #8
0
    public IEnumerator TestColonizing_Player1_Player1OwnsMoon()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9998");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(1));

        GameController gameController     = GameObject.Find("GameController").GetComponent <GameController>();
        GameObject     gameObjectKorriban = GameObject.Find("Korriban");
        GameObject     colonizer          = Resources.Load("Object/Colonizer", typeof(GameObject)) as GameObject;
        Planet         Korriban           = gameObjectKorriban.GetComponent <Planet>();

        gameController.GetCurrentPlayer().minerals   = 100;
        gameController.GetCurrentPlayer().population = 100;
        gameController.GetCurrentPlayer().solarPower = 100;
        EventManager.selectionManager.SelectedObject = gameObjectKorriban;
        yield return(new WaitForSeconds(2));

        gameController.BuildSpaceship(colonizer);
        GameObject gameObjectcolonizerSpaceShip = GameObject.Find("Colonizer(Clone)");
        Colonizer  colonizerSpaceShip           = gameObjectcolonizerSpaceShip.GetComponent <Colonizer>();

        colonizerSpaceShip.actionPoints = 100;
        GameObject gameObjetMoon = GameObject.Find("Moon");
        Planet     moon          = gameObjetMoon.GetComponent <Planet>();

        colonizerSpaceShip.GetOwner().terraforming = 100;
        EventManager.selectionManager.SelectedObject = gameObjectcolonizerSpaceShip;
        yield return(new WaitForSeconds(2));

        EventManager.selectionManager.TargetObject = gameObjetMoon;
        yield return(new WaitForSeconds(2));

        gameController.Colonize();
        yield return(new WaitForSeconds(2));

        Assert.AreEqual(moon.owner.name, "player1");
    }
Example #9
0
    public IEnumerator TestCreatingNewSpaceShip_Colonizer_NewColonizerExpected()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9986");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(1));

        GameController gameController     = GameObject.Find("GameController").GetComponent <GameController>();
        GameObject     gameObjectKorriban = GameObject.Find("Korriban");
        GameObject     scout    = Resources.Load("Object/Colonizer", typeof(GameObject)) as GameObject;
        Planet         Korriban = gameObjectKorriban.GetComponent <Planet>();

        EventManager.selectionManager.SelectedObject = gameObjectKorriban;
        yield return(new WaitForSeconds(2));

        GameObject newSpaceShip = Korriban.BuildSpaceship(scout);

        yield return(new WaitForSeconds(3));

        Assert.AreEqual(newSpaceShip.name, "Colonizer(Clone)");
    }
Example #10
0
    public IEnumerator TestMovementOfSpaceShip_Require3Moves_3MovesExpected()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9996");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(1));

        GameController gameController      = GameObject.Find("GameController").GetComponent <GameController>();
        GameObject     gameObjectspaceShip = GameObject.Find("Scout-1");
        Spaceship      spaceShip           = gameObjectspaceShip.GetComponent <Spaceship>();
        HexGrid        grid   = (GameObject.Find("HexGrid").GetComponent <HexGrid>());
        Vector3        vector = new Vector3(310.0f, 0.0f, 270.0f);

        EventManager.selectionManager.SelectedObject = gameObjectspaceShip;
        yield return(new WaitForSeconds(3));

        grid.TouchCell(vector);
        yield return(new WaitForSeconds(4));

        HexCoordinates expected = HexCoordinates.FromPosition(vector);

        Assert.AreEqual(spaceShip.Coordinates, expected);
    }
Example #11
0
 public void Next()
 {
     gameApp.PersistAllParameters("NewGameMapScene");
     levelLoader.LoadLevel("NewGameScene");
 }
Example #12
0
    public IEnumerator TestLoadGameInterface()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        if (!SceneManager.GetActiveScene().name.Equals("MainMenuScene"))
        {
            Assert.Fail();
        }

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        if (initializer == null)
        {
            Assert.Fail();
        }

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameMapScene"))
        {
            Assert.Fail();
        }


        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9999");

        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameScene"))
        {
            Assert.Fail();
        }

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();

        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(3));

        yield return(null);
    }
Example #13
0
    public IEnumerator TestCreatingNewSpaceShip()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(1));

        if (!SceneManager.GetActiveScene().name.Equals("MainMenuScene"))
        {
            Assert.Fail();
        }

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        if (initializer == null)
        {
            Assert.Fail();
        }

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(1));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameMapScene"))
        {
            Assert.Fail();
        }


        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        if (gameApp == null)
        {
            Assert.Fail();
        }
        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9999");

        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        if (levelLoader == null)
        {
            Assert.Fail();
        }
        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(1));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameScene"))
        {
            Assert.Fail();
        }

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        if (newGameSceneInit == null)
        {
            Assert.Fail();
        }
        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();

        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(1));

        GameController gameController = GameObject.Find("GameController").GetComponent <GameController>();

        if (gameController == null)
        {
            Assert.Fail();
        }

        GameObject gameObjectKorriban = GameObject.Find("Korriban");

        if (gameObjectKorriban == null)
        {
            Assert.Fail();
        }
        GameObject gameObjectspaceShip = GameObject.Find("Scout-1");

        if (gameObjectspaceShip == null)
        {
            Assert.Fail();
        }

        Planet Korriban = gameObjectKorriban.GetComponent <Planet>();

        EventManager.selectionManager.SelectedObject = gameObjectKorriban;
        yield return(new WaitForSeconds(3));

        GameObject newSpaceShip = Korriban.BuildSpaceship(gameObjectspaceShip);

        yield return(new WaitForSeconds(3));

        yield return(null);
    }
Example #14
0
    public IEnumerator TestMovementOfSpaceShip()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(1));

        if (!SceneManager.GetActiveScene().name.Equals("MainMenuScene"))
        {
            Assert.Fail();
        }

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        if (initializer == null)
        {
            Assert.Fail();
        }

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(1));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameMapScene"))
        {
            Assert.Fail();
        }


        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        if (gameApp == null)
        {
            Assert.Fail();
        }
        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9999");

        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        if (levelLoader == null)
        {
            Assert.Fail();
        }
        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(1));

        if (!SceneManager.GetActiveScene().name.Equals("NewGameScene"))
        {
            Assert.Fail();
        }

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        if (newGameSceneInit == null)
        {
            Assert.Fail();
        }
        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();

        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(1));

        GameController gameController = GameObject.Find("GameController").GetComponent <GameController>();

        if (gameController == null)
        {
            Assert.Fail();
        }

        GameObject gameObjectspaceShip = GameObject.Find("Scout-1");
        Spaceship  spaceShip           = gameObjectspaceShip.GetComponent <Spaceship>();

        if (spaceShip == null || gameObjectspaceShip == null)
        {
            Assert.Fail();
        }

        Debug.Log("1. I am here " + spaceShip.transform.localPosition);

        HexGrid grid = (GameObject.Find("HexGrid").GetComponent <HexGrid>());

        if (grid == null)
        {
            Assert.Fail();
        }
        Vector3        vector      = new Vector3(310.0f, 0.0f, 270.0f);
        HexCoordinates destination = HexCoordinates.FromPosition(vector);

        spaceShip.Destination = destination;
        EventManager.selectionManager.SelectedObject = gameObjectspaceShip;
        yield return(new WaitForSeconds(3));

        grid.TouchCell(vector);
        yield return(new WaitForSeconds(3));

        yield return(null);
    }