Example #1
0
 /// <summary>
 /// Create and return a GameObject with skybox attached to it.
 /// </summary>
 /// <param name="texture">Skybox texture (leave null for default texture).</param>
 /// <param name="parent">Optional GameObject to attach add skybox to (as a child). If null, will add to active scene's root.</param>
 /// <returns>GameObject containing skybox.</returns>
 public ECS.GameObject CreateSkybox(string texture = null, ECS.GameObject parent = null)
 {
     ECS.GameObject skybox = new ECS.GameObject("skybox", ECS.SceneNodeType.Simple);
     skybox.AddComponent(new ECS.Components.Graphics.SkyBox(texture));
     skybox.Parent = parent != null ? parent : Application.Instance.ActiveScene.Root;
     return(skybox);
 }
Example #2
0
 /// <summary>
 /// Create and return a GameObject with background attached to it.
 /// Note: also attach it to either the active scene root, or a given GameObject.
 /// </summary>
 /// <param name="texture">Skybox texture (leave null for default texture).</param>
 /// <param name="parent">Optional GameObject to attach add skybox to (as a child). If null, will add to active scene's root.</param>
 /// <returns>GameObject containing background.</returns>
 public ECS.GameObject CreateBackground(string texture, ECS.GameObject parent = null)
 {
     ECS.GameObject background = new ECS.GameObject("background", ECS.SceneNodeType.Simple);
     background.AddComponent(new ECS.Components.Graphics.SceneBackground(texture));
     background.Parent = parent != null ? parent : Application.Instance.ActiveScene.Root;
     return(background);
 }
Example #3
0
 /// <summary>
 /// Init application manager.
 /// </summary>
 public void Initialize()
 {
     // create empty scene with starting test camera
     ActiveScene = new ECS.GameScene();
     ECS.GameObject camera = new ECS.GameObject("camera", ECS.SceneNodeType.Simple);
     camera.AddComponent(new ECS.Components.Graphics.Camera());
     camera.SceneNode.Position = new Vector3(0, 0, 10);
 }
Example #4
0
        /// <summary>
        /// Spawn a prototype instance.
        /// Note: parent of new GameObject will be null.
        /// </summary>
        /// <param name="name">Prototype identifier.</param>
        /// <returns>New GameObject instance, built from prototype.</returns>
        public ECS.GameObject Spawn(string name)
        {
            // get prototype from dictionary
            object prototype = _prototypes[name];

            // try to use as a gameobject
            ECS.GameObject asGameObject = prototype as ECS.GameObject;
            if (asGameObject != null)
            {
                return(asGameObject.Clone());
            }
            // if not a game object, use as a function
            else
            {
                GameObjectGenerator func = prototype as GameObjectGenerator;
                return(func());
            }
        }
Example #5
0
 /// <summary>
 /// Register a prototype from a GameObject instance.
 /// </summary>
 /// <param name="gameObject">GameObject to register as a prototype (note: instance will not be affected, it will be cloned).</param>
 /// <param name="name">Name from prototype. If not defined, will use GameObject name.</param>
 public void Register(ECS.GameObject gameObject, string name = null)
 {
     _prototypes[name ?? gameObject.Name ?? "untitled"] = gameObject.Clone(name, false);
 }