public bool Update(BattleTurnEvent battle, Input input) { battle.battle.battleText = $"{deceased.name} is critically wounded."; elapsedTime += (int)Game1.time.ElapsedGameTime.TotalMilliseconds; if (elapsedTime >= eventTime) { // potentially an extreme small amount of chance to cause an innocent bug if actors do not have to be unique battle.aliveActors.Remove(deceased); deceased.giftedAttributes.ForEach(x => x.receiver.attributes.Remove(x.attribute)); battle.CurrentActor.battleEvents.RemoveAt(battle.eventIndex); battle.eventIndex--; // if the current player dies during his turn if (battle.CurrentActor == deceased) { battle.CurrentActor = battle.getNextActor(); // There is no event after the current actors death, therefore we dont want to signal that we should go to the next event return(false); } return(true); } return(false); }
public bool Update(BattleTurnEvent battle, Input input) { battle.battle.battleText = status; elapsedTime += (int)Game1.time.ElapsedGameTime.TotalMilliseconds; target.health.CurrentHealth = MathHelper.SmoothStep(beginHP, targetHP, (elapsedTime / (float)eventTime)); if (elapsedTime >= eventTime) { target.health.color = Color.White; target.health.CurrentHealth = targetHP; //if this attack killed its target if (target.health.CurrentHealth == 0) { battle.CurrentActor.battleEvents.Insert(battle.eventIndex + 1, new DeathEvent(target)); } battle.CurrentActor.battleEvents.RemoveAt(battle.eventIndex); battle.eventIndex--; return(true); } else { return(false); } }
public bool Update(BattleTurnEvent battle, Input input) { for (int i = 0; i < battle.CurrentActor.giftedAttributes.Count; i++) { battle.CurrentActor.giftedAttributes[i].expiration--; if (battle.CurrentActor.giftedAttributes[i].expiration == 0) { //possible bug if identic attributes battle.CurrentActor.giftedAttributes[i].receiver.attributes.Remove(battle.CurrentActor.giftedAttributes[i].attribute); } } return(true); }
public void Draw(BattleTurnEvent battle, SpriteBatch spritebatch, SpriteFont font) { spritebatch.DrawString(font, "Fight", new Vector2(Game1.screenWidth * 0.5f - 100, Game1.screenHeight * 0.6f), (0 == startIndex ? Color.Yellow : Color.White)); spritebatch.DrawString(font, "Support", new Vector2(Game1.screenWidth * 0.5f - 100, Game1.screenHeight * 0.6f + 20), (1 == startIndex ? Color.Yellow : Color.White)); if (currentState == state.FIGHT) { for (int i = 0; i < battle.CurrentActor.GetActions().FindAll(x => !x.IsSupportive()).Count; i++) { spritebatch.DrawString(font, battle.CurrentActor.GetActions().FindAll(x => !x.IsSupportive())[i].GetName(), new Vector2(Game1.screenWidth * 0.5f, Game1.screenHeight * 0.6f) + new Vector2(0, 20 * i), (i == actionIndex ? Color.Yellow : Color.White)); } } if (currentState == state.SUPPORT) { for (int i = 0; i < battle.CurrentActor.GetActions().FindAll(x => x.IsSupportive()).Count; i++) { spritebatch.DrawString(font, battle.CurrentActor.GetActions().FindAll(x => x.IsSupportive())[i].GetName(), new Vector2(Game1.screenWidth * 0.5f, Game1.screenHeight * 0.6f) + new Vector2(0, 20 * i), (i == actionIndex ? Color.Yellow : Color.White)); } } if (currentState == state.TARGET) { if (chosenAction.IsSupportive()) { for (int i = 0; i < battle.CurrentActor.GetActions().FindAll(x => x.IsSupportive()).Count; i++) { spritebatch.DrawString(font, battle.CurrentActor.GetActions().FindAll(x => x.IsSupportive())[i].GetName(), new Vector2(Game1.screenWidth * 0.5f, Game1.screenHeight * 0.6f) + new Vector2(0, 20 * i), (i == actionIndex ? Color.Yellow : Color.White)); } for (int i = 0; i < battle.aliveActors.FindAll(x => x.isPlayer).Count; i++) { spritebatch.DrawString(font, battle.aliveActors.FindAll(x => x.isPlayer)[i].name, new Vector2(Game1.screenWidth * 0.5f + 100, Game1.screenHeight * 0.6f) + new Vector2(0, 20 * i), (i == targetIndex ? Color.Yellow : Color.White)); } } else { for (int i = 0; i < battle.CurrentActor.GetActions().FindAll(x => !x.IsSupportive()).Count; i++) { spritebatch.DrawString(font, battle.CurrentActor.GetActions().FindAll(x => !x.IsSupportive())[i].GetName(), new Vector2(Game1.screenWidth * 0.5f, Game1.screenHeight * 0.6f) + new Vector2(0, 20 * i), (i == actionIndex ? Color.Yellow : Color.White)); } for (int i = 0; i < battle.aliveActors.FindAll(x => !x.isPlayer).Count; i++) { spritebatch.DrawString(font, battle.aliveActors.FindAll(x => !x.isPlayer)[i].name, new Vector2(Game1.screenWidth * 0.5f + 100, Game1.screenHeight * 0.6f) + new Vector2(0, 20 * i), (i == targetIndex ? Color.Yellow : Color.White)); } } } }
public bool Update(BattleTurnEvent battle, Input input) { // Get a random action var actions = battle.CurrentActor.GetActions(); IAction randomAction = actions[Game1.rnd.Next(actions.Count)]; // Get a random target List <Actor> possibleTargets = battle.aliveActors; Actor randomActor = possibleTargets[Game1.rnd.Next(possibleTargets.Count)]; randomAction.SetActors(battle.CurrentActor, randomActor); battle.CurrentActor.battleEvents.Insert(battle.eventIndex + 1, randomAction); return(true); }
public bool Update(BattleTurnEvent battle, Input input) { battle.battle.battleText = $"{source.name} used {GetName()}"; elapsedTime += (int)Game1.time.ElapsedGameTime.TotalMilliseconds; if (elapsedTime >= eventTime) { IAttribute newAttribute = new DefendAttribute(source); source.giftedAttributes.Add(new GivenAttribute(newAttribute.GetExpiration(), newAttribute, target)); target.attributes.Add(newAttribute); target.health.color = Color.White; battle.CurrentActor.battleEvents.RemoveAt(battle.eventIndex); battle.eventIndex--; return(true); } else { return(false); } }
public bool Update(BattleTurnEvent battle, Input input) { battle.battle.battleText = $"{source.name} used {GetName()}"; elapsedTime += (int)Game1.time.ElapsedGameTime.TotalMilliseconds; target.health.CurrentHealth = MathHelper.SmoothStep(beginHP, targetHP, (elapsedTime / (float)eventTime)); if (elapsedTime >= eventTime) { target.health.CurrentHealth = targetHP; target.health.color = Color.White; battle.CurrentActor.battleEvents.RemoveAt(battle.eventIndex); battle.eventIndex--; return(true); } else { return(false); } }
public bool Update(BattleTurnEvent battle, Input input) { var actions = battle.CurrentActor.GetActions(); IAction randomAction = actions[Game1.rnd.Next(actions.Count)]; List <Actor> possibleTargets; if (randomAction.IsSupportive()) { possibleTargets = battle.aliveActors.FindAll(x => x.isPlayer == battle.CurrentActor.isPlayer); } else { possibleTargets = battle.aliveActors.FindAll(x => x.isPlayer != battle.CurrentActor.isPlayer); } Actor randomActor = possibleTargets[Game1.rnd.Next(possibleTargets.Count)]; randomAction.SetActors(battle.CurrentActor, randomActor); battle.CurrentActor.battleEvents.Insert(battle.eventIndex + 1, randomAction); return(true); }
public void Draw(BattleTurnEvent battle, SpriteBatch spritebatch, SpriteFont font) { }
public bool Update(BattleTurnEvent battle, Input input) { switch (currentState) { case state.START: Navigation(input, ref startIndex, 2); if (input.Pressed(Keys.Enter)) { switch (startIndex) { case 0: currentState = state.FIGHT; break; case 1: currentState = state.SUPPORT; break; } } battle.battle.battleText = $"What will {battle.CurrentActor.name} do?"; break; case state.FIGHT: Navigation(input, ref actionIndex, battle.CurrentActor.GetActions().FindAll(x => !x.IsSupportive()).Count); if (input.Pressed(Keys.Enter)) { chosenAction = battle.CurrentActor.GetActions().FindAll(x => !x.IsSupportive())[actionIndex]; currentState = state.TARGET; } if (input.Pressed(Keys.Back)) { currentState = state.START; chosenAction = null; actionIndex = 0; } battle.battle.battleText = $"How will {battle.CurrentActor.name} fight?"; break; case state.SUPPORT: Navigation(input, ref actionIndex, battle.CurrentActor.GetActions().FindAll(x => x.IsSupportive()).Count); if (input.Pressed(Keys.Enter)) { chosenAction = battle.CurrentActor.GetActions().FindAll(x => x.IsSupportive())[actionIndex]; currentState = state.TARGET; } if (input.Pressed(Keys.Back)) { currentState = state.START; chosenAction = null; actionIndex = 0; } battle.battle.battleText = $"How will {battle.CurrentActor.name} support?"; break; case state.TARGET: Navigation(input, ref targetIndex, chosenAction.IsSupportive() ? battle.aliveActors.FindAll(x => x.isPlayer).Count : battle.aliveActors.FindAll(x => !x.isPlayer).Count); if (input.Pressed(Keys.Enter)) { currentState = state.FINISH; } if (input.Pressed(Keys.Back)) { currentState = chosenAction.IsSupportive() ? state.SUPPORT : state.FIGHT; targetIndex = 0; } battle.battle.battleText = $"Select a target."; break; case state.FINISH: chosenAction.SetActors(battle.CurrentActor, chosenAction.IsSupportive() ? battle.aliveActors.FindAll(x => x.isPlayer)[targetIndex] : battle.aliveActors.FindAll(x => !x.isPlayer)[targetIndex]); battle.CurrentActor.battleEvents.Insert(battle.eventIndex + 1, chosenAction); return(true); } return(false); }
public void Draw(BattleTurnEvent battle, SpriteBatch spritebatch, SpriteFont font) { spritebatch.DrawString(font, damage.ToString(), target.position + new Vector2(0, -(elapsedTime / (float)eventTime) * 50 + 20), Color.White, 0, new Vector2(), 2, SpriteEffects.None, 1); }