Esempio n. 1
0
    public void UpdateAction()
    {
        if (!CheckAvailability() || _executionStopped)
        {
            return;
        }

        if (ParentCharacter.MyAI.BlackBoard.TargetCorpse != null)
        {
            Vector3 distance = ParentCharacter.MyAI.BlackBoard.TargetCorpse.LastKnownPos - ParentCharacter.transform.position;
            if (distance.magnitude > 2)
            {
                ParentCharacter.CurrentStance = HumanStances.Run;
                ParentCharacter.MyAI.TargetingSystem.SetTargetingMode(AITargetingModes.LookAhead, Vector3.zero);
                Vector3 dest = ParentCharacter.MyAI.BlackBoard.TargetCorpse.LastKnownPos - distance.normalized * 0.5f;
                ParentCharacter.Destination = dest;
                ParentCharacter.SendCommand(CharacterCommands.GoToPosition);
            }
            else
            {
                if (ParentCharacter.MyAI.IsCharacterFriendly((Character)ParentCharacter.MyAI.BlackBoard.TargetCorpse.Target))
                {
                    //if corpse and I are friendly, then I'll check corpse and then raise alert
                    if (ParentCharacter.GetCharacterVelocity().magnitude <= 0.1f)
                    {
                        ParentCharacter.MyAnimator.SetBool("IsChecking", true);
                    }

                    _checkTimer++;

                    if (_checkTimer > 3)
                    {
                        //notify everyone on the team to draw weapon and do random patrol
                        ParentCharacter.MyAI.Bark("Somebody killed him! Search perimeter!");
                        ParentCharacter.MyAI.BlackBoard.GuardLevel = 3;
                        ParentCharacter.SendDelayCallBack(2, ParentCharacter.MyAI.Squad.SetSquadAlertLevel, 3);
                        ParentCharacter.MyAI.Squad.BroadcastMemoryFact(ParentCharacter.MyAI.BlackBoard.TargetCorpse);
                        StopAction();

                        ParentCharacter.MyEventHandler.TriggerOnActionCompletion();
                        return;
                    }
                }
                else
                {
                    //not in same faction, will consider it as a container to loot
                }
            }
        }



        if (CheckActionCompletion())
        {
            StopAction();

            ParentCharacter.MyEventHandler.TriggerOnActionCompletion();
        }
    }