Ejemplo n.º 1
0
 public void Update(GameTime gameTime)
 {
     Actors.ForEach(x => x.Update(gameTime));
     timer = (timer >= 1000) ? 0 : timer + gameTime.ElapsedGameTime.TotalMilliseconds;
     calculateScoreTimer = (calculateScoreTimer >= 10) ? 0 : calculateScoreTimer + gameTime.ElapsedGameTime.TotalMilliseconds;
     if (timer == 0 && !ended)
     {
         Time--;
         if (Time == 0)
         {
             Player.GetComponent <PlayerComponent>().Kill();
         }
     }
     if (ended && calculateScoreTimer == 0)
     {
         if (Time == 0)
         {
             MapCompleted?.Invoke(this, null);
         }
         else
         {
             Time--;
             Score++;
         }
     }
 }
Ejemplo n.º 2
0
 protected void MapQuerierOnMapAdded(object sender, MapEventArgs e)
 {
     if (!MapQueue.ContainsKey(e.Map.Id) && !MapCompleted.ContainsKey(e.Map.Id))
     {
         MapQueue.Add(e.Map.Id, e.Map);
         if (ProgressChanged != null)
         {
             ProgressChanged(this, new ProgressChangedEventArgs(MapCompleted.Count * 100 / (MapQueue.Count + MapCompleted.Count), null));
         }
     }
 }
Ejemplo n.º 3
0
        protected void MapQuerierOnQueryCompleted(object sender, MapEventArgs e)
        {
            try
            {
                if (MapQueue.ContainsKey(e.Map.Id))
                {
                    MapQueue.Remove(e.Map.Id);
                }

                if (!MapCompleted.ContainsKey(e.Map.Id))
                {
                    MapCompleted.Add(e.Map.Id, e.Map);
                }

                if (MapQueue.Count == 0)
                {
                    OnProgressChanged(this, new ProgressChangedEventArgs(100, null));
                    OnExportCompleted(this, new ExportCompletedEventArgs(OutputFileLocation, UserState, RootMap.Name));
                }
                else
                {
                    OnProgressChanged(this, new ProgressChangedEventArgs(MapCompleted.Count * 100 / (MapQueue.Count + MapCompleted.Count), null));

                    var nextMap = MapQueue.Values.FirstOrDefault();
                    if (nextMap != null)
                    {
                        if (!MapCompleted.ContainsKey(nextMap.Id))
                        {
                            ReadNextMap(nextMap);
                        }
                        else
                        {
                            var mapArgs = new MapEventArgs {
                                Container = e.Container, Map = nextMap
                            };
                            MapQuerierOnQueryCompleted(sender, mapArgs);
                        }
                    }
                    else
                    {
                        throw new NullReferenceException("Map in queue is null");
                    }
                }
            }
            catch (Exception ex)
            {
                OnExceptionRaised(sender, "Error occurred when querying map data", ex);
            }
        }