Exemplo n.º 1
0
 // Setting the target of the Squad
 public void setSquadTarget(CapturePoint.CapturePointId capturePointId)
 {
     // listOfNPCs[0].GetComponent<NpcSimple>().GoToTarget(target.transform);
     listOfNPCs[0].GetComponent <NpcSimple>().GoToCapturePoint(capturePointId, TacticalWaypoint.WaypointType.NonePoint, false);
     //listOfNPCs[0].GetComponent<NpcSimple>().GoToNearestCoverAround(new Vector3(14.93796f, -0.003662109f, 114.7996f));
     //listOfNPCs[0].GetComponent<NpcSimple>().StayStillOnPoint(true);
     capPointId = capturePointId;
 }
Exemplo n.º 2
0
    CapturePoint.CapturePointId findNearestCapturePoint()
    {
        CapturePoint.CapturePointId pointId = 0;
        float smallestDistance = 999999999.0f;

        foreach (KeyValuePair <CapturePoint.CapturePointId, CapturePoint> point in capturePointMap.GetComponent <CapturePointMap>().capturePoints)
        {
            // Calculate shortest distance to enemy flags
            if (!(point.Value.GetComponent <CapturePoint>().belongsToTeam == playerTeamSide.playerTeam))
            {
                float distance = Vector3.Distance(point.Value.transform.position, listOfCollision[0].transform.position);

                if (distance < smallestDistance)
                {
                    smallestDistance = distance;
                    pointId          = point.Key;
                }
            }
        }

        return(pointId);
    }
Exemplo n.º 3
0
    bool isPointClearForRed(GameObject squad)
    {
        bool isAtCapPoint = squad.GetComponent <NPCSquad>().listOfNPCs[0].GetComponent <NpcSimple>().IsAtCapturePoint;

        CapturePoint.CapturePointId capId = squad.GetComponent <NPCSquad>().capPointId;

        CapturePoint point = null;

        foreach (KeyValuePair <CapturePoint.CapturePointId, CapturePoint> cp in capturePointMap.GetComponent <CapturePointMap>().capturePoints)
        {
            if (cp.Key == capId)
            {
                point = cp.Value;
            }
        }

        if (isAtCapPoint && (point.GetComponent <CapturePoint>().bluePlayersInside != 0))
        {
            return(false);
        }


        return(true);
    }
Exemplo n.º 4
0
 public bool HasArrivedAtCapturePoint(CapturePoint.CapturePointId capturePointId)
 {
     return(IsAtCapturePoint);
 }
Exemplo n.º 5
0
    public void GoToCapturePoint(CapturePoint.CapturePointId captureId, TacticalWaypoint.WaypointType findWaypointType, bool preferTeamCover = true)
    {
        CapturePoint point = capturePointMap.capturePoints[captureId];


        targetArea = point.GetComponent <SphereCollider>();

        List <TacticalWaypoint> waypointTypeOnCapturePoint = null;

        switch (findWaypointType)
        {
        case TacticalWaypoint.WaypointType.NonePoint:
            waypointTypeOnCapturePoint = null;
            break;

        case TacticalWaypoint.WaypointType.CoverPoint:
            waypointTypeOnCapturePoint = point.coverpointsOnCapturePoint;
            break;

        case TacticalWaypoint.WaypointType.AmbushPoint:
            waypointTypeOnCapturePoint = point.ambushPointsOnCapturePoint;
            break;

        default:
            waypointTypeOnCapturePoint = null;
            break;
        }

        // If we want to find a cover point, and the capture point has one
        if (waypointTypeOnCapturePoint != null && waypointTypeOnCapturePoint.Count != 0)
        {
            // If we want cover that is closer to the players team side
            if (preferTeamCover)
            {
                // Create a local list of cover points that belong to a team
                List <TacticalWaypoint> teamWaypointTypes = new List <TacticalWaypoint>();

                foreach (var waypointType in waypointTypeOnCapturePoint)
                {
                    if (waypointType.closerToWhichTeamSide == team.playerTeam)
                    {
                        teamWaypointTypes.Add(waypointType);
                    }
                }

                // If we have some team cover points to go to, then pick a random one
                if (teamWaypointTypes.Count != 0)
                {
                    //targetTransform = teamWaypointTypes[Random.Range(0, teamWaypointTypes.Count)].transform;
                    TacticalWaypoint tw = teamWaypointTypes[Random.Range(0, teamWaypointTypes.Count)];
                    targetTransform = tw.transform;
                    targetArea      = tw.GetComponent <SphereCollider>();
                }
                else
                {
                    // If there are no team cover points found, just pick a random one
                    //targetTransform = waypointTypeOnCapturePoint[Random.Range(0, waypointTypeOnCapturePoint.Count)].transform;
                    TacticalWaypoint tw = waypointTypeOnCapturePoint[Random.Range(0, waypointTypeOnCapturePoint.Count)];
                    targetTransform = tw.transform;
                    targetArea      = tw.GetComponent <SphereCollider>();
                }
            }
            else
            {
                // For now go to a random cover point
                // targetTransform = waypointTypeOnCapturePoint[Random.Range(0, waypointTypeOnCapturePoint.Count)].transform;
                TacticalWaypoint tw = waypointTypeOnCapturePoint[Random.Range(0, waypointTypeOnCapturePoint.Count)];
                targetTransform = tw.transform;
                targetArea      = tw.GetComponent <SphereCollider>();
            }
        }
        else
        {
            // If we dont want to find either a cover point, or an ambush type, then just go to the capture point
            //targetTransform = capturePointMap.capturePoints[captureId].transform;

            CapturePoint tw = capturePointMap.capturePoints[captureId];
            targetTransform = tw.transform;
            targetArea      = tw.GetComponent <SphereCollider>();
        }
    }