private List <BlockEffects> activeBlocks = new List <BlockEffects>(); // blocks comme bouclier qui bloque /// <summary> /// Résoud les effets à traiter /// </summary> public void Solve() { int k = 0; while (k < ToBeTreated.Count) { Effect element = ToBeTreated[k]; bool canUse = true; int l = 0; while (l < ActiveBlocks.Count) { BlockEffects blockEffect = ActiveBlocks[l]; // si il n'y a pas de block, on applique l'effet if (blockEffect.ContientEffetType(element)) { blockEffect.NumberToBlock -= 1; if (blockEffect.NumberToBlock > 0 || blockEffect.TourEffetActif > 0) { canUse = false; break; // petite opti } } l++; } if (canUse) { element.Use(); } element.TourEffetActif--; k++; } int i = 0; while (i < ToBeTreated.Count) // la différence diminue de 1 a chaque tour de boucle { if (ToBeTreated[i].TourEffetActif <= 0) { ToBeTreated.RemoveAt(i); } else { i++; } } ActiveBlocks.RemoveAll(x => x.NumberToBlock <= 0 && x.TourEffetActif < 0);// si il n'y a plus de coup a bloquer ni de tour effet actif on le supprime de la liste des blocs actifs }
IEnumerator AsyncActivateLevelBlocks(TextAsset textAsset, bool allActive) { if (allActive) { BlocklyUI.WorkspaceView.Toolbox.SetActiveAllBlocks(); } else if (textAsset != null) { ActiveBlocks blocks = ActiveBlocks.FromJson(textAsset.text); BlocklyUI.WorkspaceView.Toolbox.SetActiveBlocks(blocks.AsMap()); } yield return(null); }
public EventSet(Stream input) { var reader = new BinaryReader(input); int numActive = reader.ReadInt16(); int numBlocks = reader.ReadInt16(); for (int i = 0; i < numActive; i++) { ActiveBlocks.Add(reader.ReadInt16()); } for (int i = 0; i < numBlocks; i++) { Blocks.Add(new Block(reader)); } }
public void Update(GameTime gameTime) { foreach (var effect in activeSprays) { effect.Update(gameTime); } for (int i = activeBursts.Count - 1; i >= 0; i--) { activeBursts[i].Update(gameTime); if (activeBursts[i].Done) { activeBursts.Remove(activeBursts[i]); } } for (int i = ActiveAbsorbs.Count - 1; i >= 0; i--) { ActiveAbsorbs[i].Update(gameTime); if (ActiveAbsorbs[i].Done) { ActiveAbsorbs.Remove(ActiveAbsorbs[i]); } } for (int i = ActiveBlocks.Count - 1; i >= 0; i--) { ActiveBlocks[i].Update(gameTime); if (ActiveBlocks[i].Done) { _gamePlayScreen.NowIsBlock(ActiveBlocks[i].LastElement, ActiveBlocks[i].ChoosenBlock); ActiveBlocks.Remove(ActiveBlocks[i]); } } for (int i = ActiveScores.Count - 1; i >= 0; i--) { ActiveScores[i].Update(gameTime); if (ActiveScores[i].Done) { ActiveScores.Remove(ActiveScores[i]); } } }
/// <summary> /// Adds the block effect. Used to make tile appear to move on board /// </summary> /// <param name="startPos">Blocks initial position</param> /// <param name="targetPos">Blocks destination</param> /// <param name="lastElement">The id of the final boardcell to be occupied</param> public void AddBlock(Vector2 startPos, Vector2 targetPos, int lastElement, int chosenBlock) { ActiveBlocks.Add(new BlockMoving(startPos, targetPos, lastElement, chosenBlock)); }