public void Init(FishSpawner fishSpawner, FishSpawn fishSpawn, Transform parent, Vector2 pos) { spawner = fishSpawner; spawn = fishSpawn; transform.SetParent(parent); transform.position = pos; }
public void SpawnSingleFish(FishSpawn spawn) { if (spawn.Prefab == null) { Debug.Log($"Spawn must have a prefab! ({name})"); return; } float x = Random.Range(min.x, max.x); float y = Random.Range(min.y, max.y); Fish fish = Instantiate(spawn.Prefab).GetComponent <Fish>(); fish.Init(this, spawn, fishContainer, new Vector2(x, y)); spawn.SpawnedCount += 1; spawn.RespawnTimer = 0f; }
private void OnDestroy() { if (isBiting) { isBiting = false; // Find boats in scene GameObject[] boats = GameObject.FindGameObjectsWithTag("Boat"); // Identify Closest boat GameObject closestBoat = GetClosestBoat(boats); // If found any boat if (closestBoat != null) { // Deduct 1 from active fishes in the FishSpawn script FishSpawn fishSpawn = closestBoat.GetComponent <FishSpawn>(); fishSpawn.numberOfActiveFishes--; } } }
void Awake() { fishRb = GetComponent <Rigidbody2D>(); initialGravityScale = fishRb.gravityScale; fishBoxCollider2D = GetComponent <BoxCollider2D>(); boatBoxCollider2D = GetComponent <BoxCollider2D>(); boatGameObject = staticBoatGameObject; FishSpawn fishSpawn = staticBoatGameObject.GetComponent <FishSpawn>(); leftRaycastDistance = fishSpawn.leftMinDistance; // Use scale.x to determine the bitesize biteSize = gameObject.transform.localScale.x * biteSizeDownScale; // flip the y if fish on right if (fishOnRightOfBoat) { fishRb.transform.Rotate(new Vector3(0, 1), -180); } }
public void FishDie(FishSpawn spawn) { spawn.SpawnedCount -= 1; }
void Start() { LowPolyFish = _lowPolyFish; HookHit = _hookHit; gameEnded = false; SpawnBoat(_boatSpawn.position, _boatSetUp.position); SpawnHook(); SpawnRadar(); SpawnTrailer(); Boat.AssignRadar(Radar); Hook.AssignBoat(Boat); //Debug.Log(_generals.Count + " generals"); //InputTimer and basic should be on the same object, but I'm explictly calling in case they ever aren't //and therefore I can still get the script _inputTimer = GetComponent <InputTimer>(); if (!_inputTimer) { Debug.Log("ERROR: Cannot get a reference to InputTimer from the Manager object."); } GlobalUI = GetComponent <GlobalUI>(); if (!GlobalUI) { Debug.Log("ERROR: Cannot get a reference to GlobalUI from the Manager object."); } Scorehandler = GetComponent <ScoreHandler>(); if (!Scorehandler) { Debug.Log("ERROR: Cannot get reference to ScoreHandler from Manager object"); } Shoppinglist = GetComponent <ShoppingList>(); if (!Shoppinglist) { Debug.Log("ERROR: Cannot get reference to ShoppingList from Manager object"); } combo = GetComponent <Combo>(); if (!combo) { Debug.Log("ERROR: Cannot get reference to Combo from Manager object"); } Gameplayvalues = GetComponent <GameplayValues>(); if (!Gameplayvalues) { Debug.Log("ERROR: Cannot get reference to GameplayValues from Manager object"); } Tempfishspawn = GetComponent <FishSpawn>(); if (!Tempfishspawn) { Debug.Log("ERROR: Cannot get reference to TempFishSpawn from Manager object"); } Camerahandler = GetComponent <CameraHandler>(); if (!Camerahandler) { Debug.Log("ERROR: Cannot get reference to CameraHandler from Manager object"); } Seafloorspawning = GetComponent <SeafloorSpawning>(); if (!Seafloorspawning) { Debug.Log("ERROR: Cannot get reference to SeafloorSpawning from Manager object"); } Camerahandler.InitializeCameraHandler(); //Find out seaDepth floor = GameObject.FindGameObjectWithTag("Floor"); Vector3 difference = floor.transform.position - Boat.transform.position; seaDepth = Mathf.Abs(difference.y) - floor.transform.lossyScale.y / 2; //Getting the position and size of the zone where the jellyfish can move _jellyfishZoneSizeX = _jellyfishZone.transform.localScale.x / 2; _jellyfishZonePosX = _jellyfishZone.transform.position.x; _jellyfishZoneSizeY = _jellyfishZone.transform.localScale.y / 2; _jellyfishZonePosY = _jellyfishZone.transform.position.y; //Find out seaWidth //_docks = GameObject.FindGameObjectWithTag("Docks"); if (!_docks) Debug.Log("WARNING (Jellyfish uses this): You need to create the Docks and tag it with Docks"); //_endOfLevel = GameObject.FindGameObjectWithTag("EndOfLevel"); if (!_endOfLevel) Debug.Log("WARNING (Jellyfish uses this): You need to create an empy object, place it at the end of the level (x) and tag it with EndOfLevel"); //_seaWidth = Vector3.Distance(_docks.transform.position, _endOfLevel.transform.position); // }