public void FishShoal(VesselDB boat) { Random random = new Random(); int catchSize = 0; int randomGrade = 0; int remainingStorage = 0; //if there is more than 200 fish only take upto 200 if (Size < 100) { catchSize = random.Next(Size + 1); } else { catchSize = random.Next(100); } // the ages 1, 2 and 3 represent the young, medium and old shoals. //this is used for the grade distribution switch (Age) { //shoal is young case 1: case 2: for (int i = 0; i < catchSize; i++) { //generate number between 4 and 6 randomGrade = random.Next(4, 7); //add the fish to the boat switch (randomGrade) { //if the fish is grade 4 (roughly weight 3) case 4: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 3) { //add fish to storage weight and remove from the shoal boat.Storage += 3; Size--; } else { Debug.Log("Not enough space"); } break; //if the fish is grade 5 (roughly weight 2) case 5: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 2) { //add fish to storage weight and remove from the shoal boat.Storage += 2; Size--; } else { Debug.Log("Not enough space"); } break; //if the fish is grade 6 case 6: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 1) { //add fish to storage weight and remove from the shoal boat.Storage += 1; Size--; } else { Debug.Log("Not enough space"); } break; default: Debug.Log("Age 1 shoal giving grade error"); break; } } break; //shoal is average case 3: case 4: case 5: for (int i = 0; i < catchSize; i++) { //generate number between 2 and 4 randomGrade = random.Next(2, 5); //add the fish to the boat switch (randomGrade) { //if the fish is grade 2 (roughly weight 5) case 2: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 5) { //add fish to storage weight and remove from the shoal boat.Storage += 5; Size--; } else { Debug.Log("Not enough space"); } break; //if the fish is grade 3 (roughly weight 4) case 3: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 4) { //add fish to storage weight and remove from the shoal boat.Storage += 4; Size--; } else { Debug.Log("Not enough space"); } break; //if the fish is grade 4 (roughly weight 3) case 4: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 3) { //add fish to storage weight and remove from the shoal boat.Storage += 3; Size--; } else { Debug.Log("Not enough space"); } break; default: Debug.Log("Age 2 shoal giving grade error"); break; } } break; default: for (int i = 0; i < catchSize; i++) { //generate number between 1 and 3 randomGrade = random.Next(1, 4); //add the fish to the boat switch (randomGrade) { //if the fish is grade 1 (roughly weight 6) case 1: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 6) { //add fish to storage weight and remove from the shoal boat.Storage += 6; Size--; } else { Debug.Log("Not enough space"); } break; //if the fish is grade 2 (roughly weight 5) case 2: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 5) { //add fish to storage weight and remove from the shoal boat.Storage += 5; Size--; } else { Debug.Log("Not enough space"); } break; //if the fish is grade 3 (roughly weight 4) case 3: remainingStorage = boat.MaxStorage - boat.Storage; if (remainingStorage >= 4) { //add fish to storage weight and remove from the shoal boat.Storage += 4; Size--; } else { Debug.Log("Not enough space"); } break; default: Debug.Log("Age 3 shoal giving grade error"); break; } } break; /* * default: * Debug.Log("Default age selected in fishing shoal"); * break; */ } }