private void Update()
        {
            // Ensure target resource has this behaviour assigned
            // Coupling is otherwise lost when reloading a game
            if (targetResource != null)
            {
                if (!targetResource.QuestResourceBehaviour)
                {
                    targetResource.QuestResourceBehaviour = this;
                }
            }

            // Handle enemy checks
            if (enemyEntityBehaviour)
            {
                // Get foe resource
                Foe foe = (Foe)targetResource;
                if (foe == null)
                {
                    return;
                }

                // If foe is hidden then remove self from game
                if (foe.IsHidden)
                {
                    Destroy(gameObject);
                    return;
                }

                // Handle restrained check
                // This might need some tuning in relation to injured and death checks
                if (foe.IsRestrained)
                {
                    // Make enemy non-hostile
                    EnemyMotor enemyMotor = transform.GetComponent <EnemyMotor>();
                    if (enemyMotor)
                    {
                        enemyMotor.IsHostile = false;
                    }

                    // Lower flag now this has been handled
                    foe.ClearRestrained();
                }

                // Handle injured check
                // This has to happen before death or script actions attached to injured event will not trigger
                if (enemyEntityBehaviour.Entity.CurrentHealth < enemyEntityBehaviour.Entity.MaxHealth && !foe.InjuredTrigger)
                {
                    foe.SetInjured();
                    return;
                }

                // Handle death check
                if (enemyEntityBehaviour.Entity.CurrentHealth <= 0 && !isFoeDead)
                {
                    foe.IncrementKills();
                    isFoeDead = true;
                }
            }
        }
Ejemplo n.º 2
0
        private void Update()
        {
            // Handle enemy checks
            if (enemyEntityBehaviour)
            {
                // Handle injured check
                // This has to happen before death or script actions attached to injured event will not trigger
                Foe foe = (Foe)targetResource;
                if (enemyEntityBehaviour.Entity.CurrentHealth < enemyEntityBehaviour.Entity.MaxHealth && !foe.InjuredTrigger)
                {
                    foe.SetInjured();
                    return;
                }

                // Handle death check
                if (enemyEntityBehaviour.Entity.CurrentHealth <= 0 && !isFoeDead)
                {
                    foe.IncrementKills();
                    isFoeDead = true;
                }
            }
        }
Ejemplo n.º 3
0
        private void Update()
        {
            // Ensure target resource has this behaviour assigned
            // Coupling is otherwise lost when reloading a game
            if (targetResource != null)
            {
                if (!targetResource.QuestResourceBehaviour)
                {
                    targetResource.QuestResourceBehaviour = this;
                }
            }

            // Handle NPC checks
            if (targetResource is Person && targetResource.QuestResourceBehaviour)
            {
                // Disable person resource if hidden or destroyed
                // Normally this is done via QuestResource.Tick() but this stops receiving ticks when quest terminates
                // Sometimes a quest person is hidden at same time quest is ended, e.g. $CUREWER when spawning lycanthrope foe
                // Also disabling here to handle this situation
                Person targetPerson = (Person)targetResource;
                if (targetPerson.IsHidden || targetPerson.IsDestroyed)
                {
                    targetPerson.QuestResourceBehaviour.gameObject.SetActive(false);
                }
            }

            // Handle enemy checks
            if (enemyEntityBehaviour)
            {
                // Get foe resource
                Foe foe = (Foe)targetResource;
                if (foe == null)
                {
                    return;
                }

                // If foe is hidden then remove self from game
                if (foe.IsHidden)
                {
                    Destroy(gameObject);
                    return;
                }

                // Handle restrained check
                // This might need some tuning in relation to injured and death checks
                if (foe.IsRestrained)
                {
                    // Make enemy non-hostile
                    EnemyMotor enemyMotor = transform.GetComponent <EnemyMotor>();
                    if (enemyMotor)
                    {
                        enemyMotor.IsHostile = false;
                    }

                    // Lower flag now this has been handled
                    foe.ClearRestrained();
                }

                // Handle injured check
                // This has to happen before death or script actions attached to injured event will not trigger
                if (enemyEntityBehaviour.Entity.CurrentHealth < enemyEntityBehaviour.Entity.MaxHealth && !foe.InjuredTrigger)
                {
                    foe.SetInjured();
                    return;
                }

                // Handle death check
                if (enemyEntityBehaviour.Entity.CurrentHealth <= 0 && !isFoeDead)
                {
                    foe.IncrementKills();
                    isFoeDead = true;
                }
            }
        }