예제 #1
0
        /// <summary>
        /// This method performs a deep copy of the initial world state to a backup array for later restoration.
        /// </summary>
        private void CopyBlocks()
        {
            for (int x = 0; x < Blocks.GetLength(0); x++)
            {
                for (int y = 0; y < Blocks.GetLength(1); y++)
                {
                    for (int z = 0; z < Blocks.GetLength(2); z++)
                    {
                        if (Blocks[x, y, z] is AirBlock)
                        {
                            InitialBlocks[x, y, z] = new AirBlock();
                        }
                        else if (Blocks[x, y, z] is MulchBlock)
                        {
                            InitialBlocks[x, y, z] = new MulchBlock();
                        }
                        else if (Blocks[x, y, z] is ContainerBlock)
                        {
                            InitialBlocks[x, y, z] = new ContainerBlock();
                        }
                        else if (Blocks[x, y, z] is GrassBlock)
                        {
                            InitialBlocks[x, y, z] = new GrassBlock();
                        }
                        else if (Blocks[x, y, z] is StoneBlock)
                        {
                            InitialBlocks[x, y, z] = new StoneBlock();
                        }
                        else if (Blocks[x, y, z] is AcidicBlock)
                        {
                            InitialBlocks[x, y, z] = new AcidicBlock();
                        }
                        else if (Blocks[x, y, z] is NestBlock)
                        {
                            InitialBlocks[x, y, z] = new NestBlock();
                        }

                        InitialBlocks[x, y, z].worldXCoordinate = x;
                        InitialBlocks[x, y, z].worldYCoordinate = y;
                        InitialBlocks[x, y, z].worldZCoordinate = z;
                    }
                }
            }
        }
예제 #2
0
    void LayNestBlock()
    {
        // if health high enough, spend 1/3rd of health to lay a nest block
        int x = (int)transform.position.x;
        int y = (int)(transform.position.y - 0.5f);
        int z = (int)transform.position.z;

        AbstractBlock nestBlock = new Antymology.Terrain.NestBlock();

        if (health > maxHealth / 2)
        {
            transform.position = new Vector3(transform.position.x, transform.position.y + 1, transform.position.z);
            wm.surfaceBlocks[x, z]++;
            wm.SetBlock(x, y + 1, z, nestBlock);


            health = health / 3;
            wm.nestBlocks++;
        }
    }