コード例 #1
0
    private void GenerateBonus()
    {
        PowerUp bonus  = ObjectPool.Instance.Get <PowerUp>();
        Vector2 bounds = GameManager.Instance.MapBounds - Vector2.one;

        int x = Random.Range((int)-bounds.x, (int)bounds.x);
        int y = Random.Range((int)-bounds.y, (int)bounds.y);

        //Debug.Log("Position: " + x + " " + y);
        bonus.transform.position = new Vector2(x, y);

        bool negative = false;

        bonus.AddBonus(GetRandomBonus(ref negative));

        bonus.EnableFollowing(negative);
        GameTime.Instance.AddTimer(new Timer(Random.Range(minDelay, maxDelay), delegate() { GenerateBonus(); }));
    }
コード例 #2
0
    private void BonusTest()
    {
        PowerUp bonus = ObjectPool.Instance.Get <PowerUp>();

        bonus.transform.position = Vector2.zero;
        bool negative = false;

        /*
         * bonus.AddBonus(new GenericBonus(delegate (GameObject target)
         * {
         *  Player player = target.GetComponent<ShipController>().GetPlayer();
         *  if (player == null)
         *      return;
         *
         *  PopUp.ShowText(target.transform.position, "Disable players", 1);
         *  System.Collections.Generic.List<Player> players = GameManager.Instance.GetPlayers();
         *  players.Remove(player);
         *
         *  for (int i = 0; i < players.Count; i++)
         *  {
         *      players[i].EnableControll(false);
         *  }
         *
         *  GameTime.Instance.AddTimer(new Timer(5, delegate ()
         *  {
         *      for (int i = 0; i < players.Count; i++)
         *      {
         *          players[i].EnableControll(true);
         *      }
         *  }));
         * }));
         */
        //bonus.AddBonus(new CircleFireBonus(15));
        bonus.AddBonus(new GenericBonus(delegate(GameObject target)
        {
            ShipController controller = target.GetComponent <ShipController>();
            if (controller == null)
            {
                return;
            }

            Vector3 position = target.transform.position;
            PopUp.ShowText(position, "Double fire", 1, Color.white, Bonus.GetAnimation(position));
            controller.GetFire().SetMode(FireMode.DOUBLESHOT);

            GameTime.Instance.AddTimer(new Timer(10, delegate()
            {
                controller.GetFire().SetMode(FireMode.ONESHOT);
            }));
        }));

        bonus.AddBonus(new GenericBonus(delegate(GameObject target)
        {
            Vector3 position = target.transform.position;
            PopUp.ShowText(position, "Black hole", 2);
            GameTime.Instance.AddTimer(new Timer(3, delegate()
            {
                BlackHole bh          = ObjectPool.Instance.Get <BlackHole>();
                ShipController player = target.GetComponent <ShipController>();
                if (player != null)
                {
                    bh.SetDamageListener(player);
                }
                bh.Initialize(position);
            }));
        }));

        bonus.EnableFollowing(negative);
    }