public override Item getOne() { FishTankFurniture fishTankFurniture = new FishTankFurniture(parentSheetIndex, tileLocation); fishTankFurniture.drawPosition.Value = drawPosition; fishTankFurniture.defaultBoundingBox.Value = defaultBoundingBox; fishTankFurniture.boundingBox.Value = boundingBox; fishTankFurniture.currentRotation.Value = (int)currentRotation - 1; fishTankFurniture.isOn.Value = false; fishTankFurniture.rotations.Value = rotations; fishTankFurniture.rotate(); fishTankFurniture._GetOneFrom(this); return(fishTankFurniture); }
public TankFish(FishTankFurniture tank, Item item) { _tank = tank; _texture = _tank.GetAquariumTexture(); string[] aquarium_fish_split = _tank.GetAquariumData()[item.ParentSheetIndex].Split('/'); fishIndex = int.Parse(aquarium_fish_split[0]); currentFrame = fishIndex; zPosition = Utility.RandomFloat(4f, 10f); Dictionary <int, string> fish_sheet_data = Game1.content.Load <Dictionary <int, string> >("Data\\Fish"); fishScale = 0.75f; if (fish_sheet_data.ContainsKey(item.ParentSheetIndex)) { string[] fish_split = fish_sheet_data[item.ParentSheetIndex].Split('/'); if (!(fish_split[1] == "trap")) { minimumVelocity = Utility.RandomFloat(0.25f, 0.35f); if (fish_split[2] == "smooth") { minimumVelocity = Utility.RandomFloat(0.5f, 0.6f); } if (fish_split[2] == "dart") { minimumVelocity = 0f; } } } if (aquarium_fish_split.Length > 1) { string fish_type_string = aquarium_fish_split[1]; if (fish_type_string == "eel") { fishType = FishType.Eel; minimumVelocity = Utility.Clamp(fishScale, 0.3f, 0.4f); } else if (fish_type_string == "cephalopod") { fishType = FishType.Cephalopod; minimumVelocity = 0f; } else if (fish_type_string == "ground") { fishType = FishType.Ground; zPosition = 4f; minimumVelocity = 0f; } else if (fish_type_string == "static") { fishType = FishType.Static; } else if (fish_type_string == "crawl") { fishType = FishType.Crawl; minimumVelocity = 0f; } else if (fish_type_string == "front_crawl") { fishType = FishType.Crawl; zPosition = 3f; minimumVelocity = 0f; } else if (fish_type_string == "float") { fishType = FishType.Float; } } if (aquarium_fish_split.Length > 2) { string[] array = aquarium_fish_split[2].Split(' '); idleAnimation = new List <int>(); string[] array2 = array; foreach (string frame4 in array2) { idleAnimation.Add(int.Parse(frame4)); } SetAnimation(idleAnimation); } if (aquarium_fish_split.Length > 3) { string animation_string3 = aquarium_fish_split[3]; string[] animation_split3 = animation_string3.Split(' '); dartStartAnimation = new List <int>(); if (animation_string3 != "") { string[] array2 = animation_split3; foreach (string frame3 in array2) { dartStartAnimation.Add(int.Parse(frame3)); } } } if (aquarium_fish_split.Length > 4) { string animation_string2 = aquarium_fish_split[4]; string[] animation_split2 = animation_string2.Split(' '); dartHoldAnimation = new List <int>(); if (animation_string2 != "") { string[] array2 = animation_split2; foreach (string frame2 in array2) { dartHoldAnimation.Add(int.Parse(frame2)); } } } if (aquarium_fish_split.Length > 5) { string animation_string = aquarium_fish_split[5]; string[] animation_split = animation_string.Split(' '); dartEndAnimation = new List <int>(); if (animation_string != "") { string[] array2 = animation_split; foreach (string frame in array2) { dartEndAnimation.Add(int.Parse(frame)); } } } Rectangle tank_bounds_local = _tank.GetTankBounds(); tank_bounds_local.X = 0; tank_bounds_local.Y = 0; position = Vector2.Zero; position = Utility.getRandomPositionInThisRectangle(tank_bounds_local, Game1.random); nextSwim = Utility.RandomFloat(0.1f, 10f); nextBubble = Utility.RandomFloat(0.1f, 10f); facingLeft = (Game1.random.Next(2) == 1); if (facingLeft) { velocity = new Vector2(-1f, 0f); } else { velocity = new Vector2(1f, 0f); } velocity *= minimumVelocity; if (fishType == FishType.Ground || fishType == FishType.Crawl || fishType == FishType.Static) { position.Y = 0f; } ConstrainToTank(); }