コード例 #1
0
    public void SetupOrbs(bool random, int type)
    {
        ShootOrbs.Clear();
        for (int i = 0; i < QueueSize; i++)
        {
            int nextType = random ? GetNextType() : type;
            ShootOrbs.Enqueue(nextType);
        }

        OnShootOrb?.Invoke(ShootOrbs.ToArray());
        OnSwapStore?.Invoke(StoredType, ShootOrbs.Peek(), true);
    }
コード例 #2
0
 public void CallOnSwapStore()
 {
     OnSwapStore?.Invoke(StoredType, ShootOrbs.Peek(), true);
 }
コード例 #3
0
    void Update()
    {
        if (BulletsLeft < 4)
        {
            BulletRechargeAmount += Time.deltaTime / BulletRechargeTime;
            if (BulletRechargeAmount > 1)
            {
                BulletsLeft++;
                BulletRechargeAmount = 0;
            }
        }

        var position = boardMover.Position;

        // Input
        if (MovementEnabled)
        {
            KeyboardMovement();
        }
        //KeyboardMovement2();

        var pos            = BoardController.Instance.GetMoverPosition(boardMover);
        int lastEmptySpace = BoardController.Instance.GetLastEmptySpace(pos.Lane);

        if (Input.GetMouseButtonDown(0) && OrbShotEnabled && !EventSystem.current.IsPointerOverGameObject())
        {
            if (lastEmptySpace == 0)
            {
                Factory.Instance.PlaySound(BlockedClip, pitchVariance.GetRandomPitch(), BlockedVolume);
                return;
            }

            // Shoot orb
            int type = ShootOrbs.Dequeue();
            Factory.Instance.CreateLaunchOrb(pos.Lane, transform.position, type, lastEmptySpace);

            ShootOrbs.Enqueue(GetNextType());
            OnShootOrb?.Invoke(ShootOrbs.ToArray());
        }
        else if (Input.GetMouseButtonDown(1))
        {
            if (LaserEnabled && BulletsLeft > 0)
            {
                BulletsLeft--;

                var   spawnPosition = BoardController.Instance.GetPosition(position);
                float degrees       = position.Lane / 8f * 360;
                var   laser         = Instantiate(LaserPrefab, spawnPosition, Quaternion.Euler(0, 0, degrees));

                laser.player         = this;
                laser.TargetPosition = new RadialPosition(position.Lane, lastEmptySpace + 1);
                Factory.Instance.PlaySound(LaserClip, pitchVariance.GetRandomPitch(), LaserVolume);

                OnShootLaser?.Invoke();
            }
            else
            {
                Factory.Instance.PlaySound(BlockedClip, 1.3f, 0.5f);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Space) && Charge == 8 && SupershotEnabled)
        {
            SuperShotDrone.Stop();
            Charge      = 0;
            BulletsLeft = Mathf.Min(BulletsLeft + 1, 4);

            Factory.Instance.CreateSuperShotLaser(position.Lane);
            Factory.Instance.CreateCampfireBlast();
            Factory.Instance.PlaySound(SuperShotClip, 1, 0.5f);
            var movers = BoardController.Instance.GetLane(position.Lane).Where(x => x != null);

            int orbCount = 0;
            foreach (var mover in movers)
            {
                if (mover.TryGetComponent <Orb>(out var orb))
                {
                    orb.Shatter(0, false);
                    ScoreController.Instance.OrbBreak(orbCount++);
                }
            }

            for (int i = 0; i < BoardController.NUM_LANES; i++)
            {
                if (i == position.Lane)
                {
                    continue;
                }
                var mover = BoardController.Instance.GetMover(new RadialPosition(i, 0));
                if (mover != null && mover.TryGetComponent <Orb>(out var orb))
                {
                    orb.Shatter(0, false);
                    ScoreController.Instance.OrbBreak(0);
                }

                mover = BoardController.Instance.GetMover(new RadialPosition(i, 1));
                if (mover != null && mover.TryGetComponent(out orb))
                {
                    orb.CheckForChain();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.E) && SwapEnabled)
        {
            int oldFront = ShootOrbs.Peek();

            for (int i = 0; i < ShootOrbs.Count; i++)
            {
                var old = ShootOrbs.Dequeue();
                if (i == 0)
                {
                    ShootOrbs.Enqueue(StoredType);
                }
                else
                {
                    ShootOrbs.Enqueue(old);
                }
            }

            OnSwapStore?.Invoke(oldFront, StoredType, false);

            StoredType = oldFront;
        }
    }