示例#1
0
        private void HandleCastSkill(SprotoType.scene_fight_event_info fight_event)
        {
            long   uid          = fight_event.attacker_uid;
            Entity scene_entity = SceneMgr.Instance.GetSceneObject(uid);
            var    isMainRole   = RoleMgr.GetInstance().IsMainRoleEntity(scene_entity);

            // isMainRole = false;//test
            if (scene_entity == Entity.Null || isMainRole)
            {
                return;
            }

            //TODO:预先判断是否能使用技能
            bool is_can_cast = true;

            if (!is_can_cast)
            {
                return;
            }

            string assetPath = SkillManager.GetInstance().GetSkillResPath((int)fight_event.skill_id);

            Debug.Log("OnAckFightEvents assetPath : " + assetPath);
            var param = new Dictionary <string, object>();

            param["FlyHurtWord"] = fight_event.defenders;
            var timelineInfo = new TimelineInfo {
                ResPath = assetPath, Owner = scene_entity, Param = param
            };

            TimelineManager.GetInstance().AddTimeline(uid, timelineInfo, SceneMgr.Instance.EntityManager);
        }
示例#2
0
        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);
        }
示例#3
0
        private void HandleCastSkill(SprotoType.scene_skill_event_info skillEvent)
        {
            long   uid          = skillEvent.attacker_uid;
            Entity scene_entity = SceneMgr.Instance.GetSceneObject(uid);
            var    isMainRole   = RoleMgr.GetInstance().IsMainRoleEntity(scene_entity);

            // isMainRole = false;//test
            if (scene_entity == Entity.Null || isMainRole)
            {
                return;
            }

            //更新朝向
            Transform trans = SceneMgr.Instance.EntityManager.GetComponentObject <Transform>(scene_entity);

            // trans.rotation = Quaternion.Euler(trans.eulerAngles.x, skillEvent.direction/100, trans.eulerAngles.z);
            trans.LookAt(new Vector3(skillEvent.target_pos_x / GameConst.RealToLogic, trans.localPosition.y, skillEvent.target_pos_z / GameConst.RealToLogic));

            //播放攻击动作
            string assetPath = SkillManager.GetInstance().GetSkillResPath((int)skillEvent.skill_id);
            // Debug.Log("OnAckFightEvents assetPath : "+assetPath);
            // var param = new Dictionary<string, object>();
            // param["FlyHurtWord"] = event.defenders;
            var timelineInfo = new TimelineInfo {
                ResPath = assetPath, Owner = scene_entity, Param = null
            };

            TimelineManager.GetInstance().AddTimeline(uid, timelineInfo, SceneMgr.Instance.EntityManager);
        }
示例#4
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);
        }
示例#5
0
        public void AddTimeline(long id, TimelineInfo info, EntityManager entityMgr)
        {
            if (info.Owner == Entity.Null || !entityMgr.HasComponent <TimelineState>(info.Owner))
            {
                return;
            }
            var  state        = entityMgr.GetComponentData <TimelineState>(info.Owner);
            bool isNeedIgnore = state.NewStatus == TimelineState.NewState.Forbid;

            if (isNeedIgnore)
            {
                return;
            }
            if (!pool.ContainsKey(id))
            {
                pool[id] = new List <TimelineInfo>();
            }
            if (pool[id].Count >= 3)
            {
                return;
            }
            pool[id].Add(info);
            if (info.StateChange != null)
            {
                info.StateChange(TimelineInfo.Event.AfterAdd);
            }
        }
示例#6
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);
        }
示例#7
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);
        }