/// <summary> /// A hero used an empty hand on the wall /// </summary> /// <returns>True if the event is processed</returns> public bool OnBash(CardinalPoint side, Item item) { #region Decoration must change on hack Decoration deco = Maze.GetDecoration(Location, side); if (deco != null && deco.OnHackId != -1) { // If forced decoration, then erase all other decorations if (deco.ForceDisplay) { for (int id = 0; id < 4; id++) { if (Decorations[id] != -1) { Decorations[id] = deco.OnHackId; } } } // change only this decoration else { Decorations[(int)side] = deco.OnHackId; } return(true); } #endregion GameMessage.AddMessage("Square: OnBash()"); return(false); }
/// <summary> /// Mouse click on the door /// </summary> /// <param name="location">Location of the click</param> /// <param name="side">Wall side</param> /// <param name="button">Mouse button state</param> /// <returns>True if the event is handled</returns> public override bool OnClick(Point location, CardinalPoint side, MouseButtons button) { // Button if (HasButton && Button.Contains(location)) { if (State == DoorState.Closed || State == DoorState.Closing) { Open(); } else if (State == DoorState.Opened || State == DoorState.Opening) { Close(); } return(true); } else { // Try to force the door if (State != DoorState.Opened) { GameMessage.AddMessage("No one is able to pry this door open."); return(true); } } return(false); }
///// <summary> ///// Loads a team party ///// </summary> ///// <param name="filename">File name to load</param> ///// <returns>True if loaded</returns> //public bool LoadParty() //{ // return true; //} /// <summary> /// Loads a party /// </summary> /// <param name="filename">Xml data</param> /// <returns>True if team successfuly loaded, otherwise false</returns> public bool Load(XmlNode xml) { if (xml == null || xml.Name.ToLower() != "team") { return(false); } // Clear the team for (int i = 0; i < Heroes.Count; i++) { Heroes[i] = null; } foreach (XmlNode node in xml) { if (node.NodeType == XmlNodeType.Comment) { continue; } switch (node.Name.ToLower()) { //case "dungeon": //{ // Dungeon = ResourceManager.CreateAsset<Dungeon>(node.Attributes["name"].Value); // //Dungeon.Team = this; //} //break; case "location": { Location = new DungeonLocation(node); } break; case "position": { HeroPosition position = (HeroPosition)Enum.Parse(typeof(HeroPosition), node.Attributes["slot"].Value, true); Hero hero = new Hero(); hero.Load(node.FirstChild); AddHero(hero, position); } break; case "message": { GameMessage.AddMessage(node.Attributes["text"].Value, Color.FromArgb(int.Parse(node.Attributes["A"].Value), int.Parse(node.Attributes["R"].Value), int.Parse(node.Attributes["G"].Value), int.Parse(node.Attributes["B"].Value))); } break; } } SelectedHero = Heroes[0]; return(true); }
/// <summary> /// /// </summary> /// <param name="location"></param> /// <param name="side"></param> /// <param name="button"></param> /// <returns></returns> public override bool OnClick(Point location, CardinalPoint side, MouseButtons button) { // No wall side or no decoration if (side != Side || Square.Maze.Decoration == null) { return(false); } // Not in the decoration zone if (!Square.Maze.Decoration.IsPointInside(IsActivated ? ActivatedDecoration : DeactivatedDecoration, location)) { return(false); } // Switch already used and not reusable if ((WasUsed && !Reusable) || !IsEnabled) { GameMessage.AddMessage("It's already unlocked.", GameColors.Red); return(true); } // Does an item is required ? if (!string.IsNullOrEmpty(NeededItem)) { // No item in hand or not the good item if (GameScreen.Team.ItemInHand == null || GameScreen.Team.ItemInHand.Name != NeededItem) { GameMessage.AddMessage("You need a key to open this lock"); return(true); } // Picklock if (GameScreen.Team.ItemInHand.Name == "PickLock") { // TODO: already unlocked => "It's already unlocked" if (PickLock()) { GameMessage.AddMessage("You pick the lock.", GameColors.Green); } else { GameMessage.AddMessage("You failed to pick the lock", GameColors.Yellow); } return(true); } // Consume item if (ConsumeItem) { GameScreen.Team.SetItemInHand(null); } } Toggle(); return(true); }
/// <summary> /// Team enters the square /// </summary> /// <returns>True on success</returns> public override bool OnTeamEnter() { // No more usage possible if (Remaining == 0) { return(false); } Hero hero = null; // Check if a hero detect the event foreach (Hero h in GameScreen.Team.Heroes) { //if (hero.SavingThrow(SavingThrowType.Will) > Dice.GetD20(1)) if (h != null && h.SavingThrow(SavingThrowType.Will) > Intelligence) { hero = h; break; } } // No one is able to detect the event if (hero == null) { return(false); } // Display message if (!string.IsNullOrEmpty(Message)) { GameMessage.AddMessage(hero.Name + ": " + Message, MessageColor); } // Create the scripted dialog if there's a picture to show if (!string.IsNullOrEmpty(PictureName)) { GameScreen.Dialog = new ScriptedDialog(Square, this); } // Decrement usage if (Remaining > 0) { Remaining--; } return(true); }
/// <summary> /// A hero interacted with a side of the block /// </summary> /// <param name="location">Location of the mouse</param> /// <param name="side">Wall side</param> /// <param name="button">Mouse buttons</param> /// <returns>True if the event is processed</returns> public bool OnClick(Point location, CardinalPoint side, MouseButtons button) { // Actor interaction if (Actor != null) { return(Actor.OnClick(location, side, button)); } // Decoration interaction Team team = GameScreen.Team; Decoration decoration = team.Maze.GetDecoration(team.FrontLocation.Coordinate, Compass.GetOppositeDirection(team.Direction)); if (decoration != null) { GameMessage.AddMessage("Decoration: OnClick()"); return(false); } return(false); }