public override void UpdateRole() { base.UpdateRole(); if (enemiesInSight.Count > 0) { if (mySoldier.LookAt(Vector3Extensions.GetPositionWithSmallestDiffAngle(enemiesInSight, mySoldier))) { mySoldier.Shoot(); } navAgent.moveToTarget = false; underFireCell = null; } else if (underFireCell != null) { mySoldier.LookAt(underFireCell.GetPosition()); if (CellExtentions.IsCellAngleSmaller(underFireCell, 50, mySoldier)) { underFireCell = null; } } else if (reportedEnemyPositions.Count > 0) { mySoldier.LookAt(Vector3Extensions.GetPositionWithSmallestDiffAngle(reportedEnemyPositions, mySoldier)); } else { if (navAgent.pathGenerated.Count > 0) { navAgent.moveToTarget = true; mySoldier.MoveTowards(navAgent.pathGenerated[0]); } if (backToHome && (navAgent.pathGenerated.Count > 0)) { mySoldier.LookAt(navAgent.pathGenerated[0]); } else { Vector3 dir = MyCell.GetPosition() + lookAtPos.GetPosition(); mySoldier.LookAt(dir); } } }
public override void UpdateRole() { base.UpdateRole(); if (enemiesInSight.Count > 0) { if (mySoldier.LookAt(Vector3Extensions.GetPositionWithSmallestDiffAngle(enemiesInSight, mySoldier))) { mySoldier.Shoot(); } navAgent.moveToTarget = false; underFireCell = null; } else if (underFireCell != null) { mySoldier.LookAt(underFireCell.GetPosition()); if (CellExtentions.IsCellAngleSmaller(underFireCell, 50, mySoldier)) { underFireCell = null; } } else { if (navAgent.pathGenerated.Count > 0) { navAgent.moveToTarget = true; mySoldier.MoveTowards(navAgent.pathGenerated[0]); mySoldier.LookAt(navAgent.pathGenerated[0]); } else { myTeam.Route.RemoveNextWaypoint(); if (!myTeam.Route.IsEmpty()) { navAgent.targetCell = myTeam.Route.GetNextWaypoint(); } } } }