Exemplo n.º 1
0
    // Change the Color of the point
    public void changePointColor(TeamSide.TeamEnum side)
    {
        // Change Point to Red
        if (side == TeamSide.TeamEnum.RedTeam)
        {
            this.GetComponent <MeshRenderer>().material           = RedTeamColor;
            pointIndicator.GetComponent <MeshRenderer>().material = RedTeamColor;
            applyPointTransparency(Point_Transparency_Alpha);
        }

        // Change Point to Blue
        else if (side == TeamSide.TeamEnum.BlueTeam)
        {
            this.GetComponent <MeshRenderer>().material           = BlueTeamColor;
            pointIndicator.GetComponent <MeshRenderer>().material = BlueTeamColor;
            applyPointTransparency(Point_Transparency_Alpha);
        }

        // Change Point to Neutral
        else if (side == TeamSide.TeamEnum.None)
        {
            this.GetComponent <MeshRenderer>().material           = NeutralTeamColor;
            pointIndicator.GetComponent <MeshRenderer>().material = NeutralTeamColor;
            applyPointTransparency(Point_Transparency_Alpha);
        }
    }
Exemplo n.º 2
0
    // Function to spawn a Squad of 5 units
    public void spawnSquad(Vector3 spawnPosition, TeamSide.TeamEnum side)
    {
        // TODO: set the npcs lane
        // Instantiate the Squad Leader
        GameObject leader = Instantiate(NPCPrefab, spawnPosition, Quaternion.identity);

        leader.GetComponent <TeamSide>().playerTeam   = side;
        leader.GetComponent <NpcSimple>().isNPCLeader = true;
        gameObject.layer = side == TeamSide.TeamEnum.RedTeam ? LayerMask.NameToLayer("RedTeam"): LayerMask.NameToLayer("BlueTeam");



        listOfNPCs.Add(leader);
        listOfNPCSimple.Add(leader.GetComponent <NpcSimple>());

        // Instantiate the four Squad Members
        for (int i = 0; i < 4; i++)
        {
            GameObject anchor = leader.GetComponent <NpcSimple>().listOfAnchorPoints[i];
            // TODO: set the npcs lane
            GameObject member = Instantiate(NPCPrefab, anchor.transform.position, Quaternion.identity);
            member.GetComponent <TeamSide>().playerTeam = side;
            member.GetComponent <NpcSimple>().GoToTarget(anchor.transform);
            listOfNPCs.Add(member);
            listOfNPCSimple.Add(member.GetComponent <NpcSimple>());
        }

        // Setting checkpoint of previous count
        lastCount = listOfNPCs.Count;
        isSpawned = true;
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        bulletReady = true;
        bulletTimer = 2.0f;
        SwitchToWeapon(0);
        myTeam = GetComponent <TeamSide>().playerTeam;

        //cursor invisible for aesthetics comment out for testing - Jason
        //Cursor.visible = false;
    }
Exemplo n.º 4
0
    // Function to spawn Units on call
    void spawnMinionToAmbushPoint(GameObject spawnPoint, TeamSide.TeamEnum side, GameObject targetLocation)
    {
        GameObject squad = new GameObject();

        squad.AddComponent <NPCSquad>();
        squad.GetComponent <NPCSquad>().setPrefabObject(NPCPrefab);
        squad.GetComponent <NPCSquad>().spawnSquad(spawnPoint.transform.position, side);
        // squad.GetComponent<NPCSquad>().setSquadTarget(targetLocation.GetComponent<CapturePoint>().capturePointId);
        squad.GetComponent <NPCSquad>().listOfNPCs[0].GetComponent <NpcSimple>().assignedLane = laneSide;
        squad.GetComponent <NPCSquad>().listOfNPCs[0].GetComponent <NpcSimple>().GoToNearestAmbushAround(targetLocation.transform.position);
    }
Exemplo n.º 5
0
    // Spawn waves on all three lanes for given side
    void spawnWave(TeamSide.TeamEnum side)
    {
        if (side == TeamSide.TeamEnum.BlueTeam)
        {
            leftLane.GetComponent <LaneWave>().spawnBlueWave();
            midLane.GetComponent <LaneWave>().spawnBlueWave();
            rightLane.GetComponent <LaneWave>().spawnBlueWave();
        }

        else
        {
            leftLane.GetComponent <LaneWave>().spawnRedWave();
            midLane.GetComponent <LaneWave>().spawnRedWave();
            rightLane.GetComponent <LaneWave>().spawnRedWave();
        }
    }
Exemplo n.º 6
0
    // Function to spawn Units on call
    void spawnMinion(GameObject spawnPoint, TeamSide.TeamEnum side, GameObject targetLocation)
    {
        GameObject squad = new GameObject();

        squad.AddComponent <NPCSquad>();
        squad.GetComponent <NPCSquad>().setPrefabObject(NPCPrefab);
        squad.GetComponent <NPCSquad>().spawnSquad(spawnPoint.transform.position, side);
        squad.GetComponent <NPCSquad>().setSquadTarget(targetLocation.GetComponent <CapturePoint>().capturePointId);

        if (side == TeamSide.TeamEnum.BlueTeam)
        {
            blueSquads.Add(squad);
        }

        else
        {
            redSquads.Add(squad);
        }
    }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        // Capture Speed Multiplier
        int captureRatio = bluePlayersInside - redPlayersInside;

        // Unit Count is even on both sides, capture is halted
        if (captureRatio == 0 || (belongsToTeam == TeamSide.TeamEnum.RedTeam && captureRatio < 0) || (belongsToTeam == TeamSide.TeamEnum.BlueTeam && captureRatio > 0))
        {
            return;
        }

        // Calculate the new capture point score
        captureValue += (captureRatio * Time.deltaTime * Capture_Rate_Modifier);


        // Red has captured the point
        if (captureValue <= -Max_Capture_Value)
        {
            belongsToTeam = TeamSide.TeamEnum.RedTeam;
            changePointColor(belongsToTeam);
        }

        // Blue has captured the point
        else if (captureValue >= Max_Capture_Value)
        {
            belongsToTeam = TeamSide.TeamEnum.BlueTeam;
            changePointColor(belongsToTeam);
        }

        // Once the caputure has passed by the value of 0, make the point neutral before capturing it
        else if ((belongsToTeam == TeamSide.TeamEnum.RedTeam && captureValue > 0) || (belongsToTeam == TeamSide.TeamEnum.BlueTeam && captureValue < 0))
        {
            belongsToTeam = TeamSide.TeamEnum.None;
            changePointColor(belongsToTeam);
        }

        //Debug.Log("Capture Rate: " + captureValue);
    }
Exemplo n.º 8
0
    GameObject nearestEnemyCapturePoint(TeamSide.TeamEnum side)
    {
        Vector3    spawnPos;
        GameObject cloestEnemyCapPoint = null;
        float      smallestDistance    = 99999999.0f;

        if (side == TeamSide.TeamEnum.BlueTeam)
        {
            spawnPos = blueSpawnPoint.transform.position;
        }

        else if (side == TeamSide.TeamEnum.RedTeam)
        {
            spawnPos = redSpawnPoint.transform.position;
        }

        else
        {
            return(null);
        }

        // ======== Prioritize Neutral Capture Points ======== //
        if (blueCapturePoint.GetComponent <CapturePoint>().belongsToTeam == TeamSide.TeamEnum.None)
        {
            return(blueCapturePoint);
        }

        else if (midCapturePoint.GetComponent <CapturePoint>().belongsToTeam == TeamSide.TeamEnum.None)
        {
            return(midCapturePoint);
        }

        else if (redCapturePoint.GetComponent <CapturePoint>().belongsToTeam == TeamSide.TeamEnum.None)
        {
            return(redCapturePoint);
        }

        // Distance from point to BlueCapturePoint
        float blueCapPointDist = Vector3.Distance(blueCapturePoint.transform.position, spawnPos);

        if (blueCapPointDist < smallestDistance && (blueCapturePoint.GetComponent <CapturePoint>().belongsToTeam != side))
        {
            smallestDistance    = blueCapPointDist;
            cloestEnemyCapPoint = blueCapturePoint;

            // Debug.Log("BLUE CAP POINT");
        }

        // Distance from point to MidCapturePoint
        float midCapPointDist = Vector3.Distance(midCapturePoint.transform.position, spawnPos);

        if (midCapPointDist < smallestDistance && (midCapturePoint.GetComponent <CapturePoint>().belongsToTeam != side))
        {
            smallestDistance    = midCapPointDist;
            cloestEnemyCapPoint = midCapturePoint;

            // Debug.Log("MID CAP POINT");
        }

        // Distance from point to BlueCapturePoint
        float redCapPointDist = Vector3.Distance(redCapturePoint.transform.position, spawnPos);

        if (redCapPointDist < smallestDistance && (redCapturePoint.GetComponent <CapturePoint>().belongsToTeam != side))
        {
            smallestDistance    = redCapPointDist;
            cloestEnemyCapPoint = redCapturePoint;

            // Debug.Log("RED CAP POINT");
        }


        // FIND FURTHEST CAPTURE POINT
        if (cloestEnemyCapPoint == null)
        {
            GameObject furtherPoint    = null;
            float      largestDistance = 0.0f;

            // Distance from point to BlueCapturePoint
            float blueCapPointDistLong = Vector3.Distance(blueCapturePoint.transform.position, spawnPos);

            if (blueCapPointDistLong > largestDistance && (blueCapturePoint.GetComponent <CapturePoint>().belongsToTeam == side))
            {
                largestDistance = blueCapPointDistLong;
                furtherPoint    = blueCapturePoint;

                // Debug.Log("BLUE CAP POINT");
            }

            // Distance from point to MidCapturePoint
            float midCapPointDistLong = Vector3.Distance(midCapturePoint.transform.position, spawnPos);

            if (midCapPointDistLong > largestDistance && (midCapturePoint.GetComponent <CapturePoint>().belongsToTeam == side))
            {
                largestDistance = midCapPointDistLong;
                furtherPoint    = midCapturePoint;

                // Debug.Log("MID CAP POINT");
            }

            // Distance from point to BlueCapturePoint
            float redCapPointDistLong = Vector3.Distance(redCapturePoint.transform.position, spawnPos);

            if (redCapPointDistLong > largestDistance && (redCapturePoint.GetComponent <CapturePoint>().belongsToTeam == side))
            {
                largestDistance = redCapPointDistLong;
                furtherPoint    = redCapturePoint;

                // Debug.Log("RED CAP POINT");
            }

            return(furtherPoint);
        }

        else
        {
            return(cloestEnemyCapPoint);
        }
    }
Exemplo n.º 9
0
    public GameObject FindNearestAmbushPoint(Vector3 fromPosition, Vector3 targetPosition, LaneScript.LaneSide laneSide, TeamSide.TeamEnum whichTeamSide)
    {
        GameObject nearestAmbushPoint = null;
        float      distance           = Mathf.Infinity;

        // Go through all the cover points
        foreach (GameObject w in ambushPoints)
        {
            TacticalWaypoint tw = w.GetComponent <TacticalWaypoint>();
            // Skip lanes that are not in the same lane as the current lane we are trying to search for
            if (tw.belongsToLane != laneSide || tw.closerToWhichTeamSide != whichTeamSide)
            {
                continue;
            }
            Debug.DrawRay(w.transform.position, targetPosition - w.transform.position, Color.blue, 2);
            // Get the distance to compare if we found one closer than a previous one
            Vector3 diff = w.transform.position - fromPosition;

            // We found a closer coverpoint
            if (diff.magnitude < distance)
            {
                // Set the nearest coverpoint to the one that is closest and actually in cover
                nearestAmbushPoint = w;
                distance           = diff.magnitude;
            }
        }
        Debug.DrawRay(targetPosition, nearestAmbushPoint.transform.position - targetPosition, Color.yellow, 5);

        return(nearestAmbushPoint);
    }