Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (localPlayerRWR == null)
        {
            if (debug)
            {
                Debug.LogWarning("Local player rwr null, pinging set to false");
            }

            rwrIcon.showPingResult(false, 0.0f, 0.0f);

            GameObject localPlayer = GameManager.getGM().localPlayer;
            if (localPlayer != null)
            {
                localPlayerRWR  = GameManager.getGM().localPlayer.GetComponent <RWR>();
                localPlayerFlow = localPlayerRWR.GetComponent <CombatFlow>();
                if (debug)
                {
                    Debug.LogWarning("Found local player: " + localPlayerFlow.gameObject.name);
                }
                //
            }
        }

        // don't ping yourself
        // can find localPlayerRWR
        // no friendly pings
        if (!myFlow.isLocalPlayer && localPlayerRWR != null && myFlow.team != localPlayerFlow.team)
        {
            if (debug)
            {
                Debug.LogWarning("Counting down timer");
            }

            if (pingTimer())
            {
                if (debug)
                {
                    Debug.LogWarning("Trying to ping");
                }
                tryPing();
            }
        }

        if (myFlow.isLocalPlayer)
        {
            if (rwrIcon != null)
            {
                GameObject.Destroy(rwrIcon.gameObject);
            }
        }
    }
Esempio n. 2
0
    public void tryPing(Radar radarSource)
    {
        if (myFlow.isLocalPlayer && myFlow.team != radarSource.myFlow.team)
        {
            bool  isPinging = !myFlow.jamming && radarSource.radarOn && radarSource.withinScope(transform.position);
            float distance  = Vector3.Distance(transform.position, radarSource.transform.position);
            float bearing   = calculateBearing(radarSource.transform.position);

            IconRWR rwrIcon = radarSource.rwrIcon;

            rwrIcon.showPingResult(isPinging, distance, bearing);
        }
    }