Exemple #1
0
 public void StartFalling()
 {
     crushedChips                   = GetChipsForChipMeta(crushChipsMeta.crushedChips);
     fallingChips                   = GetChipsForChipMeta(crushChipsMeta.fallingChips);
     faller.transform.parent        = transform;
     faller.transform.localPosition = Vector3.zero;
     foreach (Chip chip in fallingChips)
     {
         float toReplace   = crushedChips [0].transform.localPosition.y;
         int   indexOffset = chip.chipMeta.stackPos - crushedChips [0].chipMeta.stackPos;
         float relativeY   = indexOffset * chip.chipMeta.Height;
         float newY        = relativeY + toReplace;
         faller.CreateMoverFor(faller.transform, chip.transform, chip.transform.localPosition, new Vector3(chip.transform.localPosition.x, newY, chip.transform.localPosition.z));
     }
     while (crushedChips.Count > 0)
     {
         Chip chipToCrush = crushedChips [0];
         chipToCrush.transform.parent = null;
         //Create and start a particle system
         crushedChips.RemoveAt(0);
         Vector3             chipLocation = chipToCrush.transform.position;
         MJParticleExplosion explosion    = GetParticleExplosion();
         Color chipColor = chipToCrush.GetMainColor();
         explosion.Explode(chipLocation, chipColor, chipColor);
         chipToCrush.gameObject.SetActive(false);
         Destroy(chipToCrush.gameObject);
     }
     crushChipsMeta = new CrushChipsMeta();
     crushedChips.Clear();
     fallingChips.Clear();
     faller.StartFalling();
 }
Exemple #2
0
    private MJParticleExplosion GetParticleExplosion()
    {
        foreach (MJParticleExplosion explosion in explosions)
        {
            if (!explosion.gameObject.activeSelf)
            {
                explosion.gameObject.SetActive(true);
                return(explosion);
            }
        }

        MJParticleExplosion expl = Instantiate <MJParticleExplosion>(chipParticlesPrefab);

        explosions.Add(expl);
        return(expl);
    }