Beispiel #1
0
        ///// <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);
        }
Beispiel #2
0
		/// <summary>
		/// Select a hero from his position in the team
		/// </summary>
		/// <param name="position"></param>
		void SelectHero(HeroPosition position)
		{
			if (GameScreen == null)
				return;

			Hero hero = Team.GetHeroFromPosition(position);
			if (hero == null)
			{
				HeroBox.Hero = null;
				HeroBox.Enabled = false;
				RemoveHeroBox.Enabled = false;
				CreateHeroBox.Enabled = true;
			}
			else
			{
				HeroBox.Enabled = true;
				HeroBox.Hero = hero;
				RemoveHeroBox.Enabled = true;
				CreateHeroBox.Enabled = false;
			}
		}
Beispiel #3
0
        /// <summary>
        /// Removes a Hero
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RemoveHeroBox_Click(object sender, EventArgs e)
        {
            if (GameScreen == null)
            {
                return;
            }

            HeroPosition pos = HeroPosition.FrontLeft;

            if (FrontLeftBox.Checked)
            {
                pos = HeroPosition.FrontLeft;
            }
            if (FrontRightBox.Checked)
            {
                pos = HeroPosition.FrontRight;
            }
            if (MiddleLeftBox.Checked)
            {
                pos = HeroPosition.MiddleLeft;
            }
            if (MiddleRightBox.Checked)
            {
                pos = HeroPosition.MiddleRight;
            }
            if (RearLeftBox.Checked)
            {
                pos = HeroPosition.RearLeft;
            }
            if (RearRightBox.Checked)
            {
                pos = HeroPosition.RearRight;
            }

            Team.DropHero(pos);
            SelectHero(pos);
        }
Beispiel #4
0
        /// <summary>
        /// Select a hero from his position in the team
        /// </summary>
        /// <param name="position"></param>
        void SelectHero(HeroPosition position)
        {
            if (GameScreen == null)
            {
                return;
            }

            Hero hero = Team.GetHeroFromPosition(position);

            if (hero == null)
            {
                HeroBox.Hero          = null;
                HeroBox.Enabled       = false;
                RemoveHeroBox.Enabled = false;
                CreateHeroBox.Enabled = true;
            }
            else
            {
                HeroBox.Enabled       = true;
                HeroBox.Hero          = hero;
                RemoveHeroBox.Enabled = true;
                CreateHeroBox.Enabled = false;
            }
        }
Beispiel #5
0
		/// <summary>
		/// Adds a hero to the team
		/// </summary>
		/// <param name="hero"></param>
		/// <param name="position"></param>
		public void AddHero(Hero hero, HeroPosition position)
		{
			Heroes[(int)position] = hero;
		}
Beispiel #6
0
		/// <summary>
		/// Removes a hero from the team
		/// </summary>
		/// <param name="position">Hero's position</param>
		public void DropHero(HeroPosition position)
		{
			Heroes[(int)position] = null;
			ReorderHeroes();
		}
Beispiel #7
0
		/// <summary>
		/// Returns the Hero at a given position in the team
		/// </summary>
		/// <param name="pos">Position rank</param>
		/// <returns>Hero handle or null</returns>
		public Hero GetHeroFromPosition(HeroPosition pos)
		{
			return Heroes[(int)pos];
		}
Beispiel #8
0
 /// <summary>
 /// Adds a hero to the team
 /// </summary>
 /// <param name="hero"></param>
 /// <param name="position"></param>
 public void AddHero(Hero hero, HeroPosition position)
 {
     Heroes[(int)position] = hero;
 }
Beispiel #9
0
 /// <summary>
 /// Removes a hero from the team
 /// </summary>
 /// <param name="position">Hero's position</param>
 public void DropHero(HeroPosition position)
 {
     Heroes[(int)position] = null;
     ReorderHeroes();
 }
Beispiel #10
0
 /// <summary>
 /// Returns the Hero at a given position in the team
 /// </summary>
 /// <param name="pos">Position rank</param>
 /// <returns>Hero handle or null</returns>
 public Hero GetHeroFromPosition(HeroPosition pos)
 {
     return(Heroes[(int)pos]);
 }
Beispiel #11
0
        /// <summary>
        /// Returns the ground position of a hero
        /// </summary>
        /// <param name="Hero">Hero handle</param>
        /// <returns>Ground position of the hero</returns>
        public SquarePosition GetHeroGroundPosition(Hero Hero)
        {
            SquarePosition groundpos = SquarePosition.Center;


            // Get the hero position in the team
            HeroPosition pos = GetHeroPosition(Hero);


            switch (Location.Direction)
            {
            case CardinalPoint.North:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.NorthWest;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.NorthEast;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.SouthWest;
                }
                else
                {
                    groundpos = SquarePosition.SouthEast;
                }
            }
            break;

            case CardinalPoint.East:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.NorthEast;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.SouthEast;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.NorthWest;
                }
                else
                {
                    groundpos = SquarePosition.SouthWest;
                }
            }
            break;

            case CardinalPoint.South:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.SouthEast;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.SouthWest;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.NorthEast;
                }
                else
                {
                    groundpos = SquarePosition.NorthWest;
                }
            }
            break;

            case CardinalPoint.West:
            {
                if (pos == HeroPosition.FrontLeft)
                {
                    groundpos = SquarePosition.SouthWest;
                }
                else if (pos == HeroPosition.FrontRight)
                {
                    groundpos = SquarePosition.NorthWest;
                }
                else if (pos == HeroPosition.MiddleLeft || pos == HeroPosition.RearLeft)
                {
                    groundpos = SquarePosition.SouthEast;
                }
                else
                {
                    groundpos = SquarePosition.NorthEast;
                }
            }
            break;
            }


            return(groundpos);
        }
Beispiel #12
0
 public string ToString()
 {
     return($"{HeroPosition.ToDirection(Point)}: взрыв[{BoomArea}]" +
            $" свободность[{CountNearFree}] длина безопасности[{LenPathToNearPointNoBoom}] рядом противник[{IsNearEnemy}] рядом чопер[{IsNearChoper}]");
 }