コード例 #1
0
ファイル: PointCreate.cs プロジェクト: MatrixHan/XHSJ
    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);
    }
コード例 #2
0
ファイル: PointCreate.cs プロジェクト: MatrixHan/XHSJ
    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);
    }