public void SpawnEntity(PrefabEntity prefab, string entityName, Vector3 position, Vector3 scale, Category layer = Category.Cat1, GameEntityParameters parameters = null) { GameEntity entity = prefab.CreateGameEntity(this, scale, parameters); entity.Name = entityName; _entities.Add(entityName, entity); entity.SetPosition(position); entity.PhysicsEntity.SetCollisionLayer(layer); }
public GameEntity CreateGameEntity(GameWorldManager world, Vector3 scale, GameEntityParameters parameters) { GameEntity obj = new GameEntity(); obj.Init(); obj.Flags = Flags; Vector2 scale2D = new Vector2(scale.X, scale.Y); GameEntityCreatePhysics(obj, scale2D); GameEntityCreateSceneNodes(obj, scale, parameters != null ? parameters.SceneNodeParameters : null); GameEntityCreateControllers(obj); obj.Prefab = this; obj.Scale = scale; return(obj); }
public void Spawn(float spawnX) { if (_textImage == null) { throw new InvalidOperationException("No text image specified!"); } _isSpawned = true; var parameters = new GameEntityParameters { SceneNodeParameters = new Dictionary <string, object> { { MenuCubeMaterial.MenuTextImage, _textImage } } }; GameWorldManager.Instance.SpawnEntity(MenuCubePrefab.PrefabName, Id, new Vector3(spawnX, DropHeight, 0f), 1f, Category.Cat1, parameters); GameWorldManager.Instance.GetEntity(Id).SetRotation(MathHelper.Clamp(( float )(0.017f - Random.NextDouble()), -0.017f, 0.017f)); // set a small horizontal rotation to give a better impression _rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(( float )(Random.NextDouble() + Random.Next(InitialRotationMin, InitialRotationMax)))); }
public void SpawnEntity(PrefabEntity prefab, string entityName, Vector3 position, Quaternion externalRotation, float scale = 1f, Category layer = Category.Cat1, GameEntityParameters parameters = null) { SpawnEntity(prefab, entityName, position, externalRotation, Vector3.One * scale, layer, parameters); }
public void SpawnEntity(string prefabName, string entityName, Vector3 position, Quaternion externalRotation, Vector3 scale, Category layer = Category.Cat1, GameEntityParameters parameters = null) { SpawnEntity(PrefabRepository.Instance.GetPrefab(prefabName), entityName, position, externalRotation, Vector3.One * scale, layer, parameters); }