Ejemplo n.º 1
0
    void Start()
    {
        //Getting
        String scoreP1 = "(Not found)";
        String scoreP2 = "(Not found)";
        String scoreP3 = "(Not found)";
        String scoreP4 = "(Not found)";

        if (LevelParam.Get("scoreP1") != null && LevelParam.Get("scoreP2") != null && LevelParam.Get("scoreP3") != null && LevelParam.Get("scoreP4") != null)
        {
            scoreP1 = LevelParam.Get("scoreP1");
            scoreP2 = LevelParam.Get("scoreP2");
            scoreP3 = LevelParam.Get("scoreP3");
            scoreP4 = LevelParam.Get("scoreP4");
        }

        String text = "Player 1 - " + scoreP1 + " points\n";

        text = String.Concat(text, "Player 2 - " + scoreP2 + " points\n");

        if (System.Int32.Parse(LevelParam.Get("numberOfPlayer")) > 2)
        {
            text = String.Concat(text, "Player 3 - " + scoreP3 + " points\n");
        }
        if (System.Int32.Parse(LevelParam.Get("numberOfPlayer")) > 3)
        {
            text = String.Concat(text, "Player 4 - " + scoreP4 + " points");
        }

        //Displaying
        Text textObject = this.gameObject.GetComponent <Text>();

        textObject.text = text;
    }
Ejemplo n.º 2
0
    public Color getColorFromParam(int indexPlayer)
    {
        String avatar = "color" + indexPlayer;

        switch (LevelParam.Get(avatar))
        {
        case "0":
            return(new Color(1, 1, 0));

        case "1":
            return(new Color(1, 0, 1));

        case "2":
            return(new Color(0, 1, 1));

        case "3":
            return(new Color(1, 0.5f, 0));

        case "4":
            return(new Color(0, 0, 1));

        default:
            return(new Color(1, 1, 1));
        }
    }
Ejemplo n.º 3
0
    private void playerVerification()
    {
        GameObject[] players          = GameObject.FindGameObjectsWithTag("Player");
        ArrayList    alivePlayersList = new ArrayList();

        alivePlayers = 0;

        foreach (GameObject player in players)
        {
            PlayerHealth playerHealth = player.GetComponent <PlayerHealth>();
            if (!playerHealth.isDead)
            {
                alivePlayers++;
                alivePlayersList.Add(player);
            }
        }

        Debug.Log("alivePlayers = " + alivePlayers);

        if (LevelParam.Get("mode").Equals("coop") && alivePlayers == 0)
        {
            noPlayer();
        }
        if (LevelParam.Get("mode").Equals("versus") && alivePlayers == 1)
        {
            onePlayerOnly((GameObject)alivePlayersList.ToArray()[0]);
        }
    }
Ejemplo n.º 4
0
 //Can't find any enemy
 public void noEnemy()
 {
     if (LevelParam.Get("mode").Equals("coop"))
     {
         Debug.Log("[GameFlow.cs] Won Wave");
         launchWave();
     }
 }
Ejemplo n.º 5
0
    //Use this for initialization
    void Start()
    {
        //Getting all the necessary parameters
        try
        {
            if (LevelParam.Get("numberOfPlayer") != null)
            {
                numberOfPlayer = System.Int32.Parse(LevelParam.Get("numberOfPlayer"));
            }

            if (LevelParam.Get("levelNumber") != null)
            {
                levelNumber = System.Int32.Parse(LevelParam.Get("levelNumber"));
            }
            else
            {
                LevelParam.Set("levelNumber", "1");
            }

            if (LevelParam.Get("mode") != null) //"coop" or "versus"
            {
                mode = LevelParam.Get("mode");
            }
            else
            {
                LevelParam.Set("mode", "coop");
            }
        }
        catch (Exception e)
        {
            //Problem with a parameter
            Debug.Log("[GameFlow.cs] Problem with a level parameter" + e);
            Debug.Log(e.Message);
            //Back to the menu
            SceneManager.LoadScene("mainMenu", LoadSceneMode.Single);
        }

        //Loading of the level
        GameObject level = Instantiate(Resources.Load("Level/Level" + levelNumber, typeof(GameObject))) as GameObject;

        //Loading of the players
        generatePlayers(numberOfPlayer);

        if (mode.Equals("coop"))
        {
            //Launching the first wave
            waveNum = 1;
            launchWave();
        }
        else
        {
            //Launching the first round
            roundNum = 1;
            launchRound();
        }
    }
Ejemplo n.º 6
0
    public void NextLevel()
    {
        if (LevelParam.Get("levelNumber") == null)
        {
            LevelParam.Set("levelNumber", "1");
        }

        if (System.Int32.Parse(LevelParam.Get("levelNumber")) < 2)
        {
            LevelParam.Set("levelNumber", System.Int32.Parse(LevelParam.Get("levelNumber")) + 1 + "");
        }
        SceneManager.LoadScene("sandbox", LoadSceneMode.Single);
    }
Ejemplo n.º 7
0
    public void Revive()
    {
        if (LevelParam.Get("mode") == "coop")
        {
            userControl.Dead = isDead = false;
            animator.SetBool("IsDead", false);
            animator.Play("Idle");
            currentHealth = (int)(maxHealth / 2);
            Debug.Log(this.gameObject.name + " revived !");
            // Set the health bar's value to the current health.
            healthSlider.value = (float)currentHealth / maxHealth;

            GetComponent <PlayerInventory>().SetCurrentItem(0);
        }
    }
Ejemplo n.º 8
0
    //Can find only one player (versus mode)
    public void onePlayerOnly(GameObject player)
    {
        int playerNumber = player.GetComponent <UserControl>().getNumber() + 1;

        Debug.Log("[GameFlow.cs] The player " + playerNumber + " won !");


        Debug.Log("scoreP" + playerNumber + " = " + LevelParam.Get("scoreP" + playerNumber));


        int actualScore = System.Int32.Parse(LevelParam.Get("scoreP" + playerNumber));

        //We add a point to this player
        LevelParam.Set("scoreP" + playerNumber, actualScore + 1 + "");

        launchRound();
    }