Ejemplo n.º 1
0
        public override void SendBuff()
        {
            _chatService.SendMessage("SplashBomb", 1, "255 51 51", MessageType.buffSplashBomb, 5, 5);

            if (TilesSet.GetTile(5, 5).IsColored)
            {
                TilesSet.AddTile(5, 5, new Tile(true, true, TileType.BuffColorSplash, 5, 5));
            }
            else
            {
                TilesSet.AddTile(5, 5, new Tile(false, true, TileType.BuffColorSplash, 5, 5));
            }
        }
Ejemplo n.º 2
0
        public override void SendDebuff()
        {
            _chatService.SendMessage("BlackSplash", 1, "0 0 0", MessageType.debuffBlackSplash, 4, 4);

            if (TilesSet.GetTile(4, 4).IsColored)
            {
                TilesSet.AddTile(4, 4, new Tile(true, true, TileType.DebuffBlackSplash, 4, 4));
            }
            else
            {
                TilesSet.AddTile(4, 4, new Tile(false, true, TileType.DebuffBlackSplash, 4, 4));
            }
        }
Ejemplo n.º 3
0
        public override void SendBuff()
        {
            _chatService.SendMessage("buff", 1, "100 100 200", MessageType.buffFreezeOthers, 11, 11);

            if (TilesSet.GetTile(11, 11).IsColored)
            {
                TilesSet.AddTile(11, 11, new Tile(true, true, TileType.BuffFreezeOthers, 11, 11));
            }
            else
            {
                TilesSet.AddTile(11, 11, new Tile(false, true, TileType.BuffFreezeOthers, 11, 11));
            }
        }
Ejemplo n.º 4
0
        public override void SendDebuff()
        {
            _chatService.SendMessage("playerFreeze", 1, "100 149 237", MessageType.debuffFreezeYourself, 10, 10);

            if (TilesSet.GetTile(10, 10).IsColored)
            {
                TilesSet.AddTile(10, 10, new Tile(true, true, TileType.DebuffFreezeYourself, 10, 10));
            }
            else
            {
                TilesSet.AddTile(10, 10, new Tile(false, true, TileType.DebuffFreezeYourself, 10, 10));
            }
        }
Ejemplo n.º 5
0
 public void ClearBoard()
 {
     for (int x = 0; x < 20; x++)
     {
         for (int y = 0; y < 20; y++)
         {
             TilesSet.AddTile(x, y, new Tile(false, true, TileType.Neutral, x, y));
             Rectangle ColorBlock = new Rectangle();
             ColorBlock.Fill = Brushes.White;
             Grid.SetColumn(ColorBlock, x);
             Grid.SetRow(ColorBlock, y);
             gridMain.Children.Add(ColorBlock);
         }
     }
 }
Ejemplo n.º 6
0
        public override void SendBonus()
        {
            Random randNum = new Random();
            int    Randx   = randNum.Next(0, 20);
            int    Randy   = randNum.Next(0, 20);

            _chatService.SendMessage("buff", 1, ColorOptions[YellowColorShades.Light].ReceiveColorCode(), MessageType.bonusJoke, Randx, Randy);

            if (TilesSet.GetTile(Randx, Randy).IsColored)
            {
                TilesSet.AddTile(Randx, Randy, new Tile(true, true, TileType.BonusJoke, Randx, Randy));
            }
            else
            {
                TilesSet.AddTile(Randx, Randy, new Tile(false, true, TileType.BonusJoke, Randx, Randy));
            }
        }
Ejemplo n.º 7
0
 public void AddTiles()
 {
     for (int x = 0; x < 20; x++)
     {
         for (int y = 0; y < 20; y++)
         {
             TilesSet.AddTile(x, y, new Tile(false, true, TileType.Neutral, x, y));
             MessageBox.Show("Hello I am created");
             Rectangle ColorBlock = new Rectangle();
             ColorBlock.Name = "Tile" + x + y;
             ColorBlock.Fill = Brushes.Aqua;
             Grid.SetColumn(ColorBlock, x);
             Grid.SetRow(ColorBlock, y);
             gridMain.Children.Add(ColorBlock);
         }
     }
 }
Ejemplo n.º 8
0
        private void ChatService_CoordinatesMessageReceived(BoardCoordinates coordinates)
        {
            string mess = coordinates.message;

            if (coordinates.messageType == MessageType.buffFreezeOthers)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
            }
            else if (coordinates.messageType == MessageType.debuffFreezeYourself)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
            }
            else if (coordinates.messageType == MessageType.buffSplashBomb)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
            }
            else if (coordinates.messageType == MessageType.debuffBlackSplash)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
            }
            else if (coordinates.messageType == MessageType.stepedOnColorSplash)
            {
                string[] words = coordinates.color.Split(' ');
                SetTile(coordinates.x + 1, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 1, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y + 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y - 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x + 2, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 2, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y + 2, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y - 2, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x + 1, coordinates.y + 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 1, coordinates.y + 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x + 1, coordinates.y - 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 1, coordinates.y - 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
            }
            else if (coordinates.messageType == MessageType.stepedOnBlackSplash)
            {
                string[] words = coordinates.color.Split(' ');
                SetTile(coordinates.x + 1, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 1, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y + 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y - 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x + 2, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 2, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y + 2, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x, coordinates.y - 2, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x + 1, coordinates.y + 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 1, coordinates.y + 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x + 1, coordinates.y - 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                SetTile(coordinates.x - 1, coordinates.y - 1, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
            }
            else if (coordinates.messageType == MessageType.enemy || coordinates.messageType == MessageType.dazePlayerEnemy || coordinates.messageType == MessageType.stealPointEnemy || coordinates.messageType == MessageType.teleportPlayerEnemy)
            {
                if (coordinates.messageType == MessageType.enemy)
                {
                    string[] words = coordinates.color.Split(' ');

                    SetTile(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(true, true, TileType.Enemy, coordinates.x, coordinates.y));
                }
                else
                {
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(true, true, TileType.EnemyWithAbilities, coordinates.x, coordinates.y));
                }
            }
            else if (coordinates.messageType == MessageType.bonusJackPot)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));

                if (TilesSet.GetTile(coordinates.x, coordinates.y).IsColored)
                {
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(true, true, TileType.BonusJackPot, coordinates.x, coordinates.y));
                }
                else
                {
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(false, true, TileType.BonusJackPot, coordinates.x, coordinates.y));
                }
            }
            else if (coordinates.messageType == MessageType.bonusNormal)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));

                if (TilesSet.GetTile(coordinates.x, coordinates.y).IsColored)
                {
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(true, true, TileType.BonusNormal, coordinates.x, coordinates.y));
                }
                else
                {
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(false, true, TileType.BonusNormal, coordinates.x, coordinates.y));
                }
            }
            else if (coordinates.messageType == MessageType.bonusJoke)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));

                if (TilesSet.GetTile(coordinates.x, coordinates.y).IsColored)
                {
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(true, true, TileType.BonusJoke, coordinates.x, coordinates.y));
                }
                else
                {
                    TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(false, true, TileType.BonusJoke, coordinates.x, coordinates.y));
                }
            }
            else if (coordinates.messageType == MessageType.gameOver)
            {
                GenerateGameOverWindow2();
            }
            else if (coordinates.messageType == MessageType.magician)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));

                TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(false, true, TileType.Magician, coordinates.x, coordinates.y));
            }
            else if (coordinates.messageType == MessageType.masterThief)
            {
                string[] words = coordinates.color.Split(' ');

                SetEllipse(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));

                TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(false, true, TileType.MasterThief, coordinates.x, coordinates.y));
            }
            else if (coordinates.messageType == MessageType.gamePause || coordinates.messageType == MessageType.gamePauseUndo)
            {
                ;
            }
            else if (coordinates.messageType == MessageType.reset)
            {
                ClearBoard();
                string[] words = coordinates.color.Split(' ');
                //SetTile(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
            }
            else if (coordinates.messageType == MessageType.darkHole)
            {
                string[] words = coordinates.color.Split(' ');
                SetTile(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(true, true, TileType.DarkHole, coordinates.x, coordinates.y));
            }
            else if (coordinates.messageType == MessageType.lightHole)
            {
                string[] words = coordinates.color.Split(' ');
                SetTile(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                TilesSet.AddTile(coordinates.x, coordinates.y, new Tile(true, true, TileType.LightHole, coordinates.x, coordinates.y));
            }
            else
            {
                if (TilesSet.GetTile(coordinates.x, coordinates.y).TileType == TileType.DarkHole || TilesSet.GetTile(coordinates.x, coordinates.y).TileType == TileType.LightHole)
                {
                }
                else
                {
                    string[] words = coordinates.color.Split(' ');

                    SetTile(coordinates.x, coordinates.y, new SolidColorBrush(Color.FromRgb(Byte.Parse(words[0]), Byte.Parse(words[1]), Byte.Parse(words[2]))));
                }
            }
        }
Ejemplo n.º 9
0
        private void ChatService_CoordinatesMessageReceived(BoardCoordinates coordinates)
        {
            if (!gameHasEnded)
            {
                if (coordinates.messageType == MessageType.playerMovement)
                {
                    if (StepsCount == 0)
                    {
                        board.State = new Darken();
                    }
                    else if (StepsCount == SpawnRates.StepsCount / 2)
                    {
                        board.State = new Lighten();
                    }

                    board.Request();
                    if (StepsCount >= SpawnRates.StepsCount)
                    {
                        StepsCount = -1;
                    }

                    //currByte -= 1;
                    //BackgroundColor = Color.FromRgb(255, currByte, currByte).ToString();
                    //OnPropertyChanged(nameof(BackgroundColor));

                    if (coordinates.id == UniqueID)
                    {
                        MainPlayer.Score++;
                    }

                    if (BonusCount > SpawnRates.BonusCount)
                    {
                        //var a = new BonusFactory();
                        Random randNum     = new Random();
                        int    BonusNumber = randNum.Next(1, 4);
                        //a.CreateBonus(BonusNumber, _chatService).SendBonus();
                        facade.CreateBonus(BonusNumber);
                        BonusCount = 0;
                        //MainPlayer.SetMemento(memento.Memento);
                    }

                    if (FreezeYourselfStepCount >= SpawnRates.FreezeYourselfStepCount)
                    {
                        facade.CreateDeBuff(TileType.DebuffFreezeYourself);
                        FreezeYourselfStepCount = 0;
                    }

                    if (FreezeOthersStepCount >= SpawnRates.FreezeOthersStepCount)
                    {
                        facade.CreateBuff(TileType.BuffFreezeOthers);
                        FreezeOthersStepCount = 0;
                    }

                    if (BlackSplashCount >= SpawnRates.BlackSplashCount)
                    {
                        facade.CreateDeBuff(TileType.DebuffBlackSplash);
                        BlackSplashCount = 0;
                    }
                    if (ColorSplashCount >= SpawnRates.ColorSplashCount)
                    {
                        facade.CreateBuff(TileType.BuffColorSplash);
                        ColorSplashCount = 0;
                    }

                    if (EnemyCount >= SpawnRates.EnemyCount)
                    {
                        MainEnemy.ChangePossition();
                        dazeEnemy.Operation(MainEnemy.PosX, MainEnemy.PosY, _connectionProxy);
                        EnemyCount = 0;
                    }

                    if (MagicianCount > SpawnRates.MagicianCount)
                    {
                        Thief newThief = new Magician();
                        newThief.Run(_connectionProxy);
                        MagicianCount = 0;
                    }

                    if (MasterThiefCount > SpawnRates.MasterThiefCount)
                    {
                        Thief newThief2 = new MasterThief();
                        newThief2.Run(_connectionProxy);
                        MasterThiefCount = 0;
                    }

                    StepsCount++;
                    BonusCount++;
                    FreezeYourselfStepCount++;
                    FreezeOthersStepCount++;
                    EnemyCount++;
                    BlackSplashCount++;
                    ColorSplashCount++;
                    MasterThiefCount++;
                    MagicianCount++;

                    //jei turi str count bet nedaro

                    if (coordinates.id == UniqueID)
                    {
                        _message = coordinates.message;
                        _x       = coordinates.x;
                        _y       = coordinates.y;


                        if (TilesSet.GetTile(_x, _y).TileType == TileType.BonusJackPot)
                        {
                            root.AddPoint(ComponentType.JackPot);
                            MainPlayer.PlayerCalculateScore(Score.AddPoints(new BonusFactory().CreateBonus(1, _connectionProxy)));
                            MessageBox.Show(TilesSet.GetTile(_x, _y).TileType.ToString() + MainPlayer.Score);
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.BonusNormal)
                        {
                            root.AddPoint(ComponentType.Normal);
                            MainPlayer.PlayerCalculateScore(Score.AddPoints(new BonusFactory().CreateBonus(3, _connectionProxy)));
                            MessageBox.Show(TilesSet.GetTile(_x, _y).TileType.ToString() + MainPlayer.Score);
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.BonusJoke)
                        {
                            root.AddPoint(ComponentType.Joke);
                            MainPlayer.PlayerCalculateScore(Score.ReducePoints(new BonusFactory().CreateBonus(2, _connectionProxy)));
                            MessageBox.Show(TilesSet.GetTile(_x, _y).TileType.ToString() + MainPlayer.Score);
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.DebuffFreezeYourself)
                        {
                            IceDamageDealer.ProcessRequest(DamageDealerType.IceDamage, MainPlayer);
                            root.AddPoint(ComponentType.FreezeYourself);
                            MainPlayer.RequestStrategy(StrategyType.Frozen);
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.BuffFreezeOthers)
                        {
                            root.AddPoint(ComponentType.FreezeOthers);
                            MainPlayer.RequestStrategy(StrategyType.Frozen);
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.BuffColorSplash)
                        {
                            root.AddPoint(ComponentType.ColorSplash);
                            MainPlayer.SendSteppedOnColorSplash(_connectionProxy, _x, _y);
                            MessageBox.Show(TilesSet.GetTile(_x, _y).TileType.ToString());
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.DebuffBlackSplash)
                        {
                            root.AddPoint(ComponentType.BlackSplash);
                            MainPlayer.SendSteppedOnBlackSplash(_connectionProxy, _x, _y);
                            MessageBox.Show(TilesSet.GetTile(_x, _y).TileType.ToString());
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.DarkHole)
                        {
                            MainPlayer.Score -= 3;
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.LightHole)
                        {
                            MainPlayer.Score -= 2;
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.Magician)
                        {
                            Random randNum = new Random();
                            int    number  = randNum.Next(1, 1000);
                            string roman   = ToRoman(number);

                            ContextRoman context = new ContextRoman(roman);
                            foreach (ExpressionRoman exp in tree)
                            {
                                exp.Interpret(context);
                            }

                            string message = "Does " + roman + " = " + context.Output + " ?";
                            string title   = "Answer the question";

                            MessageBoxResult result = MessageBox.Show(message, title, MessageBoxButton.YesNo);
                            if (result == MessageBoxResult.No)
                            {
                                IceDamageDealer.ProcessRequest(DamageDealerType.MagitianDamage, MainPlayer);
                            }
                        }
                        if (TilesSet.GetTile(_x, _y).TileType == TileType.MasterThief)
                        {
                            IceDamageDealer.ProcessRequest(DamageDealerType.ThiefDamage, MainPlayer);
                        }

                        if (TilesSet.GetTile(_x, _y).TileType == TileType.Enemy)
                        {
                            IceDamageDealer.ProcessRequest(DamageDealerType.EnemyDamage, MainPlayer);
                            MainPlayer.RequestStrategy(StrategyType.Confused);
                        }

                        TilesSet.AddTile(_x, _y, new Tile(true, true, TileType.Neutral, _x, _y));

                        OnPropertyChanged(nameof(Message));
                        OnPropertyChanged(nameof(x));
                        MainPlayer.PosX = x;
                        MainPlayer.PosY = y;
                        OnPropertyChanged(nameof(y));
                        OnPropertyChanged(nameof(CurrentPlayerScore));
                    }
                }

                if (coordinates.messageType == MessageType.gamePause || coordinates.messageType == MessageType.gamePauseUndo)
                {
                    SetGamePause();
                }

                if (MainPlayer.Score >= 100)
                {
                    MessageBox.Show(root.Display(1));
                    MainPlayer.SendGameOverMessage(_connectionProxy, UniqueID);
                    MainPlayer.Score = 0;
                }

                if (coordinates.messageType == MessageType.gameOver)
                {
                    gameHasEnded = true;
                }

                if (coordinates.messageType == MessageType.reset)
                {
                    MainPlayer.SetMemento(memento.Memento);
                    x = MainPlayer.PosX;
                    y = MainPlayer.PosY;
                    OnPropertyChanged(nameof(x));
                    OnPropertyChanged(nameof(y));
                    OnPropertyChanged(nameof(CurrentPlayerScore));
                }
            }
        }
Ejemplo n.º 10
0
        public BoardCoordinatesViewModel(ConnectionProxy connectionProxy, Player mainPlayer, Enemy mainEnemy)
        {
            _connectionProxy = connectionProxy;
            MainPlayer       = mainPlayer;

            memento         = new MementoCareTaker();
            memento.Memento = MainPlayer.CreateMemento();

            MainEnemy = mainEnemy;
            Random randNum = new Random();

            UniqueID  = randNum.Next(100, 255);
            UniqueID2 = randNum.Next(100, 255);
            UniqueID3 = randNum.Next(100, 255);

            CurrentPlayer.color = UniqueID.ToString() + " " + UniqueID2.ToString() + " " + UniqueID3.ToString();

            enemySteal    = new StealPointsAbility();
            teleportEnemy = new TeleportAbility();
            dazeEnemy     = new DazePlayerAbility();

            enemySteal.SetEnemy(MainEnemy);
            teleportEnemy.SetEnemy(enemySteal);
            dazeEnemy.SetEnemy(teleportEnemy);


            for (int x = 0; x < 20; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    TilesSet.AddTile(x, y, new Tile(false, true, TileType.Neutral, x, y));
                }
            }

            //playerColor = UniqueID.ToString() + " " + UniqueID2.ToString() + " " + UniqueID3.ToString();
            //playerColor.Color = Color.FromArgb(255, 255, 255, 0);

            //SendCoordinatesCommand = new SendCoordinatesChatMessageCommand(this, chatService);
            MoveDownChatMessageCommand  = new MoveDownChatMessageCommand(this, _connectionProxy, MainPlayer);
            MoveLeftChatMessageCommand  = new MoveLeftChatMessageCommand(this, _connectionProxy, MainPlayer);
            MoveRightChatMessageCommand = new MoveRightChatMessageCommand(this, _connectionProxy, MainPlayer);
            MoveUpChatMessageCommand    = new MoveUpChatMessageCommand(this, _connectionProxy, MainPlayer);
            Pause       = new Pause(this, _connectionProxy);
            RestartGame = new RestartGame(this, _connectionProxy);

            _message = "Waiting for response";

            x           = MainPlayer.PosX;
            y           = MainPlayer.PosY;
            playerColor = MainPlayer.Color;

            /* CHAIN OF RESPONSIBILITY */

            EnemyDamageDealer    = new EnemyDamage();
            MagicianDamageDealer = new MagicianDamage();
            ThiefDamageDealer    = new ThiefDamage();
            IceDamageDealer      = new IceDamage();

            IceDamageDealer.SetSuccessor(ThiefDamageDealer);
            ThiefDamageDealer.SetSuccessor(MagicianDamageDealer);
            MagicianDamageDealer.SetSuccessor(EnemyDamageDealer);

            /* CHAIN OF RESPONSIBILITY */

            CurrentPlayer.x = x;
            CurrentPlayer.y = y;

            _connectionProxy.AddMessageReceiver(ChatService_CoordinatesMessageReceived);

            //chatService.CoordinatesReceived += ChatService_CoordinatesMessageReceived;
            facade = new Facade(_connectionProxy);

            root = new Effect(ComponentType.Effect);
            //Buffai

            Effect buff         = new Effect(ComponentType.Buff);
            Effect negativeBuff = new Effect(ComponentType.Negative); //negative
            Effect positiveBuff = new Effect(ComponentType.Positive); //positive

            positiveBuff.Add(new CountLeaf(ComponentType.ColorSplash));
            positiveBuff.Add(new CountLeaf(ComponentType.FreezeOthers));

            negativeBuff.Add(new CountLeaf(ComponentType.BlackSplash));
            negativeBuff.Add(new CountLeaf(ComponentType.FreezeYourself));

            buff.Add(negativeBuff);
            buff.Add(positiveBuff);

            // /Buffai
            // Bonusai

            Effect bonus = new Effect(ComponentType.Bonus);

            bonus.Add(new CountLeaf(ComponentType.JackPot));
            bonus.Add(new CountLeaf(ComponentType.Normal));
            bonus.Add(new CountLeaf(ComponentType.Joke));

            //Bonusai

            root.Add(buff);
            root.Add(bonus);

            /* INTERPRETER DESIGN PATTERN IMPLEMENTATION */
            tree = new List <ExpressionRoman>();
            tree.Add(new ThousandExpression());
            tree.Add(new HundredExpression());
            tree.Add(new TenExpression());
            tree.Add(new OneExpression());
            /* INTERPRETER DESIGN PATTERN IMPLEMENTATION */


            /* VISITOR DESIGN PATTERN IMPLEMENTATION */
            game = new GameStructure();
            game.Attach(new Hard());

            BonusSpawnRate  bonusSpawn  = new BonusSpawnRate();
            BuffSpawnRate   buffSpawn   = new BuffSpawnRate();
            DebuffSpawnRate debuffSpawn = new DebuffSpawnRate();

            game.Accept(bonusSpawn);
            game.Accept(buffSpawn);
            game.Accept(debuffSpawn);
            /* VISITOR DESIGN PATTERN IMPLEMENTATION */

            /* Flyweight design pattern */


            /* Flyweight design pattern */
        }