コード例 #1
0
 public void DeleteGameObject(LevelGameObject gameObject)
 {
     Assure.NotNull(gameObject);
     lock (instanceMutationLock) {
         gameObjects.Remove(gameObject);
     }
 }
コード例 #2
0
 public void AddGameObject(LevelGameObject gameObject)
 {
     Assure.NotNull(gameObject);
     lock (instanceMutationLock) {
         gameObjects.Add(gameObject);
     }
 }
コード例 #3
0
 public void ResetGameObject(LevelGameObject lgo)
 {
     if (currentGameObjects.ContainsKey(lgo))
     {
         currentGameObjects[lgo].Dispose();
     }
     currentGameObjects[lgo] = lgo.CreateEntity();
 }
コード例 #4
0
        public static LevelGameObject Deserialize(LevelDescription parentLevel, XElement element)
        {
            string          typeName = element.Attribute(TYPE_ATTRIBUTE_NAME).Value;
            int             id       = Int32.Parse(element.Attribute(ID_ATTRIBUTE_NAME).Value);
            Type            goType   = typeNames.Single(kvp => kvp.Value == typeName).Key;
            LevelGameObject result   = (LevelGameObject)Activator.CreateInstance(goType, parentLevel, id);

            lock (result.instanceMutationLock) {
                string groundingEntityAttrValue = element.Attribute(GROUNDING_ENTITY_ID_ATTRIBUTE_NAME).Value;
                result.groundingEntityID  = groundingEntityAttrValue == String.Empty ? (int?)null : Int32.Parse(groundingEntityAttrValue);
                result.transform          = Transform.Parse(element.Attribute(TRANSFORM_ATTRIBUTE_NAME).Value);
                result.useSimpleGrounding = Boolean.Parse(element.Attribute(USE_SIMPLE_GROUNDING_ATTRIBUTE_NAME).Value);
                result.PerformCustomDeserialization(element);
            }
            return(result);
        }
コード例 #5
0
 private void DeserializeGameObjects(XElement gameObjectsElement)
 {
     gameObjects.Clear();
     foreach (XElement element in gameObjectsElement.Elements())
     {
         gameObjects.Add(LevelGameObject.Deserialize(this, element));
     }
     if (!GameObjects.Any(go => go is Shadowcaster))
     {
         var shadowcaster = new Shadowcaster(this, GetNewGameObjectID());
         shadowcaster.Transform = new Transform(
             Vector3.ONE,
             Quaternion.FromVectorTransition(Vector3.UP, Vector3.DOWN),
             Vector3.UP * PhysicsManager.ONE_METRE_SCALED * 20f
             );
         gameObjects.Insert(0, shadowcaster);
     }
 }
コード例 #6
0
 public GroundableEntity GetGameObjectRepresentation(LevelGameObject lgo)
 {
     lock (instanceMutationLock) {
         return(currentGameObjects[lgo]);
     }
 }