Beispiel #1
0
    private void processCamOffset()
    {
        if (isReady && myFlow.isLocalPlayer)
        {
            float camOffsetVertTemp  = 0f;
            float camOffsetHorizTemp = 0f;

            if (wheels.gearIsDown)
            {
                camOffsetVertTemp = gearOffset;
            }

            // if selected weapon type needs to move camera
            Hardpoint activeHardpointRef = hardpointController.getActiveHardpoint();

            if (activeHardpointRef != null)
            {
                BasicBomb    bombScript      = activeHardpointRef.weaponTypePrefab.GetComponent <BasicBomb>();
                BasicMissile missileScript   = activeHardpointRef.weaponTypePrefab.GetComponent <BasicMissile>();
                RocketPod    rocketPodScript = activeHardpointRef.weaponTypePrefab.GetComponent <RocketPod>();



                if (rocketPodScript != null)
                {
                    camOffsetVertTemp = rocketPodOffset;
                }

                if (bombScript != null)
                {
                    camOffsetVertTemp = bombOffset;
                }

                if (activeHardpointRef.weaponTypePrefab.name.Equals("Maverick"))
                {
                    camOffsetVertTemp = maverickOffset;
                }
            }


            cam.camAxisTargetOffset_Vert  = camOffsetVertTemp;
            cam.camAxisTargetOffset_Horiz = camOffsetHorizTemp;
        }
    }
Beispiel #2
0
    // change target to unit closet to zero angle off of camera direction
    public CombatFlow changeTarget()
    {
        //Debug.Log("================== Searching for targets...");
        CombatFlow        newTarget    = null; // default point to currentTarget -- if changeTarget unsuccessful, this won't change
        List <CombatFlow> flowObjArray = CombatFlow.combatUnits;

        if (currentTarget != null && radarLocked)
        {
            if (currentTarget.rwr != null)
            {
                currentTarget.rwr.endNetLock(myRadar);
            }
        }


        float smallestAngle = 180f; //180 is max angle Vector3.angleBetween gives

        // loop through every combatFlow object
        for (short i = 0; i < flowObjArray.Count; i++)
        {
            if (flowObjArray[i] != null)
            {
                CombatFlow currentFlow = flowObjArray[i];

                if (currentFlow != null)
                {
                    float currentAngle = Vector3.Angle(playerInput.cam.camRef.transform.forward, currentFlow.transform.position
                                                       - playerInput.cam.camRef.transform.position);

                    // If maverick is equipped, bias target selection in favor of opponents with Radars


                    if (hardpointController.getActiveHardpoint().weaponTypePrefab.name.Equals("Maverick"))
                    {
                        if (currentFlow.GetComponent <Radar>() != null)
                        {
                            currentAngle *= 0.35f; // halve the angle to make it more likely to be selected
                        }
                        else if (currentFlow.GetComponent <TurretNetworking>() != null)
                        {
                            currentAngle *= 0.6f;
                        }
                    }



                    //if (currentFlow.type == CombatFlow.Type.AIRCRAFT)
                    //{
                    //    Debug.LogWarning(currentFlow + "'s angle is: " + currentAngle + " off camera center");
                    //}
                    //Debug.Log("Current target is: " + currentFlow.gameObject + ", at " + currentAngle + " degrees, smallest angle is: " + smallestAngle + " degrees.");

                    // angle within max, angle smallest, and target is not on same team as localPlayer
                    if ((currentFlow.myHudIconRef.isDetected || currentFlow.myHudIconRef.dataLink) &&
                        //!currentFlow.myHudIconRef.isFar &&
                        currentFlow.isActive &&
                        currentFlow.type != CombatFlow.Type.PROJECTILE && // cannot lock onto projectiles
                        currentAngle < changeTargetMaxAngle &&
                        currentAngle < smallestAngle &&
                        !currentFlow.isLocalPlayer &&
                        currentFlow.team != localPlayerFlow.team

                        )
                    {
                        //Debug.Log("SMALLEST ANGLE: " + currentAngle + " degrees.");
                        smallestAngle = currentAngle;
                        newTarget     = flowObjArray[i].GetComponent <CombatFlow>();
                        prevTarget    = newTarget;
                    }
                }
            }
        }

        if (newTarget != null)
        {
            TgtHudIcon newTargetHudIcon = newTarget.myHudIconRef;
            newTargetHudIcon.targetedState = TgtHudIcon.TargetedState.TARGETED;
            hudControl.mainHud.GetComponent <hudControl>().mapManager.target = newTarget.transform;
        }
        else
        {
            hudControl.mainHud.GetComponent <hudControl>().mapManager.target = null;
        }


        // Debug.Log("New Target is: " + newTarget.gameObject + ", at " + smallestAngle + "degrees off nose");

        if (newTarget != currentTarget) // changing to new target
        {
            if (currentTarget != null)
            {
                // deselect process for previous target
                currentTarget.myHudIconRef.targetedState = TgtHudIcon.TargetedState.NONE;
            }
        }

        return(currentTarget = newTarget);
    }