public MySensitiveObject(RCIntVector position, RCIntRectangle range, string name, RCColor basicColor, RCColor highColor) : base(position, range) { this.nameStrBasic = new UIString(name, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6"), new RCIntVector(2, 2), RCColor.WhiteHigh); this.nameStrHigh = new UIString(name, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6"), new RCIntVector(2, 2), RCColor.LightRed); this.backgroundBasic = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(basicColor, this.Range.Size, new RCIntVector(2, 2)); this.backgroundHigh = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(highColor, this.Range.Size, new RCIntVector(2, 2)); this.backgroundBasic.Upload(); this.backgroundHigh.Upload(); this.name = name; this.isHighlighted = false; this.activatorBtn = UIMouseButton.Undefined; this.MouseSensor.Enter += this.OnEnter; this.MouseSensor.Leave += this.OnLeave; this.MouseSensor.ButtonDown += this.OnButtonDown; this.MouseSensor.ButtonUp += this.OnButtonUp; this.MouseSensor.Wheel += this.OnWheel; this.MouseSensor.Move += this.OnMove; }
/// <summary> /// Tries to align the minimap vertically. /// </summary> /// <param name="minimapControlPixelSize">The size of the minimap control in pixels.</param> /// <param name="mapCellSize">The size of the map in cells.</param> /// <param name="minimapPosition">The position of the minimap on the minimap control in pixels.</param> /// <param name="transformation">The transformation between the map (A) and minimap (B) coordinate-systems.</param> /// <returns>True if the alignment was successfully; otherwise false.</returns> private static bool TryAlignMinimapVertically( RCIntVector minimapControlPixelSize, RCIntVector mapCellSize, out RCIntRectangle minimapPosition, out RCCoordTransformation transformation) { RCNumber vertAlignedMinimapWidth = (RCNumber)(minimapControlPixelSize.Y * mapCellSize.X) / (RCNumber)mapCellSize.Y; if (vertAlignedMinimapWidth > minimapControlPixelSize.X) { /// Cannot align vertically. minimapPosition = RCIntRectangle.Undefined; transformation = null; return(false); } /// Align vertically int minimapPixelWidth = vertAlignedMinimapWidth > (int)vertAlignedMinimapWidth ? (int)vertAlignedMinimapWidth + 1 : (int)vertAlignedMinimapWidth; minimapPosition = new RCIntRectangle((minimapControlPixelSize.X - minimapPixelWidth) / 2, 0, minimapPixelWidth, minimapControlPixelSize.Y); /// Create the coordinate transformation RCNumVector pixelSizeOnMap = new RCNumVector((RCNumber)mapCellSize.Y / (RCNumber)minimapControlPixelSize.Y, (RCNumber)mapCellSize.Y / (RCNumber)minimapControlPixelSize.Y); RCNumVector nullVectorOfMinimap = (pixelSizeOnMap / 2) - (new RCNumVector(1, 1) / 2); RCNumVector baseVectorOfMinimapX = new RCNumVector(pixelSizeOnMap.X, 0); RCNumVector baseVectorOfMinimapY = new RCNumVector(0, pixelSizeOnMap.Y); transformation = new RCCoordTransformation(nullVectorOfMinimap, baseVectorOfMinimapX, baseVectorOfMinimapY); return(true); }
/// <see cref="IUIRenderContext.RenderSprite"/> public void RenderSprite(UISprite sprite, RCIntVector position, RCIntRectangle section) { if (section == RCIntRectangle.Undefined) { this.RenderSprite(sprite, position); return; } if (this.objectDisposed) { throw new ObjectDisposedException("UIRenderLoopBase"); } if (!this.isRendering) { throw new UIException("Access denied on screen render context!"); } if (sprite == null) { throw new ArgumentNullException("sprite"); } if (position == RCIntVector.Undefined) { throw new ArgumentNullException("position"); } this.RenderSprite_i(sprite, position, section); }
/// <see cref="IFogOfWarBC.GetPlacementSuggestions"/> public RCSet <RCIntRectangle> GetPlacementSuggestions(IBuildingType buildingType) { if (this.ActiveScenario == null) { throw new InvalidOperationException("No active scenario!"); } RCIntRectangle quadWindow = this.mapWindowBC.AttachedWindow.QuadTileWindow; RCSet <Tuple <RCIntRectangle, RCIntVector> > suggestions = buildingType.GetPlacementSuggestions(this.ActiveScenario, quadWindow); RCSet <RCIntRectangle> retList = new RCSet <RCIntRectangle>(); foreach (Tuple <RCIntRectangle, RCIntVector> suggestion in suggestions) { RCIntRectangle areaToCheck = suggestion.Item1; RCIntVector suggestionTranslation = suggestion.Item2; for (int x = areaToCheck.Left; x < areaToCheck.Right; x++) { for (int y = areaToCheck.Top; y < areaToCheck.Bottom; y++) { RCIntVector quadCoordToCheck = new RCIntVector(x, y); if (quadCoordToCheck.X >= 0 && quadCoordToCheck.X < this.ActiveScenario.Map.Size.X && quadCoordToCheck.Y >= 0 && quadCoordToCheck.Y < this.ActiveScenario.Map.Size.Y && this.GetFowState(quadCoordToCheck) == FOWTypeEnum.None) { RCIntVector buildingQuadSize = this.ActiveScenario.Map.CellToQuadSize(buildingType.Area.Read().Size); retList.Add(new RCIntRectangle(areaToCheck.Location + suggestionTranslation, buildingQuadSize)); } } } } return(retList); }
/// <see cref="IFogOfWarBC.GetEntitySnapshotsInWindow"/> public IEnumerable <EntitySnapshot> GetEntitySnapshotsInWindow(RCIntRectangle quadWindow) { if (this.ActiveScenario == null) { throw new InvalidOperationException("No active scenario!"); } if (this.runningFowsCount == 0) { yield break; } for (int column = quadWindow.Left; column < quadWindow.Right; column++) { for (int row = quadWindow.Top; row < quadWindow.Bottom; row++) { RCIntVector quadCoords = new RCIntVector(column, row); /// If the FOW is full at the current quadratic tile -> continue with the next. FOWTypeEnum fowAtQuadTile = this.fowCacheMatrix.GetFowStateAtQuadTile(quadCoords); if (fowAtQuadTile == FOWTypeEnum.Full) { continue; } /// Add the entity snapshot into the returned list. EntitySnapshot snapshot = this.fowCacheMatrix.GetEntitySnapshotAtQuadTile(quadCoords); if (snapshot != null) { yield return(snapshot); } } } }
/// <summary> /// Creates an RCGameInfoPanel instance. /// </summary> /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param> /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param> /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param> /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param> /// <param name="appearDuration"> /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case /// of ShowMode.Appear. /// </param> /// <param name="disappearDuration"> /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case /// of HideMode.Disappear. /// </param> /// <param name="backgroundSprite"> /// Name of the sprite resource that will be the background of this panel or null if there is no background. /// </param> public RCGameInfoPanel(RCIntRectangle backgroundRect, RCIntRectangle contentRect, ShowMode showMode, HideMode hideMode, int appearDuration, int disappearDuration, string backgroundSprite) : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration, backgroundSprite) { }
/// <summary> /// Resets this render context before drawing. /// </summary> public void Reset(IUIRenderContext screenContext) { this.screenContext = screenContext; this.screenContext.Clip = RCIntRectangle.Undefined; this.absClipRectCache.Invalidate(); this.clipRectCache.Invalidate(); }
/// <summary> /// Constructs a details panel. /// </summary> /// <param name="productIconSprites">The product icon sprite group.</param> /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param> /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param> /// <param name="backgroundSprite">Name of the sprite resource that will be the background of this panel or null if there is no background.</param> public RCDetailsPanel(ISpriteGroup productIconSprites, RCIntRectangle backgroundRect, RCIntRectangle contentRect, string backgroundSprite) : base(backgroundRect, contentRect, ShowMode.Appear, HideMode.Disappear, 0, 0, backgroundSprite) { if (productIconSprites == null) { throw new ArgumentNullException("productIconSprites"); } this.textFont = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"); this.objectTypeTexts = new Dictionary <int, UIString>(); this.isConnected = false; this.backgroundTask = null; this.hpIndicatorSprites = new Dictionary <MapObjectConditionEnum, SpriteGroup>(); this.productIconSprites = productIconSprites; this.currentCustomContent = null; this.buttonArray = new RCSelectionButton[MAX_SELECTION_SIZE]; this.productionLineDisplay = null; this.constructionProgressDisplay = null; this.supplyDetailsDisplay = null; this.resourceAmountDisplay = null; this.weaponDetailsDisplay = null; this.multiplayerService = null; this.selectionDetailsView = null; this.mapObjectDetailsView = null; this.productionDetailsView = null; this.selectionButtonsAdded = false; this.hpTexts = new Dictionary <MapObjectConditionEnum, UIString>(); this.energyText = null; }
/// <summary> /// Constructs a UIContainer at the given position with the given range. /// </summary> public UIContainer(RCIntVector position, RCIntRectangle range) : base(position, range) { this.controls = new List <UIControl>(); this.areAttached = false; this.areAttachedSensitive = false; }
/// <see cref="IUIRenderContext.RenderRectangle"/> public void RenderRectangle(UISprite brush, RCIntRectangle rect) { if (!this.enabled) { throw new InvalidOperationException("Render context is not enabled!"); } if (brush == null) { throw new ArgumentNullException("brush"); } if (rect == RCIntRectangle.Undefined) { throw new ArgumentNullException("rect"); } /// Render only if target object is not clipped if (this.absClipRectCache.Value != RCIntRectangle.Undefined) { /// Top this.RenderSprite(brush, rect.Location, new RCIntRectangle(0, 0, rect.Width, brush.Size.Y)); /// Right this.RenderSprite(brush, new RCIntVector(rect.Right - brush.Size.X, rect.Top), new RCIntRectangle(0, 0, brush.Size.X, rect.Height)); /// Bottom this.RenderSprite(brush, new RCIntVector(rect.Left, rect.Bottom - brush.Size.Y), new RCIntRectangle(0, 0, rect.Width, brush.Size.Y)); /// Left this.RenderSprite(brush, new RCIntVector(rect.Left, rect.Top), new RCIntRectangle(0, 0, brush.Size.X, rect.Height)); } }
/// <summary> /// Excludes the given area from this TerrainObjectType. This method is only available if the tileset /// has not yet been finalized and constraints/data-changes have not yet been defined. /// </summary> /// <param name="area">The area that won't be part of this TerrainObjectType.</param> public void ExcludeArea(RCIntRectangle area) { if (area == RCIntRectangle.Undefined) { throw new ArgumentNullException("area"); } if (area.X < 0 || area.Y < 0 || area.Right > this.quadraticSize.X || area.Bottom > this.quadraticSize.Y) { throw new ArgumentOutOfRangeException("area", "The excluded area exceeds the borders of the TerrainObjectType!"); } if (this.tileset.IsFinalized) { throw new InvalidOperationException("TileSet already finalized!"); } if (!this.areaCanBeExcluded) { throw new InvalidOperationException("Excluding area is not allowed!"); } for (int x = area.X; x < area.Right; x++) { for (int y = area.Y; y < area.Bottom; y++) { this.includedQuadCoords.Remove(new RCIntVector(x, y)); } } }
/// <summary> /// Do SCV activities during construction. /// </summary> private void MakeScvActivityDuringConstruction() { /// Start using the build tool of the SCV and decrease the move-timer. TerranBuilding constructedBuilding = this.RecipientSCV.ConstructionJob.ConstructedBuilding; if (this.timeToNextScvMoveDuringConstruction.Read() > 0) { if (!this.recipientSCV.Read().MotionControl.IsMoving&& this.recipientSCV.Read().Armour.Target == null) { this.recipientSCV.Read().Armour.StartAttack(constructedBuilding.ID.Read(), SCV.SCV_BUILD_TOOL_NAME); } this.timeToNextScvMoveDuringConstruction.Write(this.timeToNextScvMoveDuringConstruction.Read() - 1); return; } /// Generate a random position inside the building area and move the SCV there. /// TODO: do not use the default random generator because the engine shall be deterministic! RCIntRectangle buildingQuadRect = constructedBuilding.MapObject.QuadraticPosition; RCIntRectangle buildingCellRect = this.Scenario.Map.QuadToCellRect(buildingQuadRect); RCNumVector movePosition = new RCNumVector( RandomService.DefaultGenerator.Next(buildingCellRect.Left, buildingCellRect.Right), RandomService.DefaultGenerator.Next(buildingCellRect.Top, buildingCellRect.Bottom)); this.recipientSCV.Read().MotionControl.StartMoving(movePosition); this.recipientSCV.Read().Armour.StopAttack(); /// Reset the timer. this.timeToNextScvMoveDuringConstruction.Write(TIME_BETWEEN_SCV_MOVES); }
/// <see cref="EntityPlacementConstraint.CheckImpl"/> protected override RCSet <RCIntVector> CheckImpl(Scenario scenario, RCIntVector position, RCSet <Entity> entitiesToIgnore) { RCIntRectangle objArea = new RCIntRectangle(position, scenario.Map.CellToQuadSize(this.EntityType.Area.Read().Size)); RCSet <RCIntVector> retList = new RCSet <RCIntVector>(); VespeneGeyser foundVespeneGeyser = null; bool isOK = true; for (int absY = objArea.Top; absY < objArea.Bottom; absY++) { for (int absX = objArea.Left; absX < objArea.Right; absX++) { RCIntVector absQuadCoords = new RCIntVector(absX, absY); if (absQuadCoords.X >= 0 && absQuadCoords.X < scenario.Map.Size.X && absQuadCoords.Y >= 0 && absQuadCoords.Y < scenario.Map.Size.Y) { retList.Add(absQuadCoords - position); VespeneGeyser vespeneGeyserAtCoords = scenario.GetFixedEntity <VespeneGeyser>(absQuadCoords); if (vespeneGeyserAtCoords == null || (foundVespeneGeyser != null && foundVespeneGeyser != vespeneGeyserAtCoords)) { /// There is no VespeneGeyser at the given coordinates OR /// the VespeneGeyser at the given coordinates is another VespeneGeyser. isOK = false; continue; } foundVespeneGeyser = vespeneGeyserAtCoords; } } } if (isOK) { retList.Clear(); } return(retList); }
/// <summary> /// Tries to align the minimap horizontally. /// </summary> /// <param name="minimapControlPixelSize">The size of the minimap control in pixels.</param> /// <param name="mapCellSize">The size of the map in cells.</param> /// <param name="minimapPosition">The position of the minimap on the minimap control in pixels.</param> /// <param name="transformation">The transformation between the map (A) and minimap (B) coordinate-systems.</param> /// <returns>True if the alignment was successfully; otherwise false.</returns> private static bool TryAlignMinimapHorizontally( RCIntVector minimapControlPixelSize, RCIntVector mapCellSize, out RCIntRectangle minimapPosition, out RCCoordTransformation transformation) { RCNumber horzAlignedMinimapHeight = (RCNumber)(minimapControlPixelSize.X * mapCellSize.Y) / (RCNumber)mapCellSize.X; if (horzAlignedMinimapHeight > minimapControlPixelSize.Y) { /// Cannot align horizontally. minimapPosition = RCIntRectangle.Undefined; transformation = null; return(false); } /// Align horizontally int minimapPixelHeight = horzAlignedMinimapHeight > (int)horzAlignedMinimapHeight ? (int)horzAlignedMinimapHeight + 1 : (int)horzAlignedMinimapHeight; minimapPosition = new RCIntRectangle(0, (minimapControlPixelSize.Y - minimapPixelHeight) / 2, minimapControlPixelSize.X, minimapPixelHeight); /// Create the coordinate transformation RCNumVector pixelSizeOnMap = new RCNumVector((RCNumber)mapCellSize.X / (RCNumber)minimapControlPixelSize.X, (RCNumber)mapCellSize.X / (RCNumber)minimapControlPixelSize.X); RCNumVector nullVectorOfMinimap = (pixelSizeOnMap / 2) - (new RCNumVector(1, 1) / 2); RCNumVector baseVectorOfMinimapX = new RCNumVector(pixelSizeOnMap.X, 0); RCNumVector baseVectorOfMinimapY = new RCNumVector(0, pixelSizeOnMap.Y); transformation = new RCCoordTransformation(nullVectorOfMinimap, baseVectorOfMinimapX, baseVectorOfMinimapY); return(true); }
/// <see cref="IUIRenderContext.RenderSprite"/> public void RenderSprite(UISprite sprite, RCIntVector position, RCIntRectangle section) { if (section == RCIntRectangle.Undefined) { this.RenderSprite(sprite, position); return; } if (!this.enabled) { throw new InvalidOperationException("Render context is not enabled!"); } if (sprite == null) { throw new ArgumentNullException("sprite"); } if (position == RCIntVector.Undefined) { throw new ArgumentNullException("position"); } if (sprite.PixelSize != this.targetObject.AbsolutePixelScaling) { throw new InvalidOperationException("Incompatible pixel size!"); } /// Render only if target object is not clipped if (this.absClipRectCache.Value != RCIntRectangle.Undefined) { this.screenContext.Clip = this.absClipRectCache.Value; RCIntVector absolutePos = this.targetObject.AbsolutePosition + position * this.targetObject.AbsolutePixelScaling; this.screenContext.RenderSprite(sprite, absolutePos, section); } }
/// <summary> /// Constructs a UIObject instance. /// </summary> /// <param name="pixelScaling">The pixel scaling value of this UIObject relative to it's parent.</param> /// <param name="position">The position of this UIObject relative to it's parent.</param> /// <param name="range">The range rectangle of this UIObject in it's local coordinate-system.</param> public UIObject(RCIntVector pixelScaling, RCIntVector position, RCIntRectangle range) { if (pixelScaling == RCIntVector.Undefined) { throw new ArgumentNullException("pixelScaling"); } if (pixelScaling.X <= 0 || pixelScaling.Y <= 0) { throw new ArgumentOutOfRangeException("pixelScaling"); } if (range == RCIntRectangle.Undefined) { throw new ArgumentNullException("range"); } if (position == RCIntVector.Undefined) { throw new ArgumentNullException("position"); } this.parent = null; this.children = new List <UIObject>(); this.childrenSet = new RCSet <UIObject>(); this.position = position; this.absPositionCache = new CachedValue <RCIntVector>(this.ComputeAbsolutePosition); this.clip = RCIntRectangle.Undefined; this.absClipCache = new CachedValue <RCIntRectangle>(this.ComputeAbsoluteClip); this.cloak = RCIntRectangle.Undefined; this.absCloakCache = new CachedValue <RCIntRectangle>(this.ComputeAbsoluteCloak); this.range = range; this.absRangeCache = new CachedValue <RCIntRectangle>(this.ComputeAbsoluteRange); this.pixelScaling = pixelScaling; this.absPixelScalingCache = new CachedValue <RCIntVector>(this.ComputeAbsolutePixelScaling); }
/// <summary> /// Creates an RCMapEditorPanel instance. /// </summary> /// <param name="isoTileSpriteGroup">Reference to the sprites of the isometric tile types.</param> /// <param name="terrainObjectSpriteGroup">Reference to the sprites of the terrain object types.</param> /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param> /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param> /// <param name="backgroundSprite"> /// Name of the sprite resource that will be the background of this panel or null if there is no background. /// </param> public RCMapEditorPanel(ISpriteGroup isoTileSpriteGroup, ISpriteGroup terrainObjectSpriteGroup, RCIntRectangle backgroundRect, RCIntRectangle contentRect, ShowMode showMode, HideMode hideMode, int appearDuration, int disappearDuration, string backgroundSprite) : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration, backgroundSprite) { this.tilesetView = ComponentManager.GetInterface <IViewService>().CreateView <ITileSetView>(); /// Create the controls. this.editModeSelector = new RCDropdownSelector(new RCIntVector(6, 6), 85, new string[4] { "Draw terrain", "Place terrain object", "Place start location", "Place resource" }); this.paletteListbox = new RCListBox(new RCIntVector(6, 24), 85, 11, 100); this.saveButton = new RCMenuButton("Save", new RCIntRectangle(6, 180, 41, 15)); this.exitButton = new RCMenuButton("Exit", new RCIntRectangle(50, 180, 41, 15)); this.minimapDisplay = new RCMinimapDisplay(isoTileSpriteGroup, terrainObjectSpriteGroup, new RCIntVector(16, 209), new RCIntVector(64, 64)); this.editModeSelector.SelectedIndexChanged += this.OnEditModeSelectionChanged; this.paletteListbox.SelectedIndexChanged += this.OnPaletteListboxSelectionChanged; this.AddControl(this.editModeSelector); this.AddControl(this.paletteListbox); this.AddControl(this.saveButton); this.AddControl(this.exitButton); this.AddControl(this.minimapDisplay); this.ResetControls(); }
/// <see cref="EntityPlacementConstraint.CheckImpl"/> protected override RCSet <RCIntVector> CheckImpl(Scenario scenario, RCIntVector position, RCSet <Entity> entitiesToIgnore) { RCIntRectangle objArea = new RCIntRectangle(position, scenario.Map.CellToQuadSize(this.EntityType.Area.Read().Size)); RCSet <RCIntVector> retList = new RCSet <RCIntVector>(); for (int absY = objArea.Top; absY < objArea.Bottom; absY++) { for (int absX = objArea.Left; absX < objArea.Right; absX++) { RCIntVector absQuadCoords = new RCIntVector(absX, absY); if (absQuadCoords.X >= 0 && absQuadCoords.X < scenario.Map.Size.X && absQuadCoords.Y >= 0 && absQuadCoords.Y < scenario.Map.Size.Y) { /// Collect all the entities that are on the ground, are too close and not to be ignored. RCIntRectangle checkedQuadRect = new RCIntRectangle(absQuadCoords - this.minimumDistance, this.checkedQuadRectSize); RCNumRectangle checkedArea = (RCNumRectangle)scenario.Map.QuadToCellRect(checkedQuadRect) - new RCNumVector(1, 1) / 2; RCSet <T> entitiesTooClose = scenario.GetElementsOnMap <T>(checkedArea, MapObjectLayerEnum.GroundObjects); if (entitiesTooClose.Any(entityTooClose => !entitiesToIgnore.Contains(entityTooClose))) { retList.Add(absQuadCoords - position); } } } } return(retList); }
/// <summary> /// Adds a sprite to this sprite palette. /// </summary> /// <param name="name">The name of the sprite to add.</param> /// <param name="variant">The variant of the sprite to add.</param> /// <param name="sourceRegion">The source region of the sprite to add.</param> /// <param name="offset">The offset of the sprite to add.</param> internal void AddSprite(string name, TVariant variant, RCIntRectangle sourceRegion, RCIntVector offset) { if (name == null) { throw new ArgumentNullException("name"); } if (sourceRegion == RCIntRectangle.Undefined) { throw new ArgumentNullException("sourceRegion"); } if (offset == RCIntVector.Undefined) { throw new ArgumentNullException("offset"); } if (this.indexTable.ContainsKey(name) && this.indexTable[name].ContainsKey(variant)) { throw new InvalidOperationException(string.Format("Sprite with name '{0}' and variant '{1}' already exists!", name, variant)); } if (!this.indexTable.ContainsKey(name)) { this.indexTable.Add(name, new Dictionary <TVariant, int>()); } this.indexTable[name].Add(variant, this.sourceRegions.Count); this.sourceRegions.Add(sourceRegion); this.offsets.Add(offset); }
/// <summary> /// Collect the shadow sprites of the given map object into the given list. /// </summary> /// <param name="mapObject">The given map object.</param> /// <param name="targetList">The given target list.</param> private void CollectMapObjectShadowSprites(MapObject mapObject, ref List <Tuple <SpriteRenderInfo, PlayerEnum> > targetList) { if (mapObject.ShadowCenter != RCNumVector.Undefined) { /// This map object has a shadow to be rendered -> calculate the display coordinates of the shadow RCIntVector shadowCenterOnDisplay = this.MapWindowBC.AttachedWindow.MapToWindowCoords(mapObject.ShadowCenter); RCIntRectangle shadowSection = this.scenarioManagerBC.Metadata.ShadowPalette.GetSection(mapObject.Owner.ElementType.ShadowSpriteIndex); RCIntVector shadowDisplayCoords = shadowCenterOnDisplay - (shadowSection.Size / 2); /// Ensure that overlapping shadows won't overlie the terrain. if ((shadowDisplayCoords.X + shadowDisplayCoords.Y) % 2 != 0) { shadowDisplayCoords += new RCIntVector(1, 0); } /// Create the sprite render info from the calculated display coordinates. targetList.Add(Tuple.Create(new SpriteRenderInfo() { SpriteGroup = SpriteGroupEnum.MapObjectShadowSpriteGroup, Index = this.scenarioManagerBC.Metadata.ShadowPalette.Index, DisplayCoords = shadowDisplayCoords, Section = shadowSection }, BizLogicHelpers.GetMapObjectLastOwner(mapObject))); } }
/// <summary> /// Converts a rectangle of quadratic tiles to a rectangle of cells. /// </summary> /// <param name="quadRect">The quadratic rectangle to convert.</param> /// <returns>The cell rectangle.</returns> public RCIntRectangle QuadToCellRect(RCIntRectangle quadRect) { if (quadRect == RCIntRectangle.Undefined) { throw new ArgumentNullException("quadRect"); } return(quadRect * new RCIntVector(MapStructure.NAVCELL_PER_QUAD, MapStructure.NAVCELL_PER_QUAD)); }
/// <summary> /// Combine the given FOW-flag into the given target render context from the given source sprite. /// </summary> /// <param name="flag">The FOW-flag to combine into the target render context.</param> /// <param name="spritePaletteImg">The image of the sprite palette.</param> /// <param name="targetRenderCtx">The target render context.</param> private void CombineFowFlag(FOWTileFlagsEnum flag, UISprite spritePaletteImg, IUIRenderContext targetRenderCtx) { int spriteIndex = this.spriteIndices[flag]; RCIntRectangle sourceSection = this.spritePalette.GetSection(spriteIndex); RCIntVector sourceOffset = this.spritePalette.GetOffset(spriteIndex); targetRenderCtx.RenderSprite(spritePaletteImg, sourceOffset, sourceSection); }
/// <summary> /// Constructs an RCMenuButton with the given text. /// </summary> public RCMenuButton(string text, RCIntRectangle buttonRect) : base(buttonRect.Location, buttonRect.Size) { this.menuButtonFont = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font9B"); this.normalText = new UIString(text, this.menuButtonFont, UIWorkspace.Instance.PixelScaling, new RCColor(220, 220, 220)); this.highlightedText = new UIString(text, this.menuButtonFont, UIWorkspace.Instance.PixelScaling, RCColor.White); this.textPosition = new RCIntVector((this.Range.Width - this.normalText.Width) / 2, (this.Range.Height - (this.menuButtonFont.CharBottomMaximum + this.menuButtonFont.CharTopMaximum + 1)) / 2 + this.menuButtonFont.CharTopMaximum); }
/// <summary> /// Creates an RCNavButtonPanel instance. /// </summary> /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param> /// <param name="buttonRect">The area of the button on the panel relative to the background rectangle.</param> /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param> /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param> /// <param name="appearDuration"> /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case /// of ShowMode.Appear. /// </param> /// <param name="disappearDuration"> /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case /// of HideMode.Disappear. /// </param> /// <param name="backgroundSprite"> /// Name of the sprite resource that will be the background of this panel or null if there is no background. /// </param> /// <param name="buttonText">The text that should be displayed on the navigation button.</param> public RCNavButtonPanel(RCIntRectangle backgroundRect, RCIntRectangle buttonRect, ShowMode showMode, HideMode hideMode, int appearDuration, int disappearDuration, string backgroundSprite, string buttonText) : base(backgroundRect, buttonRect, showMode, hideMode, appearDuration, disappearDuration, backgroundSprite) { this.navigationButton = new RCMenuButton(buttonText, this.Clip); this.AddControl(this.navigationButton); }
/// <summary> /// Creates an RCAppPanel instance. /// </summary> /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param> /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param> /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param> /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param> /// <param name="appearDuration"> /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case /// of ShowMode.Appear. /// </param> /// <param name="disappearDuration"> /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case /// of HideMode.Disappear. /// </param> /// <param name="backgroundSprite"> /// Name of the sprite resource that will be the background of this panel or null if there is no background. /// </param> /// <remarks> /// The backgroundRect shall entirely contain the contentRect. /// The origin of the panel's coordinate system will be the top-left corner of contentRect. /// The range rectangle of the panel will be backgroundRect relative to contentRect. /// The clip rectangle of the panel will be contentRect in the panel's coordinate system. /// </remarks> public RCAppPanel(RCIntRectangle backgroundRect, RCIntRectangle contentRect, ShowMode showMode, HideMode hideMode, int appearDuration, int disappearDuration, string backgroundSprite) : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration) { this.StatusChanged += this.OnPanelStatusChanged; this.background = backgroundSprite != null?UIResourceManager.GetResource <UISprite>(backgroundSprite) : null; }
/// <see cref="ISelectionService.AddToSelection"/> public void AddToSelection(RCIntRectangle selectionBox) { if (this.scenarioManager.ActiveScenario == null) { throw new InvalidOperationException("No active scenario!"); } this.selectionManager.AddEntitiesToSelection(this.mapWindowBC.AttachedWindow.WindowToMapRect(selectionBox)); }
/// <summary> /// Creates an RCSelectMapPanel instance. /// </summary> /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param> /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param> /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param> /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param> /// <param name="appearDuration"> /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case /// of ShowMode.Appear. /// </param> /// <param name="disappearDuration"> /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case /// of HideMode.Disappear. /// </param> /// <param name="backgroundSprite"> /// Name of the sprite resource that will be the background of this panel or null if there is no background. /// </param> public RCSelectMapPanel(RCIntRectangle backgroundRect, RCIntRectangle contentRect, ShowMode showMode, HideMode hideMode, int appearDuration, int disappearDuration, string backgroundSprite) : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration, backgroundSprite) { this.selectMapTitle = new UIString(SELECT_MAP_TITLE, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font9B"), UIWorkspace.Instance.PixelScaling, RCColor.LightBlue); }
/// <see cref="IUIRenderContext.RenderRectangle"/> public void RenderRectangle(UISprite brush, RCIntRectangle rect) { if (this.isClosed) { throw new UIException("Render context unavailable!"); } throw new NotImplementedException(); // TODO: implement this method }
/// <summary> /// RightLeftBottomUp scan-method implementation. /// </summary> public static IEnumerable<RCIntVector> RightLeftBottomUpScan(RCIntRectangle area) { for (int row = area.Bottom - 1; row >= area.Top; row--) { for (int col = area.Right - 1; col >= area.Left; col--) { yield return new RCIntVector(col, row); } } }
/// <summary> /// TopDownRightLeft scan-method implementation. /// </summary> public static IEnumerable<RCIntVector> TopDownRightLeftScan(RCIntRectangle area) { for (int col = area.Right - 1; col >= area.Left; col--) { for (int row = area.Top; row < area.Bottom; row++) { yield return new RCIntVector(col, row); } } }