// Start is called before the first frame update void Start() { if (parentCropTile == null) { parentCropTile = GetComponentInParent <CropTile>(); } }
public Rootbeast(CropTile cropTile, bool primary) : base(cropTile, primary, primary, !primary) { flip = cropTile.crop.flip.Value; addedSpeed = Game1.random.Next(3); HideShadow = true; }
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(); } }
public Starbeast(CropTile cropTile, bool primary) : base(cropTile, primary, primary, !primary) { IsWalkingTowardPlayer = false; HideShadow = true; Sprite.SpriteHeight = 16; Sprite.UpdateSourceRect(); }
public GiantCropbeast(CropTile cropTile, bool primary) : base(cropTile, primary, primary, primary) { HideShadow = true; Sprite.SpriteWidth = 48; Sprite.SpriteHeight = 64; defaultAnimationInterval.Value = 600; Sprite.UpdateSourceRect(); }
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"); }
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); }
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; } }
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); }
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); }
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); }
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(); } }
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(); }
public AncientBeast(CropTile cropTile, bool primary) : base(cropTile, primary, primary, !primary) { Slipperiness = 8; HideShadow = true; }
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; }
public QiBeast(CropTile cropTile, bool primary) : base(cropTile, primary, "Qi Beast") { // The harvest already has a face. faceType.Value = FaceType.Blank; }