private void CreateFood(bool good, Vector2 newPos) { Food f; f = foodList.Find(x => x._CurrentState == Sprite.SpriteState.kStateInActive); //Vector2 newPos = new Vector2(ran.Next(20, 780), ran.Next(20, 460)); if (f != null) { f.Activate(newPos); f.goodFood = good; } else { f = new Food(); f.LoadContent(@"Art/Food", Content); f.Activate(newPos); f.goodFood = good; foodList.Add(f); } if (good == true) { f.LoadContent(@"Art/Blueberry", Content); } else { f.LoadContent(@"Art/Strawberry", Content); } }
void Update() { // If I CLICK, feed fish. if (Input.GetMouseButtonDown(0) && readyFoods.Count > 0) { Food newFood = readyFoods[0]; newFood.Activate(cam.ScreenToWorldPoint(Input.mousePosition)); if (fish.state == FishState.Hungry) { FindNearestFood(fish.transform.position); } } // If I press SPACEBAR, tell all fish to randomly swim somewhere else. if (Input.GetKeyDown(KeyCode.Space) || fish.needsDest) { ScrambleFish(); } }