void DoJump()
        {
            var roleGameOE = RoleMgr.GetInstance().GetMainRole();
            var jumpState  = EntityManager.GetComponentData <JumpData>(roleGameOE.Entity);
            var isMaxJump  = jumpState.JumpCount >= GameConst.MaxJumpCount;

            if (isMaxJump)
            {
                //已经最高跳段了,就不能再跳
                return;
            }
            RoleMgr.GetInstance().StopMainRoleRunning();
            var actionData = EntityManager.GetComponentData <ActionData>(roleGameOE.Entity);

            actionData.Jump = 1;
            EntityManager.SetComponentData <ActionData>(roleGameOE.Entity, actionData);
            //这里的timeline只作跳跃中的表现,如加粒子加女主尾巴等,状态和高度控制还是放在MovementUpdateSystem里,因为跳跃这个动作什么时候结束是未知的,你可能跳崖了,这时跳跃状态会一直维持至到碰到地面,所以不方便放在timeline里。
            var newJumpCount = math.clamp(jumpState.JumpCount + 1, 0, GameConst.MaxJumpCount);
            var roleInfo     = roleGameOE.GetComponent <RoleInfo>();
            var assetPath    = ResPath.GetRoleJumpResPath(roleInfo.Career, newJumpCount);
            var timelineInfo = new TimelineInfo {
                ResPath = assetPath, Owner = roleGameOE.Entity, StateChange = null
            };
            var uid = EntityManager.GetComponentData <UID>(roleGameOE.Entity);

            TimelineManager.GetInstance().AddTimeline(uid.Value, timelineInfo, EntityManager);
        }
Beispiel #2
0
        void CastSkill(int skillIndex = -1)
        {
            var roleGameOE = RoleMgr.GetInstance().GetMainRole();
            var roleInfo   = roleGameOE.GetComponent <RoleInfo>();
            var skillID    = SkillManager.GetInstance().GetSkillIDByIndex(skillIndex);

            string assetPath      = ResPath.GetRoleSkillResPath(skillID);
            bool   isNormalAttack = skillIndex == -1;//普通攻击

            if (!isNormalAttack)
            {
                SkillManager.GetInstance().ResetCombo();//使用非普攻技能时就重置连击索引
            }
            var uid = EntityManager.GetComponentData <UID>(roleGameOE.Entity);
            Action <TimelineInfo.Event> afterAdd = null;

            if (isNormalAttack)
            {
                //普攻的话增加连击索引
                afterAdd = (TimelineInfo.Event e) =>
                {
                    if (e == TimelineInfo.Event.AfterAdd)
                    {
                        SkillManager.GetInstance().IncreaseCombo();
                    }
                };
            }
            var timelineInfo = new TimelineInfo {
                ResPath = assetPath, Owner = roleGameOE.Entity, StateChange = afterAdd
            };

            TimelineManager.GetInstance().AddTimeline(uid.Value, timelineInfo, EntityManager);
        }
Beispiel #3
0
        public void LoadMonsterResList(List <int> list, Action <bool> callBack)
        {
            if (list.Count <= 0 && callBack != null)
            {
                callBack(true);
            }
            int count = 0;

            for (int i = 0; i < list.Count; i++)
            {
                var typeID = list[i];
                if (this.prefabDic.ContainsKey("MonsterRes_" + typeID))
                {
                    count++;
                    if (callBack != null && count == list.Count)
                    {
                        callBack(true);
                    }
                    continue;
                }
                string bodyPath = ResPath.GetMonsterBodyResPath(typeID);
                if (bodyPath == string.Empty)
                {
                    Debug.LogError("ResMgr:LoadMonsterResList monster body res id 0, typeID:" + typeID);
                    if (callBack != null)
                    {
                        callBack(false);
                    }
                    return;
                }
                XLuaFramework.ResourceManager.GetInstance().LoadAsset <GameObject>(bodyPath, delegate(UnityEngine.Object[] objs) {
                    if (objs.Length > 0 && (objs[0] as GameObject) != null)
                    {
                        GameObject prefab = objs[0] as GameObject;
                        if (prefab != null)
                        {
                            // Debug.Log("load monster ok : "+"MonsterRes_"+typeID);
                            this.prefabDic["MonsterRes_" + typeID] = prefab;
                            count++;
                            if (callBack != null && count == list.Count)
                            {
                                callBack(true);
                            }
                            return;
                        }
                    }
                    Debug.LogError("ResMgr:LoadMonsterResList cannot find prefab in " + bodyPath);
                    if (callBack != null)
                    {
                        callBack(false);
                    }
                });
            }
        }
Beispiel #4
0
        public string GetSkillResPath(int skillID)
        {
            string assetPath;
            int    scene_obj_type = GetSceneObjTypeBySkillID(skillID);

            if (scene_obj_type == (int)SceneObjectType.Role)
            {
                assetPath = ResPath.GetRoleSkillResPath(skillID);
            }
            else if (scene_obj_type == (int)SceneObjectType.Monster)
            {
                assetPath = ResPath.GetMonsterSkillResPath(skillID);
            }
            else
            {
                assetPath = "";
            }
            return(assetPath);
        }
Beispiel #5
0
        public void CastSkill(int skillID)
        {
            // var skillID = GetSkillIDByIndex(skillIndex);
            var isInCD = IsSkillInCD(skillID);

            if (isInCD)
            {
                XLuaFramework.CSLuaBridge.GetInstance().CallLuaFuncStr(GlobalEvents.MessageShow, "技能冷却中...");
                return;
            }
            var roleGameOE = RoleMgr.GetInstance().GetMainRole();
            var roleInfo   = roleGameOE.GetComponent <RoleInfo>();

            string assetPath      = ResPath.GetRoleSkillResPath(skillID);
            bool   isNormalAttack = IsNormalAttack(skillID);//普通攻击

            // Debug.Log("isNormalAttack : "+isNormalAttack);
            if (!isNormalAttack)
            {
                ResetCombo();//使用非普攻技能时就重置连击索引
            }
            var uid = SceneMgr.Instance.EntityManager.GetComponentData <UID>(roleGameOE.Entity);
            Action <TimelineInfo.Event> afterAdd = null;

            if (isNormalAttack)
            {
                //普攻的话增加连击索引
                afterAdd = (TimelineInfo.Event e) =>
                {
                    if (e == TimelineInfo.Event.AfterAdd)
                    {
                        IncreaseCombo();
                    }
                };
            }
            var timelineInfo = new TimelineInfo {
                ResPath = assetPath, Owner = roleGameOE.Entity, StateChange = afterAdd
            };

            TimelineManager.GetInstance().AddTimeline(uid.Value, timelineInfo, SceneMgr.Instance.EntityManager);
        }