Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (!moveTowardsPlayer)
        {
            asteroidTransform.position += Vector3.back * Time.deltaTime * movementSpeed;
        }
        else
        {
            float step = movementSpeed * Time.deltaTime;
            transform.position = Vector3.MoveTowards(asteroidTransform.position, PlayerRef.instance.playerTransform.position, step);
            //if it's moving towards player update IsInView check
            _wasInView = _isInView;
            _isInView  = Check_ObjectIsInView();
            //update warning blip list if there is a change in view
            if (_wasInView && !_isInView || _isInView && !_wasInView) //this reads as 'if it was in view & it is not in view now || if it is in view & it wasn't in view'
            {
                WarningBlips.instance.UpdateList(this);
            }

            /* if(_isInView && !_wasInView)
             * {
             *   //asteroid popped into view,show blip
             *   warningBlipObject.SetActive(true);
             *   warningBlipObject.GetComponent<EasyTween>().OpenCloseObjectAnimation();
             * }
             * else if (_wasInView && !_isInView)
             * {
             *   //asteroid popped out of view,hide blip
             *   warningBlipObject.SetActive(false);
             * }*/
        }
        if (applyDamage)
        {
            health -= Time.deltaTime * gazeInput.gazeTime * PlayerRef.instance.powerMultiplier;
            if (health <= 0)
            {
                PlayerRef.IncreaseHealth(5);
                DestroyAsteroid();
            }
        }
    }