void Update()
    {
        if (Console.Instance != null && Console.Instance.Active)
        {
            return;
        }


        if (GameManager.GUIManager != null && GameManager.GUIManager.DialogGUI.InConversation)
        {
            return;
        }


        if (Input.GetKeyDown(KeyCode.P))
        {
            doPath = true;
        }
        else
        {
            doPath = false;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            GUIManager2.Instance.SetVisible(!GUIManager2.Instance.OpenGUIVisible);
        }

        if (GameManager.Paused)
        {
            return;
        }

        Debug.BeginDeepProfile("PlayerManagerUpdate");

        Vector3 worldMousePos = GetWorldMousePosition();

        Tick(Time.deltaTime);


        Player.Update();

        MovementUpdate();

        PlayerSelectUpdate();

        /*
         * float x = Input.GetAxis("Horizontal");
         * float z = Input.GetAxis("Vertical");
         *
         *
         * float ud = x * Mathf.Cos(-PlayerCameraScript.Theta * Mathf.Deg2Rad) + z * Mathf.Sin(-PlayerCameraScript.Theta * Mathf.Deg2Rad);
         * float lr = x * Mathf.Sin(-PlayerCameraScript.Theta * Mathf.Deg2Rad) - z * Mathf.Cos(-PlayerCameraScript.Theta * Mathf.Deg2Rad);
         *
         * x *= Mathf.Cos(PlayerCameraScript.Theta * Mathf.Deg2Rad) + Mathf.Sin(PlayerCameraScript.Theta * Mathf.Deg2Rad);
         * z *= Mathf.Sin(PlayerCameraScript.Theta * Mathf.Deg2Rad);
         *
         * LoadedPlayer.MoveInDirection(new Vector2(lr, ud));
         *
         */


        GameManager.DebugGUI.SetData("world_mouse_pos", worldMousePos.ToString());
        LoadedPlayer.LookTowardsPoint(worldMousePos);

        if (Input.GetKey(KeyCode.Alpha1))
        {
            SpellCastData data = new SpellCastData();
            data.Source = Player;
            data.Target = GetWorldMousePosition();
            Player.CombatManager.SpellManager.CastSpell(0, data);
        }

        if (Input.GetMouseButtonDown(0))
        {
            LeftMouseButton();
        }
        else if (Input.GetMouseButtonDown(1))
        {
            RightMouseButton();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            LoadedPlayer.Jump();
        }

        LoadedPlayer.SetRunning(Input.GetKey(KeyCode.LeftShift));

        Debug.EndDeepProfile("PlayerManagerUpdate");
    }
Exemple #2
0
    void Update()
    {
        LoadedPlayer.SetIdle(false);
        if (Console.Instance != null && Console.Instance.Active)
        {
            return;
        }



        if (GUIManager.Instance != null && GUIManager.Instance.DialogGUI.InConversation)
        {
            Debug.Log(GUIManager.Instance.DialogGUI.InConversation);
            Debug.Log("Caused by GUI = true");
            return;
        }



        if (Input.GetKeyDown(KeyCode.P))
        {
            doPath = true;
        }
        else
        {
            doPath = false;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            GUIManager.Instance.SetVisible(!GUIManager.Instance.OpenGUIVisible);
        }

        if (GameManager.Paused)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (PlayerCameraScript.CameraController is FirstPersonCC)
            {
                PlayerCameraScript.SetThirdPersonCamera();
            }
            else
            {
                PlayerCameraScript.SetFirstPersonCamera();
            }
        }
        // Debug.BeginDeepProfile("PlayerManagerUpdate");

        Vector3 worldMousePos = GetWorldMousePosition();


        Vec2i currentChunk = World.GetChunkPosition(Player.TilePos);

        if (currentChunk != LastChunk)
        {
            LastChunk = currentChunk;
        }
        Tick(Time.deltaTime);
        Player.Update();

        MovementUpdate();
        PlayerSelectUpdate();



        DebugGUI.Instance.SetData("world_mouse_pos", worldMousePos.ToString());
        LoadedPlayer.LookTowardsPoint(worldMousePos);

        if (Input.GetKey(KeyCode.Alpha1))
        {
            SpellCastData data = new SpellCastData();
            data.Source = Player;
            data.Target = GetWorldMousePosition();
            Player.CombatManager.EntitySpellManager.CastSpell(0, data);
        }

        if (Input.GetMouseButton(0))
        {
            LeftMouseButton();
        }
        else if (Input.GetMouseButtonDown(1))
        {
            RightMouseButton();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            LoadedPlayer.Jump();
        }

        LoadedPlayer.SetRunning(Input.GetKey(KeyCode.LeftShift));

        Debug.EndDeepProfile("PlayerManagerUpdate");
    }