Beispiel #1
0
        private static void DrawItems(Tile tile, Rectangle target)
        {
            Item tileItem = tile.MainObject as Item;

            if (tileItem != null)
            {
                ComponentHasTexture itemVisual = tileItem.GetExactComponent <ComponentHasTexture>();

                Point2D topLeft = new Point2D(0, 0);
                int     length  = itemVisual.Visuals.Count;
                for (int i = 0; i < length; i++)
                {
                    AbstractVisual visual = itemVisual.Visuals[i];
                    topLeft.X = target.X;
                    topLeft.Y = target.Y;
                    visual.Render(MapDrawer, topLeft);
                }

                ItemCountBounds.X = target.Location.X + (TileSize.X / 2);
                ItemCountBounds.Y = target.Location.Y + TileSize.Y;

                MapDrawer.DrawText(tileItem.CurrentlyStacked.ToString(), ItemCountBounds,
                                   ItemCountFont, SimpleTextRenderer.Alignment.Left, RenderLayer.MapItemCount);
            }
        }
Beispiel #2
0
        private void InitializeComponents()
        {
            ComponentHasTexture textureComponent = this.GetExactComponent <ComponentHasTexture>();

            textureComponent.Visuals.Add(OffsetTrunk);
            textureComponent.Visuals.Add(OffsetLeaves);
            textureComponent.Visuals.Add(OffsetStump);
        }
Beispiel #3
0
        /// <param name="visual">The visual representation of this floor to render.</param>
        /// <param name="walkable">If true it is possible to walk on this tile.</param>
        public Ceiling(AbstractVisual visual, bool walkable)
        {
            ComponentHasTexture textureComponent = new ComponentHasTexture(false);

            textureComponent.Visuals.Add(visual);
            this.AddComponent(textureComponent);
            this.Walkable = walkable;
        }
Beispiel #4
0
        /// <param name="visual">The visual representation of this floor to render.</param>
        /// <param name="walkable">If true it is possible to walk on this tile.</param>
        public Floor(AbstractVisual visual, bool walkable)
            : base(true)
        {
            ComponentHasTexture textureComponent = new ComponentHasTexture(false);

            textureComponent.Visuals.Add(visual);
            this.AddComponent(textureComponent);
            this.Walkable = walkable;
        }
Beispiel #5
0
        private void InitializeComponents()
        {
            int textureIndex = AssetManager.GetTextureIndex(this.TextureName);

            ComponentHasTexture textureComponent = new ComponentHasTexture(false);

            textureComponent.Visuals.Add(new StaticTexture(textureIndex, RenderLayer.Items));

            this.AddComponent(new ComponentHasTexture(false));
        }
Beispiel #6
0
        /// <param name="durability"></param>
        /// <param name="isWalkable"></param>
        /// <param name="visual"></param>
        /// <param name="partID">A constant ID utilized to identify this part of a structure across all games and saves.</param>
        /// <param name="uniqueStructureID">The unique ID of the structure this part belongs to.</param>
        public StructurePart(int durability, bool isWalkable, AbstractVisual visual, Guid partID, Guid uniqueStructureID)
            : base(false)
        {
            this.PartID            = partID;
            this.Durability        = durability;
            this.Walkable          = isWalkable;
            this.UniqueStructureID = uniqueStructureID;

            ComponentHasTexture textureComponent = new ComponentHasTexture(false);

            textureComponent.Visuals.Add(visual);
            this.AddComponent(textureComponent);
        }
Beispiel #7
0
        /// <summary>
        /// Swaps the old visuals with the new.
        /// Can handle null inputs.
        /// </summary>
        /// <param name="oldVisual">Should have a <see cref="ComponentHasTexture"/> component.</param>
        /// <param name="newVisual">Should have a <see cref="ComponentHasTexture"/> component.</param>
        private void UpdateVisuals(HasComponents oldVisual, HasComponents newVisual)
        {
            ComponentRenderer renderComponent = this.GetExactComponent <ComponentRenderer>();

            if (oldVisual != null)
            {
                //Remove old visuals
                ComponentHasTexture oldTextureComponent = oldVisual.GetExactComponent <ComponentHasTexture>();
                renderComponent.RemoveVisuals(oldTextureComponent.Visuals);
            }

            if (newVisual != null)
            {
                //Add new visuals
                ComponentHasTexture newTextureComponent = newVisual.GetExactComponent <ComponentHasTexture>();
                renderComponent.AddVisuals(newTextureComponent.Visuals);
            }
        }
Beispiel #8
0
        public Corn(string name, int durability, ComponentHarvestable harvestBehavior)
            : base(Name, durability, harvestBehavior, true)
        {
            // Determine corn yield
            Random random    = new Random();
            int    cornYield = random.Next(MinimumCornYield, MaximumCornYield);

            this.Durability = DefaultCornDurability;

            // initialize harvesting list
            List <Base.Item> list = new List <Base.Item>
            {
                new CornEar(cornYield)
            };

            this.AddComponent(new DropWhenCompletelyHarvested(list, SoundsTable.TreeFall, SoundsTable.TreeFall));

            ComponentHasTexture textureComponent = this.GetExactComponent <ComponentHasTexture>();

            textureComponent.Visuals.Add(CornSeedling);
            textureComponent.Visuals.Add(CornGrowth1);
            textureComponent.Visuals.Add(CornGrowth2);
            textureComponent.Visuals.Add(CornFullGrowth);
        }
Beispiel #9
0
        private void InitializeComponents()
        {
            ComponentHasTexture visualComponent = this.GetExactComponent <ComponentHasTexture>();

            visualComponent.Visuals.Add(new StaticTexture(AssetManager.NameToIndex[TextureLoader.LogTexture1], RenderLayer.Items));
        }
Beispiel #10
0
        private void InitializeComponents()
        {
            ComponentHasTexture visuals = this.GetExactComponent <ComponentHasTexture>();

            visuals.Visuals.Add(new StaticTexture(AssetManager.NameToIndex[this.GetRandomStoneRubbleTexture()], RenderLayer.Items));
        }