Example #1
0
        // --------------------------------------------------------------
        // Methods (General)
        // --------------------------------------------------------------

        /// <summary>
        /// Block to display on the canvas.
        /// </summary>
        /// <param name="heroKitAction">Hero kit action to display in the block.</param>
        /// <param name="indexState">ID of the state for this event.</param>
        /// <param name="indexEvent">ID of this event.</param>
        public static void Block(HeroObject heroKitObject, int indexState, int indexEvent)
        {
            // exit early if object is null
            if (heroKitObject == null)
            {
                return;
            }

            // exit early if state no longer exists
            if (heroKitObject.states.states == null || heroKitObject.states.states.Count - 1 < indexState)
            {
                return;
            }

            // exit early if event no longer exists
            if (heroKitObject.states.states[indexState].heroEvent == null || heroKitObject.states.states[indexState].heroEvent.Count - 1 < indexEvent)
            {
                return;
            }

            // save the id of the state that this event belongs in
            stateIndex = indexState;
            eventIndex = indexEvent;

            // assign hero object to this class
            heroObject = heroKitObject;
            eventBlock = heroObject.states.states[stateIndex].heroEvent[eventIndex];

            // draw components
            DrawBlock();
        }
Example #2
0
        public void HeroMove(object sender, UserInputEventArgs args)
        {
            //if (!isActive) return;
            switch (args.Key)
            {
            case ConsoleKey.UpArrow:
                NextPosition.Y--;
                break;

            case ConsoleKey.DownArrow:
                NextPosition.Y++;
                break;

            case ConsoleKey.LeftArrow:
                NextPosition.X--;
                break;

            case ConsoleKey.RightArrow:
                NextPosition.X++;
                break;
            }
            HeroEvent?.Invoke(this, EventArgs.Empty);
            Update();
            color = ConsoleColor.White;
        }
Example #3
0
        /// <summary>
        /// Move item down.
        /// </summary>
        /// <param name="obj">Item to move down.</param>
        private static void moveItemDown(object obj)
        {
            int index = (int)obj;

            HeroKitCommon.deselectField();
            int indexA = index;
            int indexB = index + 1;

            if (indexB < itemsContextMenu.Count)
            {
                HeroEvent fieldA = itemsContextMenu[indexA];
                HeroEvent fieldB = itemsContextMenu[indexB];
                itemsContextMenu[indexA] = fieldB;
                itemsContextMenu[indexB] = fieldA;
            }
        }
Example #4
0
        /// <summary>
        /// Store a deleted item for future restoration.
        /// </summary>
        /// <param name="stateID">ID of the state where the event resides.</param>
        /// <param name="eventID">ID of the event.</param>
        private static void saveDeletedItem(int stateID, int eventID)
        {
            // add to deleted item to front of the stack
            HeroEvent t = new HeroEvent();

            t = t.Clone(itemsContextMenu[eventID]);

            deletedFields.AddFirst(t);
            deletedFieldsIndex.AddFirst(eventID);
            deletedFieldsState.AddFirst(stateID);

            // if there are too many items in the stack, pop the last item in the stack
            if (deletedFields.Count > 10)
            {
                deletedFields.RemoveLast();
                deletedFieldsIndex.RemoveLast();
                deletedFieldsState.RemoveLast();
            }
        }
Example #5
0
        /// <summary>
        /// Block to display in the menu. Get list from hero kit object.
        /// </summary>
        /// <param name="heroKitObject">Hero object info to display in the menu.</param>
        /// <param name="indexState">ID of the state where this action resides.</param>
        /// <param name="indexEvent">ID of the event where this action resides.</param>
        public static void Block(HeroObject heroKitObject, int indexState, int indexEvent)
        {
            // exit early if object is null
            if (heroKitObject == null)
            {
                return;
            }

            // save the id of the state that this event belongs in
            stateIndex = indexState;
            eventIndex = indexEvent;

            // assign hero object to this class
            heroObject = heroKitObject;
            eventBlock = heroObject.states.states[stateIndex].heroEvent[eventIndex];
            items      = eventBlock.actions;

            // draw components
            DrawBlock();
        }
Example #6
0
        /// <summary>
        /// Restor the last item that was deleted from the list.
        /// </summary>
        private static void restoreItem(object obj)
        {
            if (deletedFieldsIndex.Count > 0)
            {
                HeroKitCommon.deselectField();

                int       stateID = deletedFieldsState.First();
                int       index   = deletedFieldsIndex.First();
                HeroEvent field   = deletedFields.First();

                // get state that contains the list of events
                List <HeroEvent> list = heroObject.states.states[stateID].heroEvent;

                // insert this event in the list
                list.Insert(index, field);

                // delete the field from the deleted items queue
                deletedFields.RemoveFirst();
                deletedFieldsIndex.RemoveFirst();
            }
        }