Exemplo n.º 1
0
        public static bool SpawnFigure(PlayerServiceReference.BaseUnitPackage unit, Enums.Piece piece)
        {
            for (int i = 0; i < 8; ++i)
            {
                if (Figures[-1, i] == null)
                {
                    Figure figureOnBoard = FigureManager.CreateFigure(unit, piece);

                    //if (CheckForUpgrades(figureOnBoard, true).Count != 0)
                    //    return true;

                    figureOnBoard.Untargetable = true;
                    figureOnBoard.Owner        = Owner;
                    figureOnBoard.OnDeath     += f =>
                    {
                        Figures[f.Position.Row, f.Position.Column] = null;
                        _activeAllyFigures.Remove(f);
                        if (_activeAllyFigures.Count == 0)
                        {
                            TakeDamage();
                        }
                    };
                    figureOnBoard.OnMove += MoveFigure;
                    figureOnBoard.OnSell += figure => SellFigure(figure);

                    AllFigures.Add(figureOnBoard);
                    SpawnChessFigure(AllFigures.Count - 1, -1, i);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 public static void Initialize(List <Button> buttons)
 {
     _defaultPiece = Enums.Piece.none;
     foreach (Button button in buttons)
     {
         button.Click += DefaultPieceClicked;
     }
 }
Exemplo n.º 3
0
 public void buyAttempt(Grid grid, Button button, BaseUnitPackage unit, Enums.Piece piece)
 {
     if (!UnitShop.BuyUnit(unit, piece))
     {
         return;
     }
     _unitShopButtonsUI.DisableGridAndButton(grid, button);
 }
Exemplo n.º 4
0
        public static Figure CreateFigureFromPackage(PlayerServiceReference.FigurePackage figurePackage)
        {
            Unit unit = CreateUnit(figurePackage.Name);

            Enums.Piece piece  = (Enums.Piece)Enum.Parse(typeof(Enums.Piece), figurePackage.Piece);
            Figure      figure = CreateFigure(unit, piece);

            figure.ApplyFigurePackageProperties(figurePackage);
            return(figure);
        }
Exemplo n.º 5
0
 public void BuyUnitDef(Button button, BaseUnitPackage unit, Enums.Piece piece)//Buy unit if default piece is set
 {
     if (DefaultPieceSelector.GetDefaultPiece() == Enums.Piece.none)
     {
         return;
     }
     if (!UnitShop.BuyUnit(unit, piece))
     {
         return;
     }
     button.Content   = null;
     button.IsEnabled = false;
 }
Exemplo n.º 6
0
        public static void DefaultPieceClicked(Object sender, RoutedEventArgs e)
        {
            Enums.Piece piece = (Enums.Piece)(sender as Button).DataContext;

            if (piece == _defaultPiece)
            {
                _defaultPiece = Enums.Piece.none;
            }
            else
            {
                _defaultPiece = piece;
            }
            OnDefaultPieceChange(_defaultPiece);
        }
Exemplo n.º 7
0
            private static int CalculateFinalCost(int cost, Enums.Piece piece)
            {
                switch (piece)
                {
                case Enums.Piece.Pawn:
                    if (cost <= 8)
                    {
                        return(cost);
                    }
                    return(0);

                case Enums.Piece.Bishop:
                    if (cost <= 3)
                    {
                        return(3);
                    }
                    if (cost <= 6)
                    {
                        return(6);
                    }
                    return(0);

                case Enums.Piece.Knight:
                    if (cost <= 4)
                    {
                        return(4);
                    }
                    if (cost <= 8)
                    {
                        return(8);
                    }
                    return(0);

                case Enums.Piece.Rook:
                    if (cost <= 5)
                    {
                        return(5);
                    }
                    if (cost <= 10)
                    {
                        return(10);
                    }
                    return(0);

                case Enums.Piece.Queen:
                    return(8);
                }
                return(0);
            }
Exemplo n.º 8
0
 private void onDefaultPieceChange(Enums.Piece piece)
 {
     for (int i = 0; i < 5; i++)
     {
         if (i != (int)piece - 1)
         {
             DefaultPieceButtons[i].Background = System.Windows.Media.Brushes.White;
         }
     }
     if (piece != Enums.Piece.none)
     {
         DefaultPieceButtons[(int)piece - 1].Background = System.Windows.Media.Brushes.Aqua;
         removePieceButtonGrids();
     }
 }
Exemplo n.º 9
0
        public static Figure CreateFigure(Unit unit, Enums.Piece piece)
        {
            Figure figure = new Figure();

            unit.MainViewModel.SetActive(true);

            IFigureUI figureUI = new FigureUIManager();

            figure.Unit     = unit;
            figure.FigureUI = figureUI;
            figure.Piece    = MakePiece(piece);
            figure.Cost     = Calculators.CostCalculator.CalculateFinalCost(unit, piece);

            return(figure);
        }
Exemplo n.º 10
0
        public void SetPieceToggleText(Enums.Piece piece)
        {
            System.Text.StringBuilder tooltip = new System.Text.StringBuilder();
            switch (piece)
            {
            case Enums.Piece.Pawn:
                //ToggleDisable();
                _isPawn = true;
                tooltip.Append("Pawn");
                tooltip.AppendLine("No bonuses");
                //PieceToggle.image.sprite = ImgPawn;
                break;

            case Enums.Piece.Bishop:
                tooltip.Append("Bishop");
                tooltip.AppendLine("OFF: Start battle with 100% mana");
                tooltip.AppendLine("ON: Get 2X mana");
                //PieceToggle.image.sprite = ImgBishop;
                break;

            case Enums.Piece.Knight:
                tooltip.Append("Knight");
                tooltip.AppendLine("Passive: get bonus attack speed");
                tooltip.AppendLine("OFF: Transcend grand distances quickly");
                tooltip.AppendLine("ON: Double the Range");
                //PieceToggle.image.sprite = ImgKnight;
                break;

            case Enums.Piece.Rook:
                tooltip.Append("Rook");
                tooltip.AppendLine("Passive: get bonus attack damage");
                tooltip.AppendLine("OFF: Bonus armor, magic resist and attack damage");
                tooltip.AppendLine("ON: Higher bonuses but unable to cast abilities");
                //PieceToggle.image.sprite = ImgRook;
                break;

            case Enums.Piece.Queen:
                tooltip.Append("Queen");
                tooltip.AppendLine("OFF: Bonus on all stats");
                tooltip.AppendLine("ON: On start of the battle get shield equal to 100% of HP");
                //PieceToggle.image.sprite = ImgQueen;
                break;
            }
            //PieceToggle.GetComponent<FigureTooltip>().SetTooltip(tooltip.ToString());
        }
Exemplo n.º 11
0
        public static bool BuyUnit(BaseUnitPackage unit, Enums.Piece piece)//To do
        {
            Player player = Player.Instance;
            int    cost   = Calculators.CostCalculator.CalculateFinalCost(unit, piece);

            if (player.Pawns < cost)
            {
                return(false);
            }

            if (!Board.SpawnFigure(unit, piece))
            {
                return(false);
            }

            player.Pawns -= cost;
            units.Remove(unit);
            return(true);
        }
Exemplo n.º 12
0
        private static Piece MakePiece(Enums.Piece piece)
        {
            switch (piece)
            {
            case Enums.Piece.Pawn:
                return(new Pawn());

            case Enums.Piece.Bishop:
                return(new Bishop());

            case Enums.Piece.Knight:
                return(new Knight());

            case Enums.Piece.Rook:
                return(new Rook());

            case Enums.Piece.Queen:
                return(new Queen());

            default:
                return(null);
            }
        }
Exemplo n.º 13
0
 public void UnitWantsToBeBought(Grid grid, Button button, PlayerServiceReference.BaseUnitPackage unit, Enums.Piece piece)
 {
     OnUnitBuyAttempt(grid, button, unit, piece);
 }
Exemplo n.º 14
0
 public static int CalculateFinalCost(Unit unit, Enums.Piece piece)
 {
     return(CalculateFinalCost(unit.Cost, piece));
 }
Exemplo n.º 15
0
 public static int CalculateFinalCost(PlayerServiceReference.BaseUnitPackage unit, Enums.Piece piece)
 {
     return(CalculateFinalCost(unit.Cost, piece));
 }
Exemplo n.º 16
0
 public void UpdateCostSum(Enums.Piece piece, int cost)
 {
     //    Cost[(int)piece] += cost;
     //    UpdateCostText();
 }
Exemplo n.º 17
0
        public static Figure CreateFigure(PlayerServiceReference.BaseUnitPackage unitPackage, Enums.Piece piece)
        {
            Unit unit = CreateUnit(unitPackage.Name);

            return(CreateFigure(unit, piece));
        }