Exemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     if (parentCropTile == null)
     {
         parentCropTile = GetComponentInParent <CropTile>();
     }
 }
Exemplo n.º 2
0
 public Rootbeast(CropTile cropTile, bool primary)
     : base(cropTile, primary, primary, !primary)
 {
     flip       = cropTile.crop.flip.Value;
     addedSpeed = Game1.random.Next(3);
     HideShadow = true;
 }
Exemplo n.º 3
0
    internal void PickUp(Vector3Int gridPosition)
    {
        Vector2Int position = (Vector2Int)gridPosition;

        if (crops.ContainsKey(position) == false)
        {
            return;
        }

        CropTile cropTile = crops[position];

        if (cropTile.Complete)
        {
            int dropCount = cropTile.crop.dropCount;
            while (dropCount > 0)
            {
                dropCount -= 1;
                Vector3Int position2 = gridPosition;
                position2.x += (int)(scattering_level * UnityEngine.Random.value - scattering_level / 2);
                position2.y += (int)(scattering_level * UnityEngine.Random.value - scattering_level / 2);

                ItemSpawnManager.instance.SpawnItem(targetTilemap.CellToWorld(position2), cropTile.crop.yield, cropTile.crop.count, true);
            }



            targetTilemap.SetTile(gridPosition, plowed);
            cropTile.Harvested();
        }
    }
Exemplo n.º 4
0
        public Starbeast(CropTile cropTile, bool primary)
            : base(cropTile, primary, primary, !primary)
        {
            IsWalkingTowardPlayer = false;
            HideShadow            = true;

            Sprite.SpriteHeight = 16;
            Sprite.UpdateSourceRect();
        }
Exemplo n.º 5
0
        public GiantCropbeast(CropTile cropTile, bool primary)
            : base(cropTile, primary, primary, primary)
        {
            HideShadow = true;

            Sprite.SpriteWidth             = 48;
            Sprite.SpriteHeight            = 64;
            defaultAnimationInterval.Value = 600;
            Sprite.UpdateSourceRect();
        }
Exemplo n.º 6
0
        public Trellisbeast(CropTile cropTile, bool primary)
            : base(cropTile, primary, primary, !primary)
        {
            Slipperiness = 24 + Game1.random.Next(-10, 11);
            Halt();
            IsWalkingTowardPlayer = false;
            HideShadow            = true;

            sound = Game1.soundBank.GetCue("batFlap");
        }
Exemplo n.º 7
0
        public Cactusbeast(CropTile cropTile, bool primary)
            : base(cropTile, primary, primary, !primary)
        {
            Sprite.SpriteWidth  = 32;
            Sprite.SpriteHeight = 32;
            Sprite.UpdateSourceRect();

            timeUntilNextAttack     = 2000;
            nextChangeDirectionTime = Game1.random.Next(1000, 3000);
            nextWanderTime          = Game1.random.Next(1000, 2000);
        }
Exemplo n.º 8
0
        public Grainbeast(CropTile cropTile, bool primary)
            : base(cropTile, primary, primary, !primary)
        {
            Sprite.SpriteWidth  = 18;
            Sprite.SpriteHeight = 48;
            Sprite.UpdateSourceRect();

            if (cropTile.crop.isPaddyCrop())
            {
                canWater.Value        = true;
                wateringCharges.Value = 40;
            }
        }
Exemplo n.º 9
0
        public Coffeebeast(CropTile cropTile, bool primary)
            : base(cropTile, primary, primary, !primary)
        {
            IsWalkingTowardPlayer = false;
            chargingFarmer        = Game1.random.NextDouble() < 0.8;
            Sprite.interval       = 100f;
            HideShadow            = true;

            // Randomly vary the size and meeping pitch.
            Scale       = Game1.random.Next(75, 101) / 100f;
            meep        = Game1.soundBank.GetCue("dustMeep");
            voice.Value = (byte)Game1.random.Next(1, 24);
        }
Exemplo n.º 10
0
    private void CreatePlowedTile(Vector3Int position)
    {
        CropTile crop = new CropTile();

        crops.Add((Vector2Int)position, crop);

        GameObject go = Instantiate(cropsSpritePrefab);

        go.transform.position = targetTilemap.CellToWorld(position);
        go.SetActive(false);
        crop.renderer = go.GetComponent <SpriteRenderer>();

        targetTilemap.SetTile(position, plowed);
    }
Exemplo n.º 11
0
    public void Water(Vector3Int gridPosition)
    {
        Vector2Int position = (Vector2Int)gridPosition;

        if (crops.ContainsKey(position) == false)
        {
            return;
        }

        CropTile cropTile = crops[position];

        cropTile.watered = true;
        GameManager.instance.staminaBar.Subtract(3); //zużywa wytrzymałość
        CreateWetTile(gridPosition);
    }
Exemplo n.º 12
0
    internal void PickUp(Vector3Int gridPosition)
    {
        Vector2Int position = (Vector2Int)gridPosition;

        if (crops.ContainsKey(position) == false)
        {
            return;
        }

        CropTile cropTile = crops[position];

        if (cropTile.Complete)
        {
            ItemSpawnManager.instance.SpawnItem(targetTilemap.CellToWorld(gridPosition), cropTile.crop.yield, cropTile.crop.count);

            targetTilemap.SetTile(gridPosition, plowed);
            cropTile.Harvested();
        }
    }
Exemplo n.º 13
0
        public Berrybeast(CropTile cropTile, bool primary)
            : base(cropTile, primary, primary, !primary, "Berrybeast")
        {
            // Choose what facial features will appear on the beast.
            faceType.Value = (Config.BerrybeastFace == FaceType.Random)
                                ? (FaceType)Game1.random.Next(0, (int)FaceType.Random)
                                : Config.BerrybeastFace;

            // Slightly randomize the scale.
            Scale = Game1.random.Next(95, 105) / 100f;

            // The spritesheet stores face types instead of animation
            // frames, so all of this does not apply.
            Sprite.ignoreSourceRectUpdates = true;
            Sprite.ignoreStopAnimation     = true;
            ignoreMovementAnimations       = true;

            // Set up the sprite class to track animation through the states
            // represented here in SpriteFrames.
            Sprite.framesPerAnimation = 8;
            Sprite.interval           = 400f;
        }
    public void LoadTilesFromJson(string json)
    {
        var tiles = TileListFromJson(json);

        // remove all existing tiles
        GetAllTiles();
        foreach (var t in allTiles)
        {
            Destroy(t.gameObject);
        }

        foreach (var tile in tiles)
        {
            BaseTile newTile = null;

            string typeName = "";
            if (tile.ContainsKey("type"))
            {
                typeName = tile["type"].ToString();
                // grab any variation of this tile
                BaseTile t = GetTileVariation(typeName);
                if (t != null)
                {
                    newTile = Instantiate(t);
                }
            }

            if (newTile == null)
            {
                newTile = Instantiate(GetTileVariation("Grass"));
            }

            if (typeName.Length > 0)
            {
                switch (typeName)
                {
                case "Forest":
                    TreesTile t = (TreesTile)newTile;
                    try
                    {
                        t.growth1     = int.Parse(tile["g1"].ToString());
                        t.growth2     = int.Parse(tile["g2"].ToString());
                        t.growth3     = int.Parse(tile["g3"].ToString());
                        t.growthTurns = int.Parse(tile["growth"].ToString());
                    }
                    catch (System.Exception) { }
                    t.UpdateTrees();
                    break;

                case "Crop":
                    CropTile ct = (CropTile)newTile;
                    ct.growthState    = int.Parse(tile["state"].ToString());
                    ct.growthProgress = int.Parse(tile["growth"].ToString());
                    ct.UpdatePlants();
                    break;

                case "Hut":
                    HutTile ht = (HutTile)newTile;
                    ht.SetHutCount(int.Parse(tile["huts"].ToString()));
                    break;
                }
            }

            // get position
            Vector3 tilePos = SerializationHelper.JsonToVector(tile["pos"].ToString());
            newTile.transform.position = tilePos;
        }
        GetAllTiles();
    }
Exemplo n.º 15
0
 public AncientBeast(CropTile cropTile, bool primary)
     : base(cropTile, primary, primary, !primary)
 {
     Slipperiness = 8;
     HideShadow   = true;
 }
Exemplo n.º 16
0
        public void InitialiseFromCrop(ModalWindowController modalWindowController, ISelectionBar <SeedGeneration> selectionBar, Tooltip tooltip, CropTile cropTile)
        {
            // Set dependencies.
            this.modalWindowController = modalWindowController;
            seedListController         = selectionBar;
            this.tooltip = tooltip;
            // NOTE: You may think that it would be easier to use GetComponentInParent, however, this returns the vertical layout group that's part of this object instead.
            parentList = transform.parent.GetComponent <VerticalLayoutGroup>();

            // Set label and icon.
            generationName.text = cropTile.Name;
            cropIcon.sprite     = cropTile.Icon;
        }
Exemplo n.º 17
0
 public QiBeast(CropTile cropTile, bool primary)
     : base(cropTile, primary, "Qi Beast")
 {
     // The harvest already has a face.
     faceType.Value = FaceType.Blank;
 }