コード例 #1
0
        /// <see cref="ObjectPlacementView.GetObjectRelativeQuadRectangles"/>
        protected override RCSet <Tuple <RCIntRectangle, SpriteRenderInfo[]> > GetObjectRelativeQuadRectangles()
        {
            SpriteRenderInfo[] objectSprites = new SpriteRenderInfo[0];
            if (this.previewAnimation != null)
            {
                objectSprites = new SpriteRenderInfo[this.previewAnimation.CurrentFrame.Length];
                for (int i = 0; i < objectSprites.Length; i++)
                {
                    objectSprites[i] = new SpriteRenderInfo()
                    {
                        SpriteGroup   = SpriteGroupEnum.MapObjectSpriteGroup,
                        Index         = this.objectType.SpritePalette.Index,
                        DisplayCoords = this.objectType.SpritePalette.GetOffset(this.previewAnimation.CurrentFrame[i]),
                        Section       = this.objectType.SpritePalette.GetSection(this.previewAnimation.CurrentFrame[i])
                    };
                }
            }

            RCIntVector objectQuadSize = this.Scenario.Map.CellToQuadSize(this.objectType.Area.Read().Size);

            return(new RCSet <Tuple <RCIntRectangle, SpriteRenderInfo[]> >
            {
                Tuple.Create(new RCIntRectangle(-1 * objectQuadSize / 2, objectQuadSize), objectSprites)
            });
        }
コード例 #2
0
        /// <see cref="UIObject.Render_i"/>
        protected override void Render_i(IUIRenderContext renderContext)
        {
            CommandButtonStateEnum buttonState = this.commandPanelView.GetCmdButtonState(this.slotCoords);

            if (buttonState == CommandButtonStateEnum.Invisible)
            {
                return;
            }
            if (!this.commandButtonSprites.ContainsKey(buttonState))
            {
                return;
            }

            SpriteRenderInfo renderedSprite = this.commandPanelView.GetCmdButtonSprite(this.slotCoords);

            renderContext.RenderSprite(this.commandButtonSprites[buttonState][renderedSprite.Index],
                                       renderedSprite.DisplayCoords,
                                       renderedSprite.Section);
        }
コード例 #3
0
        /// <see cref="UIObject.Render_i"/>
        protected override void Render_i(IUIRenderContext renderContext)
        {
            /// Check if this button has to be even rendered.
            if (this.layoutIndex >= this.productionDetailsView.ProductionLineCapacity)
            {
                return;
            }

            /// If there is a production item belonging to this button, then we have to render its icon.
            if (this.layoutIndex < this.productionDetailsView.ProductionLineItemCount)
            {
                SpriteRenderInfo itemIcon = this.productionDetailsView.GetProductionJobIcon(this.layoutIndex);
                renderContext.RenderSprite(this.productIconSprites[itemIcon.Index],
                                           itemIcon.DisplayCoords,
                                           itemIcon.Section);
            }

            /// Render the button sprite.
            renderContext.RenderSprite(this.productionButtonSprite, new RCIntVector(0, 0));
        }
コード例 #4
0
        /// <see cref="UIObject.Render_i"/>
        protected override void Render_i(IUIRenderContext renderContext)
        {
            if (this.layoutIndex >= this.selectionDetailsView.SelectionCount)
            {
                return;
            }

            int objectID = this.selectionDetailsView.GetObjectID(this.layoutIndex);
            MapObjectConditionEnum hpCondition = this.mapObjectDetailsView.GetHPCondition(objectID);

            if (!this.hpIndicatorSprites.ContainsKey(hpCondition))
            {
                return;
            }

            SpriteRenderInfo hpSprite = this.mapObjectDetailsView.GetSmallHPIcon(objectID);

            renderContext.RenderSprite(this.hpIndicatorSprites[hpCondition][hpSprite.Index],
                                       hpSprite.DisplayCoords,
                                       hpSprite.Section);
        }
コード例 #5
0
 /// <see cref="RCMapDisplayExtension.RenderEx_i"/>
 protected override void RenderEx_i(IUIRenderContext renderContext)
 {
     foreach (Tuple <SpriteRenderInfo, PlayerEnum> renderItem in this.mapObjectView.GetVisibleMapObjectSprites())
     {
         SpriteRenderInfo mapObjectSpriteRenderInfo = renderItem.Item1;
         PlayerEnum       ownerPlayer = renderItem.Item2;
         if (mapObjectSpriteRenderInfo.SpriteGroup == SpriteGroupEnum.MapObjectSpriteGroup)
         {
             SpriteGroup spriteGroup = this.GetMapObjectSprites(ownerPlayer);
             renderContext.RenderSprite(spriteGroup[mapObjectSpriteRenderInfo.Index],
                                        mapObjectSpriteRenderInfo.DisplayCoords,
                                        mapObjectSpriteRenderInfo.Section);
         }
         else if (mapObjectSpriteRenderInfo.SpriteGroup == SpriteGroupEnum.MapObjectShadowSpriteGroup)
         {
             renderContext.RenderSprite(this.shadowSprites[mapObjectSpriteRenderInfo.Index],
                                        mapObjectSpriteRenderInfo.DisplayCoords,
                                        mapObjectSpriteRenderInfo.Section);
         }
     }
 }
コード例 #6
0
 public void SetSprite(SpriteRenderInfo spriteInfo)
 {
     renderer.sprite = spriteInfo.sprite;
 }
コード例 #7
0
        /// <see cref="UIObject.Render_i"/>
        protected sealed override void Render_i(IUIRenderContext renderContext)
        {
            base.Render_i(renderContext);

            /// Check if we are online and in single selection mode.
            if (this.ConnectionStatus != ConnectionStatusEnum.Online)
            {
                return;
            }
            if (this.selectionDetailsView.SelectionCount != 1)
            {
                return;
            }

            /// Retrieve the ID and the HP condition of the object.
            int mapObjectID = this.selectionDetailsView.GetObjectID(0);
            MapObjectConditionEnum hpCondition = this.mapObjectDetailsView.GetHPCondition(mapObjectID);

            if (!this.hpIndicatorSprites.ContainsKey(hpCondition))
            {
                return;
            }

            /// Render the big icon of the selected object.
            SpriteRenderInfo hpSprite = this.mapObjectDetailsView.GetBigHPIcon(mapObjectID);

            renderContext.RenderSprite(this.hpIndicatorSprites[hpCondition][hpSprite.Index],
                                       RCDetailsPanel.ICON_POS + hpSprite.DisplayCoords,
                                       hpSprite.Section);

            /// Render the typename of the selected object.
            UIString    typeTextToRender  = this.objectTypeTexts[this.mapObjectDetailsView.GetObjectTypeID(mapObjectID)];
            RCIntVector typeNameStringPos = TYPENAME_STRING_MIDDLE_POS - new RCIntVector(typeTextToRender.Width / 2, 0);

            renderContext.RenderString(typeTextToRender, typeNameStringPos);

            /// Render the HP of the selected object.
            int currentHP = this.mapObjectDetailsView.GetCurrentHP(mapObjectID);

            if (currentHP != -1)
            {
                int      maxHP          = this.mapObjectDetailsView.GetMaxHP(mapObjectID);
                UIString hpTextToRender = this.hpTexts[hpCondition];
                hpTextToRender[0] = currentHP;
                hpTextToRender[1] = maxHP;

                RCIntVector hpStringPos = HP_STRING_MIDDLE_POS - new RCIntVector(hpTextToRender.Width / 2, 0);
                renderContext.RenderString(hpTextToRender, hpStringPos);
            }

            /// Render the energy of the selected object.
            int currentEnergy = this.mapObjectDetailsView.GetCurrentEnergy(mapObjectID);

            if (currentEnergy != -1)
            {
                int maxEnergy = this.mapObjectDetailsView.GetMaxEnergy(mapObjectID);
                this.energyText[0] = currentEnergy;
                this.energyText[1] = maxEnergy;

                RCIntVector energyStringPos = ENERGY_STRING_MIDDLE_POS - new RCIntVector(this.energyText.Width / 2, 0);
                renderContext.RenderString(this.energyText, energyStringPos);
            }
        }
コード例 #8
0
        /// <see cref="ObjectPlacementView.GetObjectRelativeQuadRectangles"/>
        protected override RCSet <Tuple <RCIntRectangle, SpriteRenderInfo[]> > GetObjectRelativeQuadRectangles()
        {
            this.UpdatePlacementData();

            RCSet <Tuple <RCIntRectangle, SpriteRenderInfo[]> > retList = new RCSet <Tuple <RCIntRectangle, SpriteRenderInfo[]> >();

            IBuildingType buildingType = this.buildingToBePlaced != null
                ? this.buildingToBePlaced.BuildingType
                : this.buildingTypeToBePlaced;

            if (buildingType == null)
            {
                return(retList);
            }

            /// Calculate the building rectangle and get sprites from the building preview animation if exists.
            RCIntVector    buildingQuadSize     = this.Scenario.Map.CellToQuadSize(buildingType.Area.Read().Size);
            RCIntRectangle buildingRelativeRect = new RCIntRectangle((-1) * buildingQuadSize / 2, buildingQuadSize);

            SpriteRenderInfo[] buildingSprites = new SpriteRenderInfo[0];
            if (this.buildingPreviewAnimation != null)
            {
                buildingSprites = new SpriteRenderInfo[this.buildingPreviewAnimation.CurrentFrame.Length];
                for (int i = 0; i < this.buildingPreviewAnimation.CurrentFrame.Length; i++)
                {
                    buildingSprites[i] = new SpriteRenderInfo()
                    {
                        SpriteGroup   = SpriteGroupEnum.MapObjectSpriteGroup,
                        Index         = buildingType.SpritePalette.Index,
                        DisplayCoords = buildingType.SpritePalette.GetOffset(this.buildingPreviewAnimation.CurrentFrame[i]),
                        Section       = buildingType.SpritePalette.GetSection(this.buildingPreviewAnimation.CurrentFrame[i])
                    };
                }
            }
            retList.Add(Tuple.Create(buildingRelativeRect, buildingSprites));

            if (this.addonTypeToBePlaced != null)
            {
                /// Calculate the addon rectangle and get sprites from the addon preview animation if exists.
                RCIntVector    addonQuadSize     = this.Scenario.Map.CellToQuadSize(this.addonTypeToBePlaced.Area.Read().Size);
                RCIntRectangle addonRelativeRect = new RCIntRectangle(
                    buildingRelativeRect.Location +
                    buildingType.GetRelativeAddonPosition(this.Scenario.Map, this.addonTypeToBePlaced),
                    addonQuadSize);
                SpriteRenderInfo[] addonSprites = new SpriteRenderInfo[0];
                if (this.addonPreviewAnimation != null)
                {
                    addonSprites = new SpriteRenderInfo[this.addonPreviewAnimation.CurrentFrame.Length];
                    for (int i = 0; i < this.addonPreviewAnimation.CurrentFrame.Length; i++)
                    {
                        addonSprites[i] = new SpriteRenderInfo()
                        {
                            SpriteGroup   = SpriteGroupEnum.MapObjectSpriteGroup,
                            Index         = this.addonTypeToBePlaced.SpritePalette.Index,
                            DisplayCoords = this.addonTypeToBePlaced.SpritePalette.GetOffset(this.addonPreviewAnimation.CurrentFrame[i]),
                            Section       = this.addonTypeToBePlaced.SpritePalette.GetSection(this.addonPreviewAnimation.CurrentFrame[i])
                        };
                    }
                }
                retList.Add(Tuple.Create(addonRelativeRect, addonSprites));
            }
            return(retList);
        }