Exemple #1
0
 public Portal(PortalRecord template, AbstractMapInstance instance)
 {
     this.Template  = template;
     this.m_Id      = instance.PopNextNPEntityId();
     this.CellId    = instance.Record.RandomNoBorderCell();
     this.Direction = DirectionsEnum.DIRECTION_SOUTH;
     this.Map       = instance.Record;
 }
Exemple #2
0
        public string getPortalPositionString(string name)
        {
            var portal = PortalRecord.GetPortal(name);
            var action = DelayedActionManager.GetAction(DelayedActionEnum.Portal, portal.Id.ToString());

            var nextPop = action.Timer.Interval.ConvertToMinutes();

            if (action == null || action.Value == null)
            {
                return("?");
            }

            var map = (MapRecord)action.Value;

            return(string.Format("<b>[{0},{1}]</b> ({2}) il y est encore pour " + Math.Ceiling(nextPop) + " minutes", map.Position.X, map.Position.Y, map.SubArea.Name));
        }
        public static void SpawnPortal(DelayedAction action)
        {
            int portalId = int.Parse(action.Record.Value1);

            PortalRecord record = PortalRecord.GetPortal(portalId);

            MapRecord targetedMap = null;

            if (action.Value != null)
            {
                ((MapRecord)action.Value).Instance.RemoveEntity(((MapRecord)action.Value).Instance.GetEntities <Portal>().FirstOrDefault(x => x.Template.Id == int.Parse(action.Record.Value1)));
            }

            if (action.Record.Value2 != string.Empty)
            {
                List <MapRecord> subAreaMaps = MapRecord.GetSubAreaMaps(int.Parse(action.Record.Value2))
                                               .ConvertAll <MapRecord>(x => MapRecord.GetMap(x))
                                               .FindAll(x => x.Instance.GetEntities <Portal>().FirstOrDefault(w => w.Template.Id == portalId) == null);

                if (subAreaMaps.Count > 0)
                {
                    targetedMap = subAreaMaps.Random();

                    targetedMap.Instance.AddEntity(new Portal(record, targetedMap.Instance));

                    action.Value = targetedMap;
                }
            }
            else
            {
                List <MapRecord> maps = MapRecord.Maps.FindAll(x => x.Instance.GetEntities <Portal>().FirstOrDefault(w => w.Template.Id == portalId) == null).FindAll(x => x.Position.Outdoor);

                if (maps.Count > 0)
                {
                    targetedMap = maps.Random();

                    targetedMap.Instance.AddEntity(new Portal(record, targetedMap.Instance));

                    action.Value = targetedMap;
                }
            }
        }