Beispiel #1
0
 public int continent;       //The continent this nation belongs to
 public Nation(rGame game, int X, int Y, Texture2D texture, int Continent, Player Ownership, Nation[] Neighbors, String Name)
 {
     g = game;               
     x = X;                  
     y = Y;
     tex = texture;
     Owner = Ownership;
     neighbors = Neighbors;
     continent = Continent;
     name = Name;
 }
Beispiel #2
0
        String[] continents;    //The continents and their worths; stored like this: "name,A|D|S|T"

        public rGame(Game1 game, List<Player> players, Boolean isOffline, String mapName)
        {
            g = game;

            pls = players;

            offline = isOffline;

            String[] mPosA = File.ReadAllLines("maps\\" + mapName + "\\map.txt");
            String[] mPos = mPosA[0].Split(' ');
            continents = mPosA[1].Split(' ');

            foreach (String pos in mPos)
            {
                String[] nNs = pos.Split(',')[4].Split(':');
                Nation[] nN = new Nation[nNs.Length];
                int i = 0;

                //Get all neighbouring nation objects
                foreach (Nation n in Nations)
                {
                    if(Array.IndexOf(nNs, n.name)>-1)
                    {
                        nN[i]=n;
                        i++;
                    }
                }

                //Add the actual nation. Huge function, I know.
                Nations.Add(new Nation(this,                                        //Reference to rGame(this class)
                    int.Parse(pos.Split(',')[1]), int.Parse(pos.Split(',')[2]),     //Position
                    g.gT("maps\\" + mapName + "\\" + pos.Split(',')[0] + ".png"),   //Texture
                    int.Parse(pos.Split(',')[3]),                                   //Continent ID
                    new Player(this, "none", false, Color.White),                   //Colour
                    nN,                                                             //Neighbouring nations
                    pos.Split(',')[0]));                                            //Nation name
            }

            for (int i = 0; i < pls.Count; i++)
            {
                int rNation = g.r.Next(0, mPos.Length);
                while (Nations[rNation].Owner.colour!=Color.White)
                    rNation = g.r.Next(0, mPos.Length);
                Nations[rNation].Owner = players[i];
            }
        }