public override void DrawUI(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { Vector2 pos = new Vector2(bounds.X, bounds.Y + 32); Vector2 signatureSize = new Vector2(signature.width * 8, signature.height * 8); string text = numCrystals > 1? " +" + numCrystals + " bubbles": " +1 bubble"; Vector2 textSize = Game1.font.MeasureString(text); Vector2 signaturePos = new Vector2( pos.X + (bounds.Width - (signatureSize.X + textSize.X)) * 0.5f, pos.Y + (textSize.Y - signatureSize.Y) * 0.5f ); Vector2 textPos = new Vector2( signaturePos.X + signatureSize.X, pos.Y ); Vectangle labelRect = new Vectangle(signaturePos.X, signaturePos.Y + (signatureSize.Y - textSize.Y) * 0.5f, signatureSize.X + textSize.X, Math.Max(signatureSize.Y, textSize.Y)); spriteBatch.Draw(TextureCache.white, labelRect.Bloat(5, 2), new Color(0, 0, 0, 0.5f)); signature.Draw(spriteBatch, signaturePos, true); spriteBatch.DrawString(Game1.font, text, textPos, Color.Yellow); }
public override void DrawUI(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { if (signature != null) { Vector2 signatureSize = new Vector2(signature.width * 8, signature.height * 8); string text = "" + amount; Vector2 textSize = Game1.font.MeasureString(text); Vector2 signaturePos = new Vector2( bounds.X + (bounds.Width - (signatureSize.X + textSize.X)) * 0.5f, bounds.Y + 32 + (textSize.Y - signatureSize.Y) * 0.5f - textSize.Y ); Vector2 textPos = new Vector2( signaturePos.X + signatureSize.X + 2, bounds.Y + 32 - textSize.Y ); float labelHeight = Math.Max(signatureSize.Y, textSize.Y); Vectangle labelRect = new Vectangle(signaturePos.X, signaturePos.Y + (signatureSize.Y - labelHeight) * 0.5f, signatureSize.X + textSize.X, Math.Max(signatureSize.Y, textSize.Y)); spriteBatch.Draw(TextureCache.white, labelRect.Bloat(5, 2), new Color(0, 0, 0, 0.5f)); signature.Draw(spriteBatch, signaturePos, true); spriteBatch.DrawString(Game1.font, text, textPos, Color.LightGray); } }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.Draw(spriteBatch, blackboard); Vector2 pos = new Vector2(bounds.X, bounds.Y + bounds.Height); Vector2 signatureSize = new Vector2(signature.width * 8, signature.height * 8); string text = "$" + price; Vector2 textSize = Game1.font.MeasureString(text); Vector2 signaturePos = new Vector2( pos.X + (bounds.Width - (signatureSize.X + textSize.X)) * 0.5f, pos.Y + (textSize.Y - signatureSize.Y) * 0.5f ); Vector2 textPos = new Vector2( signaturePos.X + signatureSize.X, pos.Y ); float labelHeight = Math.Max(signatureSize.Y, textSize.Y); Vectangle labelRect = new Vectangle(signaturePos.X, signaturePos.Y + (signatureSize.Y - labelHeight) * 0.5f, signatureSize.X + textSize.X, Math.Max(signatureSize.Y, textSize.Y)); spriteBatch.Draw(TextureCache.white, labelRect.Bloat(5, 2), new Color(0, 0, 0, 0.5f)); signature.Draw(spriteBatch, signaturePos, true); spriteBatch.DrawString(Game1.font, "$" + price, textPos, Color.Yellow); }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.Draw(spriteBatch, blackboard); spriteBatch.DrawString(Game1.font, label, bounds.TopCenter + new Vector2(0, -20), TextAlignment.CENTER, Color.Black); ui.Draw(spriteBatch); }
public override void DrawUI(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.DrawUI(spriteBatch, blackboard); if (selected) { ui.Draw(spriteBatch); } }
public override void Update(CityUIBlackboard blackboard) { base.Update(blackboard); if (selected) { ui.origin = bounds.Origin; ui.Update(blackboard.inputState); } }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.Draw(spriteBatch, blackboard); Vector2 weaponTexHalfSize = weapon.texture.Size() / 2; spriteBatch.Draw(weapon.texture, bounds.TopCenter + new Vector2(0, 5) - weaponTexHalfSize, Color.White); spriteBatch.DrawString(Game1.font, weapon.name, bounds.BottomCenter + new Vector2(0, 2), TextAlignment.CENTER, Color.Yellow); ui.Draw(spriteBatch); }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.Draw(spriteBatch, blackboard); Vector2 signatureSize = new Vector2(signature.width * 8, signature.height * 8); Vector2 signaturePos = new Vector2( bounds.CenterX - signatureSize.X * 0.5f, bounds.CenterY - (signatureSize.Y * 0.5f + 8) ); signature.Draw(spriteBatch, signaturePos, true); }
public override void Update(CityUIBlackboard blackboard) { if (purchased) { blackboard.cityLevel.AddObjectDeferred(spawn); blackboard.cityLevel.RemoveObjectDeferred(this); } else { base.Update(blackboard); ui.origin = bounds.Origin; ui.Update(blackboard.inputState); } }
public override void Update(CityUIBlackboard blackboard) { if (purchased) { Game1.instance.inventory.AcquireBlueprint(unlocks); blackboard.cityLevel.RemoveObjectDeferred(this); } else { base.Update(blackboard); ui.origin = bounds.Origin; ui.Update(blackboard.inputState); } }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.Draw(spriteBatch, blackboard); bool hovering = (blackboard.inputState != null) ? (blackboard.inputState.hoveringElement == this) : false; if (hovering || dragging) { spriteBatch.Draw( TextureCache.silo_hover, bounds, new Color(0.75f, 0.75f, 0.0f, 0.5f) ); } }
public override void Update(CityUIBlackboard blackboard) { if (purchased) { Game1.instance.inventory.UnlockWeapon(weapon); blackboard.cityLevel.RemoveObjectDeferred(this); Game1.instance.inventory.GainCrystals(crystals); } else { base.Update(blackboard); ui.origin = bounds.Origin; ui.Update(blackboard.inputState); } }
public override void DrawDraggingUI(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { /* * if(blackboard.selectedObject != this && blackboard.selectedObject is ChemicalFactory) * { * Rectangle dragBoxRect = GetDragBox(); * * ChemicalFactory otherFactory = (blackboard.selectedObject as ChemicalFactory); * spriteBatch.Draw(TextureCache.outlined_square, dragBoxRect, blackboard.draggingOntoObject==this? Color.Orange : Color.Beige); * * string text = "+" + otherFactory.numCores; * Vector2 textSize = Game1.font.MeasureString(text); * spriteBatch.DrawString(Game1.font, text, new Vector2((int)(dragBoxRect.Center.X - textSize.X/2), (int)(dragBoxRect.Center.Y - textSize.Y/2)), Color.Black); * * spriteBatch.Draw(TextureCache.drag_prompt, new Vector2(dragBoxRect.X-4, dragBoxRect.Bottom-8), Color.White); * }*/ }
public override void DrawUI(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { if (anyThreadStalled && warningTriangleMessage != "") { Vectangle warningRect = GetWarningRect(); spriteBatch.Draw(TextureCache.warning, warningRect, Color.White); if (showErrorMessage) { Vector2 messageSize = Game1.font.MeasureString(warningTriangleMessage); if (messageSize.X > warningRect.Left) { spriteBatch.Draw(TextureCache.white, Game1.font.GetStringBounds(warningTriangleMessage, warningRect.TopRight, TextAlignment.LEFT).Bloat(2), new Color(0.25f, 0, 0, 0.5f)); spriteBatch.DrawString(Game1.font, warningTriangleMessage, warningRect.TopRight, Color.Yellow); } else { spriteBatch.Draw(TextureCache.white, Game1.font.GetStringBounds(warningTriangleMessage, warningRect.TopLeft, TextAlignment.RIGHT).Bloat(2), new Color(0.25f, 0, 0, 0.5f)); spriteBatch.DrawString(Game1.font, warningTriangleMessage, warningRect.TopLeft, TextAlignment.RIGHT, Color.Yellow); } } } if (selected) { ui.Draw(spriteBatch); Rectangle dragBoxRect = GetDragBox(); if (commands.Count > 0) { int recordingDurationFrames = commands.Last().time; string durationStr = "(" + PlatformLevel.TimeToString(recordingDurationFrames) + " secs)"; Vector2 textPos = new Vector2((int)bounds.CenterX, (int)(bounds.Top) - 15); spriteBatch.DrawString(Game1.font, durationStr, textPos, TextAlignment.CENTER, Color.White); } /* string text = "" + numCores; * Vector2 textSize = Game1.font.MeasureString(text); * spriteBatch.Draw(TextureCache.outlined_square, dragBoxRect, numCores > DEFAULT_NUM_CORES? Color.Orange: Color.Gray); * spriteBatch.DrawString(Game1.font, text, new Vector2((int)(dragBoxRect.Center.X - textSize.X / 2), (int)(dragBoxRect.Center.Y - textSize.Y / 2)), Color.Black);*/ } }
public override void Update(CityUIBlackboard blackboard) { Rectangle dragBoxRect = GetDragBox(); if (selected && numCores > DEFAULT_NUM_CORES && dragBoxRect.Contains(blackboard.inputState.MousePos) && blackboard.inputState.WasMouseLeftJustPressed()) { // unmerging a previously merged factory numCores -= DEFAULT_NUM_CORES; UpdateThreads(); ChemicalFactory newFactory = new ChemicalFactory(cityLevel, blackboard.inputState.MousePos, true, false); blackboard.cityLevel.AddObjectDeferred(newFactory); blackboard.selectedObject = newFactory; return; } base.Update(blackboard); showErrorMessage = false; if (selected) { ui.origin = bounds.Origin; ui.Update(blackboard.inputState); } if (blackboard.inputState.hoveringElement == this && GetWarningRect().Contains(blackboard.inputState.MousePos)) { showErrorMessage = true; } /* * if (blackboard.selectedObject != null * && blackboard.selectedObject != this * && blackboard.selectedObject is ChemicalFactory * && blackboard.selectedObject.dragging * && GetDragBox().Contains(blackboard.inputState.MousePos)) * { * blackboard.draggingOntoObject = this; * }*/ }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.Draw(spriteBatch, blackboard); bool hovering = (blackboard.inputState != null) ? (blackboard.inputState.hoveringElement == this) : false; if (hovering || selected) { spriteBatch.Draw( TextureCache.centrifuge_highlight, bounds, selected ? new Color(0.7f, 0.7f, 1.0f, 1.0f) : new Color(1.0f, 1.0f, 0.0f, 1.0f) ); } spriteBatch.Draw(GetModeIcon(mode), bounds.XY + new Vector2(15, 20), Color.White); if (outputSignature != null) { outputSignature.Draw(spriteBatch, bounds.BottomRight + new Vector2(-14, -8), true); } }
public virtual void Update(CityUIBlackboard blackboard) { InputState inputState = blackboard.inputState; if (inputState.WasMouseLeftJustPressed() && inputState.hoveringElement == this) { blackboard.selectedObject = this; } if (inputState.hoveringElement == this && inputState.mouseLeft.isDown && !dragging && canDrag && inputState.MouseDelta.LengthSquared() > 0) { dragging = true; draggingOffset = inputState.OldMousePos - bounds.Origin; } if (dragging && blackboard.selectedObject == this) { if (inputState.mouseLeft.isDown) { bounds.Origin = ClampToShelf(inputState.MousePos - draggingOffset); sprite.pos = bounds.Origin; } else { dragging = false; } } else { dragging = false; } UpdateUnlimitedPipes(); selected = (blackboard.selectedObject == this); }
public void Update(CityLevel metaGame, CityUIBlackboard blackboard) { if (!movable) { return; } hovering = blackboard.inputState.hoveringElement == this;// cachedHandleRect.Contains(blackboard.inputState.MousePos); if (hovering && blackboard.inputState.WasMouseLeftJustPressed()) { dragging = true; blackboard.selectedObject = null; } if (cachedOffset.Y < 0) { ConnectTo(null); } if (dragging) { ConnectTo(null); CityObject overObject = metaGame.GetObjectAt(blackboard.inputState.MousePos); PipeSocket overSocket = null; if (overObject != null) { overSocket = overObject.GetNearestSocket(blackboard.inputState.MousePos); if (overSocket != null && overSocket.pos.Y < sourcePos.Y) { overSocket = null; } } Vector2 clampedPos = blackboard.inputState.MousePos; if (clampedPos.Y <= sourcePos.Y) { clampedPos.Y = sourcePos.Y; } if (blackboard.inputState.mouseLeft.isDown) { if (overSocket != null) { UpdateForTargetPos(overSocket.pos); } else { UpdateForTargetPos(clampedPos); } } else { dragging = false; if (overSocket != null && overSocket.parent != source) { ConnectTo(overSocket); } else { ShowDisconnected(); } } } }
public override void Update(CityUIBlackboard blackboard) { UpdateUnlimitedPipes(); }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { base.Draw(spriteBatch, blackboard); }
public override void Update(CityUIBlackboard blackboard) { }
public virtual void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { sprite.Draw(spriteBatch); }
public virtual void DrawDraggingUI(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { }
public override void Draw(SpriteBatch spriteBatch, CityUIBlackboard blackboard) { if (blackboard.selectedObject == this && blackboard.draggingOntoObject != null) { return; } base.Draw(spriteBatch, blackboard); if (isBigFactory) { spriteBatch.Draw(TextureCache.sidejug, bounds.XY + new Vector2(-14, 12), Color.White); spriteBatch.Draw(TextureCache.sidejug_right, bounds.XY + new Vector2(45, 12), Color.White); } bool hovering = (blackboard.inputState != null) ? (blackboard.inputState.hoveringElement == this) : false; if (hovering || selected) { spriteBatch.Draw( TextureCache.processor_highlight, bounds, selected ? new Color(0.8f, 0.8f, 0.8f, 0.5f) : new Color(0.75f, 0.75f, 0.0f, 0.5f) ); } anyThreadStalled = false; bool anyThreadRunning = false; foreach (FactoryThread thread in threads) { if (thread.stalled) { anyThreadStalled = true; } else { anyThreadRunning = true; } } if (anyThreadRunning) { spoolAnimCountdown--; if (spoolAnimCountdown <= 0) { spoolAnimIndex = (spoolAnimIndex + 1) % TextureCache.spools.Length; spoolAnimCountdown = 3; } } if (isBigFactory) { spriteBatch.Draw(TextureCache.spools[spoolAnimIndex], bounds.XY + new Vector2(7, 32), Color.White); } spriteBatch.Draw(TextureCache.spools[spoolAnimIndex], bounds.XY + new Vector2(24, 32), Color.White); if (internalSeller != null) { Vector2 pos = new Vector2(bounds.X, bounds.Y + bounds.Height); Vector2 signatureSize = new Vector2(internalSeller.width * 8, internalSeller.height * 8); string text = ""; switch (sellerAction) { case FactoryCommandType.EARNMONEY: text = "$" + sellerPrice; break; case FactoryCommandType.GAINCRYSTAL: text = "crystal"; break; } Vector2 textSize = Game1.font.MeasureString(text); Vector2 signaturePos = new Vector2( pos.X + (bounds.Width - (signatureSize.X + textSize.X)) * 0.5f, pos.Y + (textSize.Y - signatureSize.Y) * 0.5f ); Vector2 textPos = new Vector2( signaturePos.X + signatureSize.X, pos.Y ); internalSeller.Draw(spriteBatch, signaturePos, true); spriteBatch.DrawString(Game1.font, text, textPos, Color.Yellow); } const int CORE_SIZE = 5; const int MAX_CORES_PER_LINE = 5; int numCoresDrawn = 0; Vector2 initialBarPos = bounds.Center + new Vector2(-16, 1);// new Vector2((int)bounds.CenterX + 2 - CORE_SIZE*3, (int)(bounds.Bottom + 2)); Vector2 progressBarPos = initialBarPos; int recordingDurationFrames = 0; if (commands.Count > 0) { recordingDurationFrames = commands.Last().time; } float recordingDurationSeconds = Game1.FramesToSeconds(recordingDurationFrames); int numCoresDrawnThisLine = 0; int numCoresPerThread = (int)Math.Ceiling(recordingDurationSeconds / TIME_PER_CORE); int progressBarInternalWidth = (1 + numCoresPerThread * CORE_SIZE); foreach (FactoryThread thread in threads) { float maxTimeFraction = 1.0f;//recordingDurationSeconds / (numCoresPerThread * TIME_PER_CORE); spriteBatch.Draw(TextureCache.white, new Rectangle((int)progressBarPos.X, (int)progressBarPos.Y, numCoresPerThread * CORE_SIZE, CORE_SIZE), Color.Black); spriteBatch.Draw(TextureCache.white, new Rectangle((int)progressBarPos.X, (int)(progressBarPos.Y), (int)(progressBarInternalWidth * maxTimeFraction), CORE_SIZE), new Color(100, 100, 100)); float progressFraction = thread.internalTime / (recordingDurationSeconds * 60.0f); // (60.0f* numCoresPerThread * TIME_PER_CORE); spriteBatch.Draw(TextureCache.white, new Rectangle((int)progressBarPos.X, (int)(progressBarPos.Y), (int)(progressBarInternalWidth * progressFraction), CORE_SIZE), thread.stalled ? Color.Red : new Color(100, 200, 0)); // new Color(120,170,255)); spriteBatch.Draw(thread.stalled ? TextureCache.bad_cores_bar_small : TextureCache.cores_bar_small, new Rectangle((int)progressBarPos.X, (int)progressBarPos.Y, 1 + numCoresPerThread * CORE_SIZE, 1 + CORE_SIZE), Color.White); numCoresDrawn += numCoresPerThread; numCoresDrawnThisLine += numCoresPerThread; if (numCoresDrawnThisLine <= MAX_CORES_PER_LINE) { progressBarPos.X += numCoresPerThread * CORE_SIZE; } else { progressBarPos.X = initialBarPos.X; progressBarPos.Y += CORE_SIZE + 2; numCoresDrawnThisLine = 0; } } while (numCores > numCoresDrawn) { spriteBatch.Draw(TextureCache.empty_core, new Rectangle((int)progressBarPos.X, (int)progressBarPos.Y, 1 + CORE_SIZE, 1 + CORE_SIZE), Color.White); progressBarPos.X += CORE_SIZE; numCoresDrawn++; } }