Ejemplo n.º 1
0
            public static bool CheckPond(FarmTileId tile, Border border, PondDefinition definition, List <Pond> ponds, FarmData __instance)
            {
                if (__instance.GetFence(tile, border) != null)
                {
                    return(false);
                }
                FarmTile tile2 = __instance.GetTile(tile + border.GetBorderOffset());

                if (tile2 == null)
                {
                    return(false);
                }
                PondContents pondContents = tile2.Contents as PondContents;

                if (pondContents == null)
                {
                    return(false);
                }
                if (ponds.Contains(pondContents.Pond))
                {
                    return(false);
                }
                if (pondContents.Definition.Race != definition.Race && false)
                {
                    return(false);
                }
                if (pondContents.Pond.Tiles.Count >= settings.maxTileCount)
                {
                    return(false);
                }
                ponds.Add(pondContents.Pond);
                return(false);
            }
Ejemplo n.º 2
0
            private static bool CheckMerge(FarmTileId tile1, FarmTileId tile2, FarmData __instance)
            {
                if (!settings.isEnable)
                {
                    return(true);
                }
                FarmTile tile3 = __instance.GetTile(tile1);

                if (tile3 == null || tile3.IsEmpty)
                {
                    return(false);
                }
                FarmTile tile4 = __instance.GetTile(tile2);

                if (tile4 == null || tile4.IsEmpty)
                {
                    return(false);
                }
                if (tile3.Contents.Category == tile4.Contents.Category)
                {
                    FarmTileContentsType category = tile3.Contents.Category;
                    if (category != FarmTileContentsType.Animal)
                    {
                        if (category == FarmTileContentsType.Pond)
                        {
                            PondContents pondContents  = tile3.Contents as PondContents;
                            PondContents pondContents2 = tile4.Contents as PondContents;
                            if (pondContents.Pond == pondContents2.Pond)
                            {
                                return(false);
                            }
                            if (pondContents.Pond.Tiles.Count + pondContents2.Pond.Tiles.Count > settings.maxTileCount)
                            {
                                return(false);
                            }
                            pondContents2.Pond.Merge(pondContents.Pond);
                            tile3.StateChanged(true);
                            tile4.StateChanged(true);
                        }
                    }
                    else
                    {
                        AnimalFieldContents animalFieldContents  = tile3.Contents as AnimalFieldContents;
                        AnimalFieldContents animalFieldContents2 = tile4.Contents as AnimalFieldContents;
                        if (animalFieldContents.Field == animalFieldContents2.Field)
                        {
                            return(false);
                        }
                        if (animalFieldContents.Field.TileCount + animalFieldContents2.Field.TileCount > settings.maxTileCount)
                        {
                            return(false);
                        }
                        animalFieldContents2.Field.Merge(animalFieldContents.Field);
                        tile3.StateChanged(true);
                        tile4.StateChanged(true);
                    }
                }
                return(false);
            }
Ejemplo n.º 3
0
    void OnMouseUp()
    {
        if (villagerDraggable)
        {
            transform.position = UtilityHelper.SnapToGrid(transform.position);

            TileBase tileDroppedOn = uniqueMap.GetTile(new Vector3Int((int)transform.position.x, (int)transform.position.y, 0));

            FarmTile currentTile = uniqueMap.GetTile(new Vector3Int((int)transform.position.x, (int)transform.position.y, 0)) as FarmTile;

            if (tileDroppedOn == farmTile)
            {
                villager.ChangeState(Villager.States.Farming);
                // Play gathering food animation
                // Instantiate food in the characters hands

                // Debug.Log(currentTile.farm.GetComponent<FarmTileScript>().farmIncome); // This gives 0 not sure why

                // Bad loop that seems like it could be replaced, need a way to get whatever object is at that position
                // instead of looping through every object on that layer checking the position
                foreach (Transform farm in farmMap.transform)
                {
                    if (transform.position == farm.transform.position)
                    {
                        currentFarm = farm.gameObject;

                        // Store the food amount incase we need to revert it
                        farmFood = farm.GetComponent <FarmTileScript>().farmIncome;

                        // Set farm income to 0
                        farm.GetComponent <FarmTileScript>().farmIncome = 0;
                    }
                }

                // Set villager waypoint to their house or food storage area
                waypoint.transform.position = new Vector3(500, 500, 0);

                if ((villager.villagerFood + farmFood) > 100)
                {
                    farmFood = farmFood - (GlobalVariables.Variables.maxFarmFood - villager.villagerFood);
                    villager.villagerFood = GlobalVariables.Variables.maxFarmFood;
                }
                else
                {
                    villager.villagerFood += farmFood;
                    farmFood = 0;
                }
            }
        }

        villagerClicked   = false;
        villagerDraggable = false;
    }
Ejemplo n.º 4
0
 public static bool Prefix(FarmTile __instance, FarmTileContents content)
 {
     if (mod.Enabled)
     {
         if (startFill)
         {
             SetContent(__instance, content);
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 5
0
    private void initializeFarmTiles()
    {
        farmTiles = new FarmTile[5];

        int xCoordinate = 14;

        for (int i = 0; i < farmTiles.Length; i++)
        {
            FarmTile newTile = new FarmTile(new Vector3Int(xCoordinate, -8, 0));
            farmTiles[i] = newTile;

            xCoordinate++;
        }
    }
Ejemplo n.º 6
0
        public Crop(Texture2D texture, Vector2 position, string name, int frameCount, int minGrowTime, int maxGrowTime, FarmTile farmTile, GameState game, int minTemp, int maxTemp, int minHum, int maxHum) : base(texture, position, frameCount)
        {
            this.farmTile    = farmTile;
            this.minGrowTime = minGrowTime;
            this.maxGrowTime = maxGrowTime;
            this.random      = new Random();
            this.name        = name;
            int secondsTillNextStage = random.Next(minGrowTime, maxGrowTime);

            this.timeTillNextStage = TimeSpan.FromSeconds(secondsTillNextStage);
            this.game    = game;
            this.minTemp = minTemp;
            this.maxTemp = maxTemp;
            this.minHum  = minHum;
            this.maxHum  = maxHum;
        }
Ejemplo n.º 7
0
    public void Plant(FarmTile tile, Vector2 worldPos)
    {
        Vector3Int tileId     = BaseLayer.WorldToCell(worldPos);
        TileBase   groundTile = BaseLayer.GetTile(tileId);

        if (groundTile == farmableTile)
        {
            if (FarmLayer.GetTile(tileId) == null)
            {
                FarmLayer.SetTile(tileId, tile);
                FarmSpotInstance inst = new FarmSpotInstance();
                inst.farmTile   = tile;
                inst.currentDay = 0;
                _tileset.Add(tileId, inst);
            }
        }
    }
Ejemplo n.º 8
0
        public static void SetContent(FarmTile tile, FarmTileContents content)
        {
            var ct = Traverse.Create(tile).Field("contents");

            ct.SetValue(content);
            if (content != null)
            {
                FarmTileContentsType category = content.Category;
                var tsc = Traverse.Create(tile).Field("tileState");
                switch (category)
                {
                case FarmTileContentsType.Crop:
                    tsc.SetValue(FarmTileState.Plow);
                    break;

                default:
                    if (category != FarmTileContentsType.Flower)
                    {
                        tsc.SetValue(FarmTileState.Building);
                    }
                    else
                    {
                        tsc.SetValue(FarmTileState.Flower);
                    }
                    break;

                case FarmTileContentsType.Animal:
                    tsc.SetValue(FarmTileState.Animal);
                    break;

                case FarmTileContentsType.Pond:
                    tsc.SetValue(FarmTileState.Pond);
                    break;
                }
            }
        }
Ejemplo n.º 9
0
    private void PlantSeeds(FarmTile farmTile, Food food, Tilemap tilemap)
    {
        Tile tile = Resources.Load <Tile>("Foods/Plants/" + food.growthStageOneTile);

        farmTile.PlantCrop(food, tile, object1);
    }
Ejemplo n.º 10
0
 public void CreatePlant(FarmTile tile)
 {
     tile.Plant = CreatePlant(tile.Vox.Position + new Vector3(0.0f,1.75f, 0.0f));
     Matrix original = tile.Plant.LocalTransform;
     original.Translation += Vector3.Down;
     tile.Plant.AnimationQueue.Add(new EaseMotion(0.5f, original, tile.Plant.LocalTransform.Translation));
     PlayState.ParticleManager.Trigger("puff", original.Translation, Color.White, 20);
     SoundManager.PlaySound(ContentPaths.Audio.pluck, tile.Vox.Position, true);
     AddBody(tile.Plant);
 }
Ejemplo n.º 11
0
 public Wheat(ContentManager content, Vector2 position, FarmTile farmTile, GameState game) : base(content.Load <Texture2D>("wheatCrop"), position, "wheat", 5, 50, 70, farmTile, game, 10, 30, 50, 90)
 {
 }
Ejemplo n.º 12
0
 public Corn(ContentManager content, Vector2 position, FarmTile farmTile, GameState game) : base(content.Load <Texture2D>("cornCrop"), position, "corn", 5, 20, 30, farmTile, game, 20, 40, 40, 70)
 {
 }
Ejemplo n.º 13
0
        public GameState(Global game, GraphicsDevice graphicsDevice, ContentManager content, InventoryState inventory, MouseState mouseState, ShopState shop)
            : base(game, graphicsDevice, content)
        {
            this.chickenCount = 0;
            this.cowCount     = 0;
            font = _content.Load <SpriteFont>("defaultFont");

            this.chickenSprites = new List <Texture2D>();
            this.cowSprites     = new List <Texture2D>();

            this.mouseState = mouseState;
            this.inventory  = inventory;
            this.shop       = shop;

            this.weather = new Weather();

            this.rainTexture     = content.Load <Texture2D>("rain");
            this.buttonTexture   = content.Load <Texture2D>("Button");
            buttonFont           = content.Load <SpriteFont>("defaultFont");
            this.farmTileTexture = content.Load <Texture2D>("dirt");
            farm2       = content.Load <Texture2D>("Sprites/dirt2");
            farmTiles   = new List <FarmTile>();
            Tiles       = new List <FarmTile>();
            slotTexture = content.Load <Texture2D>("ItemSlot");

            //animal sprites
            littleCow      = content.Load <Texture2D>("cow");
            walkingCow     = content.Load <Texture2D>("Sprites/cow_walk_right");
            littleChicken  = content.Load <Texture2D>("chicken");
            walkingChicken = content.Load <Texture2D>("Sprites/chicken_walk_left");
            deadChicken    = content.Load <Texture2D>("Sprites/deadChicken");

            this.buttonSfx   = content.Load <SoundEffect>("Sound/selectionClick");
            this.buttonSound = buttonSfx.CreateInstance();

            this.currHum  = 40;
            this.currSun  = 30;
            this.currTemp = 15;
            this.currRain = true;
            this.timeTillNextWeatherUpdate = new TimeSpan(0, 0, 10);
            this.timeTillNextRain          = new TimeSpan(0, 2, 0);

            this.rainSfx            = content.Load <SoundEffect>("Sound/rain");
            this.rainSound          = rainSfx.CreateInstance();
            this.rainSound.IsLooped = true;
            if (currRain == true)
            {
                rainSound.Play();
            }
            else
            {
                rainSound.Stop();
            }

            var farmTile01 = new FarmTile(farm2, new Vector2(400, 100), 1, content, this);//fencetile

            for (int i = 0; i < 9; i++)
            {
                farmTiles.Add(new FarmTile(farmTileTexture, new Vector2(-100, -100), 1, content, this));
                Tiles.Add(new FarmTile(farmTileTexture, new Vector2(-100, -100), 1, content, this));
            }


            for (int i = 0; i < (int)Math.Ceiling(((float)farmTiles.Count / 3)); i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (i * 3 + j < farmTiles.Count)
                    {
                        farmTiles[i * 3 + j].Position = new Vector2(j * 60, i * 55 + 40);
                        farmTiles[i * 3 + j].Click   += farmTile_Click;
                    }
                }
            }


            for (int i = 0; i < 9; i++)
            {
                chickenSprites.Add(littleChicken);
                cowSprites.Add(littleCow);
            }


            var menuButton = new Button(buttonTexture, buttonFont, new Vector2(5, 435), 1)
            {
                Text = "Menu",
            };

            menuButton.Click += menuButton_Click;

            var inventoryButton = new Button(buttonTexture, buttonFont, new Vector2(320, 435), 1)
            {
                Text = "Inventory",
            };

            inventoryButton.Click += inventoryButton_Click;

            var shopButton = new Button(buttonTexture, buttonFont, new Vector2(635, 435), 1)
            {
                Text = "Shop",
            };

            shopButton.Click += shopButton_Click;

            components = new List <Entity>()
            {
                farmTile01,//fenceTile
                farmTiles[0],
                farmTiles[1],
                farmTiles[2],
                farmTiles[3],
                farmTiles[4],
                farmTiles[5],
                farmTiles[6],
                farmTiles[7],
                farmTiles[8],
                Tiles[0],
                Tiles[1],
                Tiles[2],
                Tiles[3],
                Tiles[4],
                Tiles[5],
                Tiles[6],
                Tiles[7],
                Tiles[8],
                menuButton,
                inventoryButton,
                shopButton,
            };
        }
Ejemplo n.º 14
0
 public Lettuce(ContentManager content, Vector2 position, FarmTile farmTile, GameState game) : base(content.Load <Texture2D>("lettuceCrop"), position, "lettuce", 5, 30, 50, farmTile, game, 10, 30, 45, 65)
 {
 }