/// <summary>
        /// Send an event, if the object is entering a collision.
        /// </summary>
        /// <param name="collisionInfo">
        /// The <see cref="Collision"/> collision information, reported by Unity.
        /// </param>
        public void OnCollisionEnter(Collision collisionInfo)
        {
            CollidableComponent collidee = collisionInfo.collider.GetComponent<CollidableComponent>();
            if (collidee == null)
            {
                return;
            }

            int entityId = this.GetComponent<EntityComponent>().EntityId;
            CollisionEventData data = new CollisionEventData(entityId, collidee.EntityId, collisionInfo);
            this.Game.EventManager.FireEvent(
                                    new HelGamesEvent(
                                            CollisionEvents.CollisionEntered,
                                            data));
        }
Beispiel #2
0
        /// <summary>
        /// Send an event, if the object is entering a collision.
        /// </summary>
        /// <param name="collisionInfo">
        /// The <see cref="Collision"/> collision information, reported by Unity.
        /// </param>
        public void OnCollisionExit(Collision collisionInfo)
        {
            CollidableComponent collidee = collisionInfo.collider.GetComponent <CollidableComponent>();

            if (collidee == null)
            {
                return;
            }

            int entityId            = this.GetComponent <EntityComponent>().EntityId;
            CollisionEventData data = new CollisionEventData(entityId, collidee.EntityId, collisionInfo);

            this.Game.EventManager.FireEvent(
                new HelGamesEvent(
                    CollisionEvents.CollisionLeft,
                    data));
        }
Beispiel #3
0
        /// <summary>
        /// Send an event, if the object is entering a collision.
        /// </summary>
        /// <param name="collider">
        /// The <see cref="Collider"/> collider of the trigger object, reported by Unity.
        /// </param>
        public void OnTriggerEnter(Collider collider)
        {
            CollidableComponent collidee = collider.GetComponent <CollidableComponent>();

            if (collidee == null)
            {
                return;
            }

            int entityId            = this.GetComponent <EntityComponent>().EntityId;
            CollisionEventData data = new CollisionEventData(entityId, collidee.EntityId, collider);

            this.Game.EventManager.FireEvent(
                new HelGamesEvent(
                    CollisionEvents.TriggerEntered,
                    data));
        }
        /// <summary>
        /// Send an event, if the object is entering a collision.
        /// </summary>
        /// <param name="collider">
        /// The <see cref="Collider"/> collider of the trigger object, reported by Unity.
        /// </param>
        public void OnTriggerExit(Collider collider)
        {
            CollidableComponent collidee = collider.GetComponent<CollidableComponent>();
            if (collidee == null)
            {
                return;
            }

            int entityId = this.GetComponent<EntityComponent>().EntityId;
            CollisionEventData data = new CollisionEventData(entityId, collidee.EntityId, collider);
            this.Game.EventManager.FireEvent(
                                    new HelGamesEvent(
                                            CollisionEvents.TriggerLeft,
                                            data));
        }