public static Surface Render(PlayerUnit Unit)
        {
            Surface Buffer = new Surface(PUNIT_WIDTH_PX, PUNIT_WIDTH_PX);
            Color Bg = Color.WhiteSmoke;

            switch (Unit.Class)
            {
                case UnitClasses.Archer: Bg = Color.Orange;
                    break;
                case UnitClasses.Mage: Bg = Color.Blue;
                    break;
                case UnitClasses.Paladin: Bg = Color.DeepPink;
                    break;
                case UnitClasses.Soldier: Bg = Color.Brown;
                    break;
                case UnitClasses.Thieft: Bg = Color.Yellow;
                    break;

            }

            Rectangle UnitRect = new Rectangle(new Point(0,0), new Size(Buffer.Width, Buffer.Height));
            Box Border = new Box(new Point(0, 0), new Size(Buffer.Width - 1, Buffer.Height - 1));
            Buffer.Fill(UnitRect, Bg);
            Buffer.Draw(Border, Color.WhiteSmoke, true);
            Buffer.AlphaBlending = true;
            Buffer.Alpha = 230;
            return Buffer;
        }
Exemple #2
0
 public void ChangeUnit(PlayerUnit Unit)
 {
     this.Unit = Unit;
     UpdateCaption();
 }
        public void DrawUnitRange(Surface GameSurface, MapCoord Coord, PlayerUnit Unit)
        {
            Circle MaxRange = new Circle(Coord.ToPointMiddle(), (short)Unit.Range);
            GameSurface.Draw(MaxRange, Color.Aqua, true);

            if (Unit.MinusRange != 0)
            {
                Circle MinusRange = new Circle(Coord.ToPointMiddle(), (short)Unit.MinusRange);
                GameSurface.Draw(MinusRange, Color.Red, true);
            }
        }
        public static PlayerUnit CreateUnit(UnitClasses UnitClass)
        {
            PlayerUnit Unit = new PlayerUnit();

            switch (UnitClass)
            {
                case UnitClasses.Archer: return new Archer();
                case UnitClasses.Mage: return new Mage();
                case UnitClasses.Paladin: return new Paladin();
                case UnitClasses.Soldier: return new Soldier();
                case UnitClasses.Thieft: return new Thieft();
            }

            return Unit;
        }
        /// <summary>
        /// Increase the level of a Player Unit
        /// </summary>
        /// <param name="Unit">PlayerUnit</param>
        public void IncreaseUnitLevel(PlayerUnit Unit)
        {
            if (PlayerUnits.ContainsValue(Unit) && Unit.Class != UnitClasses.None)
            {
                int Cost = PlayerUnit.LevelCost(Unit.Level + 1);

                if (Gold >= Cost)
                {
                    Unit.LevelUp();
                    Gold -= Cost;
                    Score += Unit.Level * 100;
                }
            }
        }