Пример #1
0
 private void RealizeMapObjects(List <MapObjectModel> mapObjects)
 {
     for (int i = 0; i < mapObjects.Count; i++)
     {
         MapObjectModel current = mapObjects[i];
         RealizeMapObject(current);
     }
 }
Пример #2
0
    private void RealizeMapObject(MapObjectModel model)
    {
        GameObject result;

        switch (model.MapObjectType)
        {
        case MapObjectType.SpawnPoint:
            result = (GameObject)Instantiate(SpawnPointPrototype, model.Position, Quaternion.Euler(model.Rotation));
            result.transform.SetParent(SpawnPointRoot.transform);

            SpawnPointActuator actuator = result.GetComponent <SpawnPointActuator>();
            if (actuator == null)
            {
                throw new ApplicationException("Spawn Point Prototype does not have a Spawn Point Actuator behavior on it!");
            }

            SpawnPointModel spawnPointModel = SpawnPointRepository.GetSpawnPointByName(model.ModelName);
            if (spawnPointModel == null)
            {
                throw new DataException("Spawn Point Model " + model.ModelName + " isn't defined in the SpawnPoint data file.");
            }

            actuator.RealizeModel(spawnPointModel);
            break;

        case MapObjectType.RevivableSpawnPoint:
            result = (GameObject)Instantiate(RevivableSpawnPointPrototype, model.Position, Quaternion.Euler(model.Rotation));
            result.transform.SetParent(GameObjectRoot.transform);

            RevivableSpawnPointActuator revivableSpawnPointActuator = result.GetComponent <RevivableSpawnPointActuator>();
            if (revivableSpawnPointActuator == null)
            {
                throw new ApplicationException("Revivable Spawn Point Prototype does not have a Revivable Spawn Point Actuator behavior on it!");
            }

            SpawnPointModel revivableSpawnPointModel = RevivableSpawnPointRepository.GetSpawnPointByName(model.ModelName);
            if (revivableSpawnPointModel == null)
            {
                throw new DataException("Revivable Spawn Point Model " + model.ModelName + " isn't defined in the SpawnPoint data file.");
            }

            revivableSpawnPointActuator.RealizeModel(revivableSpawnPointModel);
            break;

        case MapObjectType.Waypoint:
            result = (GameObject)Instantiate(WaypointPrototype, model.Position, Quaternion.Euler(model.Rotation));
            result.transform.SetParent(GameObjectRoot.transform);
            break;

        default:
            throw new ApplicationException("Unexpected Map Object type:" + model.MapObjectType);
        }
    }
Пример #3
0
        public void Handle(MapObjectAdded @event)
        {
            var mapObjectModel = new MapObjectModel
            {
                Id             = @event.MapObject.Id,
                CreatedAt      = @event.MapObject.CreatedAt,
                LastModifiedAt = @event.MapObject.LastModifiedAt,
                Title          = @event.MapObject.Title,
                Description    = @event.MapObject.Description,
                WktString      = @event.MapObject.Geometry.ToString(),
                Tags           = @event.MapObject.Tags.Select(x => x.Tag).ToList()
            };

            _backgroundService.RunInBackground <SendObjectAddedNotification, string, MapObjectModel>(@event.MapObject.MapId, mapObjectModel);
        }