Respawn() private method

private Respawn ( ) : void
return void
Ejemplo n.º 1
0
    void Update()
    {
        if (!PauseControl.gameIsPaused)
        {
            Vector2 playerInput;
            if (Input.GetButtonDown("Respawn"))
            {
                respawnable.Respawn();
            }
            playerInput.x = Input.GetAxis("Horizontal");
            playerInput.y = Input.GetAxis("Vertical");
            desiredJump  |= Input.GetButtonDown("Jump");
            playerInput   = Vector2.ClampMagnitude(playerInput, 1f);

            if (playerInputSpace)
            {
                Vector3 forward = playerInputSpace.forward;
                forward.y = 0f;
                forward.Normalize();
                Vector3 right = playerInputSpace.right;
                right.y = 0f;
                right.Normalize();
                desiredVelocity =
                    (forward * playerInput.y + right * playerInput.x) * maxSpeed;
            }
            else
            {
                desiredVelocity =
                    new Vector3(playerInput.x, 0f, playerInput.y) * maxSpeed;
            }

            if (groundCollisionDebug)
            {
                GetComponent <Renderer>().material.SetColor(
                    "_Color", OnGround ? Color.black : Color.white
                    );
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        // TODO: Should all of these be defined in InputManger in editor?
        if (Input.GetKeyDown("c"))
        {
            cameratized.NextCamera();
        }
        if (Input.GetKeyDown("r"))
        {
            respawnable.Respawn();
        }

        // Gravity controls
        if (Input.GetKeyDown("up"))
        {
            vehicleController.InvertGravity();
        }
        else if (Input.GetKeyDown("right"))
        {
            vehicleController.ShiftGravityClockwise();
        }
        else if (Input.GetKeyDown("left"))
        {
            vehicleController.ShiftGravityCounterClockwise();
        }

        // Vehicle movement
        // TODO: Potentially use an axis input instead for a/d
        if (Input.GetKey("a"))
        {
            vehicleController.MoveLeft();
        }
        else if (Input.GetKey("d"))
        {
            vehicleController.MoveRight();
        }

        if (Input.GetKeyDown("s"))
        {
            vehicleController.ApplyBrake();
        }
        else if (Input.GetKeyUp("s"))
        {
            vehicleController.ReleaseBrake();
        }
    }
Ejemplo n.º 3
0
    //Когда сработал триггер
    private void OnTriggerEnter2D(Collider2D other)
    {
        //Временная переменная, чтобы запомнить, кто вошел
        Respawnable respawnable = null;

        Destroyable destroyable = null;

        //Запоминаем, кто вошел и, если он имеет скрипт Respawnable
        if (other.gameObject.TryGetComponent(out respawnable) != false)
        {
            //То вызываем его метод Respawn()
            respawnable.Respawn();
        }

        if (other.gameObject.TryGetComponent(out destroyable) != false)
        {
            destroyable.Destroy();
        }
    }