protected override void ReadInput() { ElapsedTime += Time.ElapsedMilliseconds; //Remove the thrown cursor if enough time passed if (ThrownCursor != null && ElapsedTime >= ThrownCursorTime) { ThrownCursor = null; ThrownCursorTime = 0d; } //Throw a bomb if the player either pressed the button or didn't press it in a certain amount of time if (AllBombsThrown == false) { if (Input.GetKeyDown(ButtonToPress) == true || ElapsedTime >= LastBombThrowTime) { ThrowBomb(); } //Update the cursor information UpdateCursor(); } else { //If we threw all the bombs, end the command with a success once the thrown cursor disappears if (AllBombsThrown == true && ThrownCursor == null) { OnComplete(CommandResults.Success); return; } } }
public BombSquadActionCommandUI(BombSquadCommand bombSquadCommand) : base(bombSquadCommand) { Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleGFX.png"); CroppedTexture2D croppedTex2D = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46)); Cursor = new UIFourPiecedTex(croppedTex2D, croppedTex2D.WidthHeightToVector2(), .5f, Color.White); }
public TattleActionCommandUI(TattleCommand tattleCommand) : base(tattleCommand) { Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleGFX.png"); BigCursor = new UIFourPiecedTex(new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46))); SmallCursor = new UIFourPiecedTex(new CroppedTexture2D(battleGFX, new Rectangle(10, 330, 13, 12))); BigCursor.OriginOffset = new Vector2((float)BigCursor.CroppedTex2D.SourceRect.Value.Width, (float)BigCursor.CroppedTex2D.SourceRect.Value.Height); SmallCursor.OriginOffset = new Vector2(SmallCursor.CroppedTex2D.SourceRect.Value.Width, SmallCursor.CroppedTex2D.SourceRect.Value.Height); }
public override void EndInput() { base.EndInput(); NumBombsThrown = 0; ElapsedTime = LastBombThrowTime = ThrownCursorTime = 0d; Cursor = null; ThrownCursor = null; }
public PowerLiftActionCommandUI(PowerLiftCommand powerLiftCommand) : base(powerLiftCommand) { Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleGFX.png"); BigCursor = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46)); SmallCursor = new CroppedTexture2D(battleGFX, new Rectangle(10, 330, 13, 12)); ArrowIcon = new CroppedTexture2D(battleGFX, new Rectangle(5, 353, 50, 61)); BarEdge = new CroppedTexture2D(battleGFX, new Rectangle(514, 245, 7, 28)); Bar = new CroppedTexture2D(battleGFX, new Rectangle(530, 245, 1, 28)); BarFill = new CroppedTexture2D(battleGFX, new Rectangle(541, 255, 1, 1)); Cursor = new UIFourPiecedTex(BigCursor, BigCursor.WidthHeightToVector2(), .6f, CursorColor); SetUpGrid(); InitIconGraphics(); }
public override void StartInput(params object[] values) { base.StartInput(values); StartPosition = Camera.Instance.SpriteToUIPos((Vector2)values[0]); NumBombsThrown = 0; ElapsedTime = 0d; LastBombThrowTime = ElapsedTime + AutomaticThrowTime; CursorAngle = MinCursorAngle; Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleGFX.png"); CroppedTexture2D croppedTex2D = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46)); Cursor = new UIFourPiecedTex(croppedTex2D, croppedTex2D.WidthHeightToVector2(), .5f, Color.White); Cursor.Position = UtilityGlobals.GetPointAroundCircle(new Circle(StartPosition, CircleRadius), CursorAngle, true); }
private void Initialize() { //Define the UI to display Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.BattleGFX}.png"); CroppedTexture2D croppedTex2D = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46)); Cursor = new UIFourPiecedTex(croppedTex2D, croppedTex2D.WidthHeightToVector2(), .5f, Color.White); MarioHPIcon = new UICroppedTexture2D(new CroppedTexture2D(AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleHUD.png"), new Rectangle(2, 38, 45, 41))); FPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(179, 416, 40, 39))); MarioHPText = new UIText("0", Color.White); FPText = new UIText("0", Color.Black); //Set UI properties MarioHPIcon.Position = MarioHPText.Position = ActionCmd.StartPosition + new Vector2(-10, -45); FPIcon.Position = FPText.Position = ActionCmd.StartPosition + new Vector2(-45, -95); MarioHPText.Position += new Vector2(0f, 10f); FPText.Position += new Vector2(0f, 10f); if (ShowPartnerInfo == true) { PartnerHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58))); PartnerHPText = new UIText("0", Color.White); PartnerHPIcon.Position = PartnerHPText.Position = ActionCmd.StartPosition + new Vector2(-80, -45); PartnerHPText.Position += new Vector2(0f, 10f); PartnerHPIcon.Origin = PartnerHPText.Origin = new Vector2(.5f, .5f); PartnerHPIcon.Depth = .6f; PartnerHPText.Depth = .61f; } MarioHPIcon.Depth = FPIcon.Depth = .6f; MarioHPText.Depth = FPText.Depth = .61f; MarioHPIcon.Origin = FPIcon.Origin = MarioHPText.Origin = FPText.Origin = new Vector2(.5f, .5f); //Set cursor position Cursor.Position = UtilityGlobals.GetPointAroundCircle(new Circle(ActionCmd.StartPosition, ActionCmd.CircleRadius), ActionCmd.CursorAngle, true); }
public override void Update() { ElapsedTime += Time.ElapsedMilliseconds; Cursor.Position = ActionCmd.CursorPosition; Cursor.Rotation = ActionCmd.CursorRotation; //Remove the thrown cursor if enough time passed if (ThrownCursor != null && ElapsedTime >= ActionCmd.ThrownCursorTime) { ThrownCursor = null; } else if (ThrownCursor == null && ElapsedTime < ActionCmd.ThrownCursorTime) { //Create the cursor ThrownCursor = Cursor.Copy(); ThrownCursor.Depth -= .01f; ThrownCursor.TintColor = Color.Gray; } }
private void ThrowBomb() { double angleRadians = UtilityGlobals.ToRadians(CursorAngle); Vector2 throwVelocity = new Vector2((float)Math.Cos(angleRadians) * BaseThrowVelocity.X, (float)Math.Sin(angleRadians) * BaseThrowVelocity.Y); //Debug.Log($"CursorAngle: {angleRadians}, ThrowVelocity: {throwVelocity}, Cos: {Math.Cos(angleRadians)}, Sin: {Math.Sin(angleRadians)}"); NumBombsThrown++; LastBombThrowTime = ElapsedTime + AutomaticThrowTime; ThrownCursorTime = ElapsedTime + ThrownCursorDur; //Show a grey cursor indicating this is where the bomb was thrown for 1 second CursorThrownPosition = Cursor.Position; ThrownCursor = Cursor.Copy(); ThrownCursor.Depth -= .01f; ThrownCursor.TintColor = Color.Gray; SendResponse(new ActionCommandGlobals.BombSquadResponse(throwVelocity, ThrowGravity)); }
public override void EndInput() { base.EndInput(); ElapsedTime = 0d; //Clean up any remaining stars for (int i = 0; i < StarsThrown.Count; i++) { BattleUIManager.Instance.RemoveUIElement(StarsThrown[i]); StarsThrown.RemoveAt(i); i--; } //Remove any UI we added BattleUIManager.Instance.RemoveUIElement(Cursor); BattleUIManager.Instance.RemoveUIElement(MarioHPIcon); BattleUIManager.Instance.RemoveUIElement(PartnerHPIcon); BattleUIManager.Instance.RemoveUIElement(FPIcon); BattleUIManager.Instance.RemoveUIElement(MarioHPText); BattleUIManager.Instance.RemoveUIElement(PartnerHPText); BattleUIManager.Instance.RemoveUIElement(FPText); Cursor = null; MarioHPIcon = null; PartnerHPIcon = null; FPIcon = null; MarioHPText = null; PartnerHPText = null; FPText = null; IconSpawner.CleanUp(); IconSpawner = null; HealingResponse = default(SweetTreatResponse); }
public override void StartInput(params object[] values) { base.StartInput(values); ElapsedTime = 0d; PrevThrow = 0d; StartPosition = Camera.Instance.SpriteToUIPos((Vector2)values[0]); //Count how many BattleEntities are affected //If there's only one, then don't add any of the Partner information int entitiesAffected = (int)values[1]; CursorAngle = MinCursorAngle; //Define the UI to display Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.BattleGFX}.png"); CroppedTexture2D croppedTex2D = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46)); Cursor = new UIFourPiecedTex(croppedTex2D, croppedTex2D.WidthHeightToVector2(), .5f, Color.White); MarioHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58))); FPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(179, 416, 40, 39))); MarioHPText = new UIText("0", Color.Black); FPText = new UIText("0", Color.Black); //Set UI properties MarioHPIcon.Position = MarioHPText.Position = StartPosition + new Vector2(-10, -45); FPIcon.Position = FPText.Position = StartPosition + new Vector2(-45, -95); MarioHPText.Position += new Vector2(0f, 10f); FPText.Position += new Vector2(0f, 10f); if (entitiesAffected > 1) { PartnerHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58))); PartnerHPText = new UIText("0", Color.Black); PartnerHPIcon.Position = PartnerHPText.Position = StartPosition + new Vector2(-80, -45); PartnerHPText.Position += new Vector2(0f, 10f); PartnerHPIcon.Origin = PartnerHPText.Origin = new Vector2(.5f, .5f); PartnerHPIcon.Depth = .6f; PartnerHPText.Depth = .61f; } MarioHPIcon.Depth = FPIcon.Depth = .6f; MarioHPText.Depth = FPText.Depth = .61f; MarioHPIcon.Origin = FPIcon.Origin = MarioHPText.Origin = FPText.Origin = new Vector2(.5f, .5f); //Set cursor position Cursor.Position = UtilityGlobals.GetPointAroundCircle(new Circle(StartPosition, CircleRadius), CursorAngle, true); //Define the spawner Vector2 startPos = new Vector2(500, 15); Vector2 endPos = new Vector2(startPos.X, BattleManager.Instance.PartnerPos.Y + 350f); RestoreTypes[] restoreTypes = null; int[] restoreTypeCounts = null; if (entitiesAffected <= 1) { restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom }; restoreTypeCounts = new int[] { 14, 6, 2 }; } else { restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.PartnerHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom }; restoreTypeCounts = new int[] { 7, 7, 6, 2 }; } IconSpawner = new SweetTreatElementSpawner(4, 40f, 5000d, 750d, startPos, endPos, restoreTypes, restoreTypeCounts); //Add the cursor and other UI elements BattleUIManager.Instance.AddUIElement(Cursor); BattleUIManager.Instance.AddUIElement(MarioHPIcon); BattleUIManager.Instance.AddUIElement(FPIcon); BattleUIManager.Instance.AddUIElement(MarioHPText); BattleUIManager.Instance.AddUIElement(FPText); if (entitiesAffected > 1) { BattleUIManager.Instance.AddUIElement(PartnerHPIcon); BattleUIManager.Instance.AddUIElement(PartnerHPText); } HealingResponse = default(SweetTreatResponse); }