Exemplo n.º 1
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 */
        }