Esempio n. 1
0
        private void InitializePlayerStructure()
        {
            IPlayerStructure playerStructure = null;

            switch (this.num)
            {
            case PlayerNum.P1:
                playerStructure = new PlayerRed();
                this.x          = 26;
                this.y          = 26;
                break;

            case PlayerNum.P2:
                playerStructure = new PlayerBlue();
                this.x          = 534;
                this.y          = 26;
                break;

            case PlayerNum.P3:
                playerStructure = new PlayerGreen();
                this.x          = 26;
                this.y          = 434;
                break;

            case PlayerNum.P4:
                playerStructure = new PlayerYellow();
                this.x          = 534;
                this.y          = 434;
                break;
            }
            this.pictureStructure = playerStructure.GetPlayerStructure();
        }
Esempio n. 2
0
        public void UpdatePlayerStructure(string structure)
        {
            int num = (int)this.num;
            IPlayerStructure playerStructure = null;

            switch (this.num)
            {
            case PlayerNum.P1:
                playerStructure = new PlayerRed();
                break;

            case PlayerNum.P2:
                playerStructure = new PlayerBlue();
                break;

            case PlayerNum.P3:
                playerStructure = new PlayerGreen();
                break;

            case PlayerNum.P4:
                playerStructure = new PlayerYellow();
                break;
            }

            if (structure.Contains("f"))
            {
                playerStructure = new PlayerFedoraDecorator(playerStructure);
            }

            if (structure.Contains("s"))
            {
                playerStructure = new PlayerShoesDecorator(playerStructure);
            }
            this.pictureStructure = playerStructure.GetPlayerStructure();
            originator.setState(this.pictureStructure);
        }