コード例 #1
0
        void DoJump()
        {
            var roleGameOE = RoleMgr.GetInstance().GetMainRole();
            var jumpState  = EntityManager.GetComponentData <LocomotionState>(roleGameOE.Entity);
            var isMaxJump  = jumpState.JumpCount >= GameConst.MaxJumpCount;

            if (isMaxJump)
            {
                //已经最高跳段了,就不能再跳
                return;
            }
            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    = GameConst.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);
        }
コード例 #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      = GameConst.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);
        }
コード例 #3
0
        void DoJump()
        {
            var roleGameOE = RoleMgr.GetInstance().GetMainRole();
            var jumpState  = EntityManager.GetComponentData <JumpState>(roleGameOE.Entity);

            if (jumpState.JumpStatus == JumpState.State.None)
            {
                jumpState.JumpCount = 0;
                EntityManager.SetComponentData <JumpState>(roleGameOE.Entity, jumpState);
            }
            var isMaxJump = jumpState.JumpCount >= GameConst.MaxJumpCount;

            if (isMaxJump)
            {
                //已经最高跳段了,就不能再跳
                return;
            }
            var newJumpCount = math.clamp(jumpState.JumpCount + 1, 0, GameConst.MaxJumpCount);
            var roleInfo     = roleGameOE.GetComponent <RoleInfo>();
            var assetPath    = GameConst.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);
        }