Example #1
0
        string MapToString()
        {
            string returnString = string.Format("{0} {1} {2} {3} {4} {5} {6}",             // Seperator between each element
                                                "Width:",
                                                MapWidth.ToString(),
                                                "\tHeight:",
                                                MapHeight.ToString(),
                                                "\t% Walls:",
                                                PercentAreWalls.ToString(),
                                                "\n");

            List <string> mapSymbols = new List <string>();

            mapSymbols.Add("-");
            mapSymbols.Add("#");
            mapSymbols.Add("+");

            for (int column = 0, row = 0; row < MapHeight; ++row)
            {
                for (column = 0; column < MapWidth; ++column)
                {
                    returnString += mapSymbols[Map[column, row]];
                }
                returnString += "\n";
            }
            return(returnString);
        }
Example #2
0
    public static int GetValueOfHeight(MapHeight heightLevel)
    {
        switch (heightLevel)
        {
        case MapHeight.l0:
            return(0);

        case MapHeight.l1:
            return(1);

        case MapHeight.l2:
            return(2);

        case MapHeight.l3:
            return(3);

        case MapHeight.l4:
            return(4);

        case MapHeight.l5:
            return(5);

        case MapHeight.l6:
            return(6);

        case MapHeight.l7:
            return(7);

        default:
            Debug.LogWarning("this is not a simple height value(more than 1 flag used). Returning 0");
            return(0);
        }
    }
Example #3
0
        string MapToString()
        {
            string returnString = string.Join(" ",             // Seperator between each element
                                              "Width:",
                                              MapWidth.ToString(),
                                              "\tHeight:",
                                              MapHeight.ToString(),
                                              "\t% Walls:",
                                              PercentAreWalls.ToString(),
                                              Environment.NewLine
                                              );

            List <string> mapSymbols = new List <string>();

            mapSymbols.Add(".");
            mapSymbols.Add("#");
            mapSymbols.Add("+");

            for (int column = 0, row = 0; row < MapHeight; row++)
            {
                for (column = 0; column < MapWidth; column++)
                {
                    returnString += mapSymbols[Map[column, row]];
                }
                returnString += Environment.NewLine;
            }
            return(returnString);
        }
Example #4
0
    string MapToString()
    {
        string returnString = " " +
                              "Width:" +
                              MapWidth.ToString() +
                              "\tHeight:" +
                              MapHeight.ToString() +
                              "\t% Walls:" +
                              PercentAreWalls.ToString() +
                              "\n";

        List <string> mapSymbols = new List <string>();

        mapSymbols.Add(".");
        mapSymbols.Add("#");
        mapSymbols.Add("+");

        for (int column = 0, row = 0; row < MapHeight; row++)
        {
            for (column = 0; column < MapWidth; column++)
            {
                returnString += mapSymbols[Map[column, row]];
            }
            returnString += "\n";
        }
        return(returnString);
    }
Example #5
0
        public void TestMethod1()
        {
            int       mapSize = 256;
            double    snowLevel = 0.66, waterLevel = 0.25;
            MapHeight mapHeight = new MapHeight(mapSize, snowLevel, waterLevel);

            Assert.AreEqual(mapHeight.MapSize, mapSize);
        }
Example #6
0
    public void SetMapInfo(MapHeight mapHeight, int campCount)
    {
        MapHeight = mapHeight;
        int mapWidth = (int)mapHeight * 16 / 9;

        MapSize = new MapSize((int)mapHeight, mapWidth);
        //Debug.Log(string.Format("MapSize的高度是{0},宽度是{1},高度一半是{2},宽度一半是{3}",MapSize.Height,MapSize.Width,MapSize.HeightOffset,MapSize.WidthOffset));
        CampCount = campCount;
    }
Example #7
0
    public static bool CompatibleHeightLevel(MapHeight a, MapHeight b)
    {
        //esta funcion trabaja con los bits-> los niveles son compatibles si al menos uno de las dos alturas comparte un nivel.
        //ej: 0010 &                |  0001 &                |
        //    0001 --> 0000 = false |  0011  --> 0001 = true |
        var similarrities = a & b;

        return(similarrities != 0);
    }
Example #8
0
        public void CompatibleHeightLevelWorkAsIntended()
        {
            MapHeight l0_1 = MapHeight.l0 | MapHeight.l1;
            MapHeight l0   = MapHeight.l0;
            MapHeight l1   = MapHeight.l1;

            Assert.IsTrue(MapUtilities.CompatibleHeightLevel(l0_1, l0));
            Assert.IsTrue(MapUtilities.CompatibleHeightLevel(l0_1, l1));

            Assert.IsFalse(MapUtilities.CompatibleHeightLevel(l1, l0));
        }
Example #9
0
    public void SaveGeoMap()
    {
        if (activeEditorHexTiles == null)
        {
            Debug.LogError("Unable to Save");
            return;
        }
        else if (activeEditorHexTiles.Count == 0)
        {
            Debug.LogError("Unable to Save");
            return;
        }


        Dictionary <Hex, Material>  hexMaterials     = new Dictionary <Hex, Material>();
        Dictionary <Hex, Sprite>    hexSprites       = new Dictionary <Hex, Sprite>();
        Dictionary <Hex, bool>      hexWalkableFlags = new Dictionary <Hex, bool>();
        Dictionary <Hex, MapHeight> hexHeights       = new Dictionary <Hex, MapHeight>();
        Dictionary <Hex, SlopeData> hexSlopeDatas    = new Dictionary <Hex, SlopeData>();

        foreach (var tile in activeEditorHexTiles)
        {
            Hex      tileHex      = tile.Key;
            var      tileData     = tile.Value.data;
            Material tileMaterial = tileData.hexMaterial;
            Debug.Assert(tileMaterial != null, "Material null on the editor hex data", tileData);
            Sprite tileSprite = tileData.sprite;
            Debug.Assert(tileSprite != null, "Sprite null on the editor hex data", tileData);
            bool      tileWalkableFlag = tileData.walkable;
            MapHeight tileHeight       = tileData.heightLevel;
            SlopeData slopeData        = new SlopeData()
            {
                isSlope        = tileData.isSlope,
                heightSide_0tr = tileData.heightSide_TopRight,
                heightSide_1r  = tileData.heightSide_Right,
                heightSide_2dr = tileData.heightSide_DownRight,
                heightSide_3dl = tileData.heightSide_DownLeft,
                heightSide_4l  = tileData.heightSide_Left,
                heightSide_5tl = tileData.heightSide_TopLeft
            };

            hexMaterials.Add(tileHex, tileMaterial);
            hexSprites.Add(tileHex, tileSprite);
            hexWalkableFlags.Add(tileHex, tileWalkableFlag);
            hexHeights.Add(tileHex, tileHeight);
            hexSlopeDatas.Add(tileHex, slopeData);
        }

        editingMap.InitMap(hexMaterials, hexSprites, hexWalkableFlags, hexHeights, hexSlopeDatas, mapProportions);
        //var serializedObj = new UnityEditor.SerializedObject(editingMap);
        //serializedObj.ApplyModifiedProperties();
        EditorUtility.SetDirty(editingMap);
    }
Example #10
0
 public override string ToString()
 {
     return(string.Join("  ",
                        "Width:",
                        MapWidth.ToString(),
                        "\tHeight:",
                        MapHeight.ToString(),
                        "\tSeed:",
                        Seed.ToString(),
                        Environment.NewLine
                        ));
 }
Example #11
0
        public virtual string getDescription()
        {
            string returnString = string.Join("  ",
                                              "Width:",
                                              MapWidth.ToString(),
                                              "\tHeight:",
                                              MapHeight.ToString(),
                                              "\tSeed:",
                                              Seed.ToString(),
                                              Environment.NewLine
                                              );

            return(returnString);
        }
Example #12
0
        public override int GetHashCode()
        {
            int hash = 13;
            int prim = 11;

            hash = (hash * prim) ^ Difficulty.GetHashCode();
            hash = (hash * prim) ^ MapWidth.GetHashCode();
            hash = (hash * prim) ^ MapHeight.GetHashCode();
            hash = (hash * prim) ^ MineDensitiy.GetHashCode();
            hash = (hash * prim) ^ AudioVolume.GetHashCode();
            hash = (hash * prim) ^ MusicVolume.GetHashCode();
            hash = (hash * prim) ^ WindowMode.GetHashCode();
            return(hash);
        }
 private void OK_Click(object sender, RoutedEventArgs e)
 {
     try
     { XPos = Convert.ToInt32(_XPos.Text); }
     catch (FormatException)
     {
         MessageBox.Show("Value Position X ='" + _XPos.Text + "'is not in a recognizable format.", "Error");
         return;
     }
     try
     { YPos = Convert.ToInt32(_YPos.Text); }
     catch (FormatException)
     {
         MessageBox.Show("Value Position Y ='" + _YPos.Text + "'is not in a recognizable format.", "Error");
         return;
     }
     if (XPos < 0 || XPos >= MapWidth)
     {
         MessageBox.Show("A value Start position X must: 0<= x < " + MapWidth.ToString());
         return;
     }
     if (YPos < 0 || YPos >= MapWidth)
     {
         MessageBox.Show("A value Start position Y must: 0<= y < " + MapHeight.ToString());
         return;
     }
     try
     {
         LEVEL = Convert.ToInt32(Level.Text);
     }
     catch (FormatException)
     {
         MessageBox.Show("Value level: " + Level.Text + "is not in a recognizable format.", "Error");
         return;
     }
     try
     {
         TIMES = Convert.ToInt32(Times.Text);
     }
     catch (FormatException)
     {
         MessageBox.Show("Value level: " + Times.Text + "is not in a recognizable format.", "Error");
         return;
     }
     TIMES   = Convert.ToInt32(Times.Text);
     MapName = _MapName.Text;
     IsOK    = true;
     this.Close();
 }
Example #14
0
    /// <summary>
    /// 生成对战地图,应该只调用一次
    /// </summary>
    /// <param name="mapSize"></param>
    /// <param name="campCount"></param>
    public void GenerateMapInScene(MapHeight mapHeight, List <InitalCampParam> initalCampParams)
    {
        SetMapInfo(mapHeight, initalCampParams.Count);
        SetCamps(initalCampParams);

        GameObject battleMap   = Resources.Load("Prefabs/GameMap") as GameObject;
        GameObject MapInstance = Instantiate(battleMap);

        BattleMap = MapInstance.GetComponent <BattleMap>();


        InitalMap();
        //进入选首都阶段状态
        CurBattleState = BattleStateDictionary[BattleStateEnum.SelectCaptital];
        CurBattleState.EnterStateWithMouse(ref BattleMap.mapEnterAction, ref BattleMap.mapClickAction, ref BattleMap.mapExitAction);
    }
Example #15
0
        public override string ToString()
        {
            string returnString = string.Join(" ",
                                              "Width:",
                                              MapWidth.ToString(),
                                              "\tHeight:",
                                              MapHeight.ToString(),
                                              "\t% Walls:",
                                              PercentAreWalls.ToString(),
                                              "\tSeed:",
                                              Seed.ToString(),
                                              Environment.NewLine
                                              );

            return(returnString);
        }
Example #16
0
        public override string getDescription()
        {
            string returnString = string.Join("  ",
                                              "Width:",
                                              MapWidth.ToString(),
                                              "\tHeight:",
                                              MapHeight.ToString(),
                                              "\t% Walls:",
                                              PercentAreWalls.ToString(),
                                              "\tSeed:",
                                              Seed.ToString(),
                                              "\tClusters:",
                                              GetNumClusters(),
                                              Environment.NewLine
                                              );

            return(returnString);
        }
Example #17
0
        public void MapHeightsAreComparable()
        {
            MapHeight l0_1 = MapHeight.l0 | MapHeight.l1;
            MapHeight l0   = MapHeight.l0;
            MapHeight l1   = MapHeight.l1;
            MapHeight l2   = MapHeight.l2;

            var x = l0_1 & l0;
            var y = l0_1 & l1;
            var z = l0_1 & l2;

            Assert.AreEqual(l0, x);
            Assert.AreEqual(l1, y);
            Assert.AreEqual(0, z);
            Assert.IsTrue(l0_1 != l0 || l0_1 != l1);
            Assert.IsTrue(l0_1 < l2);
            Assert.IsTrue(l1 < l2);
            Assert.IsTrue(l0 < l2);
        }