private void ClearSelectedSpot() { if (selectedSpot == null) { return; } selectedSpot.ClearSpot(); selectedSpot = null; }
public CatSpot FindInterestingPlace() { if (InterestingSpotsEmpty.Count <= 0) { return(null); } CatSpot spot = InterestingSpotsEmpty[Random.Range(0, InterestingSpotsEmpty.Count)]; InterestingSpotsEmpty.Remove(spot); spot.Occupied = true; return(spot); }
private IEnumerator Behaviour() { //Cat is born //Play some nice animation - jumping out of box or something like that yield return(new WaitForSeconds(0.5f)); while (true) { while (pickedUp) { yield return(null); } if (petted) { yield return(new WaitForSeconds(1.5f)); petted = false; } if (selectedSpot == null) { if (hunger <= 5f) { PlaySound(CatManager.Instance.GetMeow()); noiseParticle.Play(); selectedSpot = CatManager.Instance.FindFoodbowl(); if (selectedSpot == null) { yield return(new WaitForSeconds(3f)); } } else if (poo >= maxPoo / 2) { selectedSpot = CatManager.Instance.FindLitterbox(); } if (selectedSpot == null) { selectedSpot = CatManager.Instance.FindInterestingPlace(); } } if (Move()) { selectedSpot?.OnSpotReach(this); yield return(new WaitForSeconds(0.5f)); if (energy <= 0) { yield return(Dance(3)); PlaySound(CatManager.Instance.GetPurr()); srBody.sprite = spriteLying; srFace.transform.position = faceLyingTransform.position; sleepParticle.Play(); energy = maxEnergy; yield return(new WaitForSeconds(sleepTime)); sleepParticle.Stop(); } srBody.sprite = spriteStaying; srFace.transform.position = faceStayingTransform.position; ClearSelectedSpot(); if (Random.value > 0.8f) { yield return(Dance(6)); } } yield return(null); } }