protected virtual void AbilityActivate()
 {
     abilityOn     = true;
     cooldownTimer = cooldownTime;
     skillTimer    = m_effect.m_duration;
     heroInfo.Deidle();
 }
Exemple #2
0
    private void TPUpdate()
    {
        shiftKeyPressed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
        agent.speed     = ((SprintingAbility) ? (shiftKeyPressed ? 25000.0f : 21500.0f) : (
                               shiftKeyPressed ? 16000.0f : 10500.0f));
        currMousePos = Input.mousePosition.x;
        bool shouldRepositionToCenter = HeroCamScript.IsOnHero && GameManager.GameRunning && !
                                        heroCamDisabler.DisabledCameraMovement && StateID.STATE_SHOP != ApplicationManager.
                                        Instance.GetAppState();

        if (Mathf.Abs(Screen.width * 0.5f - currMousePos) >= (Screen.width * 0.2f) || Mathf.Abs
                (Screen.height * 0.5f - HeroCamScript.MouseVertical) >= (Screen.height * 0.2f))
        {
            Cursor.lockState = shouldRepositionToCenter ? CursorLockMode.Locked : CursorLockMode.
                               None;
            if (shouldRepositionToCenter && CursorLockMode.None == Cursor.lockState)
            {
                Cursor.lockState = CursorLockMode.None;
                Cursor.lockState = CursorLockMode.Locked;
            }
        }
        if (GameManager.GameRunning)
        {
            if (!HeroCamScript.IsOnVantage && HeroCamScript.IsOnHero && StateID.STATE_SHOP !=
                ApplicationManager.Instance.GetAppState())
            {
                if (!GameManager.Tutorial || !heroCamDisabler.DisabledCameraMovement)
                {
                    transform.Rotate(transform.up, (currMousePos - prevMousePos) * 0.5f);
                    currentRot += (currMousePos - prevMousePos) * 0.5f;
                }
                tValue += Time.deltaTime * 2.5f;
                if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow) || Input.
                    GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow) || Input.
                    GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow) || Input.
                    GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
                {
                    if (!moving)
                    {
                        tValue = 0.0f;
                        moving = true;
                    }
                }
                if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(
                        KeyCode.A) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.S) ||
                    Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.D) || Input.GetKey(
                        KeyCode.RightArrow))
                {
                    info.Deidle();
                }
                else
                {
                    moving = false;
                }
                newVel = Vector3.zero;
                if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
                {
                    newVel += transform.forward;
                }
                if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
                {
                    newVel -= transform.forward;
                }
                if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
                {
                    newVel += transform.right;
                }
                if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
                {
                    newVel -= transform.right;
                }
                newVel         = newVel.normalized * Time.deltaTime * agent.speed;
                agent.velocity = Vector3.Lerp(Vector3.zero, newVel, tValue);
            }
        }
        if (CursorLockMode.Locked == Cursor.lockState)
        {
            prevMousePos = Screen.width * 0.5f;
            HeroCamScript.MouseVertical = Screen.height * 0.5f;
            Cursor.lockState            = CursorLockMode.None;
        }
        else
        {
            prevMousePos = Input.mousePosition.x;
            HeroCamScript.MouseVertical = Input.mousePosition.y;
        }
        rot   = transform.rotation.eulerAngles;
        rot.y = currentRot;
        transform.rotation = Quaternion.Euler(rot);
    }