Esempio n. 1
0
 public GameModel(GameModelDTO modelData, GameModel parent = null)
 {
     this.blocks = modelData.blocks.Select(block => new GameBlock(this, block)).ToArray();
     this.subModels.AddRange(modelData.subModels.Select(modelDTO => new GameModel(modelDTO, null)));
     this.relativeBounds = new BoundingBoxInt(modelData.min, modelData.max);
     foreach (AnimationDTO animationDTO in modelData.animations)
     {
         this.Animations.Add(animationDTO.Name, new Animation(animationDTO));
     }
     this.spawnLocations = modelData.spawnLocations;
 }
Esempio n. 2
0
 public GameBlock(GameModel parent, BlockType type, Position position, string scriptName = null)
     : base(position)
 {
     if (scriptName != null)
     {
         this.scriptName = Constants.SCRIPT_BLOCK_PREFIX + scriptName;
     }
     if (type == BlockType.OUT_OF_BOUNDS)
     {
         throw new Exception("Can't set blocktype to OUT_OF_BOUNDS!");
     }
     else if (type == BlockType.EMPTY)
     {
         throw new Exception("Can't set blocktype to EMPTY!");
     }
     this.type = type;
     this.parent = parent;
 }
Esempio n. 3
0
 public GameModel(GameModelDTO modelData, EggEngine engine, GameModel parent = null)
     : this(modelData, parent)
 {
     Initialize(engine);
 }
Esempio n. 4
0
 public bool Spawn(GameModel model, string at)
 {
     Position location;
     if (spawnLocations.TryGetValue(at, out location))
     {
         if (worldMatrix.tryToPlaceModel(model, location))
         {
             model.position = location;
             model.Parent = this;
             subModels.Add(model);
             return true;
         }
         else
         {
             return false;
         }
     }
     else
     {
         throw new ArgumentException("No known spawn location '" + at + "'.");
     }
 }
Esempio n. 5
0
 public GameBlock(GameModel parent, GameBlockDTO blockData)
     : this(parent, blockData.Type, blockData.Position, blockData.scriptName)
 {
 }