public float getPercentageLeftToEat(PlayerBehavior player){ if(players.Contains (player)) { return playersTimesOnSpot [players.IndexOf (player)] / secondsRequiredToEat; } return 1f; }
public void eat(PlayerBehavior player){ if (players.Contains (player)) { int index = players.IndexOf (player); playersTimesOnSpot [index] += Time.deltaTime; if(playersTimesOnSpot[index] >= secondsRequiredToEat){ Destroy (gameObject); } } else { players.Add (player); playersTimesOnSpot.Add (0f); } }
// Use this for initialization void Start () { player = gameObject.GetComponent<PlayerBehavior>(); childStart (); }