Exemple #1
0
        /// <summary>
        /// Moves the whole team to a new position on the battlefield.
        /// </summary>
        /// <param name="direction">In what direction to move.</param>
        /// <param name="step">What distance to move.</param>
        public override void Move(Direction direction, int step = 1)
        {
            //Decrease the presence of all magicians:
            foreach (Friend member in this.companions)
            {
                if (member is IMagician)
                {
                    (member as IMagician).Presence--;
                }
            }

            //Remove the magicians that have no presence left:
            for (int i = 0; i < this.companions.Count; i++)
            {
                if (this.companions[i] is IMagician)
                {
                    if ((this.companions[i] as IMagician).Presence == 0)
                    {
                        string message = string.Format("{0} has just left the team on some magician's business. Your strength has now decreased to {1:0.00}.",
                                                       this.companions[i].Name, this.Strength);
                        FriendLeftTheTeamEventArgs leftArgs = new FriendLeftTheTeamEventArgs(this.companions[i], message);
                        this.FriendLeftTheTeam(this.companions[i], leftArgs);
                        RemoveCompanion(this.companions[i]);
                    }
                }
            }

            //Move the whole team:
            base.Move(direction);
            int newRow = this.Position.Y;
            int newCol = this.Position.X;

            this.Position = new Location(newCol, newRow);
        }
Exemple #2
0
 private void FriendLeft(Friend aFriend, FriendLeftTheTeamEventArgs eventArgs)
 {
     this.joinInTeamMessage += "\n" + eventArgs.Message;
 }