Пример #1
0
        void OnTriggerEnter(Collider other)
        {
            if (!_photonView.IsMine)
            {
                return;
            }

            if (other.CompareTag(playerTag))
            {
                PhotonView   otherPhotonView = other.GetComponent <PhotonView>();
                PlayerStatus status          = other.GetComponent <PlayerStatus>();

                //Check the collideing skill what is or not myself casting.

                if (otherPhotonView.IsMine)
                {
                    if (skill.skillType == SkillType.Utility)
                    {
                        if (skill.hasEffect && !hasTriggeredEffect)
                        {
                            if (skill.stealth)
                            {
                                status.EnableInvisable(skill.buffDuration);
                            }

                            if (skill.updateHP)
                            {
                                status.Damage(-skill.HP, _ownerID); //--Negative damage <=> heal--//
                            }
                            if (skill.updatePlayerStatus)
                            {
                                status.SetPlayerStats(skill.buffDuration, skill.changeMovingSpeedRatio, skill.changeAttackRatio, skill.changeDefenseRatio);
                            }

                            hasTriggeredEffect = true;
                            if (skill.hitEffect != null)
                            {
                                PhotonNetwork.Instantiate(skill.hitEffect.name, transform.position + skill.hitEffectPositionOffset, Quaternion.identity);
                            }
                        }
                    }
                }
                else
                {
                    //Transfer the skill ownership
                    if (skill.skillType != SkillType.Utility)
                    {
                        float actualDamage = this._currentDamage * currentAttackRatio;
                        status.Damage(actualDamage, _ownerID);

                        if (skill.hasEffect)
                        {
                            status.SetPlayerStats(skill.buffDuration, skill.changeMovingSpeedRatio, skill.changeAttackRatio, skill.changeDefenseRatio);
                        }

                        if (skill.hitEffect != null)
                        {
                            PhotonNetwork.Instantiate(skill.hitEffect.name, transform.position + skill.hitEffectPositionOffset, Quaternion.identity);
                        }

                        if (skill.destroyOnImpact)
                        {
                            PhotonNetwork.Destroy(gameObject);
                        }
                    }
                }
            }
            else if (other.CompareTag(defaultTag))
            {
                CastingSkill otherSkill = other.gameObject.GetComponent <CastingSkill>();
                //--Hits Another Skill--//
                if (otherSkill != null)
                {
                    //-- If not my skill --//
                    if (otherSkill.GetOwnerID() != this._ownerID)
                    {
                        if (skill.destroyOnImpact && otherSkill.skill.destroyOnImpact)
                        {
                            float damageDifference = this._currentDamage - otherSkill.GetCurrentDamage();
                            if (damageDifference > 0.1f)
                            {
                                SetSkillStats(damageDifference, this._currentForce * 0.6f);
                            }
                            else
                            {
                                if (skill.hitSkillEffect != null)
                                {
                                    PhotonNetwork.Instantiate(skill.hitSkillEffect.name, transform.position + skill.hitEffectPositionOffset, Quaternion.identity);
                                }
                                PhotonNetwork.Destroy(this.gameObject);
                            }
                        }

                        if ((skill.skillType == SkillType.SkillShot) && (otherSkill.skill.skillType == SkillType.Utility))
                        {
                            if (otherSkill.skill.hasEffect && otherSkill.skill.cancelOtherSpell)
                            {
                                if (skill.hitSkillEffect != null)
                                {
                                    PhotonNetwork.Instantiate(skill.hitSkillEffect.name, transform.position + skill.hitEffectPositionOffset, Quaternion.identity);
                                }
                                PhotonNetwork.Destroy(this.gameObject);
                            }
                        }
                    }
                }
                //-- Hits terrain--//
                else
                {
                    if (skill.destroyOnImpact)
                    {
                        if (skill.hitEffect != null)
                        {
                            PhotonNetwork.Instantiate(skill.hitEffect.name, transform.position + skill.hitEffectPositionOffset, Quaternion.identity);
                        }
                        PhotonNetwork.Destroy(this.gameObject);
                    }
                }
            }
        }