Пример #1
0
        protected void UseSkill(string id, Vector3?aimPosition)
        {
            BaseSkill skill      = null;
            short     skillLevel = 0;

            if (!GameInstance.Skills.TryGetValue(BaseGameData.MakeDataId(id), out skill) || skill == null ||
                !PlayerCharacterEntity.GetCaches().Skills.TryGetValue(skill, out skillLevel))
            {
                return;
            }

            bool isAttackSkill = skill.IsAttack();

            if (!aimPosition.HasValue)
            {
                if (PlayerCharacterEntity.RequestUseSkill(skill.DataId, isLeftHandAttacking) && isAttackSkill)
                {
                    // Requested to use attack skill then change attacking hand
                    isLeftHandAttacking = !isLeftHandAttacking;
                }
            }
            else
            {
                if (PlayerCharacterEntity.RequestUseSkill(skill.DataId, isLeftHandAttacking, aimPosition.Value) && isAttackSkill)
                {
                    // Requested to use attack skill then change attacking hand
                    isLeftHandAttacking = !isLeftHandAttacking;
                }
            }
        }
        protected virtual void ClearQueuedSkillIfInSafeZone()
        {
            if (queueUsingSkill.skill == null || queueUsingSkill.level <= 0)
            {
                return;
            }
            BaseSkill skill = queueUsingSkill.skill;

            if (PlayerCharacterEntity.IsInSafeArea && skill.IsAttack())
            {
                ClearQueueUsingSkill();
                PlayerCharacterEntity.CurrentGameManager.SendServerGameMessage(PlayerCharacterEntity.ConnectionId,
                                                                               CustomGameMessage.NoCastingInSafeArea);
                return;
            }
        }
        protected virtual void TabTargetUpdateQueuedSkill()
        {
            if (PlayerCharacterEntity.IsDead())
            {
                ClearQueueUsingSkill();
                return;
            }
            if (queueUsingSkill.skill == null || queueUsingSkill.level <= 0)
            {
                return;
            }
            if (PlayerCharacterEntity.IsPlayingActionAnimation())
            {
                return;
            }
            destination = null;
            BaseSkill skill       = queueUsingSkill.skill;
            Vector3?  aimPosition = queueUsingSkill.aimPosition;

            if (skill.HasCustomAimControls())
            {
                // Target not required, use skill immediately
                TurnCharacterToPosition(aimPosition.Value);
                RequestUsePendingSkill();
                isFollowingTarget = false;
                return;
            }

            if (skill.IsAttack() || skill.RequiredTarget())
            {
                // Let's stick to tab targeting instead of finding a random entity
                if (CacheActionTarget != null && CacheActionTarget is BaseCharacterEntity)
                {
                    UseSkillOn(CacheActionTarget);
                    return;
                }
                ClearQueueUsingSkill();
                return;
            }
            // Target not required, use skill immediately
            RequestUsePendingSkill();
        }