예제 #1
0
        private FloraType[,] CreateFlora()
        {
            var gridSize      = terrain.GridSize;
            var grassBlocks   = terrain.GrassBlocks.ToList();
            var nbGrassBlocks = grassBlocks.Count;

            var floraTypes = new Dictionary <FloraType, int>
            {
                [FloraType.Grass] = (int)(nbGrassBlocks * grassDensity),
                [FloraType.Tree]  = (int)(nbGrassBlocks * treesDensity),
                [FloraType.Rock]  = (int)(nbGrassBlocks * rocksDensity)
            };

            var random = randomSeed.CreateRandom();

            var floraObjects = new FloraType[gridSize.x, gridSize.y].Fill(FloraType.None);

            while (floraTypes.Count > 0 && grassBlocks.Count > 0)
            {
                var position  = grassBlocks.RemoveRandom(random).GridPosition;
                var floraType = floraTypes.SubtractRandom(random);

                floraObjects[position.x, position.y] = floraType;
            }

            return(floraObjects);
        }
예제 #2
0
        /// <summary>
        /// Gets the texture from the flora type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        // TODO: REMOVE, a texture atlas will be added later
        private Texture2D FloraTexture(FloraType type)
        {
            // Get the corresponding texture
            switch (type)
            {
            case FloraType.OakTree: return(_assetManager.MapleTree);

            case FloraType.PoplarTree: return(_assetManager.OakTree);

            case FloraType.RasberryBush: return(_assetManager.Bush);

            default: return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// Adds a flora.
        /// </summary>
        /// <param name="floraType">The flora type.</param>
        /// <param name="tile">The tile where the flora will be positioned on.</param>
        public static void AddFlora(FloraType floraType, Tile tile)
        {
            // If the tile already hasn't an object and if the flora object doesn't already exists
            if (!tile.IsOccupied && !_floraObjects.ContainsKey(tile.Position))
            {
                // Create a new flora object and set it to the tile's position and pass the flora type
                Flora flora = new Flora(tile.Position, floraType);

                // Tile is occupied now
                tile.IsOccupied = true;
                // Pass the flora object to the tile
                tile.Flora = flora;

                // Add the flora object to the dictionary
                _floraObjects.Add(tile.Position, flora);

                ResetGraph();
            }
        }
예제 #4
0
        void AssignProperties(FloraSpecies thisSpecies, Point location)
        {
            gridLocation = location;

            if (thisSpecies == FloraSpecies.MoonTree)
            {
                thisFloraType    = FloraType.Tree;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Frost");
                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                hoursAvailable.Add(20);
                hoursAvailable.Add(21);
                hoursAvailable.Add(22);
                hoursAvailable.Add(23);
                hoursAvailable.Add(0);
                hoursAvailable.Add(1);
                hoursAvailable.Add(2);
                hoursAvailable.Add(3);
            }
            else if (thisSpecies == FloraSpecies.SweetWheat)
            {
                thisFloraType    = FloraType.Grass;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.BitterWheat)
            {
                thisFloraType    = FloraType.Grass;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.SourWheat)
            {
                thisFloraType    = FloraType.Grass;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Dankweed)
            {
                thisFloraType    = FloraType.Grass;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                hoursAvailable.Add(4);
                hoursAvailable.Add(5);
                hoursAvailable.Add(16);
                hoursAvailable.Add(17);
            }
            else if (thisSpecies == FloraSpecies.Tishelbush)
            {
                thisFloraType    = FloraType.Bush;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Bloomshroom)
            {
                thisFloraType    = FloraType.Fungus;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Dew");

                for (int i = 6; i < 18; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.LakeWeed)
            {
                thisFloraType    = FloraType.Algae;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Frost");
                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.SurfPalm)
            {
                thisFloraType    = FloraType.Tree;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Light");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Darkpine)
            {
                thisFloraType    = FloraType.Tree;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Frost");
                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");

                hoursAvailable.Add(20);
                hoursAvailable.Add(21);
                hoursAvailable.Add(22);
                hoursAvailable.Add(23);
                hoursAvailable.Add(0);
                hoursAvailable.Add(1);
                hoursAvailable.Add(2);
                hoursAvailable.Add(3);
            }
            else if (thisSpecies == FloraSpecies.FiremelonBush)
            {
                thisFloraType    = FloraType.Bush;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 10; i < 20; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Chillcap)
            {
                thisFloraType    = FloraType.Fungus;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Frost");
                monthsAvailable.Add("Dew");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Stinkmoss)
            {
                thisFloraType    = FloraType.Algae;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 10; i < 20; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Bramblebush)
            {
                thisFloraType    = FloraType.Bush;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Frost");
                monthsAvailable.Add("Storm");
                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 4; i < 12; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.FlameLily)
            {
                thisFloraType    = FloraType.Flower;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Light");

                for (int i = 7; i < 17; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.FloatingAqualily)
            {
                thisFloraType    = FloraType.Flower;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Flame");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 7; i < 17; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Dandytiger)
            {
                thisFloraType    = FloraType.Flower;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");
                monthsAvailable.Add("Light");

                for (int i = 0; i < 24; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
            else if (thisSpecies == FloraSpecies.Dingushroom)
            {
                thisFloraType    = FloraType.Fungus;
                thisFloraSpecies = thisSpecies;

                monthsAvailable.Add("Earth");
                monthsAvailable.Add("Spirit");
                monthsAvailable.Add("Dew");

                for (int i = 16; i < 22; ++i)
                {
                    hoursAvailable.Add(i);
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Gets the name of the object.
 /// </summary>
 /// <returns></returns>
 public string GetName()
 {
     return(FloraType.ToString());
 }
예제 #6
0
        // TODO: Add a regrowth timer? Especially for berries?

        public Flora(Vector2 position, FloraType type)
        {
            Position  = position;
            FloraType = type;
            IsCut     = false;
        }
예제 #7
0
        public static GameObject CreateKnown(KnownGameObject type)
        {
            GameObject go = new GameObject();

            switch (type)
            {
            case KnownGameObject.Owliver:
            {
                go = new Owliver();
            }
            break;

            case KnownGameObject.Shop:
            {
                go = new Shop();
            }
            break;

            case KnownGameObject.Slurp:
            {
                go = new Slurp();
            }
            break;

            case KnownGameObject.Tankton:
            {
                go = new Tankton();
            }
            break;

            case KnownGameObject.DeathConfetti:
            {
                go = new DeathConfetti();
            }
            break;

            case KnownGameObject.Projectile:
            {
                go = new Projectile();
            }
            break;

            case KnownGameObject.BackgroundScreen:
            {
                go = new BackgroundScreen();
            }
            break;

            case KnownGameObject.Gate:
            {
                go = new Gate();
            }
            break;

            case KnownGameObject.Flora_Fir:
            case KnownGameObject.Flora_FirAlt:
            case KnownGameObject.Flora_Conifer:
            case KnownGameObject.Flora_ConiferAlt:
            case KnownGameObject.Flora_Oak:
            case KnownGameObject.Flora_Orange:
            case KnownGameObject.Flora_Bush:
            {
                FloraType floraType = (FloraType)(type - KnownGameObject.Flora_Fir);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            case KnownGameObject.Bonbon_Gold:
            case KnownGameObject.Bonbon_Red:
            {
                BonbonType bonbonType = (BonbonType)(type - KnownGameObject.Bonbon_Gold);
                go = new BonbonPickup()
                {
                    BonbonType = bonbonType,
                };
            }
            break;

            case KnownGameObject.Key_Gold:
            {
                KeyType keyType = (KeyType)(type - KnownGameObject.Key_Gold);
                go = new KeyPickup()
                {
                    KeyType = keyType,
                };
            }
            break;

            case KnownGameObject.ShopItem_FruitBowl:
            case KnownGameObject.ShopItem_FishingRod:
            case KnownGameObject.ShopItem_Stick:
            {
                ShopItemType itemType = (ShopItemType)(type - KnownGameObject.ShopItem_FruitBowl);
                go = new ShopItem()
                {
                    ItemType = itemType
                };
            }
            break;

            case KnownGameObject.Random_FirTree:
            {
                FloraType floraType = _random.Choose(FloraType.Fir, FloraType.Conifer);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            case KnownGameObject.Random_FirTreeAlt:
            {
                FloraType floraType = _random.Choose(FloraType.FirAlt, FloraType.ConiferAlt);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            case KnownGameObject.Random_OakTree:
            {
                FloraType floraType = _random.Choose(FloraType.Oak, FloraType.Orange);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            default:
                throw new ArgumentException("Unknown game object type.");
            }

            int instanceID = _knownCreationCount[(int)type]++;

            go.Name = $"{type}_{instanceID}";

            return(go);
        }