Beispiel #1
0
        public void CastingSkill(int skillIndex, Vector3 pos, Vector3 direction)
        {
            if ((skillIndex >= 0) && (skillIndex <= Photon_GameSetting.instance.allKindsOfSpell.Length))
            {
                if (!_debugFlag)
                {
                    StartCoroutine(CDCounter(skillIndex, skills[skillIndex].coolDownTime));
                }


                if (skills[skillIndex].isGroundSkill)
                {
                    pos         = new Vector3(pos.x, transform.position.y, pos.z);
                    direction.y = 0;
                    pos         = pos + skills[skillIndex].castingOffset * direction;
                }
                else
                {
                    pos = pos + skills[skillIndex].castingOffset * direction;
                }

                for (int i = 0; i < skills[skillIndex].castingAmount; i++)
                {
                    Quaternion rotation = Quaternion.LookRotation(direction, Vector3.up);
                    switch (i)
                    {
                    case 1:
                        rotation *= Quaternion.Euler(0, 30, 0);
                        break;

                    case 2:
                        rotation *= Quaternion.Euler(0, -30, 0);
                        break;

                    case 3:
                        rotation *= Quaternion.Euler(0, 60, 0);
                        break;

                    case 4:
                        rotation *= Quaternion.Euler(0, -60, 0);
                        break;

                    case 5:
                        rotation *= Quaternion.Euler(0, 90, 0);
                        break;

                    case 6:
                        rotation *= Quaternion.Euler(0, -90, 0);
                        break;

                    case 7:
                        rotation *= Quaternion.Euler(0, 120, 0);
                        break;

                    case 8:
                        rotation *= Quaternion.Euler(0, -120, 0);
                        break;

                    case 9:
                        rotation *= Quaternion.Euler(0, 150, 0);
                        break;

                    case 10:
                        rotation *= Quaternion.Euler(0, -150, 0);
                        break;

                    case 11:
                        rotation *= Quaternion.Euler(0, 180, 0);
                        break;
                    }

                    GameObject   s            = PhotonNetwork.Instantiate(Path.Combine("Skills", skills[skillIndex].skillPrefab.name), pos, rotation);
                    CastingSkill castingSkill = s.GetComponent <CastingSkill>();
                    castingSkill.SetSkill(Photon_Room.instance.GetMyPlayerID(), _playerStatus.CurrentAttackRatio());
                }
            }
        }
Beispiel #2
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);
                    }
                }
            }
        }