Ejemplo n.º 1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == "Tile")
        {
            if (collision.gameObject.GetComponent <Renderer>().material.color != appear.cols[appear.colSelector]) //if the square we hit is not black.
            {
                if (appear.colSelector != 0)                                                                      //if our player is not white.
                {
                    if (collision.gameObject.GetComponent <Renderer>().material.color != appear.cols[5])          //and if that tile is not a black tile at the time we collide...
                    {
                        //KILL PLAYER
                        //disable motor
                        //enable death effect
                        //start a countdown timer to respawn
                        //etc
                        Debug.Log("Player" + appear.myPlayerNum + " touched bad square"); //we should die here!
                        GameObject particles = Instantiate(deathParticles);
                        particles.transform.up                = transform.up;
                        particles.transform.position          = gameObject.transform.position;
                        GetComponent <MeshRenderer>().enabled = false;
                        input.enabled = false;
                        motor.enabled = false;

                        //this.gameObject.SetActive(false);
                        restart.StartCoroutine(restart.Reset());
                    }
                }
            }
        }

        //Debug.Log(collision.gameObject.GetComponent<Renderer>().material.color);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("1X") && thePlayers.Count < maxPlayers)
        {
            thePlayers.Add(player);
            Debug.Log("Number of Players " + thePlayers.Count);
        }
        else if (Input.GetButtonDown("1X") && thePlayers.Count >= maxPlayers)
        {
            thePlayers.Clear();
        }

        /*if (Input.GetButton("Fire2"))
         * {
         *  for (int i = thePlayers.Count-1; i > 0; i--)
         *  {
         *      thePlayers.Remove(player);
         *  }
         *  //thePlayers.Remove(player);
         *  Debug.Log("Number of Players " + thePlayers.Count);
         * } */

        if (Input.GetButtonDown("1Options") && thePlayers.Count > 0)
        {
            for (int i = 0; i < thePlayers.Count; i++)
            {
                _playerNum++;
                GameObject newPlayer = Instantiate(player);
                newPlayer.name = "Player" + _playerNum;
                newPlayer.tag  = "Player" + _playerNum;
                newPlayer.GetComponent <Inputs>().myPlayerNum     = _playerNum;
                newPlayer.GetComponent <Appearance>().myPlayerNum = _playerNum;
                newPlayer.GetComponent <SpawnPoint>().myPlayerNum = _playerNum;
            }

            GetComponent <Initialize>().enabled = false;
            StartCoroutine(restart.Reset());
            UI.DisableMainMenu();
            //StartCoroutine(UI.EnableCountdown(_countdownTime));
        }
    }