示例#1
0
        public void assignSprite(E_Space space)
        {
            // Get graphic based on type:
            switch (space.type)
            {
            case Entity.typeSpace.blue:
                this.sprite = parentState.parentManager.game.piece_blue64;
                break;

            case Entity.typeSpace.red:
                this.sprite = parentState.parentManager.game.piece_red64;
                break;

            case Entity.typeSpace.chance:
                this.sprite = parentState.parentManager.game.piece_chance64;
                break;

            case Entity.typeSpace.bonus:
                this.sprite = parentState.parentManager.game.piece_purple64;
                break;

            case Entity.typeSpace.star:
                this.sprite = parentState.parentManager.game.piece_star64;     // TODO: make a star space sprite
                break;

            case Entity.typeSpace.invisible:
                this.sprite  = parentState.parentManager.game.noSprite;
                this.visible = false;
                break;

            default:
                this.sprite = parentState.parentManager.game.noSprite;
                break;
            }
        }
示例#2
0
        // Update:
        public override void Update(GameTime gameTime, KeyboardState ks)
        {
            base.Update(gameTime, ks);

            // Move the player
            if (moveNum > 0)
            {
                // Find next space
                E_Space spaceToMoveTo = currPlayer.currSpace.spacesAhead[0];

                // Move the meeple untill it's close enough to space
                if (Vector2.Distance(spaceToMoveTo.getMeepleLocation(), currPlayer.meeple.getPosCenter()) > 1.0F)
                {
                    float newX = MGP_Tools.Ease(currPlayer.meeple.getPosCenter().X, spaceToMoveTo.getMeepleLocation().X, 0.15F);
                    float newY = MGP_Tools.Ease(currPlayer.meeple.getPosCenter().Y, spaceToMoveTo.getMeepleLocation().Y, 0.15F);
                    currPlayer.meeple.setPos(new Vector2(newX, newY));
                    MGP_Tools.Follow_Player(parentManager, currPlayer);

                    // Play space sound effect:
                    if (!soundPlayed)
                    {
                        parentManager.audioEngine.playSound(MGP_Constants.soundEffects.space, 0.7f);
                        soundPlayed = true;
                    }
                }
                // Meeple has arrived at new space
                else
                {
                    moveNum--;
                    currPlayer.currSpace = spaceToMoveTo;

                    // allow sound to play next time:
                    soundPlayed = false;

                    // If player passes a star
                    if (currPlayer.currSpace.type == Entity.typeSpace.star)
                    {
                        S_BuyStar buyStar = new S_BuyStar(parentManager, 0, 0);
                        parentManager.AddStateQueue(buyStar);
                        this.active = false; //pause moving player
                    }
                }
            }
            // finished moving meeple
            else
            {
                // Occupy that space so another meeple doesn't run him/her over:
                currPlayer.currSpace.occupySpace(currPlayer);

                S_LandAction landAction = new S_LandAction(parentManager, 0, 0);
                parentManager.AddStateQueue(landAction);
                this.flagForDeletion = true;
            }

            // Listen for pausing here:
            ListenPause();
        }
示例#3
0
 public void assignSpaces(E_Space prev)
 {
     prev.addAhead(this);
     this.addBehind(prev);
 }
示例#4
0
 void removeBehind(E_Space newSpace)
 {
     this.spacesBehind.Remove(newSpace);
 }
示例#5
0
 void removeAhead(E_Space newSpace)
 {
     this.spacesAhead.Remove(newSpace);
 }
示例#6
0
 void addBehind(E_Space newSpace)
 {
     this.spacesBehind.Add(newSpace);
 }
示例#7
0
 void addAhead(E_Space newSpace)
 {
     this.spacesAhead.Add(newSpace);
 }
示例#8
0
        // Collection of Spaces:
        //public List<E_Space> spaces;

        // Constructor:
        public B_PirateBay(GameStateManager creator, float xPos, float yPos) : base(creator, xPos, yPos)
        {
            // --------------------------- Create Spaces: ----------------------------------
            // initialize list of spaces:
            spaces = new List <E_Space>();
            E_Space curSpace;
            E_Space prevSpace;

            // STARTING WITH BOTTOM RIGHT
            // <<---- MOVING LEFT NOW: ----->>
            // Bottom right space:
            curSpace = new E_Space(this, GetTilePosCenter(21, 16), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace);
            this.startingSpace = curSpace; // STARTING SPACE
            prevSpace          = curSpace;



            // 20, 16
            // Blue
            curSpace = new E_Space(this, GetTilePosCenter(20, 16), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 19, 16
            // Blue
            curSpace = new E_Space(this, GetTilePosCenter(19, 16), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 17, 16
            // Red
            curSpace = new E_Space(this, GetTilePosCenter(17, 16), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 16, 15
            // Blue
            curSpace = new E_Space(this, GetTilePosCenter(16, 15), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 15, 15
            // Blue
            curSpace = new E_Space(this, GetTilePosCenter(15, 15), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 14, 15
            // Red
            curSpace = new E_Space(this, GetTilePosCenter(14, 15), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 12, 15
            // Blue
            curSpace = new E_Space(this, GetTilePosCenter(12, 15), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 12, 16
            // Blue
            curSpace = new E_Space(this, GetTilePosCenter(12, 16), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 10, 16
            curSpace = new E_Space(this, GetTilePosCenter(10, 16), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 7, 16
            curSpace = new E_Space(this, GetTilePosCenter(7, 16), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 6, 16 CHANCE TIME
            curSpace = new E_Space(this, GetTilePosCenter(6, 16), Entity.typeSpace.chance);
            curSpace.setOverlapPositions(E_Space.direction.left);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;


            // <<---- MOVING UP NOW: ----->>
            // 6, 15
            curSpace = new E_Space(this, GetTilePosCenter(6, 15), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 6, 13
            curSpace = new E_Space(this, GetTilePosCenter(6, 13), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 6, 10
            curSpace = new E_Space(this, GetTilePosCenter(6, 10), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 6, 9
            curSpace = new E_Space(this, GetTilePosCenter(6, 9), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 4, 9
            curSpace = new E_Space(this, GetTilePosCenter(4, 9), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 3, 9
            curSpace = new E_Space(this, GetTilePosCenter(3, 9), Entity.typeSpace.chance);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 3, 8
            curSpace = new E_Space(this, GetTilePosCenter(3, 8), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 3, 7
            curSpace = new E_Space(this, GetTilePosCenter(3, 7), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 3, 3
            curSpace = new E_Space(this, GetTilePosCenter(3, 3), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 3, 2
            curSpace = new E_Space(this, GetTilePosCenter(3, 2), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.up);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;



            // <<---- MOVING RIGHT NOW: ----->>
            // 4, 1
            curSpace = new E_Space(this, GetTilePosCenter(4, 1), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 5, 1
            curSpace = new E_Space(this, GetTilePosCenter(5, 1), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 7, 1
            curSpace = new E_Space(this, GetTilePosCenter(7, 1), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 8, 2
            curSpace = new E_Space(this, GetTilePosCenter(8, 2), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 9, 2
            curSpace = new E_Space(this, GetTilePosCenter(9, 2), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 10, 3
            curSpace = new E_Space(this, GetTilePosCenter(10, 3), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 12, 3
            curSpace = new E_Space(this, GetTilePosCenter(12, 3), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 13, 3
            curSpace = new E_Space(this, GetTilePosCenter(13, 3), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 14, 3
            curSpace = new E_Space(this, GetTilePosCenter(14, 3), Entity.typeSpace.chance);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 16, 3
            curSpace = new E_Space(this, GetTilePosCenter(16, 3), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 17, 4
            curSpace = new E_Space(this, GetTilePosCenter(17, 4), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 18, 4
            curSpace = new E_Space(this, GetTilePosCenter(18, 4), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.right);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;



            // <<---- MOVING DOWN NOW: ----->>
            // 19, 5
            curSpace = new E_Space(this, GetTilePosCenter(19, 5), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 19, 7
            curSpace = new E_Space(this, GetTilePosCenter(19, 7), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 19, 8
            curSpace = new E_Space(this, GetTilePosCenter(19, 8), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 19, 10
            curSpace = new E_Space(this, GetTilePosCenter(19, 10), Entity.typeSpace.chance);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 19, 11
            curSpace = new E_Space(this, GetTilePosCenter(19, 11), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 19, 13
            curSpace = new E_Space(this, GetTilePosCenter(19, 13), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 21, 13
            curSpace = new E_Space(this, GetTilePosCenter(21, 13), Entity.typeSpace.blue);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 22, 13
            curSpace = new E_Space(this, GetTilePosCenter(22, 13), Entity.typeSpace.red);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace); // add to overall list
            curSpace.assignSpaces(prevSpace);
            prevSpace = curSpace;

            // 22, 15 FINAL PIECE
            curSpace = new E_Space(this, GetTilePosCenter(22, 15), Entity.typeSpace.chance);
            curSpace.setOverlapPositions(E_Space.direction.down);
            spaces.Add(curSpace);       // add to overall list
            curSpace.assignSpaces(prevSpace);
            this.finalSpace = curSpace; // FINAL SPACE

            // Finally, link up last space and first space:
            this.startingSpace.assignSpaces(this.finalSpace);

            // Assign the star space to a random space
            MGP_Tools.Assign_Star(this);

            // Assign starting space to all players
            foreach (Player p in this.gameOptions.players)
            {
                p.currSpace = this.startingSpace;
                p.meeple.setPos(p.currSpace.getMeepleLocation());

                // Occupy that space so another meeple doesn't run him/her over:
                p.currSpace.occupySpace(p);
            }
        } // end constructor