protected override void Execute(State currentState, TilemapComponent tilemap) { if (skillToActivate is AttackSkill) { source.currentAttackSkill = (AttackSkill)skillToActivate; //dialog.PostToDialog("Activated " + skillToActivate.GetType().Name, dialogNoise, false); } else if (skillToActivate is SelectTilesSkill) { skillRange = ((SelectTilesSkill)skillToActivate).GetValidTiles(tilemap.grid, source.tile); //tilemap.ActivateSelectTilesSkill(source, (SelectTilesSkill) skillToActivate); if (skillRange.Count() != 0) { // dialog.PostToDialog("Activated " + skillToActivate.GetType().Name, dialogNoise, false); } else { // dialog.PostToDialog("Tried to activate " + skillToActivate.GetType().Name + " but there were no valid tiles", dialogNoise, false); // tilemap.DeactivateSelectTilesSkill(source); var stateData = (AllySelectedState)currentState; stateData.attackRange = TilemapComponent.GenerateAttackRange(tilemap.grid, source); stateData.moveRange = TilemapComponent.GenerateMoveRange(tilemap.grid, source); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.attackRange, Tile.HighlightTypes.Attack); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.moveRange, Tile.HighlightTypes.Move); } } else if (skillToActivate is BuffSkill) { ((BuffSkill)skillToActivate).ResolveEffect(source); // dialog.PostToDialog("Activated " + skillToActivate.GetType().Name, dialogNoise, false); } }
public override State Transition(State currentState, TilemapComponent tilemap, Dialog dialog) { Execute(currentState, tilemap); DisplayInGrid(currentState, tilemap); DisplayInDialog(currentState, dialog); return(new NoSelectionState()); }
public override State Transition(State currentState, TilemapComponent tilemap, Dialog dialog) { Execute(currentState, tilemap); DisplayInGrid(currentState, tilemap); DisplayInDialog(currentState, dialog); return(new TeleportActivatedState(source, validTiles)); }
protected override void Execute(State currentState, TilemapComponent tilemap) { var stateData = (AllySelectedState)currentState; stateData.attackRange = TilemapComponent.GenerateAttackRange(tilemap.grid, source); stateData.moveRange = TilemapComponent.GenerateMoveRange(tilemap.grid, source); }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { if (completed) { var stateData = (AllySelectedState)currentState; TilemapComponent.ClearAllHighlightsFromGrid(tilemap.grid); stateData.attackRange = TilemapComponent.GenerateAttackRange(tilemap.grid, source); stateData.moveRange = TilemapComponent.GenerateMoveRange(tilemap.grid, source); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.attackRange, Tile.HighlightTypes.Attack); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.moveRange, Tile.HighlightTypes.Move); } else { // selecting a tile if (selectedTile.currentHighlights.Contains(Tile.HighlightTypes.Skill)) { selectedTile.currentHighlights.Remove(Tile.HighlightTypes.Skill); selectedTile.currentHighlights.Add(Tile.HighlightTypes.SkillSelect); } // deselecting a tile else { selectedTile.currentHighlights.Remove(Tile.HighlightTypes.SkillSelect); selectedTile.currentHighlights.Add(Tile.HighlightTypes.Skill); } } }
protected override void Execute(State currentState, TilemapComponent tilemap) { var stateData = (SelectSkillActivatedState)currentState; // selecting a tile if (stateData.validTiles.Contains(selectedTile)) { stateData.selectedTiles.Add(selectedTile); stateData.validTiles.Remove(selectedTile); } // deselecting a tile else { stateData.validTiles.Add(selectedTile); stateData.selectedTiles.Remove(selectedTile); } completed = stateData.selectedTiles.Count == stateData.activeSkill.targets; if (completed) { source.UseSkill(stateData.activeSkill); stateData.selectedTiles.ForEach(x => stateData.activeSkill.ResolveEffect(source, x)); } }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { var stateData = (AllySelectedState)currentState; source.tile.HighlightAs(Tile.HighlightTypes.SelectedEntity); stateData.attackRange.ForEach(x => x.HighlightAs(Tile.HighlightTypes.Attack)); stateData.moveRange.ForEach(x => x.HighlightAs(Tile.HighlightTypes.Move)); }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { if (skillToActivate is SelectTilesSkill) { TilemapComponent.ClearHighlightFromGrid(tilemap.grid, Tile.HighlightTypes.Attack); TilemapComponent.ClearHighlightFromGrid(tilemap.grid, Tile.HighlightTypes.Move); TilemapComponent.RefreshGridHighlights(tilemap.grid, skillRange, Tile.HighlightTypes.Skill); } }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { var stateData = (EnemySelectedState)currentState; var normalizedData = Utils.NormalizeDict(stateData.tileScoreMap); source.tile.HighlightAs(Tile.HighlightTypes.SelectedEntity); normalizedData.Keys.ToList().ForEach(x => x.tile.HighlightAs(Tile.HighlightTypes.Test, (float)normalizedData[x])); normalizedData.Keys.OrderBy(x => normalizedData[x]).First().tile.HighlightAs(Tile.HighlightTypes.Move); }
public override State Transition(State currentState, TilemapComponent tilemap, Dialog dialog) { var nextState = new AllySelectedState(source); Execute(nextState, tilemap); DisplayInGrid(nextState, tilemap); DisplayInDialog(nextState, dialog); return(nextState); }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { var stateData = (AllySelectedState)currentState; stateData.attackRange = TilemapComponent.GenerateAttackRange(tilemap.grid, source); stateData.moveRange = TilemapComponent.GenerateMoveRange(tilemap.grid, source); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.attackRange, Tile.HighlightTypes.Attack); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.moveRange, Tile.HighlightTypes.Move); }
protected override void Execute(State currentState, TilemapComponent tilemap) { if (source.currentTeleports >= 0) { validTiles = GridUtils.FlattenGridTiles(tilemap.grid, true).Where(tile => tile.occupier == null).ToList(); } else { // dialog.PostToDialog("Tried to teleport but " + source.entityName + " has already teleported this encounter", dialogNoise, false); } }
protected override void Execute(State currentState, TilemapComponent tilemap) { if (source.currentAttackSkill != null) { source.currentAttackSkill.BeforeAttack(source, target); source.MakeAttack(target); source.currentAttackSkill.AfterAttack(source, target); } else { source.MakeAttack(target); } }
public override State Transition(State currentState, TilemapComponent tilemap, Dialog dialog) { Execute(currentState, tilemap); DisplayInGrid(currentState, tilemap); DisplayInDialog(currentState, dialog); if (skillToActivate is SelectTilesSkill) { return(new SelectSkillActivatedState(source, (SelectTilesSkill)skillToActivate, skillRange)); } else { return(currentState); } }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { if (skillToDeactivate is SelectTilesSkill) { var stateData = (AllySelectedState)currentState; TilemapComponent.ClearAllHighlightsFromGrid(tilemap.grid); stateData.attackRange = TilemapComponent.GenerateAttackRange(tilemap.grid, source); stateData.moveRange = TilemapComponent.GenerateMoveRange(tilemap.grid, source); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.attackRange, Tile.HighlightTypes.Attack); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.moveRange, Tile.HighlightTypes.Move); } }
protected override void Execute(State currentState, TilemapComponent tilemap) { if (currentState is EnemyTurnState) { var stateData = (EnemyTurnState)currentState; var nextStep = stateData.aiSteps.First(); if (nextStep != null) { stateData.aiSteps.RemoveAt(0); nextStep.ToList().ForEach(behavior => behavior.DoBestAction(tilemap, currentState)); stateData.stepTaken = nextStep; } } }
public override bool DoBestAction(TilemapComponent tilemap, State currentState) { var stateData = (EnemyTurnState)currentState; Debug.Log(String.Format("{0} chose to do {1} with score of {2}", entity, "Flee", bestAction.Value)); tilemap.MoveEntity(entity.tile, bestAction.Key.tile); if (GridUtils.GetEdgesOfEnabledGrid(tilemap.grid).Contains(bestAction.Key.tile)) { this.entity.RemoveFromGrid(); stateData.enemies.Remove(this.entity); } return(true); }
public override State Transition(State currentState, TilemapComponent tilemap, Dialog dialog) { Execute(currentState, tilemap); DisplayInGrid(currentState, tilemap); DisplayInDialog(currentState, dialog); var stateData = (EnemyTurnState)currentState; if (stateData.aiSteps.Count == 0) { // can add new reinforcement / summoning state return(new NoSelectionState()); } else { return(currentState); } }
public override bool DoBestAction(TilemapComponent tilemap, State currentState) { var stateData = (EnemyTurnState)currentState; if (!(entity.lastSelectedBehavior is EvasiveTeleport)) { Debug.Log(String.Format("{0} chose to do {1} turn 1 with score of {2}", entity, "EvasiveTeleport", bestAction.Value)); entity.lastSelectedBehavior = this; // turn 1 of evasive teleport } else { // turn 2 of evasive teleport Debug.Log(String.Format("{0} chose to do {1} turn 2 with score of {2}", entity, "EvasiveTeleport", bestAction.Value)); tilemap.TeleportEntity(entity.tile, bestAction.Key.tile); entity.lastSelectedBehavior = null; } return(true); }
public override bool DoBestAction(TilemapComponent tilemap, State currentState) { Debug.Log(String.Format("{0} chose to do {1} with score of {2}", entity, "RangedAttackV1", bestAction.Value)); if (bestAction.Key.tile != entity.tile) { tilemap.MoveEntity(entity.tile, bestAction.Key.tile); } var attackRange = GridUtils.GenerateTileCircle(tilemap.grid, entity.range, entity.tile).ToList(); if (attackRange.Contains(bestTarget.tile)) { entity.MakeAttack(bestTarget); Debug.Log(String.Format("{0} chose to do {1} with score of {2} against {3}", entity, "RangedAttackV1", bestAction.Value, bestTarget)); } return(true); }
protected override void Execute(State currentState, TilemapComponent tilemap) { if (skillToDeactivate is AttackSkill) { source.currentAttackSkill = null; //dialog.PostToDialog("Activated " + skillToActivate.GetType().Name, dialogNoise, false); } else if (skillToDeactivate is SelectTilesSkill) { var stateData = (AllySelectedState)currentState; TilemapComponent.ClearHighlightFromGrid(tilemap.grid, Tile.HighlightTypes.Skill); stateData.attackRange = TilemapComponent.GenerateAttackRange(tilemap.grid, source); stateData.moveRange = TilemapComponent.GenerateMoveRange(tilemap.grid, source); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.attackRange, Tile.HighlightTypes.Attack); TilemapComponent.RefreshGridHighlights(tilemap.grid, stateData.moveRange, Tile.HighlightTypes.Move); } else if (skillToDeactivate is BuffSkill) { // do nothing for now } }
public override bool DoBestAction(TilemapComponent tilemap, State currentState) { Debug.Log(String.Format("{0} chose to do {1} with score of {2}", entity, "MeleeAttackV1", bestAction.Value)); if (bestAction.Key.tile != entity.tile) { tilemap.MoveEntity(entity.tile, bestAction.Key.tile); } var tileWithTarget = GridUtils.GenerateTileCircle(tilemap.grid, 1, entity.tile) .ToList() .FirstOrDefault(tile => tile.occupier != null && (tile.occupier.isAllied || tile.occupier.isFriendly) && !tile.occupier.outOfHP ); if (tileWithTarget != null) { entity.MakeAttack(tileWithTarget.occupier); } return(true); }
public void DeactivateGrid() { activated = false; waiting = true; GridUtils.FlattenGridTiles(tilemap.grid) .Where(tile => !tile.disabled).ToList() .ForEach(tile => DeactivateTile(tile)); TilemapComponent.ClearAllHighlightsFromGrid(tilemap.grid); factions.ToList() .Where(faction => faction.isHostileFaction).ToList() .ForEach(faction => { faction.entities .Where(entity => entity.outOfHP).ToList() .ForEach(entity => { var rand = new System.Random(); GameObject onDeathPrefab = null; if (rand.Next(2) == 0) { onDeathPrefab = entity.corpse; } else { onDeathPrefab = threadPrefabs.OrderBy(_ => rand.Next()).First(); } Instantiate(onDeathPrefab, entity.transform.position, Quaternion.identity); }); }); factions.ToList().ForEach(faction => { faction.entities.ForEach(entity => entity.RemoveFromGrid()); }); factions = new Queue <Faction>(); skillMenu.SetActive(false); }
protected override void Execute(State currentState, TilemapComponent tilemap) { }
public abstract bool DoBestAction(TilemapComponent tilemap, State currentState);
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { TilemapComponent.ClearAllHighlightsFromGrid(tilemap.grid); }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { TilemapComponent.ClearAllHighlightsFromGrid(tilemap.grid); TilemapComponent.RefreshGridHighlights(tilemap.grid, validTiles, Tile.HighlightTypes.Teleport); }
// This is the "Model" protected abstract void Execute(State currentState, TilemapComponent tilemap);
protected override void Execute(State currentState, TilemapComponent tilemap) { currentState.source.UseTeleport(); tilemap.TeleportEntity(currentState.source.tile, selectedTile); }
protected override void DisplayInGrid(State currentState, TilemapComponent tilemap) { }