示例#1
0
        public override void Refresh(ObjectData objData)
        {
            var resourceStateData = objData.GetData <ResourceStateData>();

            if (!resourceStateData.isInstantiated)
            {
                return;
            }

            var speedData = objData.GetData <SpeedData>();

            if (speedData.speed == 0)
            {
                Stop(objData.ObjectId);
                return;
            }

            var actorData = objData.GetData <ActorData>();

            if (!ActorController.CanMove(actorData.currentState))
            {
                return;
            }

            if ((actorData.currentState & (int)ActorStateType.Move) == 0)
            {
                speedData.speed = 0;
                return;
            }

            var physics2DData = objData.GetData <Physics2DData>();
            var speed         = speedData.speed;

            speedData.speed = speed - physics2DData.friction;
            if (speedData.speed <= 0)
            {
                speedData.speed       = 0;
                physics2DData.force.x = 0;

                ActorAnimator.Stop(objData, ActorStateType.Move);

                actorData.currentState &= ~(int)ActorStateType.Move;
                objData.SetDirty(actorData);
            }
            else
            {
                physics2DData.force.x = speed;

                objData.SetDirty(physics2DData);
            }
        }
示例#2
0
        public override void Refresh(ObjectData objData)
        {
            var resourceStateData = objData.GetData <ResourceStateData>();

            if (!resourceStateData.isInstantiated)
            {
                return;
            }

            var stressData = objData.GetData <ActorStressData>();

            if (stressData.duration == 0)
            {
                Stop(objData.ObjectId);
                return;
            }

            var actorData = objData.GetData <ActorData>();

            if (!ActorController.CanSkillDefault(actorData.currentState))
            {
                return;
            }

            if ((actorData.currentState & (int)ActorStateType.SkillDefault) == 0 &&
                (actorData.currentState & (int)ActorStateType.SkillCustom) == 0)
            {
                stressData.currentDuration = stressData.duration = 0;
                return;
            }

            var worldMgr = WorldManager.Instance;

            var physics2DData = objData.GetData <Physics2DData>();

            if (stressData.currentDuration == stressData.duration)
            {
                stressData.currentDuration = stressData.duration = 0;
                physics2DData.force.y      = 0;

                if ((actorData.currentState & (int)ActorStateType.SkillDefault) != 0)
                {
                    ActorAnimator.Stop(objData, ActorStateType.SkillDefault);
                }
                else if ((actorData.currentState & (int)ActorStateType.SkillDefault) != 0)
                {
                    ActorAnimator.Stop(objData, ActorStateType.SkillCustom);
                }

                actorData.currentState &= ~(int)ActorStateType.SkillDefault;
                actorData.currentState &= ~(int)ActorStateType.SkillCustom;
                objData.SetDirty(actorData);
            }
            else
            {
                var gameSystemData = worldMgr.GameCore.GetData <GameSystemData>();
                stressData.currentDuration += gameSystemData.unscaleDeltaTime;
                if (stressData.currentDuration >= stressData.duration)
                {
                    stressData.currentDuration = stressData.duration;
                    physics2DData.force.y      = 0;
                }
                else
                {
                    physics2DData.force.y = -physics2DData.mass * Constant.ACTOR_STRESS_RATE_Y;

                    objData.SetDirty(physics2DData);
                }
            }
        }
示例#3
0
        public override void Refresh(ObjectData objData)
        {
            var resourceStateData = objData.GetData <ResourceStateData>();

            if (!resourceStateData.isInstantiated)
            {
                return;
            }

            var flyData = objData.GetData <ActorFlyData>();

            if (flyData.duration == 0)
            {
                Stop(objData.ObjectId);
                return;
            }

            var actorData = objData.GetData <ActorData>();

            if (!ActorController.CanSkillDefault(actorData.currentState))
            {
                return;
            }

            if ((actorData.currentState & (int)ActorStateType.SkillDefault) == 0 &&
                (actorData.currentState & (int)ActorStateType.SkillCustom) == 0)
            {
                flyData.currentDuration = flyData.duration = 0;
                return;
            }

            var worldMgr = WorldManager.Instance;

            var physics2DData = objData.GetData <Physics2DData>();

            if (flyData.currentDuration == flyData.duration)
            {
                flyData.currentDuration = flyData.duration = 0;

                physics2DData.force.x = 0;
                physics2DData.force.y = 0;

                if ((actorData.currentState & (int)ActorStateType.SkillDefault) != 0)
                {
                    ActorAnimator.Stop(objData, ActorStateType.SkillDefault);
                }
                else if ((actorData.currentState & (int)ActorStateType.SkillDefault) != 0)
                {
                    ActorAnimator.Stop(objData, ActorStateType.SkillCustom);
                }

                actorData.currentState &= ~(int)ActorStateType.SkillDefault;
                actorData.currentState &= ~(int)ActorStateType.SkillCustom;
                objData.SetDirty(actorData);
            }
            else
            {
                var gameSystemData = worldMgr.GameCore.GetData <GameSystemData>();
                flyData.currentDuration += gameSystemData.unscaleDeltaTime;
                if (flyData.currentDuration >= flyData.duration)
                {
                    flyData.currentDuration = flyData.duration;
                    physics2DData.force.y   = 0;
                }
                else
                {
                    var seconds = flyData.currentDuration * Constant.ACTOR_FLY_SHAKE_DURATION / Constant.SECOND_TO_MILLISECOND;
                    if (seconds % 2 == 0)
                    {
                        physics2DData.force.y = Constant.ACTOR_FLY_SHAKE_Y;
                    }
                    else
                    {
                        physics2DData.force.y = -Constant.ACTOR_FLY_SHAKE_Y;
                    }
                }

                physics2DData.force.x = Constant.ACTOR_FLY_SPEED_X;

                objData.SetDirty(physics2DData);
            }
        }
示例#4
0
        public override void Refresh(ObjectData objData)
        {
            var resourceStateData = objData.GetData <ResourceStateData>();

            if (!resourceStateData.isInstantiated)
            {
                return;
            }

            var jumpData = objData.GetData <ActorJumpData>();

            var currentJump = jumpData.currentJump;

            if (currentJump.y == 0 && currentJump.x == 0)
            {
                Stop(objData.ObjectId);
                return;
            }

            var actorData = objData.GetData <ActorData>();

            if (!ActorController.CanJump(actorData.currentState))
            {
                return;
            }

            if ((actorData.currentState & (int)ActorStateType.Jump) == 0)
            {
                jumpData.currentJump = Vector3Int.zero;
                return;
            }

            var physics2DData       = objData.GetData <Physics2DData>();
            var actorControllerData = objData.GetData <ActorController2DData>();

            if (ActorPhysics2D.IsGround(actorControllerData) && jumpData.currentJump.y == 0)
            {
                jumpData.currentJump.x = 0;

                physics2DData.force.x = 0;
                physics2DData.force.y = 0;

                ActorAnimator.JumpGround(objData);
                ActorAnimator.Stop(objData, ActorStateType.Jump);

                actorData.currentState &= ~(int)ActorStateType.Jump;
                objData.SetDirty(actorData);
            }
            else
            {
                jumpData.currentJump.y = currentJump.y - physics2DData.airFriction;
                if (jumpData.currentJump.y < 0)
                {
                    jumpData.currentJump.y = 0;
                    physics2DData.force.y += -physics2DData.airFriction;
                }
                else
                {
                    physics2DData.force.y = currentJump.y;
                }

                physics2DData.force.x = jumpData.currentJump.x;

                objData.SetDirty(physics2DData);
            }
        }