Пример #1
0
        public static void Add(Unit unit, int priority, int timer)
        {
            if (unit == null)
            {
                return;
            }

            var evt = EventsList.FirstOrDefault(ev => ev.Unit == unit);

            if (evt != null)
            {
                evt.Priority += priority;
                evt.Timer    += timer;
                if (evt.Timer > 250)
                {
                    evt.Timer = 250;
                }
                return;
            }

            evt = new CoolEvent
            {
                Unit     = unit,
                Priority = priority,
                Timer    = timer
            };
            EventsList.Add(evt);
        }
Пример #2
0
        public static void Clear(CoolEvent evt)
        {
            if (evt.IsNone)
            {
                return;
            }

            EventsList.RemoveAll(e => e.Equals(evt));
        }
Пример #3
0
        public static void Add(Position pos, int priority, int timer, string pszDebug)
        {
            if (pos == null || pos.IsNone)
            {
                return;
            }

            if (pszDebug != null)
            {
                Game.Write("EVENT: {0} at priority {1} for {2} frames", pszDebug, priority, timer);
            }

            pos -= new Position(320, 200);
            pos.MakeValid();

            if (pos.CalcApproximateDistance(CurrentEvent.Position) <= 200)
            {
                CurrentEvent.Priority += priority;
                CurrentEvent.Timer    += timer;
                if (CurrentEvent.Timer > 250)
                {
                    CurrentEvent.Timer = 250;
                }
                return;
            }

            var evt = EventsList.FirstOrDefault(e => e.Position != null && pos.CalcApproximateDistance(e.Position) >= 600);

            if (evt != null)
            {
                if (pos.CalcApproximateDistance(evt.Position) > 200)
                {
                    pos         += evt.Position + pos;
                    evt.Position = new Position(pos.X / 2, pos.Y / 3);
                    evt.Position.MakeValid();
                }

                CurrentEvent.Priority += priority;
                CurrentEvent.Timer    += timer;
                if (CurrentEvent.Timer > 250)
                {
                    CurrentEvent.Timer = 250;
                }
                return;
            }
            evt = new CoolEvent
            {
                Position = pos,
                Priority = priority,
                Timer    = timer
            };
            EventsList.Add(evt);
        }
Пример #4
0
 public bool Equals(CoolEvent other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Position, Position) && Equals(other.Unit, Unit) && other.Priority == Priority && other.Timer == Timer);
 }
Пример #5
0
 static Events()
 {
     EventsList   = new List <CoolEvent>();
     CurrentEvent = new CoolEvent();
 }