Пример #1
0
        public void UseBonus(ObstaclePowerUp p)
        {
            RemovePowerUpObject(p);

            switch (p.Id)
            {
            case 1:
                StartCoroutine(Magnet());
                break;

            case 2:
                break;

            case 3:
                Boom();
                break;

            case 4:
                StartCoroutine(Flight());
                break;

            case 5:
                StartCoroutine(ScoreBoost());
                break;
            }
        }
Пример #2
0
        public static void PushPowerUp(ObstaclePowerUp p)
        {
            List <ObstaclePowerUp> array;

            if (!PoolById.TryGetValue(1, out array))
            {
                array = new List <ObstaclePowerUp>();
                PoolById.Add(1, array);
            }
            p.gameObject.SetActive(false);
            array.Add(p);
        }
Пример #3
0
 public static void AddPowerUpObjects(PlatformObject p)
 {
     foreach (Transform child in p.transform)
     {
         if (child.CompareTag("Bonus"))
         {
             if (Random.Range(1, 100) <= bonusChance)
             {
                 ObstaclePowerUp o = PopPowerUp(Random.Range(0, ListById.Length));
                 p.gameObject.AddChild(o.gameObject);
                 o.gameObject.SetActive(true);
                 o.transform.position = child.position;
             }
         }
     }
 }
Пример #4
0
        public static ObstaclePowerUp PopPowerUp(int id)
        {
            List <ObstaclePowerUp> array;
            ObstaclePowerUp        result = null;
            int count;

            if (PoolById.TryGetValue(id, out array))
            {
                count = array.Count;
                if (count > 0)
                {
                    result = (ObstaclePowerUp)array[count - 1];
                    array.RemoveAt(count - 1);
                }
            }
            if (result == null)
            {
                result = ListById[id].Clone();
            }
            return(result);
        }
Пример #5
0
 public static void RemovePowerUpObject(ObstaclePowerUp p)
 {
     PushPowerUp(p);
     p.gameObject.SetActive(false);
     PowerUpContainer.AddChild(p.gameObject);
 }