protected override void MoveAnimation() { ChangePosition(3f); if (Position == TargetPostion) { WasMove = true; if (!IsTurningBack && !IsLowering) { MatchSearcher.FindMatchs(this); if (EntityManager.Entities.Where(x => x.IsExpired).ToList().Count == 0) { IsTurningBack = true; } } else { IsTurningBack = false; IsLowering = false; EntityManager.Unlock(); } List <GameElement> turningBackElements = EntityManager.Entities.ToGameElementsList().Where(x => x.IsTurningBack).ToList(); if (turningBackElements.Count > 1) { EntityManager.SwitchElements(turningBackElements[0], turningBackElements[1]); } } }
public static void Update(GameTime gameTime) { if (Entities.Count < 1) { CreateGameElements(); } if (!IsLock) { Input.Update(gameTime); if (Input.WasClick()) { ProcessClick(); } SearchForLowering(); } foreach (Entity entity1 in Entities) { entity1.Update(); } if (!IsLock) { SearchForAdding(); GameStatus.IncreaseScores(GetExpiredElements()); if (Entities.GetEntitiesWithDelay().Count > 0) { Lock(); foreach (Entity entity in Entities.GetEntitiesWithDelay()) { entity.Delay -= gameTime.ElapsedGameTime.TotalMilliseconds; if (entity.Delay <= 0) { entity.Delay = -1; entity.IsExpired = true; Unlock(); } } } Entities = Entities.Where(x => !x.IsExpired).ToList(); } if (!(Entities.Count < RowCount * ColumnCount) && !IsLock) { MatchSearcher.Update(); } }