Beispiel #1
0
 private static string writeString(HexField.Data data)
 {
     return(data.x.ToString() + Project.fieldSeparator +
            data.y.ToString() + Project.fieldSeparator +
            (int)data.field + Project.fieldSeparator +
            data.playerControl.ToString());
 }
Beispiel #2
0
    private static void constructField(HexField.Data data, int xSize, int ySize)
    {
        GameObject obj       = Instantiate(Resources.Load <GameObject>("Materials/HexBlockGO"));
        Transform  transform = obj.transform;
        float      delta     = data.y % 2 == 1 ? xratio / 2 : 0;

        transform.SetPositionAndRotation(new Vector3(xratio * data.x - delta - (xSize * xratio / 2), 0,
                                                     data.y * yratio - (ySize * yratio / 2)), new Quaternion());
        hexMap.Add(new Vector2(data.x, data.y), transform);
        HexField field = obj.AddComponent <HexField>();

        field.data = data;
        textureGameObject(obj, data.field);
        Project.fields.Add(field);
        transform.parent = GameObject.Find("Map").transform;
    }
Beispiel #3
0
 public static void generateMap(int xSize, int ySize)
 {
     clearMap();
     for (int x = 0; x < xSize; ++x)
     {
         for (int y = 0; y < ySize; ++y)
         {
             HexField.Data data = new HexField.Data
             {
                 x             = x,
                 y             = y,
                 field         = HexField.FieldType.Grass,
                 playerControl = 0
             };
             constructField(data, xSize, ySize);
         }
     }
 }