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();
                    }
                }
            }
        }
        public static Vector3 GetPositionWithSmallestDiffAngle(List <IAgent> enemies, SoldierTeamBlueberry soldier)
        {
            List <Vector3> positions = enemies.ConvertAll(e => new Vector3(e.GetLocation().x, e.GetLocation().y, e.GetLocation().z));

            return(Vector3Extensions.GetPositionWithSmallestDiffAngle(positions, soldier));
        }
        public static Vector3 GetPositionWithSmallestDiffAngle(List <Cell> cellPositions, SoldierTeamBlueberry soldier)
        {
            List <Vector3> positions = cellPositions.ConvertAll(c => new Vector3(c.GetPosition().x, c.GetPosition().y, c.GetPosition().z));

            return(Vector3Extensions.GetPositionWithSmallestDiffAngle(positions, soldier));
        }