Пример #1
0
        /// <summary>
        /// 初始化<see cref="MapBase"/>
        /// </summary>
        public MapBase()
        {
            SafeAreas  = new List <Area>();
            HealthData = Data.GetTable("user", "health");

            location       = Data.GetTable("user", "location");
            players        = new List <Player>();
            blocks         = new List <Block>();
            ThrowItems     = new ThrowOutItems(this);
            thrownOutItems = new ThrownOutItems(this);
            ReadBlocks();

            loopThread = new Thread(Loop);
            loopThread.IsBackground = true;
            loopThread.Priority     = ThreadPriority.BelowNormal;
            loopThread.Start();
            delays = new List <Delay>();

            Trees = new TreeGen(this);
            Trees.Init();
            sky       = new SkySystem(this);
            saveDelay = new Delay(this);
            saveDelay.SetDelay(5000, WriteBlocks);
            NPCManager.InitMap(this);

            //Block block3 = new Block();
            //block3.blockId = "TestBlock03";
            //block3.updateLocation = new Vector3(548.14f, 32.61f, 588.11f);
            //block3.updateRotation = new Vector3(0f, 0f, 0f);
            //blocks.Add(block3);

            ForgetiveServer.OnPlayerQuit.Reg(OnPlayerQuit);
            Init();
        }
Пример #2
0
 public virtual int getBlockId(float width, TreeGenBlocks blocks, TreeGen gen)
 {
     return
         (width < 0.3f || NoLogs?blocks.GetLeaves(width) :
              (blocks.otherLogBlockCode != null && gen.TriggerRandomOtherBlock() ? blocks.otherLogBlockId : blocks.logBlockId)
         );
 }
Пример #3
0
 public override int getBlockId(float width, TreeGenBlocks blocks, TreeGen gen)
 {
     if (segment != 0 && width >= 0.3f)
     {
         return(blocks.trunkSegmentBlockIds[segment - 1]);
     }
     return(base.getBlockId(width, blocks, gen));
 }
Пример #4
0
 public void OnEnable()
 {
     step_ms = new TreeGen_MarkersSpawn();
     step_sc = new TreeGen_SpaceColonization();
     step_bh = new TreeGen_BorchertHonda();
     step_sa = new TreeGen_ShootAgregation();
     step_bw = new TreeGen_BranchWidth();
     step_mg = new TreeGen_MeshGen();
     pl      = new TreeGen(
         step_sc, step_bh, step_sa, step_bw
         );
 }
Пример #5
0
    public virtual IEnumerator CalculateMapFromScratch()
    {
        map = new byte[World.currentWorld.chunkWidth, World.currentWorld.chunkHeight, World.currentWorld.chunkWidth];

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < width; z++)
                {
                    //map[x, y, z] = GetTheoreticalByte(new Vector3(x, y,z)+transform.position);
                    if (y > 25)
                    {
                        map[x, y, z] = (byte)Block.ID.AIR;
                    }
                    else if (y == 25)
                    {
                        map[x, y, z] = 1;
                    }
                    else if (y < 25 && y > 0)
                    {
                        map[x, y, z] = (byte)Block.ID.STONE;
                    }
                    else if (y == 0)
                    {
                        map[x, y, z] = (byte)Block.ID.BEDROCK;
                    }
                    else
                    {
                        map[x, y, z] = (byte)Block.ID.DIRT;
                    }
                }
            }
        }

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < width; z++)
            {
                if (Random.Range(0, 300) == 1)
                {
                    TreeGen.makeTree(x, 25, z, map);
                }
            }
        }
        yield return(0);
    }