Example #1
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag.Equals("Attack2") || coll.gameObject.tag.Equals("Attack1"))
        {
            mp.CanMove();                                                  //Set movement to false

            Transform _tmpPosition = sac.GetPositionRandomSelectedRobot(); //Destroy robot too

            if (_tmpPosition != null)
            {
                string _namePlayer = sac.GetNamePlayer();
                if (_namePlayer.Equals("Player1"))
                {
                    hm.DecreasePoints(1);
                    GameObject go = Instantiate(_oldRobot, this.transform.position, this.transform.rotation);
                }
                else if (_namePlayer.Equals("Player2"))
                {
                    hm.DecreasePoints(2);
                    GameObject go = Instantiate(_newRobot, this.transform.position, this.transform.rotation);
                }

                this.transform.position = _tmpPosition.position;

                //sac.DeleteRobot(sac.GetPosition());

                Destroy(_tmpPosition.gameObject);

                mp.CanMove();   //Set movement to true

                sac.SetPosition(0);

                hm.CheckVictoryCondition();
            }
            else
            {
                Debug.LogError("Null returned. List empty");
            }
        }
    }