public (bool isFish, bool gathering) GetFish(GameRoad road) { try { Shuffle(Fishes); Random randRoad = new Random(); Random randomGathering = new Random(); Random randomFish = new Random(); if (road.Assembly.FishBait != null) { if (!road.IsFishAttack) { road.Fish = Fishes[randomFish.Next(1, 1000)]; if (IsFishAttackAbble(road.Fish, road)) { road.IsFishAttack = true; double roadCoef = road.Fish.Weight / (double)road.Assembly.Road.Power; double flineCoef = road.Fish.Weight / (double)road.Assembly.FLine.Power; road.RoadIncValue = Convert.ToInt32(roadCoef * 100); road.FLineIncValue = Convert.ToInt32(flineCoef * 100); int Gathering = randomGathering.Next(1, 100); if (road.Assembly.Road is Spinning) { if (Gathering <= 5) { return(true, true); } } if (road.Assembly.Road is Feeder) { if (Gathering <= road.Assembly.Hook.GatheringChance) { return(true, true); } } return(true, false); } } } } catch (NullReferenceException) { } return(false, false); }
public static bool IsFishAttackAbble(Fish fish, GameRoad road) { try { bool ba = false; bool pa = false; if (fish.MinDeep <= road.CurrentDeep && fish.MaxDeep >= road.CurrentDeep) { var part = fish.ActivityParts.First(p => p == Game.GetGame().Time.Part); var l = fish.WorkingLures.First(b => b.Name.Equals(road.Assembly.FishBait.Name)); ba = l == null ? false : true; pa = part == default ? false : true; } return(ba && pa); } catch (InvalidOperationException) { return(false); } }
private void CheckBorders(Point point, GameRoad road) { if (point.Y >= CurLvl.DeepArray[0, 0].Location.Y) { road.CurPoint.Y = point.Y; } else { road.CurPoint.Y = CurLvl.DeepArray[0, 0].Location.Y + 3; } if (point.X >= CurLvl.DeepArray[0, 0].Location.X) { road.CurPoint.X = point.X; } if (point.X >= CurLvl.DeepArray[CurLvl.Widgth - 1, 0].Location.X) { road.CurPoint.X = CurLvl.DeepArray[CurLvl.Widgth - 1, 0].Location.X; } }
public void SetGameRoad(Assembly ass, int index) { if (ass.IsAssemblyFull()) { switch (index) { case 1: FirstRoad = new GameRoad(ass) { RoadX = 100, RoadY = 350, Image = Roads.road }; break; case 2: SecondRoad = new GameRoad(ass) { RoadX = 200, RoadY = 350, Image = Roads.road }; break; case 3: ThirdRoad = new GameRoad(ass) { RoadX = 300, RoadY = 350, Image = Roads.road }; break; } } else { MessageBox.Show(@"Сборка не собрана"); } }
public void SetEquipedRoad(GameRoad r) { EquipedRoad = r; }