Beispiel #1
0
 // TODO: await for a mouse down instead...
 public void MouseDowned(Informant informant)
 {
     // Move
     if (mode == UI_Mode.player_unit_turn_during_action && action == UI_Action.move) {
         if (IsSameOrSubclass(typeof(Tile), informant.GetType())) {
             Dictionary<string, object> payload = new Dictionary<string, object>()
             {
                 {"action", ActionType.move},
                 {"character", selectedCharacter},
                 {"path", walking_path},
             };
             game.addAction(payload);
         }
     } else if (mode == UI_Mode.player_unit_turn_pre_action) {
         // Set selections
         setSelect (informant, true);
     }
 }
Beispiel #2
0
        public void setInRange(Informant informant, bool inRange)
        {
            if (IsSameOrSubclass (typeof(GridThing), informant.GetType ())) {
                GridThing gridThing = informant as GridThing;

            }
        }
Beispiel #3
0
 public void MouseExited(Informant informant)
 {
     // Remove highlights
     setHighlight (informant, false);
 }
Beispiel #4
0
 public void MouseEntered(Informant informant)
 {
     // Set highlights
     setHighlight (informant, true);
 }
Beispiel #5
0
 public void addInformant(Informant informant)
 {
 }
Beispiel #6
0
        private void setSelect(Informant informant, bool select)
        {
            if (IsSameOrSubclass(typeof(GridThing), informant.GetType())) {
                GridThing gridThing = informant as GridThing;
                gridThing.setSelected(select);

                // If tile, that contains a character, set select for character as well
                if (IsSameOrSubclass(typeof(Tile), informant.GetType())) {
                    Tile tile = informant as Tile;
                    if (tile.character) {
                        setSelect(tile.character, select);
                    }
                }

                // If character, select tiles in movement range
                if (select && IsSameOrSubclass(typeof(Character), informant.GetType())) {
                    Character character = informant as Character;

                    //TODO: for now this switches to movement mode,
                    // in the future this should be trigged by a button in the UI or a keypress or something explicit
                    // not just by click a character should it prompt a move...
                    this.selectedCharacter = character;
                    foreach (var tile in character.move_range) {
                        tile.setWalkableForSelectedCharacter(select);
                        this.mode = UI_Mode.player_unit_turn_during_action;
                        this.action = UI_Action.move;
                    }
                }
            }
        }
Beispiel #7
0
        private void setHighlight(Informant informant, bool highlight)
        {
            if (IsSameOrSubclass(typeof(GridThing), informant.GetType())) {
                GridThing gridThing = informant as GridThing;
                gridThing.setHighlighted(highlight);

                // If tile, that contains a character, set highlight for character as well
                if (IsSameOrSubclass(typeof(Tile), informant.GetType())) {
                    Tile tile = informant as Tile;
                    if (tile.character) {
                        setHighlight(tile.character, highlight);
                    }
                }

                // If character, highlight tiles in movement range
                if (IsSameOrSubclass(typeof(Character), informant.GetType())) {
                    Character character = informant as Character;
                    foreach (var tile in character.move_range) {
                        tile.setWalkableForHighlightedCharacter(highlight);
                    }
                }
            }

            // Display Path UI during Move Action
            if (highlight && mode == UI_Mode.player_unit_turn_during_action && action == UI_Action.move) {
                if (IsSameOrSubclass(typeof(Tile), informant.GetType())) {
                    Tile tile = informant as Tile;
                    if (tile != goal) {
                        updateMovePath();
                        goal = tile;
                    }
                }
            }
        }
Beispiel #8
0
 // Connects object to a messagehub to inform listeners
 private void setUpInformant(Informant Informant)
 {
     Informant.setUIManager (ui_manager);
 }