Example #1
0
 public void Awake()
 {
     foreach (var com in ComponentManager.GetInstance().AddingList)
     {
         com.Awake();
     }
 }
Example #2
0
 public void Start()
 {
     ComponentManager.GetInstance().AddingList.RemoveWhere(delegate(Component com)
     {
         com.Start();
         return(true);
     });
 }
Example #3
0
 public void RemoveAllComponent()
 {
     componentContainer.RemoveAll(delegate(Component com)
     {
         ComponentManager.GetInstance().RemoveComponent(com);
         return(true);
     });
 }
Example #4
0
        public Component AddComponent(Type type)
        {
            Component component = Activator.CreateInstance(type) as Component;

            component.entity = this;
            componentContainer.Add(component);
            ComponentManager.GetInstance().Add(component, type);
            return(component);
        }
Example #5
0
 public void InternalAddItem(Entity entity)
 {
     foreach (var com in entity.GetAllComponents())
     {
         ComponentManager.GetInstance().AddingList.Add(com);
     }
     if (entity.transform != null)
     {
         foreach (var childTransform in entity.transform._children)
         {
             InternalAddItem(childTransform.entity);
         }
     }
 }
Example #6
0
        public void Render(Transform transform)
        {
            Camera camera = null;

            if (ComponentManager.GetInstance().componentPool.ContainsKey(typeof(Camera)))
            {
                if (ComponentManager.GetInstance().componentPool[typeof(Camera)][0] != null)
                {
                    camera = ComponentManager.GetInstance().componentPool[typeof(Camera)][0] as Camera;
                }
            }

            if (camera == null)
            {
                return;
            }

            Matrix4 project = camera.ProjectMatrix;
            Matrix4 view    = camera.ViewMatrix;
            Matrix4 model   = transform.localToWorldMatrix;
            var     shader  = ResourceManager.GetInstance().meshShader;

            int myModelUniform = shader.GetUniformLocation(@"model");

            GL.UniformMatrix4(myModelUniform, false, ref model);

            int myViewUniform = shader.GetUniformLocation(@"view");

            GL.UniformMatrix4(myViewUniform, false, ref view);

            int myProjectUniform = shader.GetUniformLocation(@"project");

            GL.UniformMatrix4(myProjectUniform, false, ref project);

            int myDiffuseUniform = shader.GetUniformLocation(@"diffuseTex");

            GL.Uniform1(myDiffuseUniform, 0);

            GL.ActiveTexture(TextureUnit.Texture0);
            _textures[0].Bind();

            shader.Use();
            GL.BindVertexArray(vao);
            GL.DrawElements(BeginMode.Triangles, _indices.Count, DrawElementsType.UnsignedInt, 0);
            GL.BindVertexArray(0);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
Example #7
0
 public void RemoveComponent(Component com)
 {
     componentContainer.RemoveAll(delegate(Component target)
     {
         if (com == target)
         {
             ComponentManager.GetInstance().RemoveComponent(target);
             return(true);
         }
         else
         {
             return(false);
         }
     });
 }
Example #8
0
        public void Update()
        {
            if (ComponentManager.GetInstance().componentPool.ContainsKey(typeof(Script)))
            {
                ComponentManager.GetInstance().componentPool[typeof(Script)].ForEach(
                    delegate(Component script)
                {
                    if (script.isAwake)
                    {
                        (script as Script).Update();
                    }
                }
                    );
            }

            UpdateTransform();
        }
Example #9
0
 public void AddComponent(Component component)
 {
     component.entity = this;
     componentContainer.Add(component);
     ComponentManager.GetInstance().Add(component, component.GetType());
 }