示例#1
0
    public void UpdateSpace(int longitude, int latitude)
    {
        RoleData roleData = RoleData.mainRole;

        this.longitude.text = longitude.ToString();
        this.latitude.text  = latitude.ToString();

        Random.InitState(GameData.instance.seed * longitude + latitude + GameData.GetMonthCount());
        WorldUnit unit        = WorldCreate.instance.get_units(longitude, latitude);
        bool      wait_lingqi = (unit & WorldUnit.WaitLingqi) == WorldUnit.WaitLingqi;
        bool      wait_yaocai = (unit & WorldUnit.WaitYaocai) == WorldUnit.WaitYaocai;
        bool      wait_jinshi = (unit & WorldUnit.WaitJinshi) == WorldUnit.WaitJinshi;

        if (wait_lingqi)
        {
            lingqi.text = "0";
        }
        else
        {
            if (Random.Range(0, 10000) == 20)
            {
                lingqi.text = Random.Range(150, 600).ToString();
            }
            else
            {
                lingqi.text = Random.Range(10, 30).ToString();
            }
        }
        fengshui.text = Random.Range(10, 100).ToString();
        if (wait_yaocai)
        {
            yaocai.text = "0";
        }
        else
        {
            if (Random.Range(0, 10000) == 20)
            {
                yaocai.text = Random.Range(150, 600).ToString();
            }
            else
            {
                yaocai.text = Random.Range(10, 30).ToString();
            }
        }
        if (wait_jinshi)
        {
            jinshi.text = "0";
        }
        else
        {
            if (Random.Range(0, 10000) == 20)
            {
                jinshi.text = Random.Range(150, 600).ToString();
            }
            else
            {
                jinshi.text = Random.Range(10, 30).ToString();
            }
        }
    }
示例#2
0
 //检查是否可建造区域
 bool CheckPos(int x, int z)
 {
     for (int i = -4; i < 5; i++)
     {
         for (int j = -4; j < 5; j++)
         {
             int a = x + i;
             int b = z + j;
             if (a < 0 || a >= world.size || b < 0 || b >= world.size)
             {
                 return(false);
             }
             WorldUnit unit = world.get_units(a, b);
             if ((unit & WorldUnit.Mountain) == WorldUnit.Mountain)
             {
                 return(false);
             }
             if ((unit & WorldUnit.NewVillage) == WorldUnit.NewVillage)
             {
                 return(false);
             }
             if ((unit & WorldUnit.Impede) == WorldUnit.Impede)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
示例#3
0
    public void CreateWorld()
    {
        Transform worldObj = transform.parent.Find("worldObj");

        if (worldObj)
        {
            Destroy(worldObj.gameObject);
        }
        worldObj      = new GameObject().transform;
        worldObj.name = "worldObj";
        worldObj.transform.SetParent(transform.parent);

        var world = GetComponent <WorldCreate>();

        for (int z = 0; z < world.size; z++)
        {
            for (int x = 0; x < world.size; x++)
            {
                WorldUnit unit = world.get_units(x, z);
                if ((unit & WorldUnit.Impede) == WorldUnit.Impede)
                {
                    CreateObj(impede[0].obj, worldObj, new Vector3(x, 0, z), world.scale, impede[0].size);
                }
                else if ((unit & WorldUnit.Mountain) == WorldUnit.Mountain)
                {
                    CreateObj(mountain[0].obj, worldObj, new Vector3(x, 0, z), world.scale, mountain[0].size);
                }
            }
        }
    }
示例#4
0
    public void OnArmyWorldUnitBeginAutoKillDelayPeriod(WorldUnit worldUnit)
    {
        WorldPawn worldMonsterPawn = this.GetWorldMonsterPawn(worldUnit);

        if (worldMonsterPawn != null)
        {
            worldMonsterPawn.WorldPawnFinalWorldOrientationChanged -= this.WorldPawn_OnFinalWorldOrientationChanged;
        }
    }
示例#5
0
    public void OnArmyWorldUnitCreated(WorldUnit worldUnit)
    {
        WorldPawn worldMonsterPawn = this.GetWorldMonsterPawn(worldUnit);

        if (worldMonsterPawn != null)
        {
            worldMonsterPawn.WorldPawnFinalWorldOrientationChanged += this.WorldPawn_OnFinalWorldOrientationChanged;
        }
    }
示例#6
0
    private WorldPawn GetWorldMonsterPawn(WorldUnit worldUnit)
    {
        WorldPawn result = null;

        for (int i = 0; i < worldUnit.WorldPawns.Length; i++)
        {
            WorldPawn worldPawn = worldUnit.WorldPawns[i];
            if (worldPawn != null && worldPawn.Unit.UnitDesign.Tags.Contains(Kaiju.MonsterUnitTag))
            {
                result = worldPawn;
                break;
            }
        }
        return(result);
    }
示例#7
0
    void FixedUpdate()
    {
        if (explorer == null)
        {
            return;
        }

        if (topLevelWorldUnits.Count <= 0)
        {
            return;
        }

        /*
         ++exploreIndex;
         * if (exploreIndex >= topLevelWorldUnits.Count)
         * {
         *  exploreIndex = 0;
         * }
         */


        for (exploreIndex = 0; exploreIndex < topLevelWorldUnits.Count; ++exploreIndex)
        {
            WorldUnit currTopUnit = topLevelWorldUnits [exploreIndex];
            // 如果当前顶层区块超出了检查区域
            if (currTopUnit.IsOutUnitCheckRange(this.explorer))
            {
                //Log.Error(this, "超出检查区域:", currTopUnit.topLevelIndexPosX, currTopUnit.topLevelIndexPosY);
                currTopUnit.ExitExploreRange();
            }
            else
            {
                currTopUnit.EnterExploreRange();
            }

            // 进入了当前顶层区块
            if (currTopUnit.IsEnterWorldUnit(this.explorer))
            {
                currUnitIndexX = currTopUnit.topLevelIndexPosX;
                currUnitIndexY = currTopUnit.topLevelIndexPosY;

                currTopUnit.Explore(this.explorer);
                CheckAndCreateNeighborTopLevelWorldUnit(currTopUnit);
            }
        }

        //Argamente.Utils.Log.Info(this, "TopLevelCount:", topLevelWorldUnits.Count);
    }
示例#8
0
    public void CreateTopLevel(int topLevelIndexPosX, int topLevelIndexPosY)
    {
        WorldUnit unit = new WorldUnit();

        unit.unitLevel         = 3;
        unit.unit_width_count  = 30;
        unit.unit_height_count = 30;
        unit.realPos_x         = topLevelIndexPosX * unit.unit_width;
        unit.realPos_y         = topLevelIndexPosY * unit.unit_height;
        unit.topLevelIndexPosX = topLevelIndexPosX;
        unit.topLevelIndexPosY = topLevelIndexPosY;

        unit.Create();

        topLevelWorldUnits.Add(unit);
    }
示例#9
0
    bool TryCity(int x, int z, WorldUnit unit, List <PointGameObject> city)
    {
        int max     = 14; // 最大数量
        int min_dis = 8;  // 每个之间最小距离

        if (city.Count >= max)
        {
            return(false);
        }

        // 是否可以建造
        bool can = true;

        if (can)
        {
            can = (unit & WorldUnit.City) == WorldUnit.City;
        }
        if (can)
        {
            if (city.Count < 7)
            {
                can = (unit & WorldUnit.Level1) == WorldUnit.Level1;
            }
            else
            {
                can = (unit & WorldUnit.Level2) == WorldUnit.Level2;
            }
        }

        if (can)
        {
            // 在城市区域 并且在1级区域
            Vector3 position = new Vector3(x, 0, z);
            can = TryPos(position, min_dis);
            if (can)
            {
                city.Add(new PointGameObject()
                {
                    position = position, name = RandName.GetRandCityName() + (city.Count % 7 == 0 ? "城" : "镇")
                });
                this.city = city.ToArray();
            }
        }
        return(true);
    }
示例#10
0
    bool TrySign(int x, int z, WorldUnit unit, List <PointGameObject> sign)
    {
        int max     = 6; // 最大数量
        int min_dis = 6; // 每个之间最小距离

        if (sign.Count >= max)
        {
            return(false);
        }

        // 是否可以建造
        bool can = true;

        if (can)
        {
            can = (unit & WorldUnit.City) == WorldUnit.City;
        }
        if (can)
        {
            if (sign.Count < 3)
            {
                can = (unit & WorldUnit.Level1) == WorldUnit.Level1;
            }
            else
            {
                can = (unit & WorldUnit.Level2) == WorldUnit.Level2;
            }
        }

        if (can)
        {
            // 在城市区域 并且在1级区域
            Vector3 position = new Vector3(x, 0, z);
            can = TryPos(position, min_dis);
            if (can)
            {
                sign.Add(new PointGameObject()
                {
                    position = position, name = "路牌"
                });
                this.sign = sign.ToArray();
            }
        }
        return(true);
    }
示例#11
0
    bool TryPope(int x, int z, WorldUnit unit, List <PointGameObject> pope)
    {
        int max     = 12; // 最大数量
        int min_dis = 10; // 每个之间最小距离

        if (pope.Count >= max)
        {
            return(false);
        }

        // 是否可以建造
        bool can = true;

        if (can)
        {
            can = (unit & WorldUnit.City) == WorldUnit.City;
        }
        if (can)
        {
            if (pope.Count < 6)
            {
                can = (unit & WorldUnit.Level1) == WorldUnit.Level1;
            }
            else
            {
                can = (unit & WorldUnit.Level2) == WorldUnit.Level2;
            }
        }

        if (can)
        {
            // 在城市区域 并且在1级区域
            Vector3 position = new Vector3(x, 0, z);
            can = TryPos(position, min_dis);
            if (can)
            {
                pope.Add(new PointGameObject()
                {
                    position = position, name = RandName.GetRandPopeName()
                });
                this.pope = pope.ToArray();
            }
        }
        return(true);
    }
示例#12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="position">The position of the item on the screen.</param>
 /// <param name="text">The text of this item.</param>
 /// <param name="hasSubmenu">Whether or not this item has a menu below it to navigate to.</param>
 /// <param name="textBuffer">An amount to displace the text past the start of the item (to center with backgrounds)</param>
 /// <param name="centerItem">Whether or not to center the item around the position.</param>
 /// <param name="highlightable">Whether or not this item is highlightable</param>
 /// <param name="command">The command to have this item return</param>
 /// <param name="americaText">Makes the text great again</param>
 /// <param name="deferAudio">Whther or not to play the audio of the MenuItem above this one</param>
 public MenuItem(WorldUnit position, string text, bool hasSubmenu, WorldUnit textBuffer, bool highlightable,
                 bool centerItem = false, MenuCommands command = MenuCommands.Nothing, bool americaText = false,
                 bool deferAudio = true)
 {
     Position          = position;
     Text              = text;
     HasSubmenu        = hasSubmenu;
     TextBuffer        = textBuffer;
     Highlightable     = highlightable;
     CenterItem        = centerItem;
     Command           = command;
     Texture           = null;
     AmericanPositions = new List <Vector2>();
     ContainedItems    = new List <MenuItem>();
     DrawDown          = -1;
     AmericaText       = americaText;
     AmericanCounter   = 0;
     DeferAudio        = deferAudio;
 }
示例#13
0
    // 当进入某一个顶层区块时,就要相应地创建它的相邻顶层区块,
    private void CheckAndCreateNeighborTopLevelWorldUnit(WorldUnit currTopUnit)
    {
        // top Neighbor
        int neighborIndexPosX = currTopUnit.topLevelIndexPosX;
        int neighborIndexPosY = currTopUnit.topLevelIndexPosY + 1;

        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }


        // down Neighbor
        neighborIndexPosX = currTopUnit.topLevelIndexPosX;
        neighborIndexPosY = currTopUnit.topLevelIndexPosY - 1;
        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }

        // left Neighbor
        neighborIndexPosX = currTopUnit.topLevelIndexPosX - 1;
        neighborIndexPosY = currTopUnit.topLevelIndexPosY;
        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }

        // right neighbor
        neighborIndexPosX = currTopUnit.topLevelIndexPosX + 1;
        neighborIndexPosY = currTopUnit.topLevelIndexPosY;
        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }

        // left top
        neighborIndexPosX = currTopUnit.topLevelIndexPosX - 1;
        neighborIndexPosY = currTopUnit.topLevelIndexPosY + 1;
        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }

        // left down
        neighborIndexPosX = currTopUnit.topLevelIndexPosX - 1;
        neighborIndexPosY = currTopUnit.topLevelIndexPosY - 1;
        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }

        // right top
        neighborIndexPosX = currTopUnit.topLevelIndexPosX + 1;
        neighborIndexPosY = currTopUnit.topLevelIndexPosY + 1;
        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }

        // right down
        neighborIndexPosX = currTopUnit.topLevelIndexPosX + 1;
        neighborIndexPosY = currTopUnit.topLevelIndexPosY - 1;
        if (!IsTopWorldUnitExist(neighborIndexPosX, neighborIndexPosY))
        {
            CreateTopLevel(neighborIndexPosX, neighborIndexPosY);
        }
    }
示例#14
0
    bool TryVestige(int x, int z, WorldUnit unit, List <PointGameObject> vestige)
    {
        // 遗迹 -- 突破6+功法4+石阵4+药园4
        int max     = 36; // 最大数量
        int min_dis = 5;  // 每个之间最小距离

        if (vestige.Count >= max)
        {
            return(false);
        }
        string name = "";
        // 是否可以建造
        bool can = true;

        int idx = vestige.Count % 18;

        if (idx < 10)
        {
            name = "上古遗迹";
        }
        else if (idx < 14)
        {
            name = "石阵";
        }
        else if (idx < 18)
        {
            name = "药园";
        }

        if (vestige.Count < 18)
        {
            if (vestige.Count < 5)
            {
                can = (unit & WorldUnit.Level1) == WorldUnit.Level1 && (unit & WorldUnit.City) == WorldUnit.City;
            }
            else if (vestige.Count < 6)
            {
                can = (unit & WorldUnit.Level1) == WorldUnit.Level1 && (unit & WorldUnit.Monster) == WorldUnit.Monster;
            }
            else
            {
                can = (unit & WorldUnit.Level1) == WorldUnit.Level1;
            }
            if (vestige.Count < 3)
            {
                name = "通灵秘境";
            }
            else if (vestige.Count < 6)
            {
                name = "玄灵秘境";
            }
        }
        else
        {
            if (vestige.Count < 21)
            {
                name = "残破锁灵阵";
                can  = (unit & WorldUnit.Level2) == WorldUnit.Level2 && (unit & WorldUnit.City) == WorldUnit.City;
            }
            else if (vestige.Count < 24)
            {
                name = "残破封魔阵";
                can  = (unit & WorldUnit.Level2) == WorldUnit.Level2 && (unit & WorldUnit.Monster) == WorldUnit.Monster;
            }
            else
            {
                can = (unit & WorldUnit.Level2) == WorldUnit.Level2;
            }
        }

        if (can)
        {
            // 在城市区域 并且在1级区域
            Vector3 position = new Vector3(x, 0, z);
            can = TryPos(position, min_dis);
            if (can)
            {
                vestige.Add(new PointGameObject()
                {
                    position = position, name = name
                });
                this.vestige = vestige.ToArray();
            }
        }
        return(true);
    }
示例#15
0
    bool TryElement(int x, int z, WorldUnit unit, List <PointGameObject> element)
    {
        int max     = 12; // 最大数量
        int min_dis = 12; // 每个之间最小距离

        if (element.Count >= max)
        {
            return(false);
        }

        // 是否可以建造
        bool can = true;

        if (can)
        {
            can = (unit & WorldUnit.City) == WorldUnit.City;
        }
        if (can)
        {
            if (element.Count < 6)
            {
                can = (unit & WorldUnit.Level1) == WorldUnit.Level1;
            }
            else
            {
                can = (unit & WorldUnit.Level2) == WorldUnit.Level2;
            }
        }

        int    idx  = element.Count % 6;
        string name = "";

        switch (idx)
        {
        case 0:
            name = "炙炎之域";
            break;

        case 1:
            name = "极寒之域";
            break;

        case 2:
            name = "雷罚之域";
            break;

        case 3:
            name = "暴风之域";
            break;

        case 4:
            name = "流沙之域";
            break;

        case 5:
            name = "醉花之域";
            break;
        }

        if (can)
        {
            // 在城市区域 并且在1级区域
            Vector3 position = new Vector3(x, 0, z);
            can = TryPos(position, min_dis);
            if (can)
            {
                element.Add(new PointGameObject()
                {
                    position = position, name = name
                });
                this.element = element.ToArray();
            }
        }
        return(true);
    }
示例#16
0
    private void OnDrawGizmos()
    {
        if (!Application.isPlaying)
        {
            if (null != units)
            {
                //Debug.Log("to OnDrawGizmosSelected");
                for (int x = 0; x < size; x++)
                {
                    for (int y = 0; y < size; y++)
                    {
                        WorldUnit unit = get_units(x, y);
                        //Debug.Log(x + "," + y + ":" + unit);
                        if (unit != WorldUnit.None)
                        {
                            float px = (x + 0.5f) * scale;
                            float pz = (y + 0.5f) * scale;

                            if ((WorldUnit.Impede & unit) == WorldUnit.Impede)
                            {
                                Gizmos.color = drawColor[WorldUnit.Impede];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.Monster & unit) == WorldUnit.Monster)
                            {
                                Gizmos.color = drawColor[WorldUnit.Monster];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.City & unit) == WorldUnit.City)
                            {
                                Gizmos.color = drawColor[WorldUnit.City];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.Mountain & unit) == WorldUnit.Mountain)
                            {
                                Gizmos.color = drawColor[WorldUnit.Mountain];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.NewVillage & unit) == WorldUnit.NewVillage)
                            {
                                Gizmos.color = drawColor[WorldUnit.NewVillage];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.Level1 & unit) == WorldUnit.Level1)
                            {
                                Gizmos.color = drawColor[WorldUnit.Level1];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.Level2 & unit) == WorldUnit.Level2)
                            {
                                Gizmos.color = drawColor[WorldUnit.Level2];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.Level3 & unit) == WorldUnit.Level3)
                            {
                                Gizmos.color = drawColor[WorldUnit.Level3];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.Level4 & unit) == WorldUnit.Level4)
                            {
                                Gizmos.color = drawColor[WorldUnit.Level4];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                            if ((WorldUnit.Level5 & unit) == WorldUnit.Level5)
                            {
                                Gizmos.color = drawColor[WorldUnit.Level5];
                                Gizmos.DrawCube(new Vector3(px, 0, pz), unit_size);
                            }
                        }
                    }
                }
            }
            else
            {
                //Debug.Log("not OnDrawGizmosSelected");
            }
        }
    }
示例#17
0
 public void set_units(int x, int z, WorldUnit value)
 {
     units[x * size + z] = (int)value;
 }
示例#18
0
    public void Create()
    {
        seed = (seed + 1) % short.MaxValue;
        Random.InitState(seed);
        string pope_path    = Tools.SavePath("pope.data");
        string city_path    = Tools.SavePath("city.data");
        string vestige_path = Tools.SavePath("vestige.data");
        string element_path = Tools.SavePath("element.data");
        string sign_path    = Tools.SavePath("sign.data");

        if (Tools.FileExists(pope_path))
        {
            byte[] byt = Tools.ReadAllBytes(pope_path);
            this.pope = Tools.DeserializeObject(byt) as PointGameObject[];
        }
        else
        {
            this.pope = new PointGameObject[0];
        }
        if (this.pope == null)
        {
            this.pope = new PointGameObject[0];
        }

        if (Tools.FileExists(city_path))
        {
            byte[] byt = Tools.ReadAllBytes(city_path);
            this.city = Tools.DeserializeObject(byt) as PointGameObject[];
        }
        else
        {
            this.city = new PointGameObject[0];
        }
        if (this.city == null)
        {
            this.city = new PointGameObject[0];
        }

        if (Tools.FileExists(vestige_path))
        {
            byte[] byt = Tools.ReadAllBytes(vestige_path);
            this.vestige = Tools.DeserializeObject(byt) as PointGameObject[];
        }
        else
        {
            this.vestige = new PointGameObject[0];
        }
        if (this.vestige == null)
        {
            this.vestige = new PointGameObject[0];
        }

        if (Tools.FileExists(element_path))
        {
            byte[] byt = Tools.ReadAllBytes(element_path);
            this.element = Tools.DeserializeObject(byt) as PointGameObject[];
        }
        else
        {
            this.element = new PointGameObject[0];
        }
        if (this.element == null)
        {
            this.element = new PointGameObject[0];
        }

        if (Tools.FileExists(sign_path))
        {
            byte[] byt = Tools.ReadAllBytes(sign_path);
            this.sign = Tools.DeserializeObject(byt) as PointGameObject[];
        }
        else
        {
            this.sign = new PointGameObject[0];
        }
        if (this.sign == null)
        {
            this.sign = new PointGameObject[0];
        }

        List <PointGameObject> pope    = new List <PointGameObject>(this.pope);
        List <PointGameObject> city    = new List <PointGameObject>(this.city);
        List <PointGameObject> vestige = new List <PointGameObject>(this.vestige);
        List <PointGameObject> element = new List <PointGameObject>(this.element);
        List <PointGameObject> sign    = new List <PointGameObject>(this.sign);

        bool mod_pope    = false;
        bool mod_city    = false;
        bool mod_vestige = false;
        bool mod_element = false;
        bool mod_sign    = false;

        int idx = 0;

        while (true)
        {
            idx++;
            if (idx > 100000)
            {
                Debug.LogErrorFormat("more 100000! {0}-{1}-{2}-{3}", pope.Count, city.Count, vestige.Count, element.Count);
                Invoke("Create", 1);
                return;
            }
            int x = Random.Range(0, world.size);
            int z = Random.Range(0, world.size);
            if (!CheckPos(x, z))
            {
                continue;
            }
            WorldUnit unit = world.get_units(x, z);
            if (TryPope(x, z, unit, pope))
            {
                mod_pope = true;
                continue;
            }
            if (TryCity(x, z, unit, city))
            {
                mod_city = true;
                continue;
            }
            if (TryVestige(x, z, unit, vestige))
            {
                mod_vestige = true;
                continue;
            }
            if (TryElement(x, z, unit, element))
            {
                mod_element = true;
                continue;
            }
            if (TrySign(x, z, unit, sign))
            {
                mod_sign = true;
                continue;
            }
            break;
        }

        if (mod_pope)
        {
            byte[] byt = Tools.SerializeObject(this.pope);
            Tools.WriteAllBytes(pope_path, byt);
        }
        if (mod_city)
        {
            byte[] byt = Tools.SerializeObject(this.city);
            Tools.WriteAllBytes(city_path, byt);
        }
        if (mod_vestige)
        {
            byte[] byt = Tools.SerializeObject(this.vestige);
            Tools.WriteAllBytes(vestige_path, byt);
        }
        if (mod_element)
        {
            byte[] byt = Tools.SerializeObject(this.element);
            Tools.WriteAllBytes(element_path, byt);
        }
        if (mod_sign)
        {
            byte[] byt = Tools.SerializeObject(this.sign);
            Tools.WriteAllBytes(sign_path, byt);
        }
    }
示例#19
0
    void OnGUI()
    {
        if (world == null)
        {
            world = FindObjectOfType <WorldCreate>();
            if (world == null)
            {
                GUILayout.Label("没有地图数据");
                return;
            }
        }
        if (!world.has_units())
        {
            world.Init();
            this.size = world.size;
        }
        GUILayout.BeginHorizontal();
        GUILayout.Label("地图大小:");
        if (int.TryParse(GUILayout.TextField(this.size.ToString()), out int size))
        {
            this.size = size;
        }
        GUILayout.Space(40);
        if (GUILayout.Button("初始化"))
        {
            world.size  = size;
            world.units = new int[size * size];
            world.Init();
        }
        GUILayout.EndHorizontal();

        Color def = GUI.color;

        GUILayout.Space(20);
        GUILayout.BeginHorizontal();
        if (drawMode == DrawMode.Point)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("点绘制"))
        {
            drawMode = DrawMode.Point;
        }
        if (drawMode == DrawMode.Rect)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("矩形绘制"))
        {
            drawMode = DrawMode.Rect;
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(20);


        GUILayout.BeginHorizontal();
        if (drawType == DrawType.Add)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("增加模式"))
        {
            drawType = DrawType.Add;
        }
        if (drawType == DrawType.Remove)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("移除模式"))
        {
            drawType = DrawType.Remove;
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(20);



        if (unitMode == WorldUnit.None)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制空地"))
        {
            unitMode = WorldUnit.None;
        }
        if (unitMode == WorldUnit.Impede)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制障碍"))
        {
            unitMode = WorldUnit.Impede;
        }
        if (unitMode == WorldUnit.Monster)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制野怪"))
        {
            unitMode = WorldUnit.Monster;
        }
        if (unitMode == WorldUnit.City)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制城市"))
        {
            unitMode = WorldUnit.City;
        }
        if (unitMode == WorldUnit.Mountain)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制高山"))
        {
            unitMode = WorldUnit.Mountain;
        }
        if (unitMode == WorldUnit.NewVillage)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制新手村"))
        {
            unitMode = WorldUnit.NewVillage;
        }


        if (unitMode == WorldUnit.Level1)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制一级区域"))
        {
            unitMode = WorldUnit.Level1;
        }
        if (unitMode == WorldUnit.Level2)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制二级区域"))
        {
            unitMode = WorldUnit.Level2;
        }
        if (unitMode == WorldUnit.Level3)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制三级区域"))
        {
            unitMode = WorldUnit.Level3;
        }
        if (unitMode == WorldUnit.Level4)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制四级区域"))
        {
            unitMode = WorldUnit.Level4;
        }
        if (unitMode == WorldUnit.Level5)
        {
            GUI.color = Color.red;
        }
        else
        {
            GUI.color = def;
        }
        if (GUILayout.Button("绘制五级区域"))
        {
            unitMode = WorldUnit.Level5;
        }
        GUI.color = def;
        //EditorGUILayout.BeginHorizontal("box");
        //int sizeY = 100 * Mathf.CeilToInt(_items.Length / 4f);
        //_select = GUI.SelectionGrid(new Rect(new Vector2(0, 155), new Vector2(100 * 4, sizeY)), _select, _items, 4);//可以给出grid选择框,需要传入贴图数组_items}

        GUILayout.Space(20);
        GUILayout.Label("地图格子数:" + world.units_count());


        GUILayout.BeginHorizontal();
        if (GUILayout.Button("读取数据"))
        {
            byte[] byt = Tools.ReadAllBytes("config/map.data");
            world.units = Tools.DeserializeObject(byt) as int[];
            world.size  = (int)Mathf.Sqrt(world.units_count());
            world.Init();
        }
        if (GUILayout.Button("保存数据"))
        {
            byte[] byt = Tools.SerializeObject(world.units);
            Tools.WriteAllBytes("config/map.data", byt);
        }
        GUILayout.EndHorizontal();


        GUILayout.Space(20);
        if (GUILayout.Button("生成地点"))
        {
            PointCreate point = FindObjectOfType <PointCreate>();
            if (point)
            {
                point.Create();
            }
            else
            {
                Debug.LogError("找不到据点生成器");
            }
        }


        GUILayout.Space(20);
        if (GUILayout.Button("生成山脉"))
        {
            GameObjectCreate obj = FindObjectOfType <GameObjectCreate>();
            if (obj)
            {
                obj.CreateWorld();
            }
            else
            {
                Debug.LogError("找不到对象生成器");
            }
        }
    }