Ejemplo n.º 1
0
 public void reloadLevel()
 {
     Score.currentLevel = Application.loadedLevel;
     foreach (GameObject player in PlayerDatabase.players)
     {
         player.SetActive(true);
         for (int i = 0; i < 5; i++)
         {
             player.GetComponent <Inventory>().inventory[i] = player.GetComponent <Inventory>().oldInventory[i];
         }
         player.GetComponent <PlayerStats>().reloadStats();
     }
     Score.collectables = 0;
     Score.turnsTaken   = 0;
     PlayerDatabase.deleteLists();
     EnemyDatabase.deleteList();
     NodeDatabase.allNodes.Clear();
     if (Application.loadedLevel == 1 || Application.loadedLevelName == "Level00")
     {
         Application.LoadLevel("Level00");
     }
     else
     {
         Application.LoadLevel(Score.currentLevel);
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        //Checks who won and writes text accordingly
        if (PlayerDatabase.bluePlayers.Count == 0)
        {
            winner.GetComponent <Text>().text = "Red Player Wins";
        }
        else if (PlayerDatabase.redPlayers.Count == 0)
        {
            winner.GetComponent <Text>().text = "Blue Player Wins";
        }

        if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.multiPlayer && GameStateMachine.currentMPGameState == GameStateMachine.MPState.statScreen)
        {
            if (Input.GetButtonDown("Accept"))
            {
                GameStateMachine.currentGameState   = GameStateMachine.State.playerTurn;
                GameStateMachine.currentMPGameState = GameStateMachine.MPState.player1Turn;
                PlayerDatabase.deleteLists();
                EnemyDatabase.deleteList();
                GameStateMachine.currentGameMode = GameStateMachine.GameMode.menu;
                Application.LoadLevel(0);
            }
        }
    }
Ejemplo n.º 3
0
 public void exitButton()
 {
     Time.timeScale = 1;
     GameStateMachine.currentGameState   = GameStateMachine.State.playerTurn;
     GameStateMachine.currentMPGameState = GameStateMachine.MPState.player1Turn;
     for (int i = 0; i < PlayerDatabase.players.Count; i++)
     {
         Destroy(PlayerDatabase.players[i]);
     }
     Score.collectables = 0;
     Score.turnsTaken   = 0;
     PlayerDatabase.deleteLists();
     EnemyDatabase.deleteList();
     NodeDatabase.allNodes.Clear();
     GameStateMachine.currentGameMode = GameStateMachine.GameMode.menu;
     Application.LoadLevel(0);
 }
Ejemplo n.º 4
0
    public void nextLevel()
    {
        if (Application.loadedLevelName == "Level00")
        {
            Score.currentLevel = 1;
        }
        else
        {
            Score.currentLevel = Application.loadedLevel;
        }

        Score.currentLevel++;
        foreach (GameObject player in PlayerDatabase.players)
        {
            player.SetActive(true);
        }
        PlayerDatabase.deleteLists();
        EnemyDatabase.deleteList();
        NodeDatabase.allNodes.Clear();

        Application.LoadLevel(Score.currentLevel);
    }
Ejemplo n.º 5
0
    public void loadGame()
    {
        if (File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
            PlayerData      data = (PlayerData)bf.Deserialize(file);
            file.Close();
            foreach (GameObject player in PlayerDatabase.players)
            {
                player.SetActive(true);
            }
            EnemyDatabase.deleteList();
            PlayerDatabase.deleteLists();
            GameStateMachine.currentGameState = GameStateMachine.State.playerTurn;
            if (data.level == 1 || data.level == 5)
            {
                Application.LoadLevel("Level00");
            }
            else
            {
                Application.LoadLevel(data.level);
            }
            Score.collectables = 0;
            Score.turnsTaken   = 0;
            PlayerDatabase.initSingle();
            PlayerDatabase.selectedID = 0;

            foreach (GameObject player in PlayerDatabase.players)
            {
                if (player.GetComponent <PlayerStats>().job == "Swordsman")
                {
                    player.GetComponent <Inventory>().inventory[0]   = new Item(data.swordsmanInventory[0]);
                    player.GetComponent <Inventory>().inventory[1]   = new Item(data.swordsmanInventory[1]);
                    player.GetComponent <Inventory>().inventory[2]   = new Item(data.swordsmanInventory[2]);
                    player.GetComponent <Inventory>().inventory[3]   = new Item(data.swordsmanInventory[3]);
                    player.GetComponent <Inventory>().inventory[4]   = new Item(data.swordsmanInventory[4]);
                    player.GetComponent <PlayerStats>().attack       = data.swordsmanStats[0];
                    player.GetComponent <PlayerStats>().magicAttack  = data.swordsmanStats[1];
                    player.GetComponent <PlayerStats>().healPower    = data.swordsmanStats[2];
                    player.GetComponent <PlayerStats>().defense      = data.swordsmanStats[3];
                    player.GetComponent <PlayerStats>().MagicDefense = data.swordsmanStats[4];
                    player.GetComponent <PlayerStats>().str          = data.swordsmanStats[5];
                    player.GetComponent <PlayerStats>().dex          = data.swordsmanStats[6];
                    player.GetComponent <PlayerStats>().intelligence = data.swordsmanStats[7];
                    player.GetComponent <PlayerStats>().vit          = data.swordsmanStats[8];
                    player.GetComponent <PlayerStats>().mnd          = data.swordsmanStats[9];
                    player.GetComponent <PlayerStats>().spd          = data.swordsmanStats[10];
                    player.GetComponent <PlayerStats>().maxHP        = data.swordsmanStats[11];
                    player.GetComponent <PlayerStats>().maxStamina   = data.swordsmanStats[12];
                    player.GetComponent <PlayerStats>().level        = data.swordsmanStats[13];
                    player.GetComponent <PlayerStats>().experience   = data.swordsmanStats[14];
                }
                else if (player.GetComponent <PlayerStats>().job == "Knight")
                {
                    player.GetComponent <Inventory>().inventory[0]   = new Item(data.knightInventory[0]);
                    player.GetComponent <Inventory>().inventory[1]   = new Item(data.knightInventory[1]);
                    player.GetComponent <Inventory>().inventory[2]   = new Item(data.knightInventory[2]);
                    player.GetComponent <Inventory>().inventory[3]   = new Item(data.knightInventory[3]);
                    player.GetComponent <Inventory>().inventory[4]   = new Item(data.knightInventory[4]);
                    player.GetComponent <PlayerStats>().attack       = data.knightStats[0];
                    player.GetComponent <PlayerStats>().magicAttack  = data.knightStats[1];
                    player.GetComponent <PlayerStats>().healPower    = data.knightStats[2];
                    player.GetComponent <PlayerStats>().defense      = data.knightStats[3];
                    player.GetComponent <PlayerStats>().MagicDefense = data.knightStats[4];
                    player.GetComponent <PlayerStats>().str          = data.knightStats[5];
                    player.GetComponent <PlayerStats>().dex          = data.knightStats[6];
                    player.GetComponent <PlayerStats>().intelligence = data.knightStats[7];
                    player.GetComponent <PlayerStats>().vit          = data.knightStats[8];
                    player.GetComponent <PlayerStats>().mnd          = data.knightStats[9];
                    player.GetComponent <PlayerStats>().spd          = data.knightStats[10];
                    player.GetComponent <PlayerStats>().maxHP        = data.knightStats[11];
                    player.GetComponent <PlayerStats>().maxStamina   = data.knightStats[12];
                    player.GetComponent <PlayerStats>().level        = data.knightStats[13];
                    player.GetComponent <PlayerStats>().experience   = data.knightStats[14];
                }
                else if (player.GetComponent <PlayerStats>().job == "Ranger")
                {
                    player.GetComponent <Inventory>().inventory[0]   = new Item(data.rangerInventory[0]);
                    player.GetComponent <Inventory>().inventory[1]   = new Item(data.rangerInventory[1]);
                    player.GetComponent <Inventory>().inventory[2]   = new Item(data.rangerInventory[2]);
                    player.GetComponent <Inventory>().inventory[3]   = new Item(data.rangerInventory[3]);
                    player.GetComponent <Inventory>().inventory[4]   = new Item(data.rangerInventory[4]);
                    player.GetComponent <PlayerStats>().attack       = data.rangerStats[0];
                    player.GetComponent <PlayerStats>().magicAttack  = data.rangerStats[1];
                    player.GetComponent <PlayerStats>().healPower    = data.rangerStats[2];
                    player.GetComponent <PlayerStats>().defense      = data.rangerStats[3];
                    player.GetComponent <PlayerStats>().MagicDefense = data.rangerStats[4];
                    player.GetComponent <PlayerStats>().str          = data.rangerStats[5];
                    player.GetComponent <PlayerStats>().dex          = data.rangerStats[6];
                    player.GetComponent <PlayerStats>().intelligence = data.rangerStats[7];
                    player.GetComponent <PlayerStats>().vit          = data.rangerStats[8];
                    player.GetComponent <PlayerStats>().mnd          = data.rangerStats[9];
                    player.GetComponent <PlayerStats>().spd          = data.rangerStats[10];
                    player.GetComponent <PlayerStats>().maxHP        = data.rangerStats[11];
                    player.GetComponent <PlayerStats>().maxStamina   = data.rangerStats[12];
                    player.GetComponent <PlayerStats>().level        = data.rangerStats[13];
                    player.GetComponent <PlayerStats>().experience   = data.rangerStats[14];
                }
                else if (player.GetComponent <PlayerStats>().job == "Mage")
                {
                    player.GetComponent <Inventory>().inventory[0]   = new Item(data.mageInventory[0]);
                    player.GetComponent <Inventory>().inventory[1]   = new Item(data.mageInventory[1]);
                    player.GetComponent <Inventory>().inventory[2]   = new Item(data.mageInventory[2]);
                    player.GetComponent <Inventory>().inventory[3]   = new Item(data.mageInventory[3]);
                    player.GetComponent <Inventory>().inventory[4]   = new Item(data.mageInventory[4]);
                    player.GetComponent <PlayerStats>().attack       = data.mageStats[0];
                    player.GetComponent <PlayerStats>().magicAttack  = data.mageStats[1];
                    player.GetComponent <PlayerStats>().healPower    = data.mageStats[2];
                    player.GetComponent <PlayerStats>().defense      = data.mageStats[3];
                    player.GetComponent <PlayerStats>().MagicDefense = data.mageStats[4];
                    player.GetComponent <PlayerStats>().str          = data.mageStats[5];
                    player.GetComponent <PlayerStats>().dex          = data.mageStats[6];
                    player.GetComponent <PlayerStats>().intelligence = data.mageStats[7];
                    player.GetComponent <PlayerStats>().vit          = data.mageStats[8];
                    player.GetComponent <PlayerStats>().mnd          = data.mageStats[9];
                    player.GetComponent <PlayerStats>().spd          = data.mageStats[10];
                    player.GetComponent <PlayerStats>().maxHP        = data.mageStats[11];
                    player.GetComponent <PlayerStats>().maxStamina   = data.mageStats[12];
                    player.GetComponent <PlayerStats>().level        = data.mageStats[13];
                    player.GetComponent <PlayerStats>().experience   = data.mageStats[14];
                }
                else if (player.GetComponent <PlayerStats>().job == "Healer")
                {
                    player.GetComponent <Inventory>().inventory[0]   = new Item(data.healerInventory[0]);
                    player.GetComponent <Inventory>().inventory[1]   = new Item(data.healerInventory[1]);
                    player.GetComponent <Inventory>().inventory[2]   = new Item(data.healerInventory[2]);
                    player.GetComponent <Inventory>().inventory[3]   = new Item(data.healerInventory[3]);
                    player.GetComponent <Inventory>().inventory[4]   = new Item(data.healerInventory[4]);
                    player.GetComponent <PlayerStats>().attack       = data.healerStats[0];
                    player.GetComponent <PlayerStats>().magicAttack  = data.healerStats[1];
                    player.GetComponent <PlayerStats>().healPower    = data.healerStats[2];
                    player.GetComponent <PlayerStats>().defense      = data.healerStats[3];
                    player.GetComponent <PlayerStats>().MagicDefense = data.healerStats[4];
                    player.GetComponent <PlayerStats>().str          = data.healerStats[5];
                    player.GetComponent <PlayerStats>().dex          = data.healerStats[6];
                    player.GetComponent <PlayerStats>().intelligence = data.healerStats[7];
                    player.GetComponent <PlayerStats>().vit          = data.healerStats[8];
                    player.GetComponent <PlayerStats>().mnd          = data.healerStats[9];
                    player.GetComponent <PlayerStats>().spd          = data.healerStats[10];
                    player.GetComponent <PlayerStats>().maxHP        = data.healerStats[11];
                    player.GetComponent <PlayerStats>().maxStamina   = data.healerStats[12];
                    player.GetComponent <PlayerStats>().level        = data.healerStats[13];
                    player.GetComponent <PlayerStats>().experience   = data.healerStats[14];
                }
            }
        }
    }
Ejemplo n.º 6
0
    void buttonPress()
    {
        PointerEventData pointer = new PointerEventData(EventSystem.current);

        if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.menu)
        {
            switch (index)
            {
            case 0:
                ExecuteEvents.Execute(buttons[0].gameObject, pointer, ExecuteEvents.submitHandler);
                break;

            case 1:
                ExecuteEvents.Execute(buttons[1].gameObject, pointer, ExecuteEvents.submitHandler);
                break;

            case 2:
                ExecuteEvents.Execute(buttons[2].gameObject, pointer, ExecuteEvents.submitHandler);
                break;

            case 3:
                ExecuteEvents.Execute(buttons[3].gameObject, pointer, ExecuteEvents.submitHandler);
                break;

            case 4:
                ExecuteEvents.Execute(buttons[4].gameObject, pointer, ExecuteEvents.submitHandler);
                break;
            }
        }
        else if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.singlePlayer)
        {
            switch (index)
            {
            case 0:
                ExecuteEvents.Execute(buttons[0].gameObject, pointer, ExecuteEvents.submitHandler);
                break;

            case 1:
                ExecuteEvents.Execute(buttons[1].gameObject, pointer, ExecuteEvents.submitHandler);
                break;

            case 2:
                GameStateMachine.currentGameState = oldState;
                break;

            case 3:
                Time.timeScale = 1;
                GameStateMachine.currentGameState   = GameStateMachine.State.playerTurn;
                GameStateMachine.currentMPGameState = GameStateMachine.MPState.player1Turn;
                for (int i = 0; i < PlayerDatabase.players.Count; i++)
                {
                    Destroy(PlayerDatabase.players[i]);
                }
                PlayerDatabase.deleteLists();
                EnemyDatabase.deleteList();
                NodeDatabase.allNodes.Clear();
                GameStateMachine.currentGameMode = GameStateMachine.GameMode.menu;
                Application.LoadLevel(0);
                break;
            }
        }
        else if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.multiPlayer)
        {
            switch (index)
            {
            case 0:
                GameStateMachine.currentMPGameState = oldMPState;
                break;

            case 1:
                Time.timeScale = 1;
                GameStateMachine.currentGameState   = GameStateMachine.State.playerTurn;
                GameStateMachine.currentMPGameState = GameStateMachine.MPState.player1Turn;
                PlayerDatabase.deleteLists();
                EnemyDatabase.deleteList();
                NodeDatabase.allNodes.Clear();
                GameStateMachine.currentGameMode = GameStateMachine.GameMode.menu;
                Application.LoadLevel(0);
                break;
            }
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        score.GetComponent <Text> ().text = Score.turnsTaken.ToString();
        if (levels != null && PlayerDatabase.players.Count == 5)
        {
            levels.GetComponent <Text> ().text = PlayerDatabase.players [0].GetComponent <PlayerStats> ().job
                                                 + "     " + PlayerDatabase.players [1].GetComponent <PlayerStats> ().job
                                                 + "     " + PlayerDatabase.players [2].GetComponent <PlayerStats> ().job
                                                 + "     " + PlayerDatabase.players [3].GetComponent <PlayerStats> ().job
                                                 + "     " + PlayerDatabase.players [4].GetComponent <PlayerStats> ().job + "\n"
                                                 + "        " + PlayerDatabase.players [0].GetComponent <PlayerStats> ().level
                                                 + "             " + PlayerDatabase.players [1].GetComponent <PlayerStats> ().level
                                                 + "             " + PlayerDatabase.players [2].GetComponent <PlayerStats> ().level
                                                 + "             " + PlayerDatabase.players [3].GetComponent <PlayerStats> ().level
                                                 + "             " + PlayerDatabase.players [4].GetComponent <PlayerStats> ().level;
        }
        collectables.GetComponent <Text> ().text = Score.collectables.ToString() + "/" + collectablesNum;

        if (GameStateMachine.currentGameMode == GameStateMachine.GameMode.singlePlayer && GameStateMachine.currentGameState == GameStateMachine.State.statScreen)
        {
            if (Input.GetButtonDown("Accept") || Input.GetKeyDown(KeyCode.Return))
            {
                if (Application.loadedLevel != 3)
                {
                    if (Application.loadedLevelName == "Level00")
                    {
                        Score.currentLevel = 1;
                    }
                    else
                    {
                        Score.currentLevel = Application.loadedLevel;
                    }
                    Score.currentLevel++;
                    foreach (GameObject player in PlayerDatabase.players)
                    {
                        player.SetActive(true);
                    }
                    PlayerDatabase.deleteLists();
                    EnemyDatabase.deleteList();
                    NodeDatabase.allNodes.Clear();

                    Application.LoadLevel(Score.currentLevel);
                }
                else if (Application.loadedLevel == 3)
                {
                    Time.timeScale = 1;
                    GameStateMachine.currentGameState   = GameStateMachine.State.playerTurn;
                    GameStateMachine.currentMPGameState = GameStateMachine.MPState.player1Turn;
                    for (int i = 0; i < PlayerDatabase.players.Count; i++)
                    {
                        Destroy(PlayerDatabase.players[i]);
                    }
                    PlayerDatabase.deleteLists();
                    EnemyDatabase.deleteList();
                    NodeDatabase.allNodes.Clear();
                    GameStateMachine.currentGameMode = GameStateMachine.GameMode.menu;
                    Application.LoadLevel(0);
                }
            }
        }
    }