Exemplo n.º 1
0
        private void ExitState(ActorAiState oldState)
        {
            if (LockAiState)
            {
                return;
            }

            //TODO we may need this at some point
            switch (oldState)
            {
            case ActorAiState.Idle:
                break;

            case ActorAiState.Dead:
                break;

            case ActorAiState.Wandering:
                MovementComponent.AbortMove();
                AudioComponent.Ref()?.StopMoveSound();
                break;

            case ActorAiState.Chasing:
                MovementComponent.AbortMove();
                AudioComponent.Ref()?.StopMoveSound();
                break;

            case ActorAiState.Attacking:
                AttackComponent.Ref()?.EndAttack();
                break;

            case ActorAiState.Covering:
                break;

            case ActorAiState.Fleeing:
                MovementComponent.AbortMove();
                AudioComponent.Ref()?.StopMoveSound();
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        public override void Start() //TODO register into a list for AI and stuff
        {
            base.Start();

            //TODO may remove some warnings, TODO change to Debug.Log

            if (AnimationComponent == null)
            {
                AnimationComponent = GetComponent <ActorAnimationComponentBase>();
            }
            if (AnimationComponent == null)
            {
                CDebug.LogEx(name + " couldn't find AnimationComponent", LogLevel.Warning, this);
            }

            if (MovementComponent == null)
            {
                MovementComponent = GetComponent <ActorMovementComponentBase>();
            }
            if (MovementComponent == null)
            {
                CDebug.LogEx(name + " couldn't find MovementComponent", LogLevel.Error, this);
            }

            if (AttackComponent == null)
            {
                AttackComponent = GetComponent <ActorAttackComponent>();
            }
            if (AttackComponent == null)
            {
                CDebug.LogEx(name + " couldn't find AttackComponent", LogLevel.Warning, this);
            }

            if (InteractionComponent == null)
            {
                InteractionComponent = GetComponent <ActorInteractionComponent>();
            }
            if (InteractionComponent == null)
            {
                CDebug.LogEx(name + " couldn't find InteractionComponent", LogLevel.Warning, this);
            }

            if (AudioComponent == null)
            {
                AudioComponent = GetComponentInChildren <ActorAudioComponent>();
            }
            if (AudioComponent == null)
            {
                CDebug.LogEx(name + " couldn't find AudioComponent", LogLevel.Verbose, this);
            }

            InitialPosition = transform.position;

            MovementComponent.Init();

            if (InteractComponent == null)
            {
                InteractComponent = GetComponent <ActorInteractableComponent>();
            }

            if (InteractComponent == null)
            {
                InteractComponent = GetComponentInChildren <ActorInteractableComponent>();
            }

            InteractionComponent.Ref()?.Init();

            if (InteractComponent != null && InteractionComponent != null)
            {
                InteractComponent.ControllerOnInteractDelegate = InteractionComponent.OnInteract;
                InteractComponent.Tooltip = InteractionComponent.Tooltip;
                //TODO may move this to ActorInteractionComponent
            }
            else
            {
                CDebug.LogEx(name + " couldn't find ActorInteractableComponent", LogLevel.Error, this);
            }

            MaxHealth = Health;

            AnimationComponent.Init();

            AttackComponent.Ref()?.Init();

            TryExecuteOnComponents(component => component.Init(this));

            Initialized = true;

            EnterState(CurrentAiState);
        }