Esempio n. 1
0
    // Update is called once per frame
    protected void Update()
    {
        // Do nothing if dialogue is playing
        if (m_gamePaused)
        {
            return;
        }

        if (InputContainer.instance.fire.down || InputContainer.instance.fire.pressed)
        {
            // Fire at opponents
            shooter.FireProjectile(Vector2.up, 0.1f);
        }

        if (!m_gameSlowed && (InputContainer.instance.slowTime.down || InputContainer.instance.slowTime.pressed))
        {
            Debug.Log("Calling slow down time!");
            // Slow down game time
            StartCoroutine(SlowDownTimer.RunSlowDownTimer());
        }

        // Get your up/down/left/right player input
        Vector2 move = GetMovement();

        // Get your current position
        Vector2 position = rigidbody2d.position;

        // Set your position as your position plus your movement vector, times your speed multiplier, and the current game timestep;
        position = position + move * m_speed * Time.deltaTime;

        // Tell the rigidbody to move to the positon specified
        rigidbody2d.MovePosition(position);
    }