Esempio n. 1
0
        /// <summary>
        /// Creates an event box that executes an action when any entity in a list enters a certain area
        /// </summary>
        /// <param name="entities">Entities that can trigger event</param>
        /// <param name="onEnter">Rectangle that entry into triggers event</param>
        /// <param name="execute">Action to execute</param>
        /// <param name="eventParams">BoxID</param>
        /// <param name="condition">Condition that must be true before event with execute</param>
        public EventBox(List <Entity> entities, RectangleF onEnter, Action <Entity, BoxArgs> execute, BoxArgs eventParams, Condition condition = null)
        {
            //add list of entities
            checkList = entities;
            enabled   = new Dictionary <Entity, bool>();
            foreach (Entity entity in checkList)
            {
                entity.On_Move += CheckMove;
                enabled[entity] = true;
            }
            //add entry rectangle
            enterRect = new RectangleF(onEnter.X, onEnter.Y, onEnter.Width, onEnter.Height);

            entered = new List <Entity>();
            //add events
            this.eventParams = eventParams;
            executeOnEntry   = execute;

            if (condition == null)
            {
                this.checkCondition += (sender, moveAmount) => true;
            }
            else
            {
                this.checkCondition = condition;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Creates an event box that executes an action when an entity enters a certain area
 /// </summary>
 /// <param name="entity">Entity that can trigger event</param>
 /// <param name="onEnter">Rectangle that entry into triggers event</param>
 /// <param name="execute">Action to execute</param>
 /// <param name="eventParams">BoxID</param>
 /// <param name="condition">Condition that must be true before event with execute</param>
 public EventBox(Entity entity, RectangleF onEnter, Action <Entity, BoxArgs> execute, BoxArgs eventParams, Condition condition = null)
     : this(new List <Entity>() { entity }, onEnter, execute, eventParams, condition)
 {
 }