Пример #1
0
        public override void Update()
        {
            //Transform checkpointTransform = GetComponent<Transform>();
            //checkpointTransform.Rotate((Vector3.up * checkpointRotationSpeed) * Time.deltaTime);

            Vector3 playerPosition = FollowCamera.target.transform.position;
            Vector3 distance       = playerPosition - checkpointPosition;

            distance.y = 0;

            if (checkpointDisplayRadius < checkpointRadius)
            {
                checkpointDisplayRadius += checkpointRadius * 1.0f * Time.deltaTime;
                if (checkpointDisplayRadius > checkpointRadius)
                {
                    checkpointDisplayRadius = checkpointRadius;
                }
                gameObject.transform.localScale = new Vector3(checkpointDisplayRadius * 2, 8.0f, checkpointDisplayRadius * 2);
            }

            if (distance.magnitude >= checkpointRadius)
            {
                UpdateCheckpoint();
            }

            if (timeRemaining > 0 && !debugDisableTimer)
            {
                timeRemaining -= Time.deltaTime;
            }

            if (timeRemaining < 0)
            {
                //Debug.Log("Player ran out of time!");
                //end/restart game?
                // CancelInvoke("decreaseTimeRemaining");
                timeRemaining = 0;

                PlayerDeath player = GameObject.Find("PlayerCharacter").GetComponent <PlayerDeath>();
                player.killPlayer();
            }

            if (timeRemaining < 10)
            {
                checkpointTimer.color = new Color(100, 0, 0);
                if (checkpointTimer.fontSize < 65 && TextSizeFlag == true)
                {
                    checkpointTimer.fontSize += 1;
                    if (checkpointTimer.fontSize == 65)
                    {
                        TextSizeFlag = false;
                    }
                }
                else if (timeRemaining > 0)
                {
                    checkpointTimer.fontSize -= 1;
                    if (checkpointTimer.fontSize == 45)
                    {
                        TextSizeFlag = true;
                    }
                }
            }
            else
            {
                checkpointTimer.color    = new Color(0, 0, 0);
                checkpointTimer.fontSize = 65;
            }
            checkpointTimer.text = "Time Left: " + timeRemaining.ToString("0.0");

            float distFromCentre = distance.magnitude;
            float distFromEdge   = checkpointRadius - distFromCentre;

            checkpointDistance.text = distFromEdge.ToString("0") + "m";
        }