// Commands missiles to launch

    private void Awake()
    {
        weaponTypeHardpointLists = new List <List <Hardpoint> >();
        groupThisType_List       = new List <bool>();
        rootFlow       = transform.root.GetComponent <CombatFlow>();
        dropSight      = rootFlow.GetComponent <DropSightComputer>();
        rootRadar      = rootFlow.GetComponent <Radar>();
        ai_tgtComputer = rootFlow.GetComponent <AI_TgtComputer>();
    }
    private void beginUpdateAllCreeps()
    {
        List <int>        idList       = new List <int>();        // ID list
        List <float>      hpList       = new List <float>();      // HP list
        List <int>        targetIdList = new List <int>();        // targetID list
        List <Vector3>    posList      = new List <Vector3>();    // position list
        List <Quaternion> rotList      = new List <Quaternion>(); // rotation list


        for (int i = 0; i < myLaneUnits.Count; i++)
        {
            CombatFlow currentUnit = myLaneUnits[i];

            if (currentUnit != null)
            {
                idList.Add(currentUnit.photonView.ViewID);
                hpList.Add(currentUnit.getHP());
                targetIdList.Add(currentUnit.GetComponent <CreepControl>().getTargetId());
                posList.Add(currentUnit.transform.position);
                rotList.Add(currentUnit.transform.rotation);
            }
        }

        photonView.RPC("rpcUpdateAllCreeps", RpcTarget.Others, idList.ToArray(), hpList.ToArray(),
                       targetIdList.ToArray(),
                       posList.ToArray(), rotList.ToArray());
    }
Exemplo n.º 3
0
    public void linkToRadarSource(Radar radar)
    {
        hasSet      = true;
        textID.text = radar.radarID;

        CombatFlow radarFlow = radar.GetComponent <CombatFlow>();

        sourceFlow = radarFlow;

        radarSource = radar;
        linkedObj   = radar.gameObject;

        if (radarFlow.type == CombatFlow.Type.PROJECTILE)
        {
            Debug.LogWarning("Linking projectile radar " + radar.gameObject.name);
            isMissile = true;
            iconCenter.transform.localPosition = new Vector3(0, UI_POSITION_Y_MISSILE, 0);
            makeRed();
        }

        if (radarFlow.type == CombatFlow.Type.AIRCRAFT)
        {
            iconCenter.transform.localPosition = new Vector3(0, UI_POSITION_Y_AIRCRAFT, 0);
        }

        if (radarFlow.GetComponent <SamNetworking>() != null)
        {
            isSam = true;
        }
    }
Exemplo n.º 4
0
    private void tryChangeTarget()
    {
        if (rootFlow.isHostInstance)
        {
            changeCycleCounter -= Time.deltaTime;
            if (changeCycleCounter < 0)
            {
                changeCycleCounter = changeCycleCounterMax;

                CombatFlow targetFlow = findNearestTarget();
                if (targetFlow != null && targetFlow.GetComponent <Rigidbody>() != targetRb)
                {
                    //Debug.LogWarning
                    //Debug.LogWarning("new target name: " + targetFlow.name);
                    if (targetRb != null && targetFlow != null)
                    {
                        Debug.LogWarning("AAA found new target. Old: " + targetRb.gameObject.name + ", new: " + targetFlow.gameObject.name);
                    }

                    turretNet.setTarget(targetFlow);

                    // only target's instance will deal damage. Rest will be cosmetic-only
                    rootFlow.giveOwnership(targetFlow.photonView.ViewID);
                }
            }
        }
    }
Exemplo n.º 5
0
 private Rigidbody getRB()
 {
     if (rootRB == null)
     {
         rootRB = rootFlow.GetComponent <Rigidbody>();
     }
     return(rootRB);
 }
    private AI_GroundAttack doSpawn()
    {
        totalSpawnCount++;

        CombatFlow      newAircraft  = gm.spawnPlayer(CombatFlow.convertTeamToNum(spawner.team), true);
        AI_GroundAttack newAirGndAtk = newAircraft.GetComponent <AI_GroundAttack>();

        newAirGndAtk.assignToLane(decideLane(myAI));

        newAircraft.setNetName("JeffBot" + totalSpawnCount);

        return(newAirGndAtk);
    }
Exemplo n.º 7
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);
    }
Exemplo n.º 8
0
 // Start is called before the first frame update
 void Start()
 {
     rootFlow = transform.root.GetComponent <CombatFlow>();
     radar    = rootFlow.GetComponent <Radar>();
     samNet   = rootFlow.GetComponent <SamNetworking>();
 }