Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        var cmbo = Combo;

        if (Input.GetButtonDown($"{PlayerName}_Fire1"))
        {
            elapsedTime = 0.0f;
            Combo      += "A";
        }
        if (Input.GetButtonDown($"{PlayerName}_Fire2"))
        {
            elapsedTime = 0.0f;
            Combo      += "B";
        }
        else if (Input.GetButtonDown($"{PlayerName}_Fire3"))
        {
            elapsedTime = 0.0f;
            Combo      += "X";
        }
        else if (Input.GetButtonDown($"{PlayerName}_Fire4"))
        {
            elapsedTime = 0.0f;
            Combo      += "Y";
        }
        else
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > comboInterval)
            {
                Combo = "";
            }
        }

        if ((cmbo != Combo) && (!string.IsNullOrEmpty(Combo)))
        {
            OnCombo?.Invoke(this, Combo);
        }
    }
Beispiel #2
0
    private void ComboDetected(List<Block> comboBlocks, int currentComboIndex, int totalCombosCount)
    {
      int blocksCount = comboBlocks.Count;
      if (blocksCount < 3) return;

      bypassFrozen = false;

      // Light columns
      for (int b = 0; b < blocksCount; b++)
      {
        int x = comboBlocks[b].x + 1;
        columnSprites[x].color = new Color(1f, 1f, 1f, 0.75f);
      }

      // Shake shake shake
      GridShakerScript.Shake(this, 0.15f, 0.05f);

      // Reset Game Over timer
      timeBeforeGameOverCurrent = timeBeforeGameOverMax;

      totalCombos++;

      // Update chains
      bool isChain = false;
      if (PonGameScript.instance == null || PonGameScript.instance.Settings.disableChains == false)
      {
        // -- A chain is combo where at least one block is falling and it is not the latest block moved
        bool blocksAreChainable = true;
        foreach (var b in comboBlocks)
        {
          blocksAreChainable &= b.Chainable;

          if (!blocksAreChainable) break;
        }

        // -- Also a chain is never the first combo
        isChain = ComboMultiplier >= 1 && blocksAreChainable;
        if (isChain)
        {
          chainCount++;
          totalChains++;
          Log.Info("CHAIN! chainCount=" + chainCount);
        }
      }

      if (currentComboIndex >= totalCombosCount - 1)
      {
        lastMove = new Grid.MoveResult();
      }

      if (blocksCount == 4)
      {
        total4Combos++;
      }
      else if (blocksCount == 5)
      {
        total5Combos++;
      }
      else if (blocksCount > 5)
      {
        total6Combos++;
      }

      CheckForNextLevel();

      // Update combo
      IncreaseMultiplier(isChain ? 2 : 1);

      // Compute score
      long points = GetScore(blocksCount, isChain);
      AddPoints(points);

      // Add some power
      AddPower(blocksCount);

      // Combo feedback
      Vector3 loc = BlockToWorld(comboBlocks[Mathf.CeilToInt(comboBlocks.Count / 2f)].position, Vector2.zero);
      var locs = comboBlocks.Select(b =>
          BlockToWorld(b.position, Vector2.zero) + new Vector2(0.50f, 0.5f))
        .ToArray();
      OnCombo.Raise(this,
        new ComboData(blocksCount, isChain ? chainCount : comboMultiplier, isChain, loc, comboBlocks[0].Definition));

      // Center
      loc += new Vector3(0.60f, 0.5f);

      GameUIScript.DisplayComboWidget(this, comboMultiplier, blocksCount, points, comboBlocks[0].Definition,
        loc, locs);
      if (isChain)
      {
        GameUIScript.DisplayChainWidget(this, chainCount, points, comboBlocks[0].Definition.color, loc);
      }
    }
Beispiel #3
0
 public void NotifyCombo(EntityData entity, int combo)
 {
     OnCombo?.Invoke(this, entity, combo);
 }
Beispiel #4
0
    private IEnumerator FallingDown()
    {
        findMatchesStarted = true;
//        Debug.Log("@@@ Next Move search matches @@@");
        THIS.thrivingBlockDestroyed = false;
        combo = 0;
        AI.THIS.allowShowTip = false;
        var it = field.GetItems();

        for (var i = 0; i < it.Count; i++)
        {
            var item = it[i];
            if (item != null)
            {
                item.anim.StopPlayback();
            }
        }

        destLoopIterations = 0;
        while (true)
        {
            destLoopIterations++;
            checkMatchesAgain = false;

            var destroyItemsListed = field.GetItems().Where(i => i.destroyNext).ToList();
            if (destroyItemsListed.Count > 0)
            {
                yield return(new WaitWhileDestroyPipeline(destroyItemsListed, new Delays()));
            }
            yield return(new WaitWhileDestroying());

            yield return(new WaitWhile(() => StopFall));

            yield return(new WaitWhileFall());

            yield return(new WaitWhileCollect());

//            yield return new WaitWhileFallSide();
            var combineCount = CombineManager.GetCombines(field);
            if ((combineCount.Count <= 0 || !combineCount.SelectMany(i => i.items).Any()) && !field.DestroyingItemsExist() && !field.GetEmptySquares().Any() &&
                !checkMatchesAgain)
            {
                break;
            }

            if (destLoopIterations > 10)
            {
                foreach (var combine in combineCount)
                {
                    if (combine.items.Any())
                    {
                        combine.items.NextRandom().NextType = combine.nextType;
                    }
                }

                combineCount.SelectMany(i => i.items).ToList().ForEach(i => i.destroyNext = true);
            }
        }

        if (combo > 2 && gameStatus == GameState.Playing)
        {
            gratzWords[Random.Range(0, gratzWords.Length)].SetActive(true);
            combo = 0;
            OnCombo?.Invoke();
        }

        //CheckItemsPositions();
        DragBlocked        = false;
        findMatchesStarted = false;
        checkMatchesAgain  = false;
        if (gameStatus == GameState.Playing)
        {
            StartCoroutine(AI.THIS.CheckPossibleCombines());
        }

//        Debug.Log("<-next turn->");
        if (gameStatus == GameState.Playing && !FindObjectsOfType <AnimateItems>().Any())
        {
            OnTurnEnd?.Invoke();
            THIS.CheckWinLose();
        }
    }