Exemplo n.º 1
0
 private void FallEnd(Block block, bool isBottom)
 {
   if (isBottom && block.IsEmpty == false)
   {
     if (block.Definition.isGarbage)
     {
       GridShakerScript.Shake(this, 0.15f, 0.1f);
     }
   }
 }
Exemplo n.º 2
0
    private IEnumerator GameOverColumnAnimation(int x)
    {
      yield return new WaitForSeconds(Random.Range(0.01f, 0.05f));
      GridShakerScript.Shake(this, 0.25f, 0.025f * (x + 1));
      for (int y = grid.height - 1;
        y >= -grid.previewLines;
        y--)
      {
        var block = Get(x, y);

        if (block != null && block.block.IsEmpty == false)
        {
          StartCoroutine(GameOverBlockAnimation(block));
          yield return new WaitForSeconds(Random.Range(0.05f, 0.15f));
        }
      }
    }
Exemplo n.º 3
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);
      }
    }
Exemplo n.º 4
0
        public static void Shake(GridScript grid, float duration, float force)
        {
            GridShakerScript shaker = grid.gameObject.AddOrGetComponent <GridShakerScript>();

            shaker.SetShake(duration, force);
        }