コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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();
                    }
                }
            }
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }