/// <summary> /// test function /// </summary> public void TestFunc() { Console.WriteLine("\nLEVEL 1\n"); int length = 10; int width = 5; SmallFish[,] Fishes = new SmallFish[length, width]; Fishes[0, 0] = new SmallFish(); Fishes[0, 1] = new MediumFish(); Fishes[0, 2] = new BigFish(); ShowFishes(Fishes); Console.ReadKey(); Fishes[0, 1] = new SmallFish(); Console.Title = "Test Func"; RefreshConsole(Fishes); Console.ReadKey(); }
public void find(int a) { currentFish = null; if (a >= sea.GetLength(1)) { return; } for (int i = sea.GetLength(0) - 1; i >= 0; i--) { if (sea[i, a] != null) { currentFish = sea[i, a]; sea[i, a] = null; break; } } }
private bool Position(out SmallFish f, out int x, int b) { f = null; x = isFish(b); if (x + 1 >= sea.GetLength(0)) { return(false); } if (x == -1) { sea[0, b] = currentFish; currentFish = null; return(false); } f = sea[x, b]; return(true); }
public bool push(int b) { if (currentFish == null) { return(false); } int x; SmallFish previosFish; if (!Position(out previosFish, out x, b)) { return(false); } if (!(currentFish is BigFish) && currentFish is MediumFish && previosFish is BigFish) { if (((BigFish)previosFish).Eat() || ((MediumFish)currentFish).Count == 1) { sea[x, b] = null; return(true); } currentFish = null; return(false); } else if (!(currentFish is MediumFish) && !(previosFish is BigFish) && (previosFish is MediumFish)) { if (((MediumFish)previosFish).Eat()) { sea[x, b] = null; return(true); } currentFish = null; return(false); } else { sea[x + 1, b] = currentFish; currentFish = null; return(true); } }