Exemplo n.º 1
0
        public DynamicTile(CubeWorld.World.CubeWorld world, TilePosition tilePosition, bool proxy, int objectId)
            : base(objectId)
        {
            this.world        = world;
            this.tilePosition = tilePosition;
            this.position     = Utils.Graphics.TilePositionToVector3(tilePosition);
            this.proxy        = proxy;

            Tile tile = world.tileManager.GetTile(tilePosition);

            this.tileDefinition = world.tileManager.GetTileDefinition(tile.tileType);
            this.definition     = this.tileDefinition;

            if (proxy == false)
            {
                this.onFire               = tile.OnFire;
                this.castShadow           = tile.CastShadow;
                this.lightSource          = tile.LightSource;
                this.enqueued             = tile.Enqueued;
                this.ambientLuminance     = tile.AmbientLuminance;
                this.lightSourceLuminance = tile.LightSourceLuminance;
                this.energy               = tile.Energy;
                this.destroyed            = tile.Destroyed;
                this.dynamic              = tile.Dynamic;
                this.extraData            = tile.ExtraData;
            }
        }
Exemplo n.º 2
0
        public TestProgram()
        {
            string s = CWConsole.Singleton.TextLog;

            AvailableConfigurations availableConfigurations = LoadConfiguration();

            Config lastConfig;

            lastConfig = new CubeWorld.Configuration.Config();
            lastConfig.tileDefinitions = availableConfigurations.tileDefinitions;
            lastConfig.itemDefinitions = availableConfigurations.itemDefinitions;
            lastConfig.avatarDefinitions = availableConfigurations.avatarDefinitions;
            lastConfig.dayInfo = availableConfigurations.dayInfos[0];
            lastConfig.worldGenerator = availableConfigurations.worldGenerators[0];
            lastConfig.worldSize = availableConfigurations.worldSizes[0];
            lastConfig.extraMaterials = availableConfigurations.extraMaterials;
            lastConfig.gameplay = GameplayFactory.AvailableGameplays[0];

            CubeWorld.World.CubeWorld world = new CubeWorld.World.CubeWorld(this, this);
            GeneratorProcess worldGeneratorProcess = world.Generate(lastConfig);

            while (worldGeneratorProcess.Generate() == false)
            {

            }

            Console.WriteLine("World generated");
        }
Exemplo n.º 3
0
        public TestProgram()
        {
            string s = CWConsole.Singleton.TextLog;

            AvailableConfigurations availableConfigurations = LoadConfiguration();

            Config lastConfig;

            lastConfig = new CubeWorld.Configuration.Config();
            lastConfig.tileDefinitions   = availableConfigurations.tileDefinitions;
            lastConfig.itemDefinitions   = availableConfigurations.itemDefinitions;
            lastConfig.avatarDefinitions = availableConfigurations.avatarDefinitions;
            lastConfig.dayInfo           = availableConfigurations.dayInfos[0];
            lastConfig.worldGenerator    = availableConfigurations.worldGenerators[0];
            lastConfig.worldSize         = availableConfigurations.worldSizes[0];
            lastConfig.extraMaterials    = availableConfigurations.extraMaterials;
            lastConfig.gameplay          = GameplayFactory.AvailableGameplays[0];

            CubeWorld.World.CubeWorld world = new CubeWorld.World.CubeWorld(this, this);
            GeneratorProcess          worldGeneratorProcess = world.Generate(lastConfig);

            while (worldGeneratorProcess.Generate() == false)
            {
            }

            Console.WriteLine("World generated");
        }
Exemplo n.º 4
0
 public Item(CubeWorld.World.CubeWorld world, ItemDefinition itemDefinition, int objectId)
     : base(objectId)
 {
     this.world          = world;
     this.definition     = itemDefinition;
     this.itemDefinition = itemDefinition;
 }
Exemplo n.º 5
0
        public Item(CubeWorld.World.CubeWorld world, ItemDefinition itemDefinition, int objectId) 
            : base(objectId)
		{
			this.world = world;
			this.definition = itemDefinition;
			this.itemDefinition = itemDefinition;
		}
Exemplo n.º 6
0
 public void PlaySound(string soundId, CubeWorld.Utils.Vector3 position)
 {
     if (sounds.ContainsKey(soundId))
         PlayAudioClip(soundId, GraphicsUnity.CubeWorldVector3ToVector3(position), 1.0f);
     else
         Debug.Log("Unknown sound: " + soundId);
 }
Exemplo n.º 7
0
        public Avatar(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int objectId)
            : base(objectId)
        {
            this.world = world;
			this.definition = avatarDefinition;

            this.input = new AvatarInput();

            AddComponent(new AvatarComponentPhysics());
        }
Exemplo n.º 8
0
        public Avatar(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int objectId)
            : base(objectId)
        {
            this.world      = world;
            this.definition = avatarDefinition;

            this.input = new AvatarInput();

            AddComponent(new AvatarComponentPhysics());
        }
Exemplo n.º 9
0
        public DynamicTile(CubeWorld.World.CubeWorld world, TileDefinition tileDefinition, int objectId)
            : base(objectId)
        {
            this.world          = world;
            this.definition     = tileDefinition;
            this.tileDefinition = tileDefinition;

            this.onFire               = false;
            this.castShadow           = tileDefinition.castShadow;
            this.lightSource          = tileDefinition.lightSourceIntensity > 0;
            this.enqueued             = false;
            this.ambientLuminance     = 0;
            this.lightSourceLuminance = tileDefinition.lightSourceIntensity;
            this.energy               = (byte)tileDefinition.energy;
            this.destroyed            = false;
            this.dynamic              = true;
            this.extraData            = 0;
        }
Exemplo n.º 10
0
    public void DestroyWorld()
    {
		objectsManagerUnity.Clear();
		
		sectorManagerUnity.Clear();

        if (world != null)
        {
            world.Clear();
            world = null;
        }

        surroundingsUnity.Clear();
		
		playerUnity = null;

        System.GC.Collect(System.GC.MaxGeneration, System.GCCollectionMode.Forced);
    }
Exemplo n.º 11
0
 public void PlayEffect(string effectId, CubeWorld.World.Objects.CWObject fromObject)
 {
 }
Exemplo n.º 12
0
    public void CreateSurroundings(ConfigSurroundings configSurroundings)
    {
        if (configSurroundings.surroundingMaterial >= 0)
        {
            float SURROUNDING_PLANE_SIZE  = 1000.0f;
            float SURROUNDING_PLANE_SCALE = 10.0f;

            float surroundingLevel = configSurroundings.surroundingLevel.EvaluateInt(gameManagerUnity.world);
            surroundingLevel += configSurroundings.surroundingOffsetY;

            CubeWorld.World.CubeWorld world = gameManagerUnity.world;

            goContainer      = new GameObject();
            goContainer.name = "Surroundings";
            goContainer.transform.position   = new Vector3(0, 0, 0);
            goContainer.transform.rotation   = Quaternion.identity;
            goContainer.transform.localScale = new Vector3(1, 1, 1);

            GameObject goPlane1 = GameObject.CreatePrimitive(PrimitiveType.Plane);
            goPlane1.name             = "A1";
            goPlane1.transform.parent = goContainer.transform;
            GameObject goPlane2 = GameObject.CreatePrimitive(PrimitiveType.Plane);
            goPlane2.name             = "A2";
            goPlane2.transform.parent = goContainer.transform;
            GameObject goPlane3 = GameObject.CreatePrimitive(PrimitiveType.Plane);
            goPlane3.name             = "A3";
            goPlane3.transform.parent = goContainer.transform;
            GameObject goPlane4 = GameObject.CreatePrimitive(PrimitiveType.Plane);
            goPlane4.name             = "A4";
            goPlane4.transform.parent = goContainer.transform;

            goPlane1.GetComponent <Renderer>().material = new Material(materialSurrounding);
            goPlane2.GetComponent <Renderer>().material = new Material(materialSurrounding);
            goPlane3.GetComponent <Renderer>().material = new Material(materialSurrounding);
            goPlane4.GetComponent <Renderer>().material = new Material(materialSurrounding);

            Texture2D surroundingTexture = GraphicsUnity.GetTilesetTexture((Texture2D)gameManagerUnity.materialTransparent.mainTexture, configSurroundings.surroundingMaterial);
            surroundingTexture.wrapMode = TextureWrapMode.Repeat;

            goPlane1.GetComponent <Renderer>().material.mainTexture = surroundingTexture;
            goPlane2.GetComponent <Renderer>().material.mainTexture = surroundingTexture;
            goPlane3.GetComponent <Renderer>().material.mainTexture = surroundingTexture;
            goPlane4.GetComponent <Renderer>().material.mainTexture = surroundingTexture;

            goPlane1.transform.localScale = new Vector3(world.sizeX / SURROUNDING_PLANE_SCALE, 0, SURROUNDING_PLANE_SIZE / SURROUNDING_PLANE_SCALE);
            goPlane1.transform.position   = new Vector3(world.sizeX / 2.0f - 0.5f, surroundingLevel - 0.5f, -SURROUNDING_PLANE_SIZE / 2.0f - 0.5f);
            goPlane1.GetComponent <Renderer>().material.mainTextureScale = new Vector2(goPlane1.transform.localScale.x * SURROUNDING_PLANE_SCALE, goPlane1.transform.localScale.z * SURROUNDING_PLANE_SCALE);

            goPlane2.transform.localScale = new Vector3(world.sizeX / SURROUNDING_PLANE_SCALE, 0, SURROUNDING_PLANE_SIZE / SURROUNDING_PLANE_SCALE);
            goPlane2.transform.position   = new Vector3(world.sizeX / 2.0f - 0.5f, surroundingLevel - 0.5f, world.sizeZ - 0.5f + SURROUNDING_PLANE_SIZE / 2.0f);
            goPlane2.GetComponent <Renderer>().material.mainTextureScale = new Vector2(goPlane2.transform.localScale.x * SURROUNDING_PLANE_SCALE, goPlane2.transform.localScale.z * SURROUNDING_PLANE_SCALE);

            goPlane3.transform.localScale = new Vector3(SURROUNDING_PLANE_SIZE / SURROUNDING_PLANE_SCALE, 0, SURROUNDING_PLANE_SIZE / SURROUNDING_PLANE_SCALE * 2.0f + world.sizeX / SURROUNDING_PLANE_SCALE);
            goPlane3.transform.position   = new Vector3(world.sizeX + SURROUNDING_PLANE_SIZE / 2.0f - 0.5f, surroundingLevel - 0.5f, world.sizeZ / 2.0f - 0.5f);
            goPlane3.GetComponent <Renderer>().material.mainTextureScale = new Vector2(goPlane3.transform.localScale.x * SURROUNDING_PLANE_SCALE, goPlane3.transform.localScale.z * SURROUNDING_PLANE_SCALE);

            goPlane4.transform.localScale = new Vector3(SURROUNDING_PLANE_SIZE / SURROUNDING_PLANE_SCALE, 0, SURROUNDING_PLANE_SIZE / SURROUNDING_PLANE_SCALE * 2.0f + world.sizeX / SURROUNDING_PLANE_SCALE);
            goPlane4.transform.position   = new Vector3(-SURROUNDING_PLANE_SIZE / 2.0f - 0.5f, surroundingLevel - 0.5f, world.sizeZ / 2.0f - 0.5f);
            goPlane4.GetComponent <Renderer>().material.mainTextureScale = new Vector2(goPlane4.transform.localScale.x * SURROUNDING_PLANE_SCALE, goPlane4.transform.localScale.z * SURROUNDING_PLANE_SCALE);

            goSurroundings.Add(goPlane1);
            goSurroundings.Add(goPlane2);
            goSurroundings.Add(goPlane3);
            goSurroundings.Add(goPlane4);
        }
    }
Exemplo n.º 13
0
        public DynamicTile(CubeWorld.World.CubeWorld world, TilePosition tilePosition, bool proxy, int objectId)
            : base(objectId)
		{
			this.world = world;
			this.tilePosition = tilePosition;
			this.position = Utils.Graphics.TilePositionToVector3(tilePosition);
			this.proxy = proxy;
			
			Tile tile = world.tileManager.GetTile(tilePosition);
			
			this.tileDefinition = world.tileManager.GetTileDefinition(tile.tileType);
			this.definition = this.tileDefinition;
			
			if (proxy == false)
			{
				this.onFire = tile.OnFire;
				this.castShadow = tile.CastShadow;
				this.lightSource = tile.LightSource;
				this.enqueued = tile.Enqueued;
				this.ambientLuminance = tile.AmbientLuminance;
				this.lightSourceLuminance = tile.LightSourceLuminance;
				this.energy = tile.Energy;
				this.destroyed = tile.Destroyed;
				this.dynamic = tile.Dynamic;
                this.extraData = tile.ExtraData;
			}
		}
Exemplo n.º 14
0
        public DynamicTile(CubeWorld.World.CubeWorld world, TileDefinition tileDefinition, int objectId)
            : base(objectId)
		{
			this.world = world;
			this.definition = tileDefinition;
			this.tileDefinition = tileDefinition;
			
			this.onFire = false;
			this.castShadow = tileDefinition.castShadow;
			this.lightSource = tileDefinition.lightSourceIntensity > 0;
			this.enqueued = false;
			this.ambientLuminance = 0;
			this.lightSourceLuminance = tileDefinition.lightSourceIntensity;
			this.energy = (byte) tileDefinition.energy;
			this.destroyed = false;
			this.dynamic = true;
            this.extraData = 0;
		}
Exemplo n.º 15
0
 public void PlayEffect(string effectId, CubeWorld.Utils.Vector3 position)
 {
     if (effects.ContainsKey(effectId))
         ((GameObject) GameObject.Instantiate(effects[effectId], GraphicsUnity.CubeWorldVector3ToVector3(position), Quaternion.identity)).transform.parent = goContainer.transform;
     else
         Debug.Log("Unknown effect: " + effectId);
 }
Exemplo n.º 16
0
    /**
     * Only update lighting, it works only if the mesh hasn't changed, so we can change only the color components.
     */
    public void UpdateAmbientLight()
    {
        if (visibleByPlayer == false)
        {
            willRequireLightUpdate = true;
            return;
        }

        if (totalAmbientLuminance == 0)
        {
            willRequireLightUpdate = false;
            return;
        }

        //If the mesh is invalid, then we don't do anything since the light is going to be updated
        //when the mesh is updated
        if (willRequireMeshUpdate == false)
        {
            CubeWorld.World.CubeWorld world = gameManagerUnity.world;
            TileManager tileManager         = world.tileManager;

            Color[] colors = mesh.colors;

            int index = 0;

            int tileOffsetX = sector.tileOffset.x;
            int tileOffsetY = sector.tileOffset.y;
            int tileOffsetZ = sector.tileOffset.z;

            float ambientLightIntensity = MeshUtils.luminanceMapper[world.dayCycleManager.ambientLightLuminance];

            for (int z = tileOffsetZ; z < SectorManager.SECTOR_SIZE + tileOffsetZ; z++)
            {
                for (int y = tileOffsetY; y < SectorManager.SECTOR_SIZE + tileOffsetY; y++)
                {
                    for (int x = tileOffsetX; x < SectorManager.SECTOR_SIZE + tileOffsetX; x++)
                    {
                        TilePosition pos = new TilePosition(x, y, z);

                        Tile tile = tileManager.GetTile(pos);
                        if (tile.tileType == TileDefinition.EMPTY_TILE_TYPE || tile.Dynamic)
                        {
                            continue;
                        }

                        TileDefinition tileDefinition = tileManager.GetTileDefinition(tile.tileType);

                        TileDefinition.DrawMode drawMode = tileDefinition.drawMode;

                        bool drawingLiquidSurface = false;

                        if (drawMode == TileDefinition.DrawMode.LIQUID &&
                            tileManager.IsValidTile(pos + new TilePosition(0, 1, 0)) &&
                            tileManager.GetTileType(pos + new TilePosition(0, 1, 0)) != tile.tileType)
                        {
                            drawingLiquidSurface = true;
                        }

                        for (int face = 0; face < 6; face++)
                        {
                            int material = tileDefinition.materials[face];

                            if (material < 0)
                            {
                                continue;
                            }

                            TileDefinition.DrawMode nearTileDrawMode = TileDefinition.DrawMode.NONE;
                            TilePosition            normalInt        = MeshUtils.faceNormalsTile[face];
                            TilePosition            near             = pos + normalInt;

                            if (tileManager.IsValidTile(near))
                            {
                                nearTileDrawMode = tileManager.GetTileDrawMode(near);
                                bool nearDynamic = tileManager.GetTileDynamic(near);

                                TilePosition nearAbove = near + new TilePosition(0, 1, 0);

                                bool drawingLiquidSurfaceBorder = (drawMode == nearTileDrawMode &&
                                                                   drawMode == TileDefinition.DrawMode.LIQUID &&
                                                                   drawingLiquidSurface == false &&
                                                                   tileManager.IsValidTile(nearAbove) &&
                                                                   tileManager.GetTileType(nearAbove) != tile.tileType &&
                                                                   face != (int)CubeWorld.Utils.Graphics.Faces.Top &&
                                                                   face != (int)CubeWorld.Utils.Graphics.Faces.Bottom);


                                if (drawMode != nearTileDrawMode ||
                                    drawMode == TileDefinition.DrawMode.SOLID_ALPHA ||
                                    nearDynamic ||
                                    drawingLiquidSurfaceBorder)
                                {
                                    float lightIntensity = ambientLightIntensity *
                                                           MeshUtils.luminanceMapper[tileManager.GetTileAmbientLuminance(near)] +
                                                           MeshUtils.luminanceMapper[tileManager.GetTileLightSourceLuminance(near)];

                                    if (lightIntensity > 1.0f)
                                    {
                                        lightIntensity = 1.0f;
                                    }

                                    Color faceColor = new Color(lightIntensity * MeshUtils.faceBright[face],
                                                                lightIntensity * MeshUtils.faceBright[face],
                                                                lightIntensity * MeshUtils.faceBright[face]);

                                    if (tile.OnFire && MeshUtils.faceVectorsFireAvailable[face])
                                    {
                                        for (int i = 0; i < 4; i++)
                                        {
                                            colors[index++] = faceColor;
                                        }
                                    }

                                    for (int i = 0; i < 4; i++)
                                    {
                                        colors[index++] = faceColor;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            mesh.colors = colors;

            willRequireLightUpdate = false;
        }
    }
Exemplo n.º 17
0
 public void PlaySound(string soundId, CubeWorld.World.Objects.CWObject fromObject)
 {
 }
Exemplo n.º 18
0
 public void DestroyObject(CubeWorld.World.Objects.CWObject cwobject)
 {
 }
Exemplo n.º 19
0
 public ItemTile(CubeWorld.World.CubeWorld world, ItemTileDefinition itemTileDefinition, int objectId)
     : base(world, itemTileDefinition, objectId)
 {
     this.itemTileDefinition = itemTileDefinition;
 }
Exemplo n.º 20
0
		public AvatarManager (CubeWorld.World.CubeWorld world)
		{
			this.world = world;
		}
Exemplo n.º 21
0
 public void UpdateObject(CubeWorld.World.Objects.CWObject cwobject)
 {
 }
Exemplo n.º 22
0
 public AvatarManager(CubeWorld.World.CubeWorld world)
 {
     this.world = world;
 }
Exemplo n.º 23
0
 public void PlaySound(string soundId, CubeWorld.Utils.Vector3 position)
 {
 }
Exemplo n.º 24
0
    public GameObject CreateAvatarGameObject(CubeWorld.Avatars.Avatar avatar)
    {
        GameObject g;
        AvatarUnity avatarUnity;

        if (avatar.definition.id == "player")
        {
            g = (GameObject) GameObject.Instantiate(Resources.Load("Prefabs/Player", typeof(GameObject)));

            avatarUnity = g.GetComponent<PlayerUnity>();

            gameManagerUnity.playerUnity = g.GetComponent<PlayerUnity>();

            gameManagerUnity.playerUnity.gameManagerUnity = gameManagerUnity;
            gameManagerUnity.playerUnity.avatar = avatar;
            gameManagerUnity.playerUnity.Reset();
        }
        else
        {
            g = new GameObject();
            avatarUnity = (NonPlayerAvatarUnity)g.AddComponent(typeof(NonPlayerAvatarUnity));
            avatarUnity.gameManagerUnity = gameManagerUnity;
            avatarUnity.avatar = avatar;
        }

        unityAvatars.Add(avatarUnity);

        return g;
    }
Exemplo n.º 25
0
 public void PlayEffect(string effectId, CubeWorld.Utils.Vector3 position)
 {
 }
Exemplo n.º 26
0
    public void UpdateMesh()
    {
        if (visibleByPlayer == false)
        {
            willRequireMeshUpdate = true;
            return;
        }

        mesh.Clear();

        CubeWorld.World.CubeWorld world = gameManagerUnity.world;
        TileManager tileManager         = world.tileManager;

        colors.Clear();
        vertices.Clear();
        uvs.Clear();
        uvs2.Clear();
        normals.Clear();
        trianglesNormal.Clear();
        trianglesTransparent.Clear();
        trianglesTranslucid.Clear();
        trianglesDamage.Clear();
        trianglesAnimated.Clear();

        int   index   = 0;
        float uvdelta = 1.0f / GraphicsUnity.TILE_PER_MATERIAL_ROW;

        int tileOffsetX = sector.tileOffset.x;
        int tileOffsetY = sector.tileOffset.y;
        int tileOffsetZ = sector.tileOffset.z;

        float ambientLightIntensity = MeshUtils.luminanceMapper[world.dayCycleManager.ambientLightLuminance];

        totalAmbientLuminance = 0;

        for (int z = tileOffsetZ; z < SectorManager.SECTOR_SIZE + tileOffsetZ; z++)
        {
            for (int y = tileOffsetY; y < SectorManager.SECTOR_SIZE + tileOffsetY; y++)
            {
                for (int x = tileOffsetX; x < SectorManager.SECTOR_SIZE + tileOffsetX; x++)
                {
                    TilePosition pos = new TilePosition(x, y, z);

                    Tile tile = tileManager.GetTile(pos);

                    totalAmbientLuminance += tile.AmbientLuminance;

                    if (tile.tileType == TileDefinition.EMPTY_TILE_TYPE || tile.Dynamic)
                    {
                        continue;
                    }

                    Vector3 offset = GraphicsUnity.TilePositionToVector3(x - tileOffsetX, y - tileOffsetY, z - tileOffsetZ);

                    TileDefinition tileDefinition = tileManager.GetTileDefinition(tile.tileType);

                    List <int> triangles;
                    Vector3[]  faceVectors = MeshUtils.faceVectorsNormal;

                    TileDefinition.DrawMode drawMode = tileDefinition.drawMode;

                    if (drawMode == TileDefinition.DrawMode.SOLID ||
                        drawMode == TileDefinition.DrawMode.LIQUID && tileDefinition.solid)
                    {
                        if (tile.Energy == tileDefinition.energy)
                        {
                            triangles = trianglesNormal;
                        }
                        else
                        {
                            triangles = trianglesDamage;
                        }
                    }
                    else if (drawMode == TileDefinition.DrawMode.SOLID_ALPHA)
                    {
                        triangles = trianglesTranslucid;
                    }
                    else
                    {
                        triangles = trianglesTransparent;
                    }

                    if (tileDefinition.animated)
                    {
                        triangles = trianglesAnimated;
                    }

                    bool drawingLiquidSurface = false;

                    if (drawMode == TileDefinition.DrawMode.LIQUID &&
                        tileManager.IsValidTile(pos + new TilePosition(0, 1, 0)) &&
                        tileManager.GetTileType(pos + new TilePosition(0, 1, 0)) != tile.tileType)
                    {
                        drawingLiquidSurface = true;
                    }

                    float[] liquidVertexHeights = null;

                    for (int face = 0; face < 6; face++)
                    {
                        int material = tileDefinition.materials[face];

                        if (material < 0)
                        {
                            continue;
                        }

                        TileDefinition.DrawMode nearTileDrawMode = TileDefinition.DrawMode.NONE;
                        TilePosition            normalInt        = MeshUtils.faceNormalsTile[face];
                        TilePosition            near             = pos + normalInt;

                        if (tileManager.IsValidTile(near))
                        {
                            nearTileDrawMode = tileManager.GetTileDrawMode(near);
                            bool nearDynamic = tileManager.GetTileDynamic(near);

                            TilePosition nearAbove = near + new TilePosition(0, 1, 0);

                            bool drawingLiquidSurfaceBorder = (drawMode == nearTileDrawMode &&
                                                               drawMode == TileDefinition.DrawMode.LIQUID &&
                                                               drawingLiquidSurface == false &&
                                                               tileManager.IsValidTile(nearAbove) &&
                                                               tileManager.GetTileType(nearAbove) != tile.tileType &&
                                                               face != (int)CubeWorld.Utils.Graphics.Faces.Top &&
                                                               face != (int)CubeWorld.Utils.Graphics.Faces.Bottom);

                            if (drawMode != nearTileDrawMode ||
                                drawMode == TileDefinition.DrawMode.SOLID_ALPHA ||
                                nearDynamic ||
                                drawingLiquidSurfaceBorder)
                            {
                                float lightIntensity = ambientLightIntensity *
                                                       MeshUtils.luminanceMapper[tileManager.GetTileAmbientLuminance(near)] +
                                                       MeshUtils.luminanceMapper[tileManager.GetTileLightSourceLuminance(near)];

                                if (lightIntensity > 1.0f)
                                {
                                    lightIntensity = 1.0f;
                                }

                                Color faceColor = new Color(lightIntensity * MeshUtils.faceBright[face],
                                                            lightIntensity * MeshUtils.faceBright[face],
                                                            lightIntensity * MeshUtils.faceBright[face]);
                                Vector3 faceNormal = MeshUtils.faceNormals[face];

                                if (tile.OnFire && MeshUtils.faceVectorsFireAvailable[face])
                                {
                                    for (int i = 0; i < 4; i++)
                                    {
                                        vertices.Add(MeshUtils.faceVectorsFire[(face << 2) + i] + offset);
                                        normals.Add(faceNormal);
                                        colors.Add(faceColor);
                                    }

                                    trianglesTranslucid.Add(index + 0);
                                    trianglesTranslucid.Add(index + 1);
                                    trianglesTranslucid.Add(index + 2);

                                    trianglesTranslucid.Add(index + 2);
                                    trianglesTranslucid.Add(index + 3);
                                    trianglesTranslucid.Add(index + 0);

                                    int fireMaterial = gameManagerUnity.extraMaterials.fireMaterials[(x + y + z) % gameManagerUnity.extraMaterials.fireMaterials.Length];

                                    float uvxFire = uvdelta * (fireMaterial % GraphicsUnity.TILE_PER_MATERIAL_ROW);
                                    float uvyFire = 1.0f - uvdelta * (fireMaterial / GraphicsUnity.TILE_PER_MATERIAL_ROW);

                                    uvs.Add(new Vector2(uvxFire, uvyFire - uvdelta));
                                    uvs.Add(new Vector2(uvxFire, uvyFire));
                                    uvs.Add(new Vector2(uvxFire + uvdelta, uvyFire));
                                    uvs.Add(new Vector2(uvxFire + uvdelta, uvyFire - uvdelta));

                                    uvs2.Add(Vector2.zero);
                                    uvs2.Add(Vector2.zero);
                                    uvs2.Add(Vector2.zero);
                                    uvs2.Add(Vector2.zero);

                                    index += 4;
                                }

                                if ((drawingLiquidSurface || drawingLiquidSurfaceBorder) && liquidVertexHeights == null)
                                {
                                    liquidVertexHeights = GetLiquidVertexHeights(tileManager, pos, tile);
                                }

                                for (int i = 0; i < 4; i++)
                                {
                                    if (drawingLiquidSurface || drawingLiquidSurfaceBorder)
                                    {
                                        Vector3 liquidVertex = faceVectors[(face << 2) + i];

                                        if (drawingLiquidSurface && liquidVertex.y == CubeWorld.Utils.Graphics.HALF_TILE_SIZE ||
                                            drawingLiquidSurfaceBorder && liquidVertex.y == -CubeWorld.Utils.Graphics.HALF_TILE_SIZE)
                                        {
                                            if (liquidVertex.x == CubeWorld.Utils.Graphics.HALF_TILE_SIZE)
                                            {
                                                //x = 1
                                                if (liquidVertex.z == CubeWorld.Utils.Graphics.HALF_TILE_SIZE)
                                                {
                                                    //z = 1
                                                    liquidVertex.y = liquidVertexHeights[0];
                                                }
                                                else
                                                {
                                                    //z = -1
                                                    liquidVertex.y = liquidVertexHeights[1];
                                                }
                                            }
                                            else
                                            {
                                                //x = -1
                                                if (liquidVertex.z == CubeWorld.Utils.Graphics.HALF_TILE_SIZE)
                                                {
                                                    //z = 1
                                                    liquidVertex.y = liquidVertexHeights[3];
                                                }
                                                else
                                                {
                                                    //z = -1
                                                    liquidVertex.y = liquidVertexHeights[2];
                                                }
                                            }
                                        }

                                        vertices.Add(liquidVertex + offset);
                                    }
                                    else
                                    {
                                        vertices.Add(faceVectors[(face << 2) + i] + offset);
                                    }

                                    normals.Add(faceNormal);
                                    colors.Add(faceColor);
                                }

                                triangles.Add(index + 0);
                                triangles.Add(index + 1);
                                triangles.Add(index + 2);

                                triangles.Add(index + 2);
                                triangles.Add(index + 3);
                                triangles.Add(index + 0);

                                float uvx = uvdelta * (material % GraphicsUnity.TILE_PER_MATERIAL_ROW);
                                float uvy = 1.0f - uvdelta * (material / GraphicsUnity.TILE_PER_MATERIAL_ROW);

                                uvs.Add(new Vector2(uvx, uvy - uvdelta));
                                uvs.Add(new Vector2(uvx, uvy));
                                uvs.Add(new Vector2(uvx + uvdelta, uvy));
                                uvs.Add(new Vector2(uvx + uvdelta, uvy - uvdelta));

                                if (drawMode == TileDefinition.DrawMode.SOLID && tile.Energy < tileDefinition.energy)
                                {
                                    int materialDamageIndex = ((tileDefinition.energy - tile.Energy) * gameManagerUnity.extraMaterials.damageMaterials.Length) / tileDefinition.energy;
                                    if (materialDamageIndex >= gameManagerUnity.extraMaterials.damageMaterials.Length)
                                    {
                                        materialDamageIndex = gameManagerUnity.extraMaterials.damageMaterials.Length - 1;
                                    }

                                    int materialDamage = gameManagerUnity.extraMaterials.damageMaterials[materialDamageIndex];

                                    uvx = uvdelta * (materialDamage % GraphicsUnity.TILE_PER_MATERIAL_ROW);
                                    uvy = 1.0f - uvdelta * (materialDamage / GraphicsUnity.TILE_PER_MATERIAL_ROW);

                                    uvs2.Add(new Vector2(uvx, uvy - uvdelta));
                                    uvs2.Add(new Vector2(uvx, uvy));
                                    uvs2.Add(new Vector2(uvx + uvdelta, uvy));
                                    uvs2.Add(new Vector2(uvx + uvdelta, uvy - uvdelta));
                                }
                                else
                                {
                                    uvs2.Add(Vector2.zero);
                                    uvs2.Add(Vector2.zero);
                                    uvs2.Add(Vector2.zero);
                                    uvs2.Add(Vector2.zero);
                                }

                                index += 4;
                            }
                        }
                    }
                }
            }
        }

        mesh.vertices     = vertices.ToArray();
        mesh.colors       = colors.ToArray();
        mesh.normals      = normals.ToArray();
        mesh.uv           = uvs.ToArray();
        mesh.uv2          = uvs2.ToArray();
        mesh.subMeshCount = 4;

        mesh.bounds = new Bounds(new Vector3(SectorManager.SECTOR_SIZE / 2, SectorManager.SECTOR_SIZE / 2, SectorManager.SECTOR_SIZE / 2), new Vector3(SectorManager.SECTOR_SIZE + 1, SectorManager.SECTOR_SIZE + 1, SectorManager.SECTOR_SIZE + 1));

        List <Material> materials = new List <Material>();

        if (trianglesNormal.Count > 0)
        {
            materials.Add(gameManagerUnity.material);
        }

        if (trianglesTranslucid.Count > 0)
        {
            materials.Add(gameManagerUnity.materialTranslucid);
        }

        if (trianglesTransparent.Count > 0)
        {
            materials.Add(gameManagerUnity.materialTransparent);
        }

        if (trianglesDamage.Count > 0)
        {
            materials.Add(gameManagerUnity.materialDamaged);
        }

        if (trianglesAnimated.Count > 0)
        {
            materials.Add(gameManagerUnity.materialLiquidAnimated);
        }

        meshRenderer.sharedMaterials = materials.ToArray();

        int trianglesGroupIndex = 0;

        if (trianglesNormal.Count > 0)
        {
            mesh.SetTriangles(trianglesNormal.ToArray(), trianglesGroupIndex++);
        }
        if (trianglesTranslucid.Count > 0)
        {
            mesh.SetTriangles(trianglesTranslucid.ToArray(), trianglesGroupIndex++);
        }
        if (trianglesTransparent.Count > 0)
        {
            mesh.SetTriangles(trianglesTransparent.ToArray(), trianglesGroupIndex++);
        }
        if (trianglesDamage.Count > 0)
        {
            mesh.SetTriangles(trianglesDamage.ToArray(), trianglesGroupIndex++);
        }
        if (trianglesAnimated.Count > 0)
        {
            mesh.SetTriangles(trianglesAnimated.ToArray(), trianglesGroupIndex++);
        }

        willRequireMeshUpdate  = false;
        willRequireLightUpdate = false;
    }