コード例 #1
0
 static void MergeSkillList(SkillType type, List <SkillInstance> to_skill_list, List <uint> from_skill_list)
 {
     for (int i = 0; i < from_skill_list.Count; ++i)
     {
         SkillAttr skill = GameSystem.Instance.SkillConfig.GetSkill(from_skill_list[i]);
         if (skill != null && skill.type == type)
         {
             if (skill.subtype == SkillSubType.SPEC)
             {
                 List <SkillAttr> targetSkills = GameSystem.Instance.SkillConfig.basic_skills.FindAll(
                     inSkill => inSkill.area.SequenceEqual(skill.area) && (inSkill.action_type == skill.action_type));
                 SkillAttr targetSkill = targetSkills.Find(inSkill => inSkill.SameAction(skill));
                 if (targetSkill != null)
                 {
                     SkillInstance toRemoveInst = to_skill_list.Find(inSkillInst => inSkillInst.skill == targetSkill);
                     if (to_skill_list.Remove(toRemoveInst))
                     {
                         Debug.Log("special skill: " + skill.id + " replace skill: " + toRemoveInst.skill.id);
                     }
                 }
                 else
                 {
                     Debug.Log("There is no basic skill to be replaced by skill: " + skill.id);
                 }
             }
             SkillInstance inst = new SkillInstance();
             inst.skill = skill;
             inst.level = 1;
             to_skill_list.Add(inst);
         }
     }
 }
コード例 #2
0
ファイル: Skill.cs プロジェクト: yh821/Zombie
    protected Skill(ResSkill data)
    {
        Data = data;
        ID   = Data.id;

        Attr = new SkillAttr(Data);
    }
コード例 #3
0
    bool _MatchArea(GameMatch match, SkillInstance skillInstance)
    {
        SkillAttr skill = skillInstance.skill;

        if (skill.area.Count == 0)
        {
            return(true);
        }
        PlayGround playground = match.mCurScene.mGround;

        IM.Number fPlayerToNet = GameUtils.HorizonalDistance(match.mCurScene.mBasket.m_vShootTarget, m_player.position);
        if (skill.action_type == 2)                             //layup
        {
            Area eArea = playground.GetLayupArea(m_player);
            if (!skill.area.Contains((uint)eArea))
            {
                return(false);
            }
            SkillSpec spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eLayup_dist_min, skillInstance);
            if (fPlayerToNet < spc.value)
            {
                return(false);
            }
            spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eLayup_dist_max, skillInstance);
            if (fPlayerToNet > spc.value)
            {
                return(false);
            }
        }
        else if (skill.action_type == 3)                        //dunk
        {
            Area eArea = playground.GetDunkArea(m_player);
            if (!skill.area.Contains((uint)eArea))
            {
                return(false);
            }
            SkillSpec spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eDunk_dist_min, skillInstance);
            if (fPlayerToNet < spc.value)
            {
                return(false);
            }
            spc = m_player.GetSkillSpecialAttribute(SkillSpecParam.eDunk_dist_max, skillInstance);
            if (fPlayerToNet > spc.value)
            {
                return(false);
            }
        }
        else
        {
            Area eArea = playground.GetArea(m_player);
            if (!skill.area.Contains((uint)eArea))
            {
                return(false);
            }
        }
        return(true);
    }
コード例 #4
0
    List <SkillInstance> _GetSkillList(SkillType type, RoleInfo roleInfo)
    {
        List <SkillInstance> skill_list = new List <SkillInstance>();

        foreach (SkillAttr skill in GameSystem.Instance.SkillConfig.basic_skills)
        {
            if (skill.type == type)
            {
                SkillInstance inst = new SkillInstance();
                inst.skill = skill;
                inst.level = 1;
                skill_list.Add(inst);
            }
        }

        if (roleInfo != null)
        {
            foreach (SkillSlotProto skillSlot in roleInfo.skill_slot_info)
            {
                if (skillSlot.skill_uuid == 0)
                {
                    continue;
                }

                uint skillID    = skillSlot.skill_id;
                uint skillLevel = 1;

                Goods goods = MainPlayer.Instance.GetGoods(GoodsCategory.GC_SKILL, skillSlot.skill_uuid);
                if (goods != null)
                {
                    skillLevel = goods.GetLevel();
                }

                SkillAttr attr = GameSystem.Instance.SkillConfig.GetSkill(skillID);
                if (attr.type == type)
                {
                    SkillInstance inst = new SkillInstance();
                    inst.skill = attr;
                    inst.level = skillLevel;
                    skill_list.Add(inst);
                }
            }
        }

        if (!m_player.m_bIsNPC)
        {
            RoleBaseData2 data = GameSystem.Instance.RoleBaseConfigData2.GetConfigData(m_player.m_roleInfo.id);
            MergeSkillList(type, skill_list, data.training_skill_all);
        }
        else
        {
            NPCConfig config = GameSystem.Instance.NPCConfigData.GetConfigData(m_player.m_id);
            MergeSkillList(type, skill_list, config.skills);
        }
        return(skill_list);
    }
コード例 #5
0
    static int SameAction(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        SkillAttr obj  = (SkillAttr)LuaScriptMgr.GetNetObjectSelf(L, 1, "SkillAttr");
        SkillAttr arg0 = (SkillAttr)LuaScriptMgr.GetNetObject(L, 2, typeof(SkillAttr));
        bool      o    = obj.SameAction(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
コード例 #6
0
    static int GetSkill(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        SkillConfig obj  = (SkillConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "SkillConfig");
        uint        arg0 = (uint)LuaScriptMgr.GetNumber(L, 2);
        SkillAttr   o    = obj.GetSkill(arg0);

        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
コード例 #7
0
 public bool SameAction(SkillAttr other)
 {
     if (other == null || other.actions.Count != actions.Count)
     {
         return(false);
     }
     for (int i = 0; i < actions.Count; ++i)
     {
         if (!actions[i].SameInput(other.actions[i]))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #8
0
    static int _CreateSkillAttr(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            SkillAttr obj = new SkillAttr();
            LuaScriptMgr.PushObject(L, obj);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: SkillAttr.New");
        }

        return(0);
    }
コード例 #9
0
    private void CancelEnsureTomahawkDunk()
    {
        match.mainRole.m_skillSystem.CancelDisableCommand(Command.Layup);               //Cancel disable layup

        foreach (SkillSlotProto proto in match.mainRole.m_roleInfo.skill_slot_info)
        {
            Goods goods = MainPlayer.Instance.GetGoods(GoodsCategory.GC_TOTAL, proto.skill_uuid);
            if (goods != null && goods.GetID() == SKILL_ID)
            {
                SkillAttr skill = GameSystem.Instance.SkillConfig.GetSkill(goods.GetID());
                if (skill != null)
                {
                    SkillLevel lvl = skill.levels[goods.GetLevel()];
                    lvl.weight = oldWeight;
                }
            }
        }
    }
コード例 #10
0
    static int set_id(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        SkillAttr obj = (SkillAttr)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name id");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index id on a nil value");
            }
        }

        obj.id = (uint)LuaScriptMgr.GetNumber(L, 3);
        return(0);
    }
コード例 #11
0
    static int get_name(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        SkillAttr obj = (SkillAttr)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name name");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index name on a nil value");
            }
        }

        LuaScriptMgr.Push(L, obj.name);
        return(1);
    }
コード例 #12
0
    static int set_cast(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        SkillAttr obj = (SkillAttr)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name cast");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index cast on a nil value");
            }
        }

        obj.cast = LuaScriptMgr.GetString(L, 3);
        return(0);
    }
コード例 #13
0
    static int set_side_effects(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        SkillAttr obj = (SkillAttr)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name side_effects");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index side_effects on a nil value");
            }
        }

        obj.side_effects = (Dictionary <int, SkillSideEffect>)LuaScriptMgr.GetNetObject(L, 3, typeof(Dictionary <int, SkillSideEffect>));
        return(0);
    }
コード例 #14
0
    static int set_equip_conditions(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        SkillAttr obj = (SkillAttr)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name equip_conditions");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index equip_conditions on a nil value");
            }
        }

        obj.equip_conditions = (Dictionary <uint, uint>)LuaScriptMgr.GetNetObject(L, 3, typeof(Dictionary <uint, uint>));
        return(0);
    }
コード例 #15
0
    static int set_attrange(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        SkillAttr obj = (SkillAttr)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name attrange");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index attrange on a nil value");
            }
        }

        obj.attrange = (IM.Number)LuaScriptMgr.GetNetObject(L, 3, typeof(IM.Number));
        return(0);
    }
コード例 #16
0
    static int set_condition(IntPtr L)
    {
        object    o   = LuaScriptMgr.GetLuaObject(L, 1);
        SkillAttr obj = (SkillAttr)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name condition");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index condition on a nil value");
            }
        }

        obj.condition = (List <int>)LuaScriptMgr.GetNetObject(L, 3, typeof(List <int>));
        return(0);
    }
コード例 #17
0
    bool _MatchAction(Command curCommand, SkillInstance skillInstance, bool bIgnoreDir)
    {
        List <SkillAction> matchedActions = new List <SkillAction>();

        SkillAttr skill = skillInstance.skill;
        int       cnt   = skill.actions.Count;

        for (int idx = 0; idx != cnt; idx++)
        {
            SkillAction action = skill.actions[idx];
            SkillInput  input  = action.inputs[0];
            if (input.cmd != curCommand)
            {
                continue;
            }
            EDirection dir = m_player.m_inputDispatcher.GetMoveDirection(input.inputType);
            if (input.moveDir != dir || (bIgnoreDir && input.moveDir != EDirection.eNone))
            {
                continue;
            }
            matchedActions.Add(action);
        }

        if (matchedActions.Count == 0)
        {
            return(false);
        }

        int         iSelActionIdx = IM.Random.Range(0, matchedActions.Count);
        SkillAction finalAction   = matchedActions[iSelActionIdx];

        PlayerState       curState   = m_player.m_StateMachine.m_curState;
        PlayerState_Skill skillState = curState as PlayerState_Skill;

        if (finalAction.interrupts.Count > 0)
        {
            foreach (SkillInterrupt interrupt in finalAction.interrupts)
            {
                if (!curState.m_lstActionId.Contains(interrupt.id))
                {
                    continue;
                }
                Debug.Log("Interrupt action: " + skillInstance.skill.action_type + " , action id: " + finalAction.id);
                //matched
                skillInstance.curAction     = finalAction;
                skillInstance.matchedKeyIdx = iSelActionIdx;
                return(true);
            }
            return(false);
        }
        else if (skillState == null)
        {
            skillInstance.curAction     = finalAction;
            skillInstance.matchedKeyIdx = iSelActionIdx;
            return(true);
        }
        else if (skillState != null && skillState.m_bPersistent)
        {
            skillInstance.curAction     = finalAction;
            skillInstance.matchedKeyIdx = iSelActionIdx;
            return(true);
        }

        return(false);
    }
コード例 #18
0
ファイル: ActorObject.cs プロジェクト: yh821/Zombie
 public override void OnCreate()
 {
     base.OnCreate();
     Attr         = new SkillAttr();
     mExpDataList = DataReader <ResExp> .DataList;
 }
コード例 #19
0
    private void ReadSkillAttrConfig()
    {
        string text = ResourceLoadManager.Instance.GetConfigText(name2);

        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name2);
            return;
        }
        basic_skills.Clear();

        //读取以及处理XML文本的类
        XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_SKILL_ATTR, text);
        //解析xml的过程
        XmlNodeList nodelist = xmlDoc.SelectSingleNode("Data").ChildNodes;

        foreach (XmlElement xe in nodelist)
        {
            XmlNode comment = xe.SelectSingleNode(GlobalConst.CONFIG_SWITCH_COLUMN);
            if (comment != null && comment.InnerText == GlobalConst.CONFIG_SWITCH)
            {
                continue;
            }
            SkillAttr data = new SkillAttr();
            foreach (XmlElement xel in xe)
            {
                if (xel.Name == "id")
                {
                    uint.TryParse(xel.InnerText, out data.id);
                }
                else if (xel.Name == "name")
                {
                    data.name = xel.InnerText;
                }
                else if (xel.Name == "icon")
                {
                    data.icon = xel.InnerText;
                }
                else if (xel.Name == "actions")
                {
                    string[]    tokens = xel.InnerText.Split('/');
                    uint        actionId;
                    SkillAction action;
                    foreach (string token in tokens)
                    {
                        if (uint.TryParse(token, out actionId))
                        {
                            if (!actions.TryGetValue(actionId, out action))
                            {
                                continue;
                            }
                            data.actions.Add(action);
                        }
                    }
                }
                else if (xel.Name == "intro")
                {
                    data.intro = xel.InnerText;
                }
                else if (xel.Name == "cast")
                {
                    data.cast = xel.InnerText;
                }
                else if (xel.Name == "type")
                {
                    uint value;
                    uint.TryParse(xel.InnerText, out value);
                    data.type = (SkillType)value;
                }
                else if (xel.Name == "subtype")
                {
                    uint value;
                    uint.TryParse(xel.InnerText, out value);
                    data.subtype = (SkillSubType)value;
                }
                else if (xel.Name == "actiontype")
                {
                    uint value;
                    uint.TryParse(xel.InnerText, out value);
                    data.action_type = value;
                }
                else if (xel.Name == "sideeffect")
                {
                    string[] sideeffects = xel.InnerText.Split('&');
                    foreach (string effect in sideeffects)
                    {
                        if (string.IsNullOrEmpty(effect))
                        {
                            continue;
                        }
                        string[]        tokens      = effect.Split(':');
                        SkillSideEffect side_effect = new SkillSideEffect();
                        side_effect.type  = int.Parse(tokens[0]);
                        side_effect.value = IM.Number.Parse(tokens[1]);
                        data.side_effects.Add(side_effect.type, side_effect);
                    }
                }
                else if (xel.Name == "position")
                {
                    string[] positions = xel.InnerText.Split('&');
                    foreach (string pos in positions)
                    {
                        int position;
                        if (int.TryParse(pos, out position))
                        {
                            data.positions.Add(position);
                        }
                    }
                }
                else if (xel.Name == "role")
                {
                    string[] roles = xel.InnerText.Split('&');
                    foreach (string role in roles)
                    {
                        uint role_id;
                        if (uint.TryParse(role, out role_id))
                        {
                            data.roles.Add(role_id);
                        }
                    }
                }
                else if (xel.Name == "use_area")
                {
                    string[] areas = xel.InnerText.Split('&');
                    foreach (string area in areas)
                    {
                        uint area_id;
                        if (uint.TryParse(area, out area_id))
                        {
                            data.area.Add(area_id);
                        }
                    }
                }
                else if (xel.Name == "condition")
                {
                    string[] tokens = xel.InnerText.Split('&');
                    foreach (string token in tokens)
                    {
                        int condition;
                        if (!int.TryParse(token, out condition))
                        {
                            continue;
                        }
                        data.condition.Add(condition);
                    }
                }
                else if (xel.Name == "attrange")
                {
                    IM.Number tempAttrange;
                    if (!IM.Number.TryParse(xel.InnerText, out tempAttrange))
                    {
                        continue;
                    }
                    data.attrange = tempAttrange;
                }
            }
            for (int i = 1; ; ++i)
            {
                XmlNode nodeid = xe.SelectSingleNode("equip_cond_id" + i);
                if (nodeid == null)
                {
                    break;
                }
                XmlNode nodevalue = xe.SelectSingleNode("equip_cond_value" + i);
                if (nodevalue == null)
                {
                    break;
                }
                uint id;
                uint value;
                if (uint.TryParse(nodeid.InnerText, out id) && uint.TryParse(nodevalue.InnerText, out value))
                {
                    data.equip_conditions.Add(id, value);
                }
            }
            try
            {
                skills.Add(data.id, data);
                if (data.type == SkillType.ACTIVE && data.subtype == SkillSubType.BASIC)
                {
                    basic_skills.Add(data);
                }
            }
            catch (ArgumentException ex)
            {
                Debug.LogError(ex.Message);
            }
        }
    }