예제 #1
0
 public void dispose()
 {
     (_curDecoration as DecorationRemoveBase).isGrow = false;
     _params        = null;
     _curDecoration = null;
     _attachChunk   = null;
 }
예제 #2
0
 public GrowDecoration(GrowDecorationParam paras)
 {
     _params            = paras;
     _params.growedTime = 0;
     _growMark          = true;
     _curDecoration     = DecorationFactory.GetDecorationInstance((DecorationType)_params.plantData.decorationType);
     (_curDecoration as DecorationRemoveBase).isGrow = true;
     _attachChunk = World.world.GetChunk((int)_params.pos.x, (int)_params.pos.y, (int)_params.pos.z);
     _curDecoration.Decorade(_attachChunk, (int)_params.loacalPos.x, (int)_params.loacalPos.y, (int)_params.loacalPos.z, _params.random);
     _growNeedTime = _params.plantData.growTime;
 }
예제 #3
0
        ////把植物种植到场景中
        public void buildPlant(Vector3 position, DecorationType type = DecorationType.FaceTree, int aoId = 0, float growTime = 0)
        {
            MTBPlantData        data  = MTBPlantDataManager.Instance.getData((int)type);
            GrowDecorationParam paras = new GrowDecorationParam(data);

            if (aoId == 0)
            {
                paras.aoId = AoIdManager.instance.getAoId();
            }
            else
            {
                paras.aoId = aoId;
            }
            paras.growedTime = 0;
            paras.pos        = position;
            paras.random     = _random;
            int x      = ((int)position.x);
            int z      = ((int)position.z);
            int localx = x % Chunk.chunkWidth;
            int localz = z % Chunk.chunkDepth;

            localx = localx < 0 ? localx + Chunk.chunkWidth : localx;
            localz = localz < 0 ? localz + Chunk.chunkDepth : localz;
            Chunk chunk = World.world.GetChunk(x, (int)position.y, z);

            for (int y = (int)position.y + 5; y >= (int)position.y - 5; y--)
            {
                BlockType curType = chunk.GetBlock(localx, y, localz).BlockType;
                if (curType != BlockType.Air && curType != BlockType.StillWater)
                {
                    paras.loacalPos = new Vector3(localx, y + 1, localz);
                    GrowDecoration decoration = new GrowDecoration(paras);
                    World.world.CheckAndRecalculateMesh(x, y, z, World.world.GetBlock(x, y, z));
                    _plantMap.Add(paras.aoId, decoration);
                    AddToChunkMap(decoration);
                    return;
                }
            }
        }