protected void FormPattern(LanePattern pattern, int lane, LaneManager[] Board) { LaneManager TheLane = Board[lane - 1]; CreatureBase[] FriendlyCreatures = TheLane.GetFriendliesInLane(this).ToArray(); if (FriendlyCreatures.Length == 0) { foreach (Spawnable spawntype in pattern.PatternDefinition) { AIResponse.Spawn(spawntype, lane); } return; } LanePattern lanePattern = new LanePattern(FriendlyCreatures); if (LanePattern.Equals(lanePattern)) { return; } for (int i = 0; i < LanePattern.PatternDefinition.Length; i++) { if (lanePattern.PatternDefinition.Length <= i || LanePattern.PatternDefinition[i] != lanePattern.PatternDefinition[i]) { if (!AIResponse.Spawn(LanePattern.PatternDefinition[i], lane)) { Debug.Log("~~~~ Failed Spawn in Pattern"); } else { Debug.Log("~~~~ Success Spawn in Pattern"); } } } }
private void SpawnEnemy() { // Round robin spawning if (_lanetospawn > 3) { _lanetospawn = 1; } if (_lastSpawned == Spawnable.Unicorn) { if (AIResponse.Spawn(Spawnable.Bunny, _lanetospawn)) { _lastSpawned = Spawnable.Bunny; } } else if (_lastSpawned == Spawnable.Bunny) { if (AIResponse.Spawn(Spawnable.Unicorn, _lanetospawn)) { _lastSpawned = Spawnable.Unicorn; } } _lanetospawn++; }
public override void OnTick(IBoardState[] data) { //Spend all tokens //Spawn in each lane otherwise attack or move int maxCycles = 99; while (AIResponse.Tokens > 0 && maxCycles > 0) //Spend all tokens { maxCycles--; if (Random.Range(0, 2) == 0 || _Creatures.Count == 0) { int randomLane = Random.Range(1, TournamentManager._instance.lanes.Count + 1); // LogStack.Log ("Random Spawn Lane " + randomLane, LogLevel.System); if (!AIResponse.Spawn(Random.Range(0, 2) == 0 ? Spawnable.Bunny : Spawnable.Unicorn, randomLane)) { if (_Creatures.Count > 0) { CreatureBase randomCreature = _Creatures[Random.Range(0, _Creatures.Count)]; AttemptMoveAttack(randomCreature); } } } else if (_Creatures.Count > 0) { CreatureBase randomCreature = _Creatures[Random.Range(0, _Creatures.Count)]; AttemptMoveAttack(randomCreature); } } AIResponse.FinalizeResponse(); }
public override void OnTick(IBoardState[] data) { if (!AIResponse.Spawn(Spawnable.Unicorn, 1)) { } //IResponse[] responses = AIResponse.QueryResponse(); AIResponse.FinalizeResponse(); }
public void Auto_Nearest(LaneManager[] Board) { Tuple <CreatureBase, int> nearestAndRange = GetNearestCreatureToNearestEnemy(Board); if (nearestAndRange != null && _Creatures.Count > 0) { LogStack.Log("I have a nearby unit", Logging.LogLevel.Color); List <CreatureBase> inRange = nearestAndRange.Item1.ActiveLaneNode.laneManager.SearchRange((int)nearestAndRange.Item1.Range, nearestAndRange.Item1.ActiveLaneNode, nearestAndRange.Item1.Owner); if (inRange.GetEnemies(nearestAndRange.Item1.Owner).Count > 0) { // if (AIResponse.Attack (nearestAndRange.Item1)) { if (!AIResponse.Attack(nearestAndRange.Item1, nearestAndRange.Item1.CreatureType == Spawnable.Bunny ? 1 : (int)GetNearestEnemy(Board).Health)) { // LogStack.Log ("Attack Validation check failed", Logging.LogLevel.System); } else { LogStack.Log("Nearby Unit Attacking", Logging.LogLevel.Color); } } else { LogStack.Log("Try Move " + nearestAndRange.Item1.GetInstanceID(), Logging.LogLevel.System); if (!AIResponse.Move(nearestAndRange.Item1)) { LogStack.Log("Move validation check failed", Logging.LogLevel.Color); } else { LogStack.Log("Nearby Unit Moving", Logging.LogLevel.Stack); } } } else if (Opponent._Creatures.Count > 0) { CreatureBase nearestCreature = GetNearestEnemy(Board); int nearestLane = 1; Spawnable spawnCreature = Spawnable.Bunny; if (nearestCreature != null) { spawnCreature = nearestCreature.LaneProgress < 6 ? Spawnable.Unicorn : Spawnable.Bunny; nearestLane = nearestCreature.ActiveLaneNode.laneManager.LaneNumber; } if (!AIResponse.Spawn(spawnCreature, nearestLane)) { LogStack.Log("Spawn Validation check failed", Logging.LogLevel.Stack); } } else if (Opponent._Creatures.Count == 0) { LogStack.Log("Wait till opponent does something", Logging.LogLevel.Stack); } }
public override void OnTick(IBoardState[] data) { if (!AIResponse.Spawn(Random.Range(0, 2) == 0 ? Spawnable.Bunny : Spawnable.Unicorn, Random.Range(1, 4))) { if (_Creatures.Count > 0) { AIResponse.Attack(_Creatures[0]); } } //IResponse[] responses = AIResponse.QueryResponse(); AIResponse.FinalizeResponse(); }
public void SelectLane(int _laneNumber) { if (!AIResponse.Spawn(lastSpawnable, _laneNumber)) { Debug.Log("Could not spawn " + lastSpawnable + " in lane " + _laneNumber); SkipTurn(false); } else if (AIResponse.Tokens > 0) { OpenUI(); } else { Finalise(); CloseUI(); } }
private void SpawnTroop(int iLane) { CreatureBase creatureofFirstNode = B_StartLeft ? TournamentManager._instance.lanes[iLane].startNode.activeCreature : TournamentManager._instance.lanes[iLane].endNode.activeCreature; if (creatureofFirstNode == null) { //LogStack.Log("Trying to spawn in slot... 0:" + iLane, LogLevel.Debug); if (AIResponse.Spawn((LI_LaneTypes[iLane]) ? Spawnable.Unicorn : Spawnable.Bunny, iLane + 1)) { //Swaps spawning creature type (Alternates between bunnies and unicorns!) LI_LaneTypes[iLane] = !LI_LaneTypes[iLane]; } } else { ShiftLane(iLane); } }
//Do spawn is zero indexed but uses spawing like it needsit public void DoSpawn(int lane = 0, bool randomlane = false) { var enemiesinlane = 0; var friendliesinlane = 0; int cnt = 0; LaneManager mostImportant = null; foreach (LaneManager l in TournamentManager._instance.lanes) { enemiesinlane = l.GetEnemiesInLane(this).Count; friendliesinlane = l.GetFriendliesInLane(this).Count; if (mostImportant == null) { mostImportant = l; } else { if (enemiesinlane > 0 && friendliesinlane == 0) { mostImportant = l; } else if (enemiesinlane == 0 && friendliesinlane > 0) { if (!(mostImportant.GetEnemiesInLane(this).Count == 0 && mostImportant.GetFriendliesInLane(this).Count == 0) && !(mostImportant.GetEnemiesInLane(this).Count > 0 && mostImportant.GetFriendliesInLane(this).Count == 0)) { mostImportant = l; } } else if (enemiesinlane == 0 && friendliesinlane == 0) { mostImportant = l; } else { if (!(mostImportant.GetEnemiesInLane(this).Count == 0 && mostImportant.GetFriendliesInLane(this).Count == 0) && !(mostImportant.GetEnemiesInLane(this).Count > 0 && mostImportant.GetFriendliesInLane(this).Count == 0) && !(mostImportant.GetEnemiesInLane(this).Count == 0 && mostImportant.GetFriendliesInLane(this).Count > 0)) { mostImportant = l; } } } cnt++; } Debug.Log("Most important lane is: " + mostImportant.LaneNumber); if (mostImportant != null) { enemiesinlane = mostImportant.GetEnemiesInLane(this).Count; friendliesinlane = mostImportant.GetFriendliesInLane(this).Count; cnt = mostImportant.LaneNumber - 1; if (enemiesinlane == 0 && friendliesinlane == 0) { if (Random.Range(0, 3) >= 1) { AIResponse.Spawn(Spawnable.Unicorn, cnt + 1); } else { AIResponse.Spawn(Spawnable.Bunny, cnt + 1); } } else if (friendliesinlane == 0) { if (Random.Range(0, 3) >= 1) { AIResponse.Spawn(Spawnable.Unicorn, cnt + 1); } else { AIResponse.Spawn(Spawnable.Bunny, cnt + 1); } } else { CreatureBase highestprog = null; foreach (CreatureBase creat in mostImportant.GetFriendliesInLane(this)) { if (highestprog == null) { highestprog = creat; } else if (creat.LaneProgress > highestprog.LaneProgress) { highestprog = creat; } } if (highestprog != null) { MoveAtk(highestprog); } } } }