Пример #1
0
 private void Update()
 {
     // Debug.Log("main world update");
     m_Systems.Update();
     GameInput.GetInstance().Reset();
 }
Пример #2
0
        public void SampleInput(ref UserCommand command, float deltaTime)
        {
            Vector2 moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
            // GameInput.GetInstance().JoystickDir = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
            float angle = Vector2.Angle(Vector2.up, moveInput);

            if (moveInput.x < 0)
            {
                angle = 360 - angle;
            }
            float magnitude = Mathf.Clamp(moveInput.magnitude, 0, 1);

            command.moveYaw       = angle;
            command.moveMagnitude = magnitude;

            var roleGameOE = RoleMgr.GetInstance().GetMainRole();

            EntityManager.SetComponentData <ActionData>(roleGameOE.Entity, ActionData.Empty);

            float invertY = 1.0f;

            Vector2 deltaMousePos = new Vector2(0, 0);

            if (deltaTime > 0.0f)
            {
                deltaMousePos += new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y") * invertY);
            }

            const float configMouseSensitivity = 1.5f;

            command.lookYaw += deltaMousePos.x * configMouseSensitivity;
            command.lookYaw  = command.lookYaw % 360;
            while (command.lookYaw < 0.0f)
            {
                command.lookYaw += 360.0f;
            }

            command.lookPitch += deltaMousePos.y * configMouseSensitivity;
            command.lookPitch  = Mathf.Clamp(command.lookPitch, 0, 180);

            command.jump   = (command.jump != 0 || Input.GetKeyDown(KeyCode.Space))?1:0;
            command.sprint = (command.sprint != 0 || Input.GetKey(KeyCode.LeftShift))?1:0;

            if (GameInput.GetInstance().GetKeyUp(KeyCode.J))
            {
                SkillManager.GetInstance().CastSkillByIndex(-1);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.I))
            {
                SkillManager.GetInstance().CastSkillByIndex(0);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.O))
            {
                SkillManager.GetInstance().CastSkillByIndex(1);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.K))
            {
                SkillManager.GetInstance().CastSkillByIndex(2);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.L))
            {
                SkillManager.GetInstance().CastSkillByIndex(3);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.Space))
            {
                DoJump();
            }
        }
Пример #3
0
        public void SampleInput(ref UserCommand command, float deltaTime)
        {
            Vector2 moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
            float   angle     = Vector2.Angle(Vector2.up, moveInput);

            if (moveInput.x < 0)
            {
                angle = 360 - angle;
            }
            float magnitude = Mathf.Clamp(moveInput.magnitude, 0, 1);

            // if (magnitude > maxMoveMagnitude)
            // {
            //     maxMoveYaw = angle;
            //     maxMoveMagnitude = magnitude;
            // }
            command.moveYaw       = angle;
            command.moveMagnitude = magnitude;

            float invertY = 1.0f;

            Vector2 deltaMousePos = new Vector2(0, 0);

            if (deltaTime > 0.0f)
            {
                deltaMousePos += new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y") * invertY);
            }

            const float configMouseSensitivity = 1.5f;

            command.lookYaw += deltaMousePos.x * configMouseSensitivity;
            command.lookYaw  = command.lookYaw % 360;
            while (command.lookYaw < 0.0f)
            {
                command.lookYaw += 360.0f;
            }

            command.lookPitch += deltaMousePos.y * configMouseSensitivity;
            command.lookPitch  = Mathf.Clamp(command.lookPitch, 0, 180);

            command.jump   = (command.jump != 0 || Input.GetKeyDown(KeyCode.Space))?1:0;
            command.sprint = (command.sprint != 0 || Input.GetKey(KeyCode.LeftShift))?1:0;

            if (GameInput.GetInstance().GetKeyUp(KeyCode.J))
            {
                CastSkill(-1);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.I))
            {
                CastSkill(0);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.O))
            {
                CastSkill(1);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.K))
            {
                CastSkill(2);
            }
            else if (GameInput.GetInstance().GetKeyUp(KeyCode.L))
            {
                CastSkill(3);
            }
        }