示例#1
0
    // Gives XP to player when trigger is entered
    void OnTriggerEnter(Collider other)
    {
        ChampionXP championXP = other.GetComponent <ChampionXP>();

        if (championXP != null)
        {
            PhotonView photonView = championXP.photonView;
            if (photonView.isMine)
            {
                photonView.RPC("GiveXP", PhotonTargets.All, amount);
            }
        }
    }
示例#2
0
    void EntityDamage(float amount, int attackerId)
    {
        // Update the health bar UI and kill the entity if necessary
        if (useEntityBehaviour)
        {
            health = Mathf.Max(health - amount, 0f);
            if (healthBarFill != null)
            {
                healthBarFill.fillAmount = health / maxHealth;
            }
            if (health <= 0f)
            {
                IsDead = true;

                // Give XP to all enemy champions who are not in the area
                if (PhotonNetwork.isMasterClient)
                {
                    Collider[] hitColliders = Physics.OverlapSphere(transform.position, XPRadius);
                    for (int i = 0; i < hitColliders.Length; i++)
                    {
                        PlayerChampion playerChampion = hitColliders[i].GetComponent <PlayerChampion>();
                        if (playerChampion != null)
                        {
                            if (playerChampion.PhotonView.owner.GetTeam() != team)
                            {
                                ChampionXP championXP = playerChampion.GetComponent <ChampionXP>();
                                championXP.photonView.RPC("GiveXP", PhotonTargets.All, XPOnDeath, false);
                            }
                        }
                    }
                }

                // Tell other scripts we're dead
                if (onEntityDeath != null)
                {
                    onEntityDeath(attackerId);
                }

                // Destroy the bullet
                if (PhotonNetwork.isMasterClient)
                {
                    PhotonNetwork.Destroy(gameObject);
                }
            }
        }
    }