/* * * * */ public override void OnDamageInflicted(Combat combat, AnimationData currentData) { //if(true) if (ConditionasMet(combat, currentData)) { Skill s = Globals.campaign.contentLibrary.skillDatabase.GetCopy(skillIDToUse); TileNode node; if (castOnTarget) { node = currentData.DestNode; } else { node = currentData.sourceNode; } // Look at the combat class // think about how to add stuff to the combate node map // I think we all we need to do here is add the approiate animatino data AnimationData data = AnimationData.NewAntionData(s, currentData.sourceNode, node); combat.animationQueue.Enqueue(data); /* * */ } }
public override IEnumerator ExecuteAction(Actor source, BoardManager bm) { bm.Selector.MoveTo(moveTarget.data.posX, moveTarget.data.posY); //move to the target tile int pathLeng = MoveToTarget(source, bm, moveTarget.data.posX, moveTarget.data.posY); // use skill Combat c = new Combat(source); yield return(new WaitForSeconds(waitTime * pathLeng)); AnimationData data = AnimationData.NewAntionData(skillToUse, Globals.GetBoardManager().pathfinding.GetTileNode(source), skillTarget); bm.tileSelection.ClearAllRange(); //AttackRange(bm, source); bm.tileSelection.PopulateMovementRange( bm.pathfinding.GetSkillRange(skillToUse, source, source.GetPosX(), source.GetPosY())); bm.ui.SkillInUseName.InitLabel(skillToUse.GetName()); bm.Selector.MoveTo(skillTarget.data.posX, skillTarget.data.posY); yield return(new WaitForSeconds(.75f)); bm.tileSelection.ClearAllRange(); //targeted tiles List <TileNode> nodesInRange = skillToUse.GetTargetedTiles(source, skillTarget); bm.tileSelection.PopulateAttackRange(nodesInRange); yield return(new WaitForSeconds(.75f)); //targeted tiles cleared bm.tileSelection.ClearAllRange(); bm.ui.SkillInUseName.ToggleOff(); c.animationDatas.Add(data); ///HACK ///This is hacked as f**k source.Wait(); bm.inputFSM.SwitchState(new PlayingAnimationInputState(bm, c)); bm.turnManager.CalculateFastest(); /* * c.animationDatas.Add(data); * * c.UseSkill(); * c.PayCostsCDAttack(); * source.Wait(); * * * bm.turnManager.CalculateFastest(); //this is when the state machine changes */ }
public Combat(Actor source, Skill skill, TileNode center, TileNode startNode) { this.source = source; this.center = center; //targets = skill.GetFinalTargetedTiles(source, center); animationDatas = new List <AnimationData>(); actorDamageMap = new List <CombatNode>(); foreach (string item in skill.animControllerID) { animationDatas.Add(AnimationData.NewAntionData(skill, startNode, center)); } }
public override void ProcessInput() { //display current skill range; if (range[selector.mapPosX, selector.mapPosY]) { if (selector.ChangedPosition()) { List <TileNode> nodes = currentSkill.GetTargetedTiles(currentActor, pathfinding.GetTileNode(selector.mapPosX, selector.mapPosY)); if (nodes == null) { return; } selection.PopulateSkillEffect(nodes); previewManager.ClearPreview(); TileNode node = pathfinding.GetTileNode(selector.mapPosX, selector.mapPosY); if (combat == null) { combat = new Combat(currentActor); } else { combat.source = currentActor; } AnimationData data = AnimationData.NewAntionData(currentSkill, boardManager.pathfinding.GetTileNode(currentActor), node); previewManager.InitPreview(combat.DisplayCombatPreview(data)); selector.posChanged = false; } } selector.ProccessInput(inputHandler); if (inputHandler.IsKeyPressed(KeyBindingNames.Select) || Input.GetMouseButtonDown(0)) { if (range[selector.mapPosX, selector.mapPosY]) { // We could move this stuff to the animation state to make sure that the // animations line up with the animations // TileNode node = pathfinding.GetTileNode(selector.mapPosX, selector.mapPosY); AnimationData data = new AnimationData(); data.skillUsed = currentSkill; data.DestNode = node; data.sourceNode = startNode; combat.animationDatas.Add(data); //combat.PoopulateCombat(data); if (currentSkill is Skill) { Skill temp = currentSkill as Skill; if (temp.nextSkill != null) { selection.ClearMovementRange(); if (temp.nextSkill.useActorSource) { node = pathfinding.GetTileNode(currentActor); } temp = Globals.campaign.contentLibrary.skillDatabase.GetData(temp.nextSkill.skillKey); inputFSM.SwitchState(new AbilityInUseState(boardManager, currentActor, node, temp, combat)); } else { PlayAnimations(); } } else { PlayAnimations(); } } } else if (Input.GetKeyDown(KeyCode.Q)) { previewManager.ShiftUp(); } else if (Input.GetKeyDown(KeyCode.E)) { previewManager.ShfitDown(); } else if (inputHandler.IsKeyPressed(KeyBindingNames.Cancel) || Input.GetMouseButtonDown(1)) { inputFSM.SwitchState(new UsersTurnState(boardManager)); // selector.MoveTo(currentActor.GetPosX(), currentActor.GetPosY()); } }
public override IEnumerator CalculateActions(List <AIAction> validActions, BoardManager gm, Actor ai) { if (ai.CanAttack()) { List <TileNode> movementNodes = GetTileNodeMovementRange(gm, ai); /// Store the actual position of the ai so that we can restore it later int originalX = ai.GetPosX(); int originalY = ai.GetPosY(); //Just going to get skills for now, expand to equipment and inventory // List <Skill> avaliableSkills = ai.actorData.JobDataState.GetAllSkillsOffCoolDown(ai); //stress test more skills // 7 * 3 = 21 skills to consider // a little inaccurate since coping this many skills would take more time than just processing them but ya know // Debug.Log("Skill count: " + avaliableSkills.Count); // So we're going to cycle through the possible movement options // use that as the source to find the range for each target type // use each node in that range for the target of each type //foreach tilenode /pretend we moved there //foreach skill /pretend we used that skill from there to find a rance //foreach tilenode in range /pretend we used the skill //record the combat data for that skill used int n = 0; //cycle through every place we can move foreach (TileNode movementOption in movementNodes) { // Basically we need to actually change the positional data of the ai to // accurately predict the best ability to use //We should also be checking if the unit is calculating from the area tha tit's starting from if (movementOption.data.posX == originalX && movementOption.data.posY == originalY) { Debug.Log("Calculating from starting position"); } ai.actorData.gridPosX = movementOption.data.posX; ai.actorData.gridPosY = movementOption.data.posY; //this might serve some purpose that i don't understand // yield return null; //cycle through every skill that can be used foreach (Skill skillOption in avaliableSkills) { //find the range of the skill // Get a list of tiles associated with that skill's range // List <TileNode> nodesInRange = gm.pathfinding.GetNodes( gm.pathfinding.ValidBFS(skillOption, movementOption, ai )); //gm.tileSelection.PopulateAttackRange(nodesInRange); foreach (TileNode nodeInSkillrange in nodesInRange) //should be valid targets for the skill based on when it's being used from { /// So now we are cycling through a list of valid targets, /// so we'll use the skill on this target and calculate the score /// //yield return null; Combat testCombat = new Combat(ai); AnimationData animationData = AnimationData.NewAntionData(skillOption, gm.pathfinding.GetTileNode(ai), nodeInSkillrange); testCombat.animationDatas.Add(animationData); testCombat.PoopulateCombat(animationData); // So now we have a combat damage map we can use to determine the score and create an action //check to make sure there is an actor here and that the actor is player controlled // so we dont just randomaly blow up our own ppl // further work: give negative score if allied units would be damaged? AttackEnemyAction action = new AttackEnemyAction(nodeInSkillrange, movementOption, ai, skillOption); CalculateDamageScore(testCombat, action); CalcuateTileCost(movementOption, ai, action); CalculateBuffScore(testCombat, action); CacluateSummonScore(testCombat, action); validActions.Add(action); //make this is like a heap or something later /* * if (score != 0) * { * Debug.Log("Target Node: " + nodeInSkillrange.data.posX + ", " + nodeInSkillrange.data.posY + * ". Skilled Used: " + skillOption.GetKey() + * ". Move Target: " + movementOption.data.posX + ", " + movementOption.data.posY + * "Score: " + action.GetScore()); * }*/ } } } //Debug.Log("Time compexity kinda: " + n); //POTENTIAL OPTIMIZATION: we theoretically know the ranges of skills and the aoe of there target //types so maybe we can just do math to cut out tiles where we know there wont be anything //Set the position back to where the actor ACTUALLY is ai.actorData.gridPosX = originalX; ai.actorData.gridPosY = originalY; //yield return null; } yield return(null); }