void Awake() { // Initialize components and visual effects hidden InitializeSelectionHighlight(); InitializeMiniMapIcon(); InitializeParticleEffects(); HealthBar = GetComponentInChildren <HealthBarManager>(); maxHealth = Health; UnitID = UnitTracker.GetNewUnitID(); // Minimum degree angle required to skip the unit rotation, above will require rotate toward destination PermissiveDestinationAngleDelta = 1; // If the unit is already in the scene when launching the game, setting the destination to the current // position of the GameObject here has the same result as setting it at the variable declaration above. // But, if a new unit instance is requested while the game is running, the reference of the unit to be // instanciated will immediately exist while the actual instance will only be generated on the next frame. // Therefore, 'MoveToDestination' could be called to set the desired destination, but it would immediately // be overriden by the first 'Start' call when it is instanciated on the next frame. // Setting the variable in the 'Start' call resolves the problem no matter when the unit is instanciated. if (destinationRequest.Equals(Vector3.zero)) { destinationRequest = transform.position; } }
void AcquireTarget() { if (targetObject == null) { GameObject closestEnemy = null; foreach (GameObject go in UnitTracker.GetActiveEnemies(gameObject)) { if (closestEnemy == null) { closestEnemy = go; continue; } if ((go.transform.position - transform.position).magnitude < (closestEnemy.transform.position - transform.position).magnitude) { closestEnemy = go; } } targetObject = closestEnemy; if (targetObject != null) { target = targetObject.transform.position; } } }
// Update is called once per frame void Update() { if (UnitTracker.GetActiveEnemyCount() == 0) { if (bossSpawned == false) { UnitSpawner.SpawnUnitsInArea(UnitReferences.EnemyBattleship, 1, enemySpawns[3]); bossSpawned = true; } else { GameController.Instance.PlayerVictorious(); } } if (UnitTracker.GetActiveEnemyCount() < 20 && enemiesKilled < 20) { int randomSpawn = Random.Range(0, 2); int tempEnemiesKilled = 20 - UnitTracker.GetActiveEnemyCount(); UnitSpawner.SpawnUnitsInArea(UnitReferences.EnemyFighter1, tempEnemiesKilled, enemySpawns[randomSpawn]); enemiesKilled += tempEnemiesKilled; } if (UnitTracker.GetActiveAllyCount() < 10 && alliesKilled < 15) { int randomSpawn = Random.Range(0, 2); int temAllyKilled = 10 - UnitTracker.GetActiveAllyCount(); UnitSpawner.SpawnUnitsInArea(UnitReferences.AlliedFighter1, temAllyKilled, allySpawns[randomSpawn]); alliesKilled += temAllyKilled; } }
void Start() { playerAtComputer = GameObject.FindGameObjectWithTag("Player"); ut = FindObjectOfType <UnitTracker>(); am = FindObjectOfType <AllegianceManager>(); cm = FindObjectOfType <CityManager>(); }
protected override void UnitDeath() { if (UnitTracker.GetActiveEnemyCount() == 0) { AdvancePhase(); } }
void CheckForWin() { if (UnitTracker.GetActiveEnemyCount() == 0 && UnitTracker.PlayerShip != null && TimerController.Instance.GetTime() > 0 && currentProgressionPoint == 2) { HUDController.Instance.DisplayMessage("You win."); } }
// Start is called before the first frame update void Start() { ut = FindObjectOfType <UnitTracker>(); player = GameObject.FindGameObjectWithTag("Player"); //TODO multiplayer this PopulateSectorIntensitieswithZero(); SetFadeTimeInEachSector(); }
protected override void UnitDeath() { if (UnitTracker.GetActiveEnemyCount() == 0 && !bossSpawned) { UnitSpawner.SpawnUnit(UnitReferences.EnemyBattleship, new Vector3(0, 100, 200)); bossSpawned = true; } }
// Start is called before the first frame update void Start() { ut = FindObjectOfType <UnitTracker>(); ownIFF = GetComponentInChildren <IFF>(); attackRange = weaponLifetime * weaponSpeed; selectedFiringSound = SelectSoundFromArray(firingSounds); sh = GetComponentInChildren <StealthHider>(); }
// Use this for initialization void Awake() { instance = this; UnitTracker.Clear(); ProjectileTracker.Clear(); UnitSpawner.SpawnUnit(GameSettings.CurrentPlayerShip, currentLevelController.CurrentPlayerSpawn.transform.position, RotationCalculator.RotationTowardLocation(currentLevelController.CurrentPlayerSpawn.transform.position, currentLevelController.PositionPlayerLooksAtSpawn)); }
// Update is called once per frame void Update() { alliedCount = UnitTracker.GetActiveAllyCount(); if (alliedCount < 2) { GameController.Instance.PlayerDefeated(); } if (cruiser.GetComponent <CruiserAIController>().WayPointNumber == 3) { GameController.Instance.PlayerVictorious(); } }
public void Start() { sr = GetComponent <SpriteRenderer>(); if (isHouse) { ChooseHouseImage(); } ut = FindObjectOfType <UnitTracker>(); ut.AddUnitToTargetableList(gameObject); UpdateCurrentOwner(); timeSinceLastMoneyDrop = UnityEngine.Random.Range(0, timeBetweenMoneyDrops); }
// Start is called before the first frame update public override void OnStartServer() { base.OnStartServer(); ut = FindObjectOfType <UnitTracker>(); ownIFF = GetComponent <IFF>(); attackRange = weaponLifetime * weaponSpeed; sh = GetComponentInChildren <StealthHider>(); ss = GetComponentInChildren <StealthSeeker>(); ss.OnSeekerDetection += EvaluateDetectedObject; ss.OnSeekerLostContact += HandleLostContact; ut.AddUnitToTargetableList(gameObject); ownIFF.OnChangeIFF += CheckForAlliesAsTargetsAfterIFFChange; }
protected virtual void Start() { ut = FindObjectOfType <UnitTracker>(); ut.AddUnitToTargetableList(gameObject); move = GetComponentInChildren <Movement>(); attack = GetComponentInChildren <Attack>(); targetGO = GameObject.FindGameObjectWithTag("Player"); iff = GetComponent <IFF>(); cm = FindObjectOfType <CityManager>(); health = GetComponentInChildren <Health>(); am = FindObjectOfType <AllegianceManager>(); if (TryGetComponent <NavMeshAgent>(out nma)) { nma.updateRotation = false; } }
// Gets the enemy closest to crosshairs GameObject GetEasiestTarget() { GameObject easiestTarget = null; foreach (GameObject enemy in UnitTracker.GetActiveEnemies(myInfo.TeamID)) { if ((easiestTarget == null) || (Vector3.Angle(transform.forward, easiestTarget.transform.position - transform.position) > Vector3.Angle(transform.forward, enemy.transform.position - transform.position))) { easiestTarget = enemy; } } targetTimer = 0; return(easiestTarget); }
void Die() { if (myInfo.Explosion != null) { Instantiate(myInfo.Explosion, transform.position, transform.rotation); } //If this unit is not the player: Remove it from the unitTracker and raise the OnUnitDeath event. if (!myInfo.IsPlayerShip) { UnitTracker.RemoveUnit(gameObject); try { if (OnUnitDeath != null) { OnUnitDeath(); } } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n" + ex.StackTrace); } } else //If this unit is the player: Remove its reference in the unitTracker and raise the OnPlayerDeath event. { UnitTracker.PlayerShip = null; try { if (OnPlayerDeath != null) { OnPlayerDeath(); } } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n" + ex.StackTrace); } } if (myInfo.IsPooled) { gameObject.SetActive(false); } else { Destroy(gameObject); } }
// Gets the closest enemy GameObject GetClosestTarget() { GameObject closestTarget = null; foreach (GameObject enemy in UnitTracker.GetActiveEnemies(myInfo.TeamID)) { if ((closestTarget == null) || (Vector3.Distance(enemy.transform.position, this.transform.position) > Vector3.Distance(closestTarget.transform.position, this.transform.position))) { closestTarget = enemy; } } targetTimer = 0; return(closestTarget); }
EnemyDecision FindBestAttackAt(Vector3Int move) { UnitTracker ut = GetComponent <UnitTracker>(); List <Vector3Int> possibleAttacks = ut.PossibleAttacksAtTile(move); Vector3Int bestAttack = new Vector3Int(-1, -1, -1); float bestRating = 0; bool freeAttackFound = false; foreach (Vector3Int attack in possibleAttacks) { if (TileManager.instance.allUnits.ContainsKey(attack) && TileManager.instance.allUnits[attack].tag != tag) { GameObject target = TileManager.instance.allUnits[attack]; BattleSimulation battle = new BattleSimulation(gameObject, target, move, target.GetComponent <UnitTracker>().GetLocation()); if (!freeAttackFound && battle.GetDefenderAttacks() == 0) { freeAttackFound = true; bestRating = CalculateRating(battle); bestAttack = attack; } else if (!freeAttackFound && battle.GetDefenderAttacks() != 0) { float tempRating = CalculateRating(battle); if (tempRating > bestRating) { bestRating = tempRating; bestAttack = attack; } } else if (battle.GetDefenderAttacks() == 0) { float tempRating = CalculateRating(battle); if (tempRating > bestRating) { bestRating = tempRating; bestAttack = attack; } } } } return(new EnemyDecision(bestAttack)); }
/// <summary> /// Returns if the given position is within a collider of any unit in the scene. /// </summary> /// <param name="position"></param> /// <returns>True if the given position is within any unit's collider, false if not.</returns> static bool PositionInsideAnyUnitCollider(Vector3 position) { List <GameObject> units = UnitTracker.GetActiveUnits(); foreach (GameObject go in units) { MeshCollider mc = go.GetComponent <MeshCollider>(); if (mc == null) { continue; } if (mc.bounds.Contains(position)) { return(true); } } return(false); }
/// <summary> /// Returns the closest enemy of given UnitTypes that is within the given maximum distance. /// </summary> /// <param name="myUnit">Unit to find the enemies of.</param> /// <param name="unitTypes">Array of unit types that are valid targets.</param> /// <param name="maxDistance">Maximum distance to find enemies.</param> /// <returns>Closest enemy unit within max distance.</returns> public static GameObject GetClosestEnemy(GameObject myUnit, UnitType[] unitTypes, int maxDistance, bool objectiveUnitsOnly) { List <GameObject> enemies; if (objectiveUnitsOnly) { enemies = UnitTracker.GetObjectiveEnemies(myUnit); } else { enemies = UnitTracker.GetActiveEnemies(myUnit); } GameObject closestEnemy = null; float closestEnemyDistance = float.MaxValue; foreach (GameObject go in enemies) { bool isCorrectShipType = false; foreach (UnitType ut in unitTypes) { if (go.GetComponent <UnitInfo>().UnitType == ut) { isCorrectShipType = true; break; } } if (!isCorrectShipType) { continue; } float dist = (go.transform.position - myUnit.transform.position).magnitude; if (dist < closestEnemyDistance && dist <= maxDistance) { closestEnemyDistance = (go.transform.position - myUnit.transform.position).magnitude; closestEnemy = go; } } return(closestEnemy); }
float maxTargetLength = 10.0f; // Maximum amount of time to have a target before searching for a new one void Start() { myInfo = GetComponent <UnitInfo>(); weaponsController = GetComponent <WeaponsController>(); myRigidbody = GetComponent <Rigidbody>(); target = GetEasiestTarget(); myHealth = GetComponent <Health> (); phase = 1; shieldsOn = true; boosted = false; if (!UnitTracker.GetActiveUnits().Contains(this.gameObject)) { UnitTracker.AddUnit(this.gameObject); } // set target on spawn messageTxt = GameObject.Find("MessageText").GetComponent <MessageTextController>(); messageTxt.DisplayMessage("Their shields are too strong for our weapons. Try to find a weak point."); }
/// <summary> /// Find the closest enemy unit and sets it as our target. /// </summary> void AcquireTarget() { if (!ownerAndTeamSet) { return; } if (targetObject == null || targetObject.activeInHierarchy == false) { //If our owner is the player: Set our target as the player's target. if (GetComponent <ProjectileInfo>().Owner == UnitTracker.PlayerShip && TargettingController.Instance != null) { targetObject = TargettingController.Instance.Target; } if (targetObject == null) { GameObject closestEnemy = null; foreach (GameObject go in UnitTracker.GetActiveEnemies(gameObject)) { if (closestEnemy == null) { closestEnemy = go; continue; } if ((go.transform.position - transform.position).magnitude < (closestEnemy.transform.position - transform.position).magnitude) { closestEnemy = go; } } targetObject = closestEnemy; } if (targetObject != null) { target = targetObject.transform.position; } } }
/// <summary> /// Spawns a given unit type at given location with a given rotation. /// </summary> /// <param name="unitType">Type of unit to spawn.</param> /// <param name="spawnLocation">Location to spawn the unit.</param> /// <param name="spawnRotation">Rotation to spawn the unit.</param> /// <returns></returns> public static GameObject SpawnUnit(GameObject unitType, Vector3 spawnLocation, Quaternion spawnRotation) { if (unitType == null) { throw new MissingReferenceException("Given unitType was null, can't spawn."); } if (unitType.GetComponent <UnitInfo>() == null) { throw new MissingComponentException("Given unitType doesn't have a UnitInfo component. Is it a unit?"); } if (unitType.GetComponent <UnitInfo>().IsPlayerShip&& UnitTracker.PlayerShip != null) { throw new System.Exception("A player ship already exists in this scene and you are trying to instantiate another player ship."); } GameObject unit; if (unitType.GetComponent <UnitInfo>().IsPooled) { unit = PoolController.Instance.GetObject(unitType, spawnLocation, spawnRotation); } else { unit = Instantiate(unitType, spawnLocation, spawnRotation) as GameObject; } if (unit.GetComponent <UnitInfo>().IsPlayerShip) { UnitTracker.PlayerShip = unit; } else if (!unit.GetComponent <UnitInfo>().NotTargettable) { UnitTracker.AddUnit(unit); } return(unit); }
void SwitchTarget() { //Get the list of enemies... List <GameObject> units = UnitTracker.GetActiveEnemies(); //cycle through the list of enemies... for (int i = 0; i < units.Count; i++) { if (units [i] != null && units [i].GetComponent <UnitInfo> () != null) { //First, we need to check if we currently have a target. If we don't just assign the first one for now if (target == null || !target.activeInHierarchy) { target = units [i]; targetIndex = i; } //If the current unit being checked ISN'T the target and is closest to the reticle then pick that one targetLoc = playerCam.WorldToScreenPoint(units[i].transform.position); Vector2 currentTargetLoc = playerCam.WorldToScreenPoint(target.transform.position); //We also want to check if the target is within the camera's view. if (target != units [i] && (units[i].GetComponent <Renderer>().isVisible)) { //Now, we check to see if the new target is CLOSER to the reticle than the current target. If so, switch targets. if (Mathf.Sqrt((targetLoc.x - (Screen.width / 2f)) * (targetLoc.x - (Screen.width / 2f)) + (targetLoc.y - (Screen.height / 2f)) * (targetLoc.y - (Screen.height / 2f))) < //if distance1 from center is less than Mathf.Sqrt((currentTargetLoc.x - (Screen.width / 2f)) * (currentTargetLoc.x - (Screen.width / 2f)) + (currentTargetLoc.y - (Screen.height / 2f)) * (currentTargetLoc.y - (Screen.height / 2f)))) // Distance 2... //After that sinful line of code we assign the target if the current one being checked is closest to the center of the screen (reticle) { target = units [i]; targetIndex = i; targetTitle.text = target.GetComponent <UnitInfo> ().ShipTitle; targetIcon.GetComponent <AudioSource> ().Play(); } } } } }
public EnemyDecision GetDecision() { UnitTracker ut = GetComponent <UnitTracker>(); switch (behaviour) { case EnemyBehaviour.IDLE: //In this state, enemies will simply stand still, and will not attack (will still counterattack) return(new EnemyDecision()); case EnemyBehaviour.HOLD: //In this state, enemies will stay in place, and will not move. They will attack anything in their immediate range, //but will not move to attack a unit return(FindBestAttackAt(ut.GetLocation())); case EnemyBehaviour.WAIT: //In this state, enemies will stay in place, but will move to attack any enemies they can move to and attack return(FindBestMoveAttack(ut.PossibleMovement())); case EnemyBehaviour.SEEK: //In this state, enemies will stay in place, but will move to attack any enemies they can move to and attack //If there are no enemies to attack, enemies will move towards their goal EnemyDecision bestCombat = FindBestMoveAttack(ut.PossibleMovement()); if (bestCombat.pass) { return(FindBestMove(new Vector3Int(0, 0, 0))); } else { return(bestCombat); } } print("???"); return(new EnemyDecision()); }
void FixedUpdate() { if (playerObj != null) { int playerTeamID = -1; if (playerObj.GetComponent <UnitInfo>() != null) { playerTeamID = playerObj.GetComponent <UnitInfo>().TeamID; } //We update the player's location every physics step playerLoc = playerObj.transform.position; //Get the active enemies and iterate through the list List <GameObject> enemies = UnitTracker.GetActiveEnemies(); int requiredEnemyIcons = 0; for (int i = 0; i < enemies.Count; i++) { if (enemies[i] != null && enemies[i].GetComponent <UnitInfo>() != null) { //Calculate the distance of each enemy from the player and check if it's outside the range of the radar Vector2 distFromPlayer = new Vector2(playerLoc.x - enemies[i].transform.position.x, playerLoc.z - enemies[i].transform.position.z); float length = Mathf.Sqrt((distFromPlayer.x * distFromPlayer.x) + (distFromPlayer.y * distFromPlayer.y)); if (length < radarRange) { //Draw the unit on the radar, maintain scale, rotation etc Vector3 pos = new Vector3((transform.position.x - distFromPlayer.x / (radarRange / 150)), (transform.position.y - distFromPlayer.y / (radarRange / 150)), transform.position.z); if (requiredEnemyIcons < enemyIcons.Count) { enemyIcons[requiredEnemyIcons].transform.position = pos; } else { enemyIcons.Add(PoolController.Instance.GetObject(enemyIcon, pos, Quaternion.identity, transform)); } requiredEnemyIcons++; } } } //Remove unneccessary enemy icons. for (int i = enemyIcons.Count - 1; i >= requiredEnemyIcons; i--) { enemyIcons[i].SetActive(false); enemyIcons.Remove(enemyIcons[i]); } List <GameObject> allies = UnitTracker.GetActiveAllies(); int requiredAllyIcons = 0; for (int i = 0; i < allies.Count; i++) { if (allies[i] == playerObj) { continue; } if (allies[i] != null && allies[i].GetComponent <UnitInfo>() != null) { //Calculate the distance of each enemy from the player and check if it's outside the range of the radar Vector2 distFromPlayer = new Vector2(playerLoc.x - allies[i].transform.position.x, playerLoc.z - allies[i].transform.position.z); float length = Mathf.Sqrt((distFromPlayer.x * distFromPlayer.x) + (distFromPlayer.y * distFromPlayer.y)); if (length < radarRange) { //Draw the unit on the radar, maintain scale, rotation etc Vector3 pos = new Vector3((transform.position.x - distFromPlayer.x / (radarRange / 150)), (transform.position.y - distFromPlayer.y / (radarRange / 150)), transform.position.z); if (requiredAllyIcons < allyIcons.Count) { allyIcons[requiredAllyIcons].transform.position = pos; } else { allyIcons.Add(PoolController.Instance.GetObject(allyIcon, pos, Quaternion.identity, transform)); } requiredAllyIcons++; } } } //Remove unneccessary ally icons. for (int i = allyIcons.Count - 1; i >= requiredAllyIcons; i--) { allyIcons[i].SetActive(false); allyIcons.Remove(allyIcons[i]); } //Get the player ships rotation Vector3 playerRotation = playerObj.transform.eulerAngles; //Rotate our radar with the player ship, but only on one axis transform.eulerAngles = new Vector3(transform.rotation.x, transform.rotation.y, -playerRotation.y); } }
public LazySightFinder(UnitTracker UnitTracker) { this.UnitTracker = UnitTracker; }
EnemyDecision FindBestMoveAttack(List <Vector3Int> possibleMoves) { UnitTracker ut = GetComponent <UnitTracker>(); if (possibleMoves.Count == 0) { return(FindBestAttackAt(ut.GetLocation())); } Vector3Int bestMove = new Vector3Int(-1, -1, -1); Vector3Int bestAttack = new Vector3Int(-1, -1, -1); float bestRating = 0; bool freeAttackFound = false; foreach (Vector3Int move in possibleMoves) //Loop through every possible move a character can make { foreach (Vector3Int attack in ut.PossibleAttacksAtTile(move)) //Loop through every possible attack at each move { if (TileManager.instance.allUnits.ContainsKey(attack) && TileManager.instance.allUnits[attack].tag != tag) //Check to see if there is an attackable unit { GameObject target = TileManager.instance.allUnits[attack]; BattleSimulation battle = new BattleSimulation(gameObject, target, move, target.GetComponent <UnitTracker>().GetLocation()); if (!TileManager.instance.allUnits.ContainsKey(move)) { if (!freeAttackFound && battle.GetDefenderAttacks() == 0) { freeAttackFound = true; bestRating = CalculateRating(battle); bestMove = move; bestAttack = attack; } else if (!freeAttackFound && battle.GetDefenderAttacks() != 0) { float tempRating = CalculateRating(battle); if (tempRating > bestRating) { bestRating = tempRating; bestMove = move; bestAttack = attack; } } else if (battle.GetDefenderAttacks() == 0) { float tempRating = CalculateRating(battle); if (tempRating > bestRating) { bestRating = tempRating; bestMove = move; bestAttack = attack; } } } } } } if (bestMove.z == -1 && bestAttack.z == -1) { return(new EnemyDecision()); } List <Vector3Int> path = ShortestPath.instance.FindPath(gameObject.GetComponent <UnitTracker>().GetLocation(), bestMove, "Red"); return(new EnemyDecision(path, bestAttack)); }
public static HitChance GetHitChance(SpellSlot spellslot, float range, SkillShotType type, float delay, float speed, float radius, Vector3 fromPoint, Obj_AI_Base target) { // CAN'T MOVE SPELLS /////////////////////////////////////////////////////////////////////////////////// if (UnitTracker.GetSpecialSpellEndTime(target) > 0 || target.HasBuff("recall") || (UnitTracker.GetLastStopMoveTime(target) < 0.1d && target.IsRooted)) { return(HitChance.High); } // PREPARE MATH /////////////////////////////////////////////////////////////////////////////////// var tempHitchance = HitChance.Low; var lastWaypiont = target.RealPath().Last(); var distanceUnitToWaypoint = lastWaypiont.Distance(target.ServerPosition); var distanceFromToUnit = fromPoint.Distance(target.ServerPosition); var distanceFromToWaypoint = lastWaypiont.Distance(fromPoint); var getAngle = GetAngle(fromPoint, target); float speedDelay = distanceFromToUnit / speed; if (Math.Abs(speed - float.MaxValue) < float.Epsilon) { speedDelay = 0; } float totalDelay = speedDelay + delay; float moveArea = target.MoveSpeed * totalDelay; float fixRange = moveArea * 0.4f; float pathMinLen = 900 + +moveArea; double angleMove = 31; if (radius > 70) { angleMove++; } else if (radius <= 60) { angleMove--; } if (delay < 0.3) { angleMove++; } if (UnitTracker.GetLastNewPathTime(target) < 0.1d) { tempHitchance = HitChance.High; pathMinLen = 700f + moveArea; angleMove += 1.5; fixRange = moveArea * 0.3f; } if (type == SkillShotType.Circular) { fixRange -= radius / 2; } // FIX RANGE /////////////////////////////////////////////////////////////////////////////////// if (distanceFromToWaypoint <= distanceFromToUnit) { if (distanceFromToUnit > range - fixRange) { tempHitchance = HitChance.Medium; // return tempHitchance; } } else if (distanceUnitToWaypoint > 350) { angleMove += 1.5; } // SPAM CLICK /////////////////////////////////////////////////////////////////////////////////// if (UnitTracker.PathCalc(target)) { //OktwCommon.debug("PRED: SPAM CLICK"); if (distanceFromToUnit < range - fixRange) { tempHitchance = HitChance.High; } else { tempHitchance = HitChance.Medium; } // return tempHitchance; } // SPAM POSITION /////////////////////////////////////////////////////////////////////////////////// if (UnitTracker.SpamSamePlace(target)) { //OktwCommon.debug("PRED: SPAM POSITION"); return(HitChance.High); } // SPECIAL CASES /////////////////////////////////////////////////////////////////////////////////// if (distanceFromToUnit < 250) { //OktwCommon.debug("PRED: SPECIAL CASES NEAR"); return(HitChance.High); } else if (target.MoveSpeed < 250) { //OktwCommon.debug("PRED: SPECIAL CASES SLOW"); return(HitChance.High); } else if (distanceFromToWaypoint < 250) { //OktwCommon.debug("PRED: SPECIAL CASES ON WAY"); return(HitChance.High); } // LONG CLICK DETECTION /////////////////////////////////////////////////////////////////////////////////// if (distanceUnitToWaypoint > pathMinLen) { //OktwCommon.debug("PRED: LONG CLICK DETECTION"); return(HitChance.High); } // RUN IN LANE DETECTION /////////////////////////////////////////////////////////////////////////////////// if (getAngle < angleMove && distanceUnitToWaypoint > 260) { //OktwCommon.debug(GetAngle(input.From, target) + " PRED: ANGLE " + angleMove + " DIS " + distanceUnitToWaypoint); return(HitChance.High); } // CIRCLE NEW PATH /////////////////////////////////////////////////////////////////////////////////// if (type == SkillShotType.Circular) { if (UnitTracker.GetLastNewPathTime(target) < 0.1d && distanceUnitToWaypoint > fixRange) { //OktwCommon.debug("PRED: CIRCLE NEW PATH"); return(HitChance.High); } } // LOW HP DETECTION /////////////////////////////////////////////////////////////////////////////////// if (target.HealthPercent < 20 || ObjectManager.Player.HealthPercent < 20) { tempHitchance = HitChance.Medium; // return HitChance.Medium; } // STOP LOGIC /////////////////////////////////////////////////////////////////////////////////// if (target.RealPath().LastOrDefault() != target.ServerPosition) { if ((UnitTracker.GetLastAutoAttackTime(target) < 0.1 || UnitTracker.GetLastStopMoveTime(target) < 0.1) && totalDelay < 0.6) { //OktwCommon.debug("PRED: STOP LOGIC WINDING"); tempHitchance = HitChance.Medium; } else if (UnitTracker.GetLastStopMoveTime(target) < 0.5) { tempHitchance = HitChance.Medium; } else { //OktwCommon.debug("PRED: STOP LOGIC"); tempHitchance = HitChance.Medium; } return(tempHitchance); } //Program.debug("PRED: NO DETECTION"); return(tempHitchance); }
void OnDisable() { UnitTracker.RemoveUnit(gameObject); }