Ejemplo n.º 1
0
 // called if the desired map to read does not exsist, building a plain one instead.
 private void CreateBlankMap()
 {
     for (int x = 0; x < MapMaster.MapRadius; x++)
     {
         for (int z = 0; z < MapMaster.MapRadius; z++)
         {
             MapMaster.MakeTile(x, z);
         }
     }
 }
Ejemplo n.º 2
0
    private void LoadMap(string [] lines)
    {
        string rawData; // the entire line of text read from the file

        string[] dData; // the data after being split up based on the given delim above.

        string data = lines[0];

        int rad = System.Int32.Parse(data);

        MapMaster.SetMap(rad);

        for (int i = 1; i < lines.Length - 1; i++)
        {
            rawData = lines[i];
            dData   = rawData.Split(DELIM);

            if (dData.Length >= 5)
            {
                int  q = int.Parse(dData[(int)CellData.q]);
                int  r = int.Parse(dData[(int)CellData.r]);
                Unit u = ((dData[(int)CellData.unit] == "null") ? null : MapMaster.MakeTerrain(dData[(int)CellData.unit])); // if the hex has any terrain, the Get Terrain method returns the related type after spawning it.
                if (u != null)
                {
                    u.UDirection = int.Parse(dData[(int)CellData.unitRotation]); // rotation of the unit
                }
                HexSize  s = (HexSize)int.Parse((dData[(int)CellData.size]));
                TileType type;

                if (dData.Length <= (int)CellData.type)
                {
                    type = 0;
                }
                else
                {
                    type = (TileType)int.Parse((dData[(int)CellData.type]));
                }

                MapMaster.MakeTile(q, r);

                if (u != null) // depending on the natue of how we handle loading terrain, we might be checking for the string "null" here instead and not loading the object itself until we get to TerranPass
                {
                    MapMaster.Map[r, q].Unit            = u;
                    MapMaster.Map[r, q].Unit.CurrentHex = MapMaster.Map[r, q];
                    toBuild.Add(MapMaster.Map[r, q]);
                }

                if ((int)s != 0)
                {
                    MapMaster.Map[r, q].Size = s;
                    toSize.Add(MapMaster.Map[r, q]);
                }

                if ((int)type != 0)
                {
                    MapMaster.Map[r, q].Type = type;
                    toType.Add(MapMaster.Map[r, q]);
                }
            }
        }

        SizePass();    // any cells needing to have their scale changed are handled here.
        TerrainPass(); // any cells that are to have terrain is handled here.
        TypePass();    //any cells that need to have their cost and matieral changed are handled here.

        ViewMaster.PlaceCubes();
    }