Ejemplo n.º 1
0
 public static void Unsubscribe(SlimeAvatar avatar)
 {
     avatars.Remove(avatar);
     if (generators.Count == 0 && avatars.Count == 0)
     {
         Notify();
     }
 }
Ejemplo n.º 2
0
    public static SlimeAvatar CreateSlime()
    {
        GameObject slimeInstance = Instantiate(_instance.slimePrefab);

        slimeInstance.transform.parent = _instance.transform;
        slimeInstance.SetActive(false);
        SlimeAvatar slime = slimeInstance.GetComponent <SlimeAvatar>();

        return(slime);
    }
Ejemplo n.º 3
0
    private void PreinstantiateSlimes(/*int quantity*/)
    {
        SlimeGenerator[] slimeGenerators = FindObjectsOfType <SlimeGenerator>();
        slimesToPreinstantiate = 0;

        for (int j = 0; j < slimeGenerators.Length; j++)
        {
            slimesToPreinstantiate += slimeGenerators[j].ToGenerate;
        }


        for (int i = 0; i < slimesToPreinstantiate; i++)
        {
            SlimeAvatar slime = CreateSlime();
            _availableSlimes.Enqueue(slime);
        }
    }
Ejemplo n.º 4
0
    public static SlimeAvatar GetSlime(Vector2 spawnPosition)
    {
        SlimeAvatar slime = null;

        if (_availableSlimes.Count > 0)
        {
            slime = _availableSlimes.Dequeue();
        }
        if (slime == null)
        {
            slime = CreateSlime();
        }

        slime.gameObject.SetActive(true);
        slime.GetComponent <SpriteRenderer>().color = color;
        slime.transform.position = spawnPosition;
        return(slime);
    }
Ejemplo n.º 5
0
 public static void Subscribe(SlimeAvatar avatar)
 {
     avatars.Add(avatar);
 }
Ejemplo n.º 6
0
 public static void Release(SlimeAvatar slime)
 {
     slime.ResetState();
     slime.gameObject.SetActive(false);
     _availableSlimes.Enqueue(slime);
 }