示例#1
0
    /// <summary>
    /// user使用的技能对targetPosition产生skillRes指定的技能效果.
    /// </summary>
    public static ErrorCode SkillTakeEffect(BattleUnit user, SkillCommonTableItem skillRes, Vector3 targetPosition)
    {
        AttackerAttr attackerAttr = new AttackerAttr(user, (uint)skillRes.resID);

        if (skillRes.projectileResID != uint.MaxValue)
        {
            createProjectiles(user, (uint)skillRes.resID, skillRes.projectileResID, targetPosition);
        }

        // 给技能使用者添加的效果.
        ErrorHandler.Parse(
            AddSkillEffectByResource(attackerAttr, user, skillRes.skillEffect2UserInUseState)
            );

        // 向前延伸一定距离, 作为目标选择的中心点.
        Vector3 centerPosition = Utility.MoveVector3Towards(attackerAttr.AttackerPosition,
                                                            user.GetDirection(), skillRes.distForward);

        // 在中心点进行目标选择, 并添加技能效果.
        SelectTargetAndAddSkillEffect(attackerAttr, centerPosition, user.GetDirection(),
                                      skillRes.targetSelection, skillRes.skillEffect2Others);

        // 创建召唤物.
        ErrorHandler.Parse(
            CreateCreationAround(attackerAttr, skillRes.creationID, user.GetPosition(), user.GetDirection())
            );

        return(ErrorCode.Succeeded);
    }
示例#2
0
    private bool checkWeapon()
    {
        DataType myName           = DataType.DATA_WEAPON;
        IDictionaryEnumerator itr = DataManager.WeaponTable.GetEnumerator();

        while (itr.MoveNext())
        {
            WeaponTableItem item = itr.Value as WeaponTableItem;
            if (item.upgrade < 0)
            {
                continue;
            }

            if (!DataManager.PromoteTable.ContainsKey((int)item.upgrade))
            {
                GameDebug.LogError("进阶ID为" + item.upgrade.ToString() + "不存在表格promote.txt中 ");
                return(false);
            }

            if (item.skill_1 >= 0)
            {
                SkillCommonTableItem fireSkill = DataManager.SkillCommonTable[item.skill_1] as SkillCommonTableItem;
                if (fireSkill == null)
                {
                    checkParam(false, myName, item.id, "射击技能 I", "未找到资源");
                    return(false);
                }

                if (!checkParam(fireSkill.isRegularAttack, DataType.DATA_SKILL_COMMON, fireSkill.resID, "是否为普通攻击", "武器技能必须标识为普通攻击"))
                {
                    return(false);
                }
            }

            if (item.skill_2 >= 0)
            {
                SkillCommonTableItem fireSkill2 = DataManager.SkillCommonTable[item.skill_2] as SkillCommonTableItem;
                if (fireSkill2 == null)
                {
                    checkParam(false, myName, item.id, "射击技能 II", "未找到资源");
                    return(false);
                }

                if (!checkParam(fireSkill2.isRegularAttack, DataType.DATA_SKILL_COMMON, fireSkill2.resID, "是否为普通攻击", "武器技能必须标识为普通攻击"))
                {
                    return(false);
                }
            }
        }
//      foreach (int key in DataManager.WeaponTable.Keys)
//      {
//
//      }

        return(true);
    }
示例#3
0
    public float GetSkillMaxCoolDownByID(int skillid)
    {
        if (skillid < 0)
        {
            return(0.0f);
        }
        SkillCommonTableItem skillfalse = DataManager.SkillCommonTable[skillid] as SkillCommonTableItem;

        if (skillfalse == null)
        {
            return(0.0f);
        }
        return(skillfalse.myCd);
    }
示例#4
0
    /// <summary>
    /// 对血量和魔法值进行修改, 并触发随机事件.
    /// </summary>
    private void impactModify(int hpChanged, int manaChanged, bool critical)
    {
        // 自己给自己添加的impact.
        bool impact2Self = (mAttackerAttr.AttackerID == mOwner.InstanceID);

        // 攻击者和受伤者的随机事件.
        // 攻击者必须是有效的而且是其他单位.
        if (!mAttackerAttr.StructMadeByRandEvent && hpChanged < 0 &&            // 如果攻击者通过随机事件触发命中, 那么不触发被攻击者的随机事件.
            mAttackerAttr.AttackerID != uint.MaxValue && !impact2Self)
        {
            // 被击的随机事件.
            BeAttackedEventArg beAttackedEventArg = new BeAttackedEventArg(-hpChanged);
            mOwner.ApplyRandEvent(mAttackerAttr.CheckedAttackerObject(),
                                  RandEventTriggerType.OnBeAttacked,
                                  beAttackedEventArg
                                  );

            hpChanged = -beAttackedEventArg.PositiveDamage;
        }

        DamageInfo damageInfo = new DamageInfo()
        {
            Value      = hpChanged,
            Critical   = critical,
            DamageType = mImpactRes.impactDamageType
        };

        bool ownerDead = false;

        if (hpChanged != 0 && !mOwner.AddDamage(damageInfo, mAttackerAttr))
        {
            // 经过AddDamage之后, owner已经死亡, 不再播放被击特效, 以及修改魔法.
            ownerDead = true;
        }

        // 只有普通攻击才能触发攻击者的随机事件.
        SkillCommonTableItem skillRes = DataManager.SkillCommonTable[mAttackerAttr.SkillCommonID] as SkillCommonTableItem;

        if (mImpactRes.harmful && !impact2Self && skillRes != null && skillRes.isRegularAttack)
        {
            applyAttackerRandEvent(-hpChanged, critical);
        }

        if (!ownerDead && manaChanged != 0)
        {
            mOwner.AddMana(manaChanged);
        }
    }
示例#5
0
    static public float GetSkillMinRangle(int skillId)
    {
        if (!DataManager.SkillCommonTable.ContainsKey(skillId))
        {
            return(0.0f);
        }

        SkillCommonTableItem item = DataManager.SkillCommonTable[skillId] as SkillCommonTableItem;

        if (item == null)
        {
            return(0.0f);
        }

        return(item.minRange);
    }
示例#6
0
    public void AutoFire()
    {
        if (IsDead())
        {
            return;
        }
        int skillid = GetWeaponSkillID();

        SkillCommonTableItem skillRes = DataManager.SkillCommonTable[skillid] as SkillCommonTableItem;

        if (skillRes == null)
        {
            return;
        }

        Vector3 pos = GetAimTargetPos();

        if (pos == Vector3.zero)
        {
            return;
        }

        UseSkill(skillid, pos);
    }
示例#7
0
    private bool checkSkillCommon()
    {
        DataType myName           = DataType.DATA_SKILL_COMMON;
        IDictionaryEnumerator itr = DataManager.SkillCommonTable.GetEnumerator();

        while (itr.MoveNext())
        {
            SkillCommonTableItem item = itr.Value as SkillCommonTableItem;
            if (!checkParam(item.myCd != uint.MaxValue, myName, item.resID, "cd"))
            {
                return(false);
            }

            if (!checkParam(item.manaCost != uint.MaxValue && item.bulletCost != uint.MaxValue,
                            myName, item.resID, "cost"))
            {
                return(false);
            }

            if (!checkParam(item.skillUseStateDuration > item.skillEffectStartTime, myName, item.resID, "技能覆盖时间",
                            "assert(技能开始时间 < 技能覆盖时间)"))
            {
                return(false);
            }

            if (!checkParam(item.skillUseStateLoopLeft != 0, myName, item.resID, "技能使用阶段的循环次数"))
            {
                return(false);
            }

            if (!checkParam(item.maxRange > 0 && item.minRange >= 0, myName, item.resID, "skillrange"))
            {
                return(false);
            }

            if (item.chargeBehaviour != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_BEHAVIOUR, item.chargeBehaviour))
            {
                return(false);
            }

            if (item.useBehaviour != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_BEHAVIOUR, item.useBehaviour))
            {
                return(false);
            }

            if (item.buffToSkillUser != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_BUFF, item.buffToSkillUser))
            {
                return(false);
            }

            if (item.buffToSkillUser != uint.MaxValue)
            {
                SkillBuffTableItem buffItem = DataManager.BuffTable[item.buffToSkillUser] as SkillBuffTableItem;
                if (!checkParam(buffItem.lifeMilliseconds == uint.MaxValue, DataType.DATA_SKILL_BUFF, (int)item.buffToSkillUser,
                                "buffToSkillUser", "控制行为的buff的持续时间必须为-1"))
                {
                    return(false);
                }
            }

            if (item.skillEffect2UserInUseState != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_EFFECT, item.skillEffect2UserInUseState))
            {
                return(false);
            }

            if (item.targetSelection != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_TARGET_SELECTION, item.targetSelection))
            {
                return(false);
            }

            if (item.skillEffect2Others != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_EFFECT, item.skillEffect2Others))
            {
                return(false);
            }

            if (item.projectileResID != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_PROJECTILE_SETTINGS, item.projectileResID))
            {
                return(false);
            }

            if (item.creationID != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_CREATION, item.creationID))
            {
                return(false);
            }
        }
//      foreach (int key in DataManager.SkillCommonTable.Keys)
//      {
//
//      }

        return(true);
    }
 public OnSkillFinishedEventArg(SkillCommonTableItem skillResource)
 {
     SkillRes = skillResource;
 }