예제 #1
0
        // Update is called once per frame
        private void Update()
        {
            if (_health.IsDead || _target == null)
            {
                return;
            }

            if (_restTimer > 0)
            {
                _restTimer -= Time.deltaTime;
                return;
            }

            if (_targetHealth.IsDead)
            {
                _isAttacked = false;
                _actionScheduler.CancelCurrentAction();
            }

            if (DistanceToPlayer() && Fighter.CanAttack(_target) && !IsGoingHome || _isAttacked)
            {
                AttackBehaviour();
            }
            else
            {
                PreparePatrolBehaviour();
                PatrolBehaviour();
            }

            if (patroller != null)
            {
                _timeSinceLastBreak += Time.deltaTime;
            }
        }
예제 #2
0
 void DeathCheack()
 {
     if (IsDead)
     {
         //onDeathTest();
         SetComponent();
         myAnimator.TriggerDeath();
         actionScheduler.CancelCurrentAction();//?????
     }
 }
예제 #3
0
 public void RestoreState(object state)
 {
     _agent.enabled     = false;
     transform.position = ((SerializableVector3)state).ToVector3();
     _agent.enabled     = true;
     _actionScheduler.CancelCurrentAction();
 }
 public void Die()
 {
     if (_isDead)
     {
         return;
     }
     _isDead = true;
     if (_anim != null)
     {
         _anim.SetTrigger("die");
     }
     if (_actionScheduler != null)
     {
         _actionScheduler.CancelCurrentAction();
     }
     //foreach (var item in _colliders)
     //{
     //    item.enabled = false;
     //}
     //foreach (var item in _components)
     //{
     //    item.enabled = false;
     //}
     if (_colliders != null)
     {
         new List <Collider>(_colliders).ForEach(item => item.enabled = false);
     }
     if (_components != null)
     {
         new List <MonoBehaviour>(_components).ForEach(item => item.enabled = false);
     }
 }
예제 #5
0
 // placeholder parameter
 void DisablePlayerControl(PlayableDirector stuff)
 {
     if (pc != null)
     {
         print("disabling control");
         actionScheduler.CancelCurrentAction();
         pc.enabled = false;
     }
 }
예제 #6
0
        public void RestoreState(object state)
        {
            var position = (SerializableVector3)state;

            m_NavMeshAgent.enabled = false;
            transform.position     = position.ToVector();
            m_NavMeshAgent.enabled = true;
            m_ActionScheduler.CancelCurrentAction();
        }
예제 #7
0
        private void Die()
        {
            if (IsDead)
            {
                return;
            }

            IsDead = true;

            if (_animator != null)
            {
                _animator.SetTrigger("die");
            }

            if (_actionScheduler != null)
            {
                _actionScheduler.CancelCurrentAction();
            }

            //_capsuleCollider.enabled = false;
            //_navMeshAgent.enabled = false;

            Enemy enemy = gameObject.GetComponent <Enemy>();

            if (enemy)
            {
                GameManager.Instance.uiManager.LevelManagerGO.GetComponent <LevelManager>().levelWindow.levelSystem.AddExperience(enemy.XpValue);
                if (spawner != null)
                {
                    spawner.RemoveObject(gameObject);
                }
            }

            if (_death != null)
            {
                StopCoroutine(_death);
            }

            if (!CompareTag("Player"))
            {
                var gold = (int)Random.Range(GetComponent <CombatTarget>().MINGold, GetComponent <CombatTarget>().MAXGold);
                GameManager.Instance.player.inventory.gold += gold;
                _death = StartCoroutine(DestroyEnemy(_combatTarget.ListLoot.Count > 0 ? destroyTimeWithLoot : destroyTime));
                PurgeManager.Instance.killedCount += 1;

                if (GetComponent <AISpellController>() == null)
                {
                    return;
                }

                GameManager.Instance.Boss.SetActive(true);
            }
            else
            {
                StartCoroutine(RespawnPlayer());
            }
        }
예제 #8
0
        private void Die()
        {
            if (IsDead)
            {
                return;
            }

            m_Animator.SetTrigger(s_Die);
            m_ActionScheduler.CancelCurrentAction();
            IsDead = true;
        }
예제 #9
0
 private void Die(bool immediate = false)
 {
     isDead = true;
     if (immediate)
     {
         anim.Play("Death", 0, 1);
     }
     else
     {
         anim.SetTrigger("DeathTrigger");
     }
     actionScheduler.CancelCurrentAction();
 }
예제 #10
0
        public void RestoreState(object state)
        {
            if (!isInited)
            {
                Init();
            }

            SerializableVector3 pos = (SerializableVector3)state;

            agent.enabled      = false;
            transform.position = pos.ToVector3();
            agent.enabled      = true;

            actionScheduler.CancelCurrentAction();
        }
예제 #11
0
        public void StartMoveAction(Vector3 position, float speedFraction = 1f)
        {
            if (attackIsAnimating)
            {
                return;
            }
            if (GetComponent <Health>() != null && !GetComponent <Health>().Alive)
            {
                return;
            }
            ActionScheduler actionScheduler = GetComponent <ActionScheduler>();

            actionScheduler.CancelCurrentAction();
            actionScheduler.StartAction(this);
            MoveTo(position, Mathf.Clamp01(speedFraction));
        }
예제 #12
0
 private void AttackPlayer()
 {
     if (IsAggrevated())
     {
         timeSinceLastSawPlayer = 0;
         enemyFighter.Attack(player);
         AggrevateNearbyEnemies();
     }
     else if (timeSinceLastSawPlayer < susWaitTime)
     {
         actionScheduler.CancelCurrentAction();
     }
     else
     {
         PatrolBehavior();
     }
 }
예제 #13
0
        private void Die()
        {
            if (isDead)
            {
                return;
            }
            isDead = true;
            GetComponent <Animator>().SetTrigger("die");
            GetComponent <CapsuleCollider>().enabled = false;
            ActionScheduler actionScheduler     = GetComponent <ActionScheduler>();
            Transform       interactionCollider = transform.Find("InteractionCollider");

            if (interactionCollider != null)
            {
                Destroy(interactionCollider.gameObject);
            }
            if (actionScheduler == null)
            {
                return;
            }
            actionScheduler.CancelCurrentAction();
        }
예제 #14
0
        private void PatrolBehaviour()
        {
            //initialize first destination
            Vector3 nextPosition = m_PositionToGuard;

            if (m_PatrolPath != null)
            {
                if (AtWayPoint())
                {
                    m_ActionScheduler.CancelCurrentAction();
                    m_TimeSinceArrivedAtLastWaypoint = 0f;
                    CycleWayPoint();
                }
                nextPosition = GetCurrentWaypoint();
            }

            //Don't move until we have dwelled first
            if (m_TimeSinceArrivedAtLastWaypoint > m_WaypointDwellTime)
            {
                m_Mover.StartMoveAction(nextPosition);
            }
        }
 private void DisableControl(PlayableDirector pd)
 {
     m_ActionScheduler.CancelCurrentAction();
     m_PlayerController.enabled = false;
     OnCinematicStart(true);
 }
예제 #16
0
 private void SuspicionBehaviour()
 {
     // Suspicion state
     actionScheduler.CancelCurrentAction();
 }
 private void DisableControl(PlayableDirector _)
 {
     playerActionScheduler.CancelCurrentAction();
     playerController.enabled = false;
 }
예제 #18
0
 private void SuspicionBehavior()
 {
     actionScheduler.CancelCurrentAction();
 }
예제 #19
0
 private void SuspicionBehaviour()
 {
     actionScheduler.CancelCurrentAction();
     hasShouted = false;
 }
예제 #20
0
 public void CancelCurrentAction()
 {
     actionScheduler.CancelCurrentAction();
 }
예제 #21
0
 private void Die()
 {
     GetComponent <Animator>().SetTrigger("die");
     isDead = true;
     actionScheduler.CancelCurrentAction();
 }
예제 #22
0
 private void Die()
 {
     isDead = true;
     animator.SetTrigger("die");
     actionScheduler.CancelCurrentAction();
 }