コード例 #1
0
    public void NewLife()
    {
        GameObject[] backgroundObjects = GameObject.FindGameObjectsWithTag("Background");
        scoreMultiplier = 1;
        maxHealth       = startingMaxHealth;
        currentHealth   = maxHealth;
        if (hasMovementUpgrade)
        {
            maxMoveCapacity     = startingMaxMoveCapacity;
            maxForceSingleMove *= .80f;
            maxSpeed           += maxSpeed *= .80f;
        }
        currentMoveCapacity = maxMoveCapacity;
        hasHealthUpgrade    = false;
        hasMovementUpgrade  = false;
        transform.position  = Vector3.zero;
        transform.rotation  = Quaternion.identity;
        GetComponent <Rigidbody2D>().angularVelocity = 0;
        GetComponent <Rigidbody2D>().velocity        = Vector3.zero;

        CheckUpgradeSprites();
        foreach (GameObject backgroundObject in backgroundObjects)
        {
            SpaceObjectController backgroundController = backgroundObject.GetComponent <SpaceObjectController>();
            if (backgroundController != null && !backgroundController.avoidCentreDuringGeneration)
            {
                backgroundController.ResetPosition();
            }
        }
        Vector3 newCamPosition = mainCamera.transform.position;

        newCamPosition.x = 0f;
        newCamPosition.y = 0f;
        mainCamera.transform.position = newCamPosition;
        timeKeeper.ClearCentre();
        timeKeeper.RestoreNonRenewableObjects();
        lostLife = false;
        alive    = true;
        if (UI.isFastForward)
        {
            UI.fastForwardToggle.isOn = false;
        }
        UI.HideLostLifeUI();
        UI.UpdateLivesText();
        StartCoroutine(PlayerHurt("new life"));
    }