Beispiel #1
0
 public BoardPiece(int ID,int type, String name,Player owner, int pos, int pri, int hnr, int hprice, int inc, int[] hinc, bool mort, int mortprice, int umortprice)
 {
     this.IDvalue = ID;
     this.typevalue = type;
     this.namevalue = name;
     this.ownervalue = owner;
     this.positionvalue = pos;
     this.pricevalue = pri;
     this.housenrvalue = hnr;
     this.housepricevalue = hprice;
     this.incomevalue = inc;
     this.houseincomevalue = hinc;
     this.mortagevalue = mort;
     this.mortagepricevalue = mortprice;
     this.umortagepricevalue = umortprice;
 }
 public void listnames(Player player, Rectangle rect)
 {
     this.X = rect.X;
     this.Y = rect.Y;
     this.sizeX = rect.Width;
     this.sizeY = rect.Height;
     mouseState_ = Mouse.GetState();
     mousePosition_ = new Point(mouseState_.X, mouseState_.Y);
     if (bigPic)
     {
         ShowStreet (currentPiece);
     }
     for (int i = 0; i < player.streetlist.Count; i++) {
         if (Y + i * 12 < Y+sizeY) {
             streetRect[i] = new Rectangle (X, Y + 3 + (i * 12), 100, 12);
             if (streetRect[i].Contains (mousePosition_)) {
                 if (mouseState_.LeftButton == ButtonState.Pressed )
                 {
                     bigPic = true;
                     currentPiece = player.streetlist[i];
                     ShowStreet (player.streetlist [i]);
                 }
             }
             Z = (i + 1) * 12;
         }
     else {
             streetRect[i] = new Rectangle (X + 100, Y + 3 + (i * 12) - Z, 100, 12);
         if (streetRect[i].Contains (mousePosition_)) {
                 if (mouseState_.LeftButton == ButtonState.Pressed && prevMouseState_.LeftButton == ButtonState.Released) {
                     bigPic = true;
                     currentPiece = player.streetlist[i];
                     ShowStreet (player.streetlist [i]);
                 }
             }
         }
     }
     prevMouseState_ = mouseState_;
 }
 /*	public void add(BoardPiece piece)
 {
     streetlist.Add (piece);
 }
 */
 public void updatelist(Player player, BoardPiece[] piece)
 {
     player.streetlist = new List<BoardPiece> ();
     for(int i=0; i<piece.Length;i++)
     {
         if(player.ID == piece[i].owner.ID)
         {
             player.add (piece [i]);
         }
     }
 }
        public void listnamesDraw(Player player, Rectangle rect)
        {
            this.X = rect.X;
            this.Y = rect.Y;
            this.sizeX = rect.Width;
            this.sizeY = rect.Height;
            if (bigPic)
            {
                ShowStreetDraw (currentPiece);
            }
            for (int i = 0; i < player.streetlist.Count; i++) {
                if (Y + i * 12 < Y+sizeY) {
                    temprect = new Rectangle (X, Y + 3 + (i * 12), 100, 12);
                    if(temprect.Contains(Mouse.GetState().Position))
                    {
                        streetColor = Color.Green;
                    }
                    spriteBatch_.DrawString (font, player.streetlist [i].name + ", " + player.streetlist[i].housenr, new Vector2 (X, Y + (i * 12)), streetColor);
                    Z = (i + 1) * 12;
                }
                else {
                    temprect = new Rectangle (X + 100, Y + 3 + (i * 12) - Z, 100, 12);
                    if(temprect.Contains(Mouse.GetState().Position))
                    {
                        streetColor = Color.Green;
                    }
                    spriteBatch_.DrawString (font, player.streetlist [i].name + ", " + player.streetlist[i].housenr, new Vector2 (X + 100, Y + (i * 12) - Z), streetColor);
                }
                streetColor = Color.Black;

            }
        }
Beispiel #5
0
        public BoardPiece getsectionbysection(BoardPiece piece)
        {
            int pos = piece.position;
            int Xtemp = piece.X;
            int Ytemp = piece.Y;

            XElement xelement = getXELE();
            var data = from d in xelement.Elements("Section")
                    where (string)d.Element("position") == pos.ToString()
                select d;
            Player p = new Player (50,"-1",0,0,0,false,false,false,0);
            BoardPiece b = new BoardPiece (0, 0, "", p, 0, 0, 0, 0, 0, new int[]{ 0, 0, 0, 0, 0, 0 }, false, 0, 0);
            foreach (XElement d in data)
                b = new BoardPiece (Int32.Parse (d.Element ("ID").Value),
                    Int32.Parse (d.Element ("type").Value),
                    d.Element ("name").Value,
                    getplayerbyID(Int32.Parse (d.Element ("owner").Value)),
                    Int32.Parse (d.Element ("position").Value),
                    Int32.Parse (d.Element ("price").Value),
                    Int32.Parse (d.Element ("housenr").Value),
                    Int32.Parse (d.Element ("houseprice").Value),
                    Int32.Parse (d.Element ("income").Value),
                    new int[] {
                        Int32.Parse (d.Element("houseincome").Element ("h0").Value),
                        Int32.Parse (d.Element("houseincome").Element ("h1").Value),
                        Int32.Parse (d.Element("houseincome").Element ("h2").Value),
                        Int32.Parse (d.Element("houseincome").Element ("h3").Value),
                        Int32.Parse (d.Element("houseincome").Element ("h4").Value),
                        Int32.Parse (d.Element("houseincome").Element ("h5").Value)
                    },
                    Convert.ToBoolean (d.Element ("mortage").Value),
                    Int32.Parse (d.Element ("mortageprice").Value),
                    Int32.Parse (d.Element ("umortageprice").Value));
            b.Y = Ytemp;
            b.X = Xtemp;
            return b;
        }
Beispiel #6
0
 //Get player by ID;
 public Player getplayerbyplayer(Player player)
 {
     int ID = player.ID;
     int state = player.state;
     //List<BoardPiece> templist;
     //templist = player.streetlist;
     XElement xelement = getXELE();
     var data = from d in xelement.Elements("Player")
             where (string)d.Element("ID") == ID.ToString()
         select d;
     Player p = null;
     foreach (XElement d in data)
         p = new Player (Int32.Parse(d.Element("ID").Value,0),
             d.Element("name").Value,
             Int32.Parse(d.Element("prison").Value),
             Int32.Parse(d.Element("position").Value),
             Int32.Parse(d.Element("property").Value),
             Convert.ToBoolean(d.Element("playing").Value),
             Convert.ToBoolean(d.Element("isCurrent").Value),
             Convert.ToBoolean(d.Element("isAI").Value),
             Int32.Parse(d.Element("state").Value));
     //p.streetlist = templist;
     p.state = state;
     return p;
 }
Beispiel #7
0
 //Get player by ID;
 public Player getplayerbyID(int ID)
 {
     try
     {
         XElement xelement = getXELE();
         var data = from d in xelement.Elements("Player")
                 where (string)d.Element("ID") == ID.ToString()
             select d;
         Player p = new Player(0, "name", 0, 0, 0, false, false, false,0);
         foreach (XElement d in data)
             p = new Player(Int32.Parse(d.Element("ID").Value),
                 d.Element("name").Value,
                 Int32.Parse(d.Element("prison").Value),
                 Int32.Parse(d.Element("position").Value),
                 Int32.Parse(d.Element("property").Value),
                 Convert.ToBoolean(d.Element("playing").Value),
                 Convert.ToBoolean(d.Element("isCurrent").Value),
                 Convert.ToBoolean(d.Element("isAI").Value),
                 Int32.Parse(d.Element("state").Value));
         return p;
     }
     catch(IOException e)
     {
         Console.WriteLine("getPlayerByID");
         return new Player(50, "-1", 0, 0, 0, false, false, false,0);
     }
 }
Beispiel #8
0
 //Decides if the player is AI or human
 public void run(Player player, BoardPiece piece)
 {
     if(player.isAI)
     {
         AI_.run (player, piece);
     }
     else
     {
         GUIStateHandler_.checkState (player, piece);
     }
 }