Exemple #1
0
        private IEnumerator UseSkillRoutine(
            CharacterSkill characterSkill,
            Vector3 position,
            float triggerDuration,
            float totalDuration,
            SkillAttackType skillAttackType,
            CharacterItem weapon,
            DamageInfo damageInfo,
            Dictionary <DamageElement, MinMaxFloat> allDamageAmounts)
        {
            // Update skill usage states
            var newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.Skill, characterSkill.dataId);

            newSkillUsage.Use(this, characterSkill.level);
            skillUsages.Add(newSkillUsage);

            yield return(new WaitForSecondsRealtime(triggerDuration));

            ApplySkill(characterSkill, position, skillAttackType, weapon, damageInfo, allDamageAmounts);
            yield return(new WaitForSecondsRealtime(totalDuration - triggerDuration));
        }
Exemple #2
0
        protected virtual void NetFuncUseGuildSkill(int dataId)
        {
            if (IsDead())
            {
                return;
            }

            GuildSkill guildSkill;

            if (!GameInstance.GuildSkills.TryGetValue(dataId, out guildSkill) || guildSkill.skillType != GuildSkillType.Active)
            {
                return;
            }

            GuildData guild;

            if (GuildId <= 0 || !gameManager.TryGetGuild(GuildId, out guild))
            {
                return;
            }

            short level = guild.GetSkillLevel(dataId);

            if (level <= 0)
            {
                return;
            }

            if (this.IndexOfSkillUsage(dataId, SkillUsageType.GuildSkill) >= 0)
            {
                return;
            }

            // Apply guild skill
            CharacterSkillUsage newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.GuildSkill, dataId);

            newSkillUsage.Use(this, level);
            skillUsages.Add(newSkillUsage);
            ApplyBuff(dataId, BuffType.GuildSkillBuff, level);
        }
Exemple #3
0
        private IEnumerator UseSkillRoutine(
            Skill skill,
            short level,
            AnimActionType animActionType,
            int skillOrWeaponTypeDataId,
            int animationIndex,
            float triggerDuration,
            float totalDuration,
            bool isLeftHand,
            CharacterItem weapon,
            DamageInfo damageInfo,
            Dictionary <DamageElement, MinMaxFloat> allDamageAmounts,
            bool hasAimPosition,
            Vector3 aimPosition)
        {
            if (onUseSkillRoutine != null)
            {
                onUseSkillRoutine.Invoke(skill, level, animActionType, skillOrWeaponTypeDataId, animationIndex, triggerDuration, totalDuration, isLeftHand, weapon, damageInfo, allDamageAmounts, hasAimPosition, aimPosition);
            }

            // Set doing action data
            isCastingSkillCanBeInterrupted = skill.canBeInterruptedWhileCasting;
            isCastingSkillInterrupted      = false;

            float castDuration = skill.GetCastDuration(level);

            if (castDuration > 0f)
            {
                // Play casting effects on clients
                RequestPlayEffect(skill.castEffects.Id);

                // Tell clients that character is casting
                RequestSkillCasting(skill.DataId, castDuration);

                yield return(new WaitForSecondsRealtime(castDuration));
            }

            // If skill casting not interrupted, continue doing action
            if (!isCastingSkillInterrupted || !isCastingSkillCanBeInterrupted)
            {
                // Play animation on clients
                RequestPlayActionAnimation(animActionType, skillOrWeaponTypeDataId, (byte)animationIndex);

                // Update skill usage states
                CharacterSkillUsage newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.Skill, skill.DataId);
                newSkillUsage.Use(this, level);
                skillUsages.Add(newSkillUsage);

                yield return(new WaitForSecondsRealtime(triggerDuration));

                // Reduce ammo amount
                if (skill.skillAttackType != SkillAttackType.None)
                {
                    Dictionary <DamageElement, MinMaxFloat> increaseDamages;
                    ReduceAmmo(weapon, isLeftHand, out increaseDamages);
                    if (increaseDamages != null)
                    {
                        allDamageAmounts = GameDataHelpers.CombineDamages(allDamageAmounts, increaseDamages);
                    }
                }

                ApplySkill(skill, level, isLeftHand, weapon, damageInfo, allDamageAmounts, hasAimPosition, aimPosition);
                yield return(new WaitForSecondsRealtime(totalDuration - triggerDuration));
            }
            isAttackingOrUsingSkill = false;
        }