public override void Initialize() { //Check if any of the items can target anyone Mystery mystery = (Mystery)ItemUsed; BattleItem[] mysteryItems = mystery.GetItemSet(); if (mysteryItems != null) { for (int i = 0; i < mysteryItems.Length; i++) { ItemAction itemAction = mysteryItems[i].GetActionAssociated(User); //If the item can target anyone, then add it to the revised set BattleEntity[] entities = itemAction.GetEntitiesMoveAffects(); if (entities != null && entities.Length > 0) { RevisedItemSet.Add(mysteryItems[i]); } else { Debug.Log($"Mystery item: {mysteryItems[i].Name} is excluded from the revised item set because it can't target anyone!"); } } } //If no items in the Mystery can target anyone, disable the Mystery itself if (UtilityGlobals.IListIsNullOrEmpty(RevisedItemSet) == true) { Disabled = true; DisabledString = "There's no one this move can target!"; } }
protected override void ReadInput() { //If the time passed or there's no valid data, end with a failure if (ElapsedTime >= CommandTime || UtilityGlobals.IListIsNullOrEmpty(BarRanges) == true) { OnComplete(CommandResults.Failure); return; } ElapsedTime += Time.ElapsedMilliseconds; CursorTimeVal += Time.ElapsedMilliseconds; //The cursor value updates before accepting input - this is evident if you press A when doing Shell Shield with frame advance UpdateCursorVal(); if (AutoComplete == true) { //Assume the last one is the highest value BarRangeData rangeData = BarRanges[BarRanges.Length - 1]; if (rangeData.IsValueInRange(CurBarVal) == true) { //Send the response and rank, and complete with a Success SendResponse(rangeData.Value); SendCommandRank(rangeData.Rank); OnComplete(CommandResults.Success); } return; } if (Input.GetKeyDown(ButtonToPress) == true) { //Check the range the cursor is in for (int i = 0; i < BarRanges.Length; i++) { BarRangeData rangeData = BarRanges[i]; //Check for the range if (rangeData.IsValueInRange(CurBarVal) == true) { //Send the response and rank, and complete with a Success SendResponse(rangeData.Value); SendCommandRank(rangeData.Rank); OnComplete(CommandResults.Success); break; } } } }
public override void StartInput(params object[] values) { base.StartInput(values); //The cursor starts in the middle and starts out moving to the left //Multiply by 1.5 to consider the offset CursorTimeVal = CursorTime * 1.5f; UpdateCursorVal(); if (UtilityGlobals.IListIsNullOrEmpty(BarRanges) == true) { Debug.LogError($"{nameof(BarRanges)} is null or empty, so the command cannot be completed properly. Please input valid data!"); } }
private void RenderBattleEntities(IList <BattleEntity> allEntities) { //Render all BattleEntities normally for (int i = allEntities.Count - 1; i >= 0; i--) { if (allEntities[i].HasCharge() == true) { ChargedEntities.Add(allEntities[i]); continue; } allEntities[i].Draw(); } //End batch for the set drawn SpriteRenderer.Instance.EndBatch(SpriteRenderer.Instance.spriteBatch); if (UtilityGlobals.IListIsNullOrEmpty(ChargedEntities) == false) { Effect chargeEffect = AssetManager.Instance.ChargeShader; Texture2D chargeShaderTex = AssetManager.Instance.ChargeShaderTex; //Render the Charged BattleEntities with the Charge shader for (int i = 0; i < ChargedEntities.Count; i++) { BattleEntity chargedEntity = ChargedEntities[i]; Texture2D spriteSheet = chargedEntity.AnimManager.CurrentAnim.SpriteSheet; //Set effect information Vector2 dimensionRatio = new Vector2(chargeShaderTex.Width, chargeShaderTex.Height) / new Vector2(spriteSheet.Width, spriteSheet.Height); chargeEffect.Parameters["chargeTex"].SetValue(chargeShaderTex); chargeEffect.Parameters["chargeAlpha"].SetValue(RenderingGlobals.ChargeShaderAlphaVal); chargeEffect.Parameters["chargeOffset"].SetValue(new Vector2(0f, RenderingGlobals.ChargeShaderTexOffset)); chargeEffect.Parameters["chargeTexRatio"].SetValue(dimensionRatio.Y); chargeEffect.Parameters["objFrameOffset"].SetValue(spriteSheet.GetTexCoordsAt(chargedEntity.AnimManager.CurrentAnim.CurFrame.DrawRegion)); //Render with the shader SpriteRenderer.Instance.BeginBatch(SpriteRenderer.Instance.spriteBatch, BlendState.AlphaBlend, null, chargeEffect, Camera.Instance.Transform); chargedEntity.Draw(); SpriteRenderer.Instance.EndBatch(SpriteRenderer.Instance.spriteBatch); } } }
private void RenderStatusInfo(IList <BattleEntity> allEntities) { //Ignore if we shouldn't show this UI if (battleManager.ShouldShowPlayerTurnUI() == true && UtilityGlobals.IListIsNullOrEmpty(allEntities) == false) { List <StatusEffect> statuses = (allEntities.Count == 0) ? null : new List <StatusEffect>(); for (int i = 0; i < allEntities.Count; i++) { BattleEntity entity = allEntities[i]; Vector2 statusIconPos = new Vector2(entity.Position.X + 10, entity.Position.Y - 40); entity.EntityProperties.GetStatuses(statuses); int index = 0; for (int j = 0; j < statuses.Count; j++) { StatusEffect status = statuses[j]; CroppedTexture2D texture = status.StatusIcon; //Don't draw the status if it doesn't have an icon or if it's Icon suppressed if (texture == null || texture.Tex == null || status.IsSuppressed(Enumerations.StatusSuppressionTypes.Icon) == true) { continue; } float yOffset = ((index + 1) * StatusGlobals.IconYOffset); Vector2 iconPos = Camera.Instance.SpriteToUIPos(new Vector2(statusIconPos.X, statusIconPos.Y - yOffset)); float depth = .35f - (index * .01f); float turnStringDepth = depth + .0001f; status.DrawStatusInfo(iconPos, depth, turnStringDepth); index++; } statuses.Clear(); } } }
public override void StartInput(params object[] values) { base.StartInput(values); //The cursor starts in the middle and starts out moving to the left //Multiply by 1.5 to consider the offset CursorTimeVal = CursorTime * 1.5f; UpdateCursorVal(); if (UtilityGlobals.IListIsNullOrEmpty(BarRanges) == true) { Debug.LogError($"{nameof(BarRanges)} is null or empty, so the command cannot be completed properly. Please input valid data!"); } Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.BattleGFX}.png"); MovingCursor = new CroppedTexture2D(battleGFX, new Rectangle(498, 304, 46, 38)); BarEnd = new CroppedTexture2D(battleGFX, new Rectangle(514, 245, 6, 28)); BarMiddle = new CroppedTexture2D(battleGFX, new Rectangle(530, 245, 1, 28)); Box = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Box.png"); }