Ejemplo n.º 1
0
    public void OnTriggerEnter2D(Collider2D col)  //столкновение
    {
        if (Creator == "Player")
        {
            if (col.gameObject.tag == "Enemy")
            {
                Destroy(this.gameObject);
                if (DontDestroy.GetComponent <DontDestroyScript>().NetworkGame == false)
                {
                    Instantiate(PartGun, this.transform.position, Quaternion.identity);
                    col.gameObject.GetComponent <EnemyScript>().NowHealth -= Damage;
                }
                else
                {
                    PhotonNetwork.Instantiate("FireCollision", this.transform.position, Quaternion.identity, 0);
                }
            }
        }
        if (Creator == "Enemy")
        {
            if (col.gameObject.tag == "Player")
            {
                Destroy(this.gameObject);
                Instantiate(PartGun, this.transform.position, Quaternion.identity);
                col.gameObject.GetComponent <MoveScript>().NowHealth -= Damage;
                col.gameObject.GetComponent <AudioSource>().Play();
            }
        }

        if (col.gameObject.tag == "Player")  //столконовение с др игроком
        {
            if (DontDestroy.GetComponent <DontDestroyScript>().NetworkGame == true)
            {
                if (Creator != PhotonNetwork.playerName)
                {
                    PhotonView photonView1 = PhotonView.Find(col.gameObject.GetComponent <PhotonView>().viewID);
                    photonView1.RPC("EnterDamage", PhotonTargets.All, Damage);
                    PhotonView.DestroyObject(this.gameObject);
                    GameObject Part = PhotonNetwork.Instantiate(StrPartGun, this.transform.position, Quaternion.identity, 0);
                    col.gameObject.GetComponent <AudioSource>().Play();
                }
            }
        }
    }