Exemplo n.º 1
0
        /// <summary>
        /// Open the door if an actor entered the activation trigger. If the actor is the player check for the key in the inventory.
        /// </summary>
        /// <param name="_args">Trigger entered args.</param>
        private void OnTriggerEntered(OnTriggerEntered _args)
        {
            if (openCloseTrigger == _args.trigger)
            {
                // We want to always open the door to the AI.
                bool opendDoor = true;
                if (_args.actor.CompareTag("Player"))
                {
                    Inventory playerInventory = _args.actor.GetComponent <Inventory>();
                    if (!playerInventory.HasItem(keyId))
                    {
                        opendDoor = false;

                        OnGameEventEventArgs args = new OnGameEventEventArgs()
                        {
                            eventId = "player.no.key"
                        };

                        EventController.QueueEvent(GameEvents.PLAYER_HAS_NO_KEY, args);
                    }
                }

                if (opendDoor)
                {
                    OpenDoor();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Triggers a player won event if the actor is the player.
        /// </summary>
        /// <param name="_actor"></param>
        protected override void OnActorEnter(Actor _actor)
        {
            if (_actor.CompareTag("Player"))
            {
                OnGameEventEventArgs args = new OnGameEventEventArgs()
                {
                    eventId = "player.won"
                };

                EventController.QueueEvent(GameEvents.PLAYER_WON, args);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sends a player death event when the player health reeaches zero.
        /// </summary>
        /// <param name="_args">Player death args.</param>
        protected override void OnActorDeath(OnActorEventEventArgs _args)
        {
            if (GetOwner == _args.actor)
            {
                OnGameEventEventArgs args = new OnGameEventEventArgs()
                {
                    eventId = "player.death"
                };

                EventController.QueueEvent(GameEvents.PLAYER_DEATH, args);
            }
        }