Пример #1
0
    void Update()
    {
        if (_state == MeteorState.ChasePlayer)
        {
            Vector3 playerPos = Player.Instance.transform.position;
            Vector3 direction = playerPos + new Vector3(0f, _explodeHeight * 0.6f, 0f) - _boomTransform.position;

            Vector3 velocity = direction.normalized * _speed;

            _boomRb.velocity = Vector3.Lerp(_boomRb.velocity, velocity, _lerpSpeed * Time.deltaTime);

            if (_boomTransform.position.y < _explodeHeight)
            {
                // phát nổ ngay tại đây
                _state = MeteorState.StopMoving;

                _boomAnimator.SetTrigger("Disappear");

                _explosion.transform.position = _boomTransform.position;
                _castDamage.gameObject.SetActive(true);
                _explosion.SetActive(true);


                _audioSource.PlayOneShot(_clip, 0.3f);

                StartCoroutine(TurnOffCastDamage(0.4f));
                StartCoroutine(Deactive(1f));
            }
        }
        else
        {
            _boomRb.velocity = Vector3.zero;
        }
    }
Пример #2
0
 public override void Setup()
 {
     objectRadius          = 0.3f;
     CanBehHitWithImploder = false;
     healthPoints          = 100;
     damage = 60;
     State  = new MeteorState();
 }
Пример #3
0
 public void ToggleToDestructingTargetState(Vector3 _targetPosition)
 {
     rb.drag = 1000; // stopingTheMovement
     State   = MeteorState.DestructingTarget;
     //Calculate Vector of Animation Direction
     // Send Vector To Aniamtionhandler
     TimeingManager.SchoudleDelayedFunctionTrigger(1f, RemoveFromSimulation);
 }
Пример #4
0
    // gọi hàm này sau khi Wizard gọi Meteor active lên
    public void AfterSetActive()
    {
        // đưa boom lên trên đầu player
        Vector3 playerPos = Player.Instance.transform.position;

        Vector3 insideSphere = Random.insideUnitSphere;

        insideSphere.y = 0f;

        Vector3 boomPos = playerPos + new Vector3(0f, _height, 0f) + insideSphere * _randomRange;

        _boomTransform.position = boomPos;

        // hướng di chuyển ban đầu
        _originDirection = playerPos /* + new Vector3(0f, _explodeHeight * 0.8f, 0f)*/ - boomPos;
        _originDirection = _originDirection.normalized;
        _boomRb.velocity = Vector3.zero;

        //
        _explosion.SetActive(false);
        _state = MeteorState.ChasePlayer;
    }
Пример #5
0
 public void ToggleToMoveTowardsTargetAsImploded()
 {
     State = MeteorState.MovingTowardsTargetAsImplosionCatched;
 }
Пример #6
0
 public void ToggleToMoveTowardsPlayer()
 {
     State   = MeteorState.MovingTowardsPlayer;
     rb.drag = regulatDrag;
     rb.mass = regularMass;
 }
Пример #7
0
 public void ToggleToAerialDestructionState()
 {
     isAvaiableForInteraction = false;
     State = MeteorState.DestructingAerial;
     TimeingManager.SchoudleDelayedFunctionTrigger(1f, RemoveFromSimulation);
 }