Esempio n. 1
0
 public void Eat(Vegetation pFood)
 {
     _movement.Stop(1f);
     _status.Eat(pFood);
     pFood.Destroy();
     _audio.Play();
 }
Esempio n. 2
0
File: Hex.cs Progetto: Pfnetsch/LD45
    public void setVegetation(Vegetation vegetation)
    {
        this.vegetation   = vegetation;
        durabilityInTicks = (int)(vegetation.getDurability() * 100);

        this.neighbours = null;
    }
Esempio n. 3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Vegetation vegetation = (Vegetation)target;

        if (GUILayout.Button("Run texturing"))
        {
            vegetation.RunTexturing();
        }

        if (GUILayout.Button("Run tree generator"))
        {
            vegetation.RunTreeGenerator();
        }

        if (GUILayout.Button("Remove trees"))
        {
            vegetation.RunRemoveTrees();
        }

        if (GUILayout.Button("Run rock generator"))
        {
            vegetation.RunRockGenerator();
        }
    }
Esempio n. 4
0
    public bool plantVegetation(Vector3Int position, Vegetation vegetation)
    {
        Hex hex = getHexAt(position.y, position.x);

        if (hex == null)
        {
            return(false);
        }

        if (canGrow(position, vegetation))
        {
            this.hexes[position.y, position.x].setVegetation(vegetation);
            this.updateMapVisuals();

            if (!firstVeggieTextShown)
            {
                popUpInfo.ShowFirstPlantInfoText();
                firstVeggieTextShown = true;
            }

            return(true);
        }

        return(false);
    }
Esempio n. 5
0
File: Hex.cs Progetto: Pfnetsch/LD45
 public void removeVegetation()
 {
     this.level      = 0;
     this.vegetation = null;
     this.burning    = false;
     this.infested   = false;
 }
Esempio n. 6
0
File: Hex.cs Progetto: Pfnetsch/LD45
 public Hex(HexMap hexMap, int q, int r, TERRAIN_TYPE terrainType = TERRAIN_TYPE.DEFAULT)
 {
     this.hexMap      = hexMap;
     this.q           = q;
     this.r           = r;
     this.terrainType = terrainType;
     this.vegetation  = null;
 }
Esempio n. 7
0
    // prepara el terreno y crea un tile donde plantar arroz
    public void createRiceChunk(uint row, uint col, bool flooded)
    {
        int chunkID = chunkNextID++;

        Debug.Log("Building Chunk #" + chunkID);
        chunkTilesPos[chunkID] = new List <Pair <uint, uint> > ();

        for (uint i = row - RICE_CHUNK_SEPARATION; i < row + RICE_CHUNK_H + RICE_CHUNK_SEPARATION; ++i)
        {
            for (uint j = col - RICE_CHUNK_SEPARATION; j < col + RICE_CHUNK_W + RICE_CHUNK_SEPARATION; ++j)
            {
                if (i < row || i >= row + RICE_CHUNK_H ||
                    j < col || j >= col + RICE_CHUNK_W)
                {
                    if (worldTerrainType [i, j] != TileTerrainType.CANAL)
                    {
                        worldTerrainType [i, j] = TileTerrainType.SEPARATOR;
                    }
                }
                else
                {
                    chunkTilesPos[chunkID].Add(new Pair <uint, uint>(i, j));
                    worldTerrainType [i, j] = TileTerrainType.RICE_TERRAIN;
                    riceTerrains [i, j]     = new RiceTerrainTile(i, j, flooded);
                    riceTerrains [i, j].setChunkNumber(chunkID);
                    riceTerrains[i, j].setLocalID(chunkTilesPos[chunkID].Count - 1);


                    Vegetation veg = getTileVegetation(i, j);
                    if (veg != null)
                    {
                        veg.delete();
                    }

                    if (canalManager.tileHasCanal(i, j))
                    {
                        canalManager.deleteCanal(i, j);
                    }
                }

                updateTileRepresentation(i, j);
            }
        }
        canalManager.addRiceChunk(chunkID, row, col, RICE_CHUNK_W, RICE_CHUNK_H);
        canalManager.updateCanals();
        m_chunkChangedListener();
        m_chunkAddedListener(chunkID);
        _weedFactory.addChunkID(chunkID);
        PenalizationManager.GetInstance().checkActionsTillCurrentPhase();

        TypeFase phase = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager> ().getCurrentPhase();

        if (phase != TypeFase.PREWORK_I && phase != TypeFase.NONE)
        {
            disableChunk(chunkID);
        }
    }
Esempio n. 8
0
        public int GetMovementCost(Vector2D position)
        {
            Tile tmp          = Tiles[position.x][position.y];
            int  movementCost = TileBaseType.GetBaseType(tmp.Type).MovementCost;

            movementCost += Relief.GetRelief(tmp.Relief).MovementCost;
            movementCost += Vegetation.GetVegetation(tmp.Vegetation).MovementCost;
            return(movementCost);
        }
Esempio n. 9
0
        public Terrain(Program owner)
        {
            vegetation = new Vegetation(owner);

            ground              = new GameObject();
            heightMap           = new Heightmap("data/text_height.png", 1000f, 100, 100);
            heightMap.MaxHeight = 100f;
            TerrainMesh sceneryMesh = new TerrainMesh(1.0f, heightMap);

            //sceneryMesh.Texture = new Bonsai.Objects.Textures.TextureBase("data\\grass.png");
            ground.Mesh = sceneryMesh;
            //ground.RotateXAngle = (float)Math.PI / 2;

            splatShader = new ShaderBase("splatting", "splatting3.fx");
            if (Framework.Instance.DeviceCaps.PixelShaderVersion.Major >= 3)
            {
                splatShader.SetTechnique("TextureSplatting_fx30");
            }
            else
            {
                splatShader.SetTechnique("TextureSplatting");
            }
            splatShader.SetVariable("matViewProj", ShaderBase.ShaderParameters.CameraProjection);
            splatShader.SetVariable("sunPosition", new Vector3(1, 1, 1));
            splatShader.SetVariable("underwater", 0.0f);
            splatShader.SetVariable("matWorld", ShaderBase.ShaderParameters.World);
            splatShader.SetVariable("matInvertTransposeWorld", ShaderBase.ShaderParameters.WorldInvertTranspose);
            splatShader.SetVariable("cameraPos", ShaderBase.ShaderParameters.CameraPosition);
            splatShader.SetVariable("nearRepeat", 64.0f);
            splatShader.SetVariable("farRepeat", 20.0f);
            splatShader.SetVariable("nearFactor2", 3.0f);
            splatShader.SetVariable("farFactor2", 2.0f);
            splatShader.SetVariable("nearFactor3", 3.0f);
            splatShader.SetVariable("farFactor3", 2.0f);
            splatShader.SetVariable("nearFactor4", 3.0f);
            splatShader.SetVariable("farFactor4", 2.0f);
            splatShader.SetVariable("blendSqDistance", 50f * 50f);
            splatShader.SetVariable("blendSqWidth", 1.0f / (200f * 200f));
            TextureBase normalMap       = new TextureBase("data/text_norm.png");
            TextureBase alphaMap        = new TextureBase("data/text.dds");
            TextureBase grassTexture    = new TextureBase("data/grass.png");
            TextureBase rockTexture     = new TextureBase("data/rock.png");
            TextureBase rockNormal      = new TextureBase("data/splat_rock_normal.jpg");
            TextureBase sandTexture     = new TextureBase("data/sand.png");
            TextureBase concreteTexture = new TextureBase("data/road.png");

            splatShader.SetVariable("NormalMapTexture", normalMap);
            splatShader.SetVariable("AlphaTexture", alphaMap);
            splatShader.SetVariable("DetailTexture1", grassTexture);
            splatShader.SetVariable("DetailTexture2", rockTexture);
            splatShader.SetVariable("DetailTexture2NormalMap", rockNormal);
            splatShader.SetVariable("DetailTexture3", sandTexture);
            splatShader.SetVariable("DetailTexture4", concreteTexture);

            ground.Shader = splatShader;
        }
Esempio n. 10
0
 public Taco(IngredientFactory ingredientFactory)
 {
     _poultry     = ingredientFactory.GetPoultry();
     _meat        = ingredientFactory.GetMeat();
     _vegetation  = ingredientFactory.GetVegetation();
     _cheese      = ingredientFactory.GetCheese();
     _guacomole   = ingredientFactory.GetGuacomole();
     _rice        = ingredientFactory.GetRice();
     _beans       = ingredientFactory.GetBeans();
     _creamCheese = ingredientFactory.GetCreamCheese();
     _tomato      = ingredientFactory.GetTomato();
     _chili       = ingredientFactory.GetChili();
 }
    void HandleInteractClick()
    {
        if (Input.GetMouseButtonDown(1))
        {
            if (character.CanMove)
            {
                Vegetation vegetation      = GetVegetationOnMousePosition();
                Vector3    clickedPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                // Gift item to NPC
                if (npcInRange != null)
                {
                    NPC npc = GetNPCOnMousePosition();
                    if (npcInRange.fullName == npc.fullName)
                    {
                        InventoryItem selectedItem = Manager.hotbarManager.GetSelectedItem();

                        if (selectedItem != null && selectedItem.canBeGifted)
                        {
                            print("Give item to " + npc);
                            // Giving item to NPC
                            HandleGivingItemToNPC(npc);
                        }
                    }
                }
                else if (vegetation != null && vegetation.CanBeHarvested() && character.IsInRange(clickedPosition))
                {
                    vegetation.HarvestVegetation();
                }
                else if (character.CanPickUpItem(clickedPosition))
                {
                    // Harvest crop
                    character.HarvestCrop(clickedPosition);
                }
                else if (Manager.hotbarManager.GetSelectedItem() is Seed seed)
                {
                    // Plant seed
                    seed.UseSeed(seed, (int)clickedPosition.x, (int)clickedPosition.y);
                }
                else if (Manager.hotbarManager.GetSelectedItem() is Consumable consumable)
                {
                    InventoryItem selectedItem = Manager.hotbarManager.GetSelectedItem();
                    // Consume item in inventory
                    confirmationDialogUI.ShowQuestion($"Are you sure you want to use the {selectedItem.itemName}?", () =>
                    {
                        consumable.OnUse();
                    }, () => { });
                }
            }
        }
    }
Esempio n. 12
0
 public void Dispose()
 {
     Skybox.Dispose();
     Terrain.Dispose();
     Water.Dispose();
     Ship.Dispose();
     Shark.Dispose();
     Character.Dispose();
     Fishes.ForEach(fish => fish.Dispose());
     Vegetation.Dispose();
     Common.Dispose();
     Weapon.Dispose();
     Bubble.Dispose();
 }
Esempio n. 13
0
 public void clearVegetation(uint i, uint j, uint w, uint h)
 {
     for (uint ii = i; ii < i + h; ++ii)
     {
         for (uint jj = j; jj < j + w; ++jj)
         {
             Vegetation veg = getTileVegetation(ii, jj);
             if (veg != null)
             {
                 veg.delete();
             }
         }
     }
 }
    private Vegetation GetVegetationOnMousePosition()
    {
        RaycastHit2D[] hits = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

        foreach (RaycastHit2D hit in hits)
        {
            if (hit.collider.gameObject.GetComponent <Vegetation>() != null)
            {
                Vegetation vegetation = hit.collider.gameObject.GetComponent <Vegetation>();
                return(vegetation);
            }
        }

        return(null);
    }
Esempio n. 15
0
        private void GetDestination()
        {
            if (!_override)
            {
                switch (GetMovementType())
                {
                case StatusComponent.Status.None:
                    //TODO only move to preferred terrain
                    RandomDestination();
                    break;

                case StatusComponent.Status.Scared:
                    //Shouldn't need to do anything
                    break;

                case StatusComponent.Status.Hungry:
                    _food = (Vegetation)Scene.Current.GameObjects.NearestWithinDistance(GameObject, _vision * 64, "Vegetation");
                    if (_food != null)
                    {
                        _destination = _food.Position;
                    }
                    else if (!_destinationSet)
                    {
                        RandomDestination();
                    }
                    break;

                case StatusComponent.Status.Mating:
                    _mate = (Organism)Scene.Current.GameObjects.NearestWithinDistance(GameObject, _vision * 64, "Organism");
                    if (_mate != null)
                    {
                        _destination = _mate.Position;
                    }
                    else if (!_destinationSet)
                    {
                        RandomDestination();
                    }
                    break;
                }
                _destinationSet = true;
                _destination    = Vector2.Clamp(_destination, Vector2.Zero, new Vector2(Evolusim.WorldSize, Evolusim.WorldSize));
            }
        }
Esempio n. 16
0
        public void MoveTo(Vector2 pPosition, bool pOverride)
        {
            if (_status.HasStatus(StatusComponent.Status.Sleeping))
            {
                if (pOverride)
                {
                    _status.RemoveStatus(StatusComponent.Status.Sleeping);
                }
                else
                {
                    return;
                }
            }

            _override       = pOverride;
            _destination    = pPosition;
            _destinationSet = true;
            _mate           = null;
            _food           = null;
        }
Esempio n. 17
0
    public Boolean canGrow(Vector3Int position, Vegetation vegetation)
    {
        Hex hex = getHexAt(position.y, position.x);

        if (hex == null)
        {
            return(false);
        }

        if (hex.hasVegetation())
        {
            return(false);
        }

        if (hex.isWaterSource())
        {
            return(false);
        }

        return(hex.getWaterLevel() >= vegetation.getWaterRequirement());
    }
Esempio n. 18
0
        private void InitializeLevel()
        {
            //Create terrain
            _terrain = new TerrainMap();
            _minimap = new Minimap(_terrain, 200, 256);
            _toolbar = new InspectionBar();

            Vegetation.Populate();

            for (int i = 0; i < 5; i++)
            {
                var x = Generator.Random.Next(0, 100);
                var y = Generator.Random.Next(0, 100);
                EnemySpawner.Create(x, y);
            }


            for (int i = 0; i < 100; i++)
            {
                Organism.Create();
            }
        }
Esempio n. 19
0
    public void ToolBarPointerEnter(int index)
    {
        switch (index)
        {
        case 0:     // Grass
            _veggie = new Grass();
            leftInfoBox.GetComponentInChildren <Text>().text = infoTextGrassland.text;
            break;

        case 1:     // Shrub
            _veggie = new Shrub();
            leftInfoBox.GetComponentInChildren <Text>().text = infoTextShrub.text;
            break;

        case 2:     // Tree 1 // Leaf
            _veggie = new LeafTree();
            leftInfoBox.GetComponentInChildren <Text>().text = infoTextLeafTree.text;
            break;

        case 3:     // Tree 2 // Fir
            _veggie = new FirTree();
            leftInfoBox.GetComponentInChildren <Text>().text = infoTextFirTree.text;
            break;

        case 4:     // Cactus
            _veggie = new Cactus();
            leftInfoBox.GetComponentInChildren <Text>().text = infoTextCactus.text;
            break;

        default:
            break;
        }

        toolTipList.GetComponent <ToolTipList>().Veggie = _veggie;
        toolTipList.GetComponent <ToolTipList>().locked = true;

        leftInfoBox.SetActive(true);
    }
Esempio n. 20
0
        private void ResolveDestination()
        {
            if (!_override)
            {
                switch (GetMovementType())
                {
                case StatusComponent.Status.None:
                case StatusComponent.Status.Scared:
                    break;

                case StatusComponent.Status.Hungry:
                    if (_food == null)
                    {
                        _destinationSet = false;
                        return;
                    }

                    _gameObject.Eat(_food);
                    _food = null;
                    break;

                case StatusComponent.Status.Mating:
                    if (_mate == null)
                    {
                        _destinationSet = false;
                        return;
                    }

                    _gameObject.Mate(_mate);
                    _mate = null;
                    break;
                }
            }

            _destinationSet = false;
            _override       = false;
        }
Esempio n. 21
0
    // Start is called before the first frame update
    void Start()
    {
        date            = new DateTime(2019, 10, 7);
        disasterHitDate = date.AddYears(YEARS_WITHOUT_DISASTERS);
        endDate         = date.AddYears(MAX_GAME_TIME_YEARS);

        Vegetation.setSeedsOrSaplings(typeof(Grass), 4);
        Vegetation.setSeedsOrSaplings(typeof(Shrub), 2);
        Vegetation.setSeedsOrSaplings(typeof(LeafTree), 1);
        Vegetation.setSeedsOrSaplings(typeof(FirTree), 1);
        Vegetation.setSeedsOrSaplings(typeof(Cactus), 1);

        _fireTile1 = Resources.Load <Tile>("Tiles/Feuer1_1");
        _fireTile2 = Resources.Load <Tile>("Tiles/Feuer1_2");
        _bugTile1  = Resources.Load <Tile>("Tiles/Bug1");
        _bugTile2  = Resources.Load <Tile>("Tiles/Bug2");

        popUpInfo = FindObjectOfType <PopUpInfo>();
        popUpInfo.gameObject.SetActive(false);

        grid = FindObjectOfType <Grid>();
        generateMap();
        CenterMainCameraOnGrid();
    }
Esempio n. 22
0
    private Color32 SetVegColor(Vegetation val)
    {
        Color32 tempColor = iconControl.GetHexVegColor(val);

        return tempColor;
    }
Esempio n. 23
0
 public void addVegetation(List <TgcMesh> list)
 {
     Vegetation.AddRange(list);
 }
Esempio n. 24
0
    private void initWorldData()
    {
        TextAsset file = Resources.Load("TiledMap/map.json", typeof(TextAsset)) as TextAsset;

        Debug.Assert(file != null);

        JSONNode node = JSON.Parse(file.text);

        numTilesX = (uint)node ["width"].AsInt;
        numTilesY = (uint)node ["height"].AsInt;
        Debug.Log("MapW: " + numTilesX);
        Debug.Log("MapH: " + numTilesY);


        Debug.Log("Map Sice: " + numTilesX + " W, " + numTilesY + " H");
        worldTerrainType           = new TileTerrainType[numTilesY, numTilesX];
        worldTerrainID             = new TileTerrainIDs[numTilesY, numTilesX];
        worldTerrainRepresentation = new GameObject[numTilesY, numTilesX];
        riceTerrains  = new RiceTerrainTile[numTilesY, numTilesX];
        chunkTilesPos = new Dictionary <int, List <Pair <uint, uint> > >();
        vegetation    = new Dictionary <uintPair, Vegetation> ();
        canalManager  = new CanalManager(numTilesX, numTilesY);
        _weedFactory  = new WeedFactory(this, RICE_CHUNK_W * RICE_CHUNK_H);

        chunkNextID = 0;

        // TERRAIN
        for (uint k = 0; k < numTilesX * numTilesY; ++k)
        {
            uint i = k / numTilesX;
            uint j = k % numTilesX;
            //Debug.Log("Data["+i+","+j+"]="+node ["layers"] [0] ["data"] [k]);
            TileTerrainIDs v = (TileTerrainIDs)node ["layers"] [0] ["data"] [(int)k].AsInt;
            worldTerrainID [i, j]   = v;
            worldTerrainType [i, j] = (v == TileTerrainIDs.HERBS) ? TileTerrainType.FREE : TileTerrainType.DECORATION;
        }


        // VEGETATION
        for (uint k = 0; k < numTilesX * numTilesY; ++k)
        {
            uint i = k / numTilesX;
            uint j = k % numTilesX;
            //Debug.Log("Data["+i+","+j+"]="+node ["layers"] [0] ["data"] [k]);
            int v = node ["layers"] [1] ["data"] [(int)k].AsInt;
            if (v != 0)
            {
                uintPair matrixPos = new uintPair(i, j);
                vegetation [matrixPos] = new Vegetation(i, j, (VegID)v);
            }
        }

        // CANALS
        for (uint k = 0; k < numTilesX * numTilesY; ++k)
        {
            uint i = k / numTilesX;
            uint j = k % numTilesX;
            //Debug.Log("Data["+i+","+j+"]="+node ["layers"] [0] ["data"] [k]);
            int v = node ["layers"] [2] ["data"] [(int)k].AsInt;
            if ((TileOthersIDs)v == TileOthersIDs.CANAL)
            {
                addCanal(i, j);
            }
            else if ((TileOthersIDs)v == TileOthersIDs.WATER_SOURCE)
            {
                addCanal(i, j);
                canalManager.addWaterSource(3, 6);
            }
        }
        canalManager.updateCanals();

        //RICE CHUNKS
        for (uint k = 0; k < numTilesX * numTilesY; ++k)
        {
            uint i = k / numTilesX;
            uint j = k % numTilesX;
            //Debug.Log("Data["+i+","+j+"]="+node ["layers"] [0] ["data"] [k]);
            int v = node ["layers"] [2] ["data"] [(int)k].AsInt;
            if ((TileOthersIDs)v == TileOthersIDs.RICE_CHUNK)
            {
                createRiceChunk(i, j, true);
            }
        }

        canalManager.updateCanals();
    }
Esempio n. 25
0
        private void InitializerObjects()
        {
            FogShader = TGCShaders.Instance.LoadEffect(ShadersDir + "Shaders.fx");

            FogShader.SetValue("ColorFog", Color.SteelBlue.ToArgb());
            FogShader.SetValue("StartFogDistance", 2000);
            FogShader.SetValue("EndFogDistance", 10000);
            FogShader.SetValue("globalLightPosition", TGCVector3.TGCVector3ToFloat4Array(LightPosition));

            SetMaterialColors();

            /* Initializer object */
            LightBox    = TGCBox.fromSize(TGCVector3.One * 150, Color.White);
            Skybox      = new Skybox(MediaDir, Camera);
            Water       = new Water(MediaDir, ShadersDir, new TGCVector3(0, 3500, 0));
            Ship        = new Ship(MediaDir);
            ShowScene   = true;
            Terrain     = new Terrain(MediaDir, ShadersDir);
            MeshBuilder = new MeshBuilder(Terrain, Water);
            Shark       = new Shark(MediaDir, Skybox, Terrain, Camera, SoundManager);
            Character   = new Character(Camera, Input, SoundManager);
            Weapon      = new Weapon(MediaDir, Camera);
            Vegetation  = new Vegetation(MediaDir);
            Common      = new Common(MediaDir);
            Fishes      = Common.ListFishes.Select(mesh => new Fish(Skybox, Terrain, mesh)).ToList();
            Bubble      = new Bubble(MediaDir);
            AddWeaponToCharacter();

            /* Location */

            MeshBuilder.LocateMeshesInWorld(meshes: ref Vegetation.ListAlgas, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListCorals, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListOres, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListRock, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Common.ListFishes, area: Skybox.CurrentPerimeter);
            MeshBuilder.LocateMeshesInWorld(meshes: ref Bubble.Bubbles, area: Skybox.CurrentPerimeter);

            Common.LocateObjects();

            /* Add rigidBody to the world */

            PhysicalWorld = new PhysicalWorld();
            PhysicalWorld.AddBodyToTheWorld(Terrain.Body);
            PhysicalWorld.AddBodyToTheWorld(Character.Body);
            PhysicalWorld.AddBodyToTheWorld(Ship.BodyOutdoorShip);
            PhysicalWorld.AddBodyToTheWorld(Ship.BodyIndoorShip);
            PhysicalWorld.AddBodyToTheWorld(Shark.Body);
            Common.ListCorals.ForEach(coral => PhysicalWorld.AddBodyToTheWorld(coral.Body));
            Common.ListOres.ForEach(ore => PhysicalWorld.AddBodyToTheWorld(ore.Body));
            Common.ListRock.ForEach(rock => PhysicalWorld.AddBodyToTheWorld(rock.Body));
            AddRoofRigidBody();

            Bubble.SetShader(FogShader, "FogBubble");
            Skybox.SetShader(FogShader, "Fog");
            Common.SetShader(FogShader, "Fog");
            Shark.SetShader(FogShader, "Fog");
            Vegetation.SetShader(FogShader, "FogVegetation");
            Ship.SetShader(ref FogShader);

            LightBox.Transform = TGCMatrix.Translation(LightPosition);

            var meshes = GetStaticMeshes();

            QuadTree.Camera = Camera;
            QuadTree.create(meshes, Terrain.world.BoundingBox);
        }
Esempio n. 26
0
 /// <summary>
 ///     Remueve el mesh, no le hace Dispose.
 /// </summary>
 /// <param name="v"></param>
 public void removeVegetation(TgcMesh v)
 {
     Vegetation.Remove(v);
 }
Esempio n. 27
0
        public void Run()
        {
            Chunk currentChunk;

            while (true)
            {
                if (!Variables.Game.IsInitialized)
                {
                    continue;
                }

                if (UnloadQueue.Count > 0)
                {
                    currentChunk = UnloadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Unload Chunk
                    if (Constants.World.SaveDynamicWorld)
                    {
                        ChunkManager.StoreChunkImmediate(currentChunk);
                    }
                    else
                    {
                        currentChunk = null;
                    }
                    Console.Write("UnloadQueue: " + UnloadQueue.Count);

                    // End Unload Chunk

                    LoadQueue.Remove(currentChunk);
                    GenerationQueue.Remove(currentChunk);
                    SetupQueue.Remove(currentChunk);
                }
                else if (LoadQueue.Count > 0)
                {
                    currentChunk = LoadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Load Chunk

                    ChunkManager.LoadChunkImmediate(currentChunk);
                    currentChunk.BuildOctree();
                    currentChunk.HasData = true;

                    Console.Write("LoadQueue: " + LoadQueue.Count);

                    // End Load Chunk

                    if (SetupQueue.Contains(currentChunk))
                    {
                        SetupQueue.Remove(currentChunk);
                        SetupQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        SetupQueue.Enqueue(currentChunk);
                    }
                }
                else if (GenerationQueue.Count > 0)
                {
                    currentChunk = GenerationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Generate Chunk

                    TerrainGenerator.SetChunkTerrain(currentChunk);

                    Console.Write("GenerationQueue: " + GenerationQueue.Count);

                    // End Generate Chunk

                    if (VegetationQueue.Contains(currentChunk))
                    {
                        VegetationQueue.Remove(currentChunk);
                        VegetationQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToVegetation(currentChunk);
                    }
                }
                else if (VegetationQueue.Count > 0)
                {
                    currentChunk = VegetationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Vegetate Chunk

                    Vegetation.Vegetate(currentChunk);

                    Console.Write("VegetationQueue: " + VegetationQueue.Count);

                    // End Vegetate Chunk

                    if (BuildQueue.Contains(currentChunk))
                    {
                        BuildQueue.Remove(currentChunk);
                        BuildQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToBuild(currentChunk);
                    }

                    if (VegetationQueue.Count == 0 && !Constants.Engines.Physics.Player.IsReleased)
                    {
                        Constants.Engines.Physics.Player.Release();
                    }
                }
                else if (BuildQueue.Count > 0)
                {
                    currentChunk = BuildQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Build Chunk

                    currentChunk.BuildOctree();
                    currentChunk.HasData = true;

                    Console.Write("BuildQueue: " + BuildQueue.Count);

                    // End Build Chunk

                    if (SetupQueue.Contains(currentChunk))
                    {
                        SetupQueue.Remove(currentChunk);
                        SetupQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToSetup(currentChunk);
                    }
                }
                else if (SetupQueue.Count > 0)
                {
                    currentChunk = SetupQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }
                    currentChunk.SetupState = 4;

                    // Setup Chunk

                    currentChunk.BuildGeometry(false);
                    currentChunk.SetupState = 1;

                    Console.Write("SetupQueue: " + SetupQueue.Count);
                    // End Setup Chunk
                }
            }
        }
Esempio n. 28
0
 public void addVegetation(TgcMesh v)
 {
     Vegetation.Add(v);
 }
Esempio n. 29
0
 /// <summary>
 ///     Elimina toda la vegetacion.
 /// </summary>
 public void clearVegetation()
 {
     Vegetation.Clear();
     InstancesManager.Clear();
 }
Esempio n. 30
0
    //Generates Vegetation for a hex
    public void GenerateVeg()
    {
        Vegetation veg = Vegetation.Moderate;

        if(localBiome == Biome.Arctic)															{veg--;}
        if(localBiome == Biome.Desert)															{veg--;}
        if(localBiome == Biome.Tundra)															{veg--;}
        if(localBiome == Biome.Rainforest)														{veg++;}
        if(localBiome == Biome.Reef)															{veg++;}
        if(localBiome == Biome.Lotic)															{veg++;}
        if(localBiome == Biome.Estuary)															{veg++;}

        if(localClimate == Climate.Wet)															{veg += 2;}
        if(localClimate == Climate.Humid)														{veg++;}
        if(localClimate == Climate.Desert)														{veg--;}

        if(localTemp == Temperature.Scorching)													{veg--;}
        if(localTemp == Temperature.Hot)														{veg--;}
        if(localTemp == Temperature.Cold)														{veg--;}
        if(localTemp == Temperature.Arctic)														{veg--;}
        if(gridLocation.y == 0 || gridLocation.y == 4)											{veg--;}

        if(NeighborContainsBiome(Biome.Lotic))													{veg++;}

        if(veg < 0)																				{veg = 0;}
        if(veg >= Vegetation.Dense)																{veg = Vegetation.Dense;}

        localVeg = veg;
    }
Esempio n. 31
0
    // Update is called once per frame
    void Update()
    {
        if (highlightActive == false)
        {
            return;
        }

        // get tile for mousepos
        Vector3    pos    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector3Int posInt = grid.LocalToCell(pos);
        Hex        hex    = hexMap.getHexAt(posInt.y, posInt.x);

        if (lastTilePos != posInt)
        {
            // tile changed, unhighlight last tile
            highlightTilemap.SetTile(lastTilePos, null);

            if (veggieToPlant != null)
            {
                if (!hexMap.canGrow(posInt, veggieToPlant))
                {
                    highlightTilemap.SetTile(posInt, notAllowedTile);
                }
                else
                {
                    highlightTilemap.SetTile(posInt, veggieToPlant.getTileForLevel(0));
                }
            }
            else
            {
                if (hex != null)
                {
                    highlightTilemap.SetTile(posInt, highlightTile);
                }
            }

            tooltipList.Hex = hex;
            lastTilePos     = posInt;

            if (Input.GetMouseButton(0) && veggieToPlant == null && hex != null)
            {
                hex.harvestVegetation();
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            veggieToPlant = null;
            highlightTilemap.SetTile(posInt, highlightTile);
        }

        if (Input.GetMouseButtonDown(0) && buttonDown == false)
        {
            buttonDown = true;

            //Debug.Log(posInt);

            if (veggieToPlant != null && hexMap.canGrow(posInt, veggieToPlant))
            {
                if (hexMap.plantVegetation(posInt, veggieToPlant))
                {
                    veggieToPlant.SeedsOrSaplings--;
                }

                if (veggieToPlant.SeedsOrSaplings == 0)
                {
                    veggieToPlant = null;
                }
            }
            else if (hex != null)
            {
                hex.harvestVegetation();
            }
        }

        if (Input.GetMouseButtonUp(0) && buttonDown)
        {
            buttonDown = false;
        }
    }
Esempio n. 32
0
    public void SetBaseValues()
    {
        baseBiome = localBiome;
        baseAlt = localAlt;
        baseClimate = localClimate;
        baseVeg = localVeg;
        baseTemp = localTemp;

        CorrectGeos();
    }
Esempio n. 33
0
    public void SetVegetation(Vegetation veg)
    {
        if(veg < 0)																{localVeg = Vegetation.Barren;}
        else if(veg >= Vegetation.Dense)										{localVeg = Vegetation.Dense;}

        localVeg = veg;
    }
Esempio n. 34
0
    public void DecreaseVeg()
    {
        localVeg--;

        if(localVeg < 0)														{localVeg = Vegetation.Barren;}
        else if(localVeg >= Vegetation.Dense)									{localVeg = Vegetation.Dense;}
    }
Esempio n. 35
0
        public void Run()
        {
            Chunk currentChunk;

            while (true)
            {
                if (!Variables.Game.IsInitialized)
                {
                    continue;
                }

                if (UnloadQueue.Count > 0)
                {
                    currentChunk = UnloadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Unload Chunk
                    if (Constants.World.SaveDynamicWorld)
                    {
                        ChunkManager.SaveChunk(currentChunk);
                    }
                    else
                    {
                        currentChunk = null;
                    }
                    Console.Write("UnloadQueue: " + UnloadQueue.Count);

                    // End Unload Chunk

                    LoadQueue.Remove(currentChunk);
                    GenerationQueue.Remove(currentChunk);
                }
                else if (LoadQueue.Count > 0)
                {
                    currentChunk = LoadQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Load Chunk

                    ChunkManager.LoadChunkImmediate(currentChunk);

                    Console.Write("LoadQueue: " + LoadQueue.Count);

                    // End Load Chunk
                }
                else if (GenerationQueue.Count > 0)
                {
                    currentChunk = GenerationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Generate Chunk

                    TerrainGenerator.SetChunkTerrain(currentChunk);

                    Console.Write("GenerationQueue: " + GenerationQueue.Count);

                    // End Generate Chunk

                    if (VegetationQueue.Contains(currentChunk))
                    {
                        VegetationQueue.Remove(currentChunk);
                        VegetationQueue.Enqueue(currentChunk);
                    }
                    else
                    {
                        AddToVegetation(currentChunk);
                    }
                }
                else if (VegetationQueue.Count > 0)
                {
                    currentChunk = VegetationQueue.Dequeue();

                    if (currentChunk == null)
                    {
                        continue;
                    }

                    // Vegetate Chunk

                    Vegetation.Vegetate(currentChunk);


                    Console.Write("VegetationQueue: " + VegetationQueue.Count);

                    // End Vegetate Chunk
                }
            }
        }