public override void Reallocate()
        {
            renderComponent = null;
            physicsComponent = null;

            base.Reallocate();
        }
        public override void Initialize()
        {
            renderComponent  = Parent.GetComponent <IRenderComponent>();
            physicsComponent = Parent.GetComponent <IPhysicsComponent>();

            base.Initialize();
        }
        public override void Initialize()
        {
            renderComponent = Parent.GetComponent<IRenderComponent>();
            physicsComponent = Parent.GetComponent<IPhysicsComponent>();

            base.Initialize();
        }
        public override void Reallocate()
        {
            renderComponent  = null;
            physicsComponent = null;

            base.Reallocate();
        }
Exemple #5
0
 /// <summary>
 /// Removes a layer from the render components.
 /// </summary>
 /// <param name="layer">The component to remove.</param>
 protected void RemoveLayer(IRenderComponent layer)
 {
     lock (Layers)
     {
         Layers.Remove(layer);
     }
 }
        public Dictionary<string, IRenderable> GenerateRenderables(XElement element, IRenderComponent parent)
        {
            Dictionary<string, IRenderable> renderables = new Dictionary<string, IRenderable>();
            IEnumerable<XElement> renderableElements = element.Elements("renderable");

            int i = 0;

            foreach (XElement renderableElement in renderableElements)
            {
                IRenderable renderable = GenerateRenderable(renderableElement, parent);

                if (renderable != null)
                {
                    string name;

                    XAttribute nameAttrib = renderableElement.Attribute("name");
                    if (nameAttrib != null)
                        name = nameAttrib.Value;
                    else
                        name = i.ToString(CultureInfo.InvariantCulture);
                    
                    renderables.Add(name, renderable);

                    i++;
                }
            }
            
            return renderables;
        }
Exemple #7
0
        //A bounding box is created in intialise to check for input using collision detection with the mouse position.
        public override void Initialise()
        {
            _renderComponent         = new RenderComponent(this);
            _renderComponent.Texture = ContentService.content.Load <Texture2D>("hard_menu");
            _boundingBox             = new Rectangle((int)this._position.X, (int)this._position.Y, _renderComponent.Texture.Width, _renderComponent.Texture.Height);
            _inputComponent          = new InputComponent(this);

            base.Initialise();
        }
 //A bounding box is created in intialise to check for input using collision detection with the mouse position.
 public override void Initialise()
 {
     _renderComponent         = new RenderComponent(this);
     _renderComponent.Texture = this._texture;
     _boundingBox             = new Rectangle((int)this._position.X, (int)this._position.Y, _renderComponent.Texture.Width, _renderComponent.Texture.Height);
     _inputComponent          = new InputComponent(this);
     _audioComponent          = new AudioComponent(this);
     _audioComponent.SoundEffect(_sound);
     base.Initialise();
 }
 /// <summary>
 /// Compares the current object with another object of the same type.
 /// </summary>
 /// <returns>
 /// A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public int CompareTo(IRenderComponent other)
 {
     if (Order > other.Order)
     {
         return(1);
     }
     if (Order == other.Order)
     {
         return(0);
     }
     return(-1);
 }
Exemple #10
0
        /// <summary>
        /// Adds a layer to the render components of the surface.
        /// </summary>
        /// <param name="layer">The layer to add.</param>
        /// <param name="order">Override the layer order.</param>
        public void AddLayer(IRenderComponent layer, int order = -1)
        {
            if (order != -1)
            {
                layer.Order = order;
            }

            lock (Layers)
            {
                Layers.AddSorted(layer);
            }
        }
Exemple #11
0
        //Sets up the components as well as the starting position of the town.
        public override void Initialise()
        {
            _renderComponent         = new RenderComponent(this);
            _renderComponent.Texture = this._texture;
            _inputComponent          = new InputComponent(this);
            _townComponent           = new TownComponent(this);
            _townUtility             = new TownProperties(this);
            _audioComponent          = new AudioComponent(this);
            _audioComponent.SoundEffect(_sound);

            _townComponent.TownName   = _townUtility.getName;
            _townComponent.Population = _townUtility.getPopulation;
            this.setPosition(_townUtility.getPosition);
            _townComponent.setPosition(this.getPosition);
            _boundingBox = new Rectangle((int)this._position.X, (int)this._position.Y, _renderComponent.Texture.Width, _renderComponent.Texture.Height);
            base.Initialise();
        }
        public IRenderable GenerateRenderable(XElement element, IRenderComponent parent)
        {
            IRenderable renderable = null;

            XAttribute classAttrib = element.Attribute("class"),
                       typeAttrib  = element.Attribute("type");

            if (classAttrib != null && typeAttrib != null)
            {
                Type classType = Type.GetType(classAttrib.Value);

                renderable = (IRenderable)Activator.CreateInstance(classType);
                renderable.Deserialize(element);
                renderable.Load(contentManager);
                renderable.Visible = true;
                renderable.Parent  = parent;
            }
            return(renderable);
        }
        public IRenderable GenerateRenderable(XElement element, IRenderComponent parent)
        {
            IRenderable renderable = null;

            XAttribute classAttrib = element.Attribute("class"), 
                        typeAttrib = element.Attribute("type");

            if (classAttrib != null && typeAttrib != null)
            {
                Type classType = Type.GetType(classAttrib.Value);

                renderable = (IRenderable) Activator.CreateInstance(classType);
                renderable.Deserialize(element);
                renderable.Load(contentManager);
                renderable.Visible = true;
                renderable.Parent = parent;
            }
            return renderable;
        }
Exemple #14
0
 public override void Initialise()
 {
     _renderComponent         = new RenderComponent(this);
     _renderComponent.Texture = this._texture;
 }
Exemple #15
0
 public Entity AddRenderComponent(IRenderComponent component)
 {
     RenderComponent = component;
     component.Owner = this;
     return(this);
 }
        public Dictionary <string, IRenderable> GenerateRenderables(XElement element, IRenderComponent parent)
        {
            Dictionary <string, IRenderable> renderables        = new Dictionary <string, IRenderable>();
            IEnumerable <XElement>           renderableElements = element.Elements("renderable");

            int i = 0;

            foreach (XElement renderableElement in renderableElements)
            {
                IRenderable renderable = GenerateRenderable(renderableElement, parent);

                if (renderable != null)
                {
                    string name;

                    XAttribute nameAttrib = renderableElement.Attribute("name");
                    if (nameAttrib != null)
                    {
                        name = nameAttrib.Value;
                    }
                    else
                    {
                        name = i.ToString(CultureInfo.InvariantCulture);
                    }

                    renderables.Add(name, renderable);

                    i++;
                }
            }

            return(renderables);
        }