// ====================================================================
    // *****************************     LATEUPDATE     *******************
    // ====================================================================
    void LateUpdate()
    {
        if (aircraftRootObj != null)
        {
            // Set readout values
            float mpsVelToKPH = 3.6f;
            throttleText.text   = writeThrottleText();
            speedText.text      = Mathf.RoundToInt(root_rbRef.velocity.magnitude * mpsVelToKPH).ToString() + "kph";
            altitudeText.text   = Mathf.RoundToInt(aircraftRootObj.transform.position.y).ToString() + "m";
            climbText.text      = Mathf.RoundToInt(root_flightInfoObjRef.readVertVelocity).ToString() + "m/s >";
            airDensityText.text = "AIR DENSITY: " + Mathf.RoundToInt(root_Engine.currentAirDensity * 100f).ToString() + "%";
            fuelAmtText.text    = "FUEL: " + Mathf.RoundToInt(root_Engine.currentFuelMass) + "kg";
            burnAvailText.text  = "BURN AVAIL: " + Mathf.RoundToInt(root_Engine.currentBurnMod * 100f).ToString() + "%";
            hpText.text         = Mathf.RoundToInt(root_combatFlow.getHP()).ToString() + "HP";



            processSpedometerOffset();
            processThrottleLadder();
            processClimbLadder();
            processAltimeterOffset();
            processHealthBar();



            noseAndVelIndicators();
        }
    }
Beispiel #2
0
    public void rpcContactProcess(Vector3 position, int otherId)
    {
        if (oneImpactVictim == null)
        {
            transform.position = position;

            GameObject other     = null;
            CombatFlow otherFlow = null;

            if (otherId != -1)
            {
                other     = PhotonNetwork.GetPhotonView(otherId).gameObject;
                otherFlow = other.gameObject.GetComponent <CombatFlow>();
            }

            if (other != null)
            {
                oneImpactVictim = other.transform.root.gameObject;
            }

            Debug.Log("Bomb collided");
            // die immediately on collision
            myCombatFlow.dealLocalDamage(myCombatFlow.getHP());

            if (otherFlow != null && myCombatFlow.localOwned)
            {
                otherFlow.dealDamage(impactDamage);
            }
        }
    }
    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());
    }
Beispiel #4
0
    public void rpcContactProcess(Vector3 position, int otherId)
    {
        //Debug.LogWarning("rpcContactProcess locally called");
        GameObject otherRoot = null;
        CombatFlow otherFlow = null;

        if (otherId != -1)
        {
            otherRoot = PhotonNetwork.GetPhotonView(otherId).gameObject;
            otherFlow = otherRoot.GetComponent <CombatFlow>();
        }

        transform.position = position;

        //Weapon otherWeapon = otherRoot.gameObject.GetComponent<Weapon>();


        // If other has a flow and is the one impact victim
        if (otherFlow != null && otherRoot != impactVictimRoot)
        {
            //myCombatFlow.explodeStats.doExplode = false;
            impactVictimRoot = otherRoot;

            // don't explode if victim will die and if victim is not a projectile
            if (impactDamage > otherFlow.getHP() && otherFlow.type != CombatFlow.Type.PROJECTILE)
            {
                myCombatFlow.explodeStats.doExplode = false; // death will only trigger enemy explosion
            }

            // =========  TRY TO DEAL IMPACT

            bool doDealImpact = false;

            // leaving this super obfuscated like this in case more complex conditions wanted later
            if (otherFlow != null)
            {
                doDealImpact = true;
            }


            // finally, deal the impact
            if (doDealImpact && myCombatFlow.localOwned)
            {
                otherFlow.dealDamage(impactDamage);
                Debug.Log("Impact dealing " + impactDamage + " damage to " + otherFlow);
            }
        }

        if (effectsObj != null)
        {
            effectsObj.GetComponent <Light>().enabled = false;
        }

        if (myCombatFlow != null)
        {
            myCombatFlow.dealLocalDamage(myCombatFlow.getHP());
        }
    }
Beispiel #5
0
    private void FixedUpdate()
    {
        if (launched)
        {
            if (myCombatFlow.localOwned)
            {
                if (myTarget != null && !hasPassed && myTarget.GetComponent <CreepControl>() == null &&
                    Vector3.Distance(myTarget.transform.position,
                                     transform.position) < PASS_OWNERSHIP_DISTANCE)
                {
                    // target's instance will own this missile and show accurate position
                    myCombatFlow.giveOwnership(targetID);
                    Debug.LogWarning("Giving missile ownership");
                }


                if (armed && rbRef.velocity.magnitude < selfDestructSpeed)
                {
                    myCombatFlow.dealLocalDamage(myCombatFlow.getHP());
                }

                if (myTarget != null)
                {
                    updateTargetPosition();
                }

                if (checkProximityFuse())
                {
                    // make this rpc
                    if (effectsObj != null)
                    {
                        //effectsObj.GetComponent<Light>().enabled = false;
                        photonView.RPC("rpcDisableLight", RpcTarget.All);
                    }
                    if (myCombatFlow != null && myCombatFlow.localOwned)
                    {
                        // blow up local instance. Death itself should be networked fine
                        myCombatFlow.dealLocalDamage(myCombatFlow.getHP());
                    }
                }
            }
        }
    }
Beispiel #6
0
    public void impactLocal(Vector3 position, GameObject other)
    {
        GameObject otherRoot = other;
        CombatFlow otherFlow = other.GetComponent <CombatFlow>();


        transform.position = position;

        if (otherRoot != null) // do not do anything against effects
        {
            bool doExplode = !otherRoot.CompareTag("Effects");

            //Debug.LogWarning("NOTE: ROCKET FOUND OTHER ROOT GAMEOBJECT");

            if (otherFlow != null)
            {
                if (otherFlow.team != myTeam || friendlyImpact)
                {
                    if (myFlow.localOwned)
                    {
                        //otherFlow.currentHP -= impactDamage;
                        otherFlow.dealDamage(impactDamage);
                    }
                }
                else
                {
                    doExplode = false;
                }
            }

            if (doExplode)
            {
                // myFlow.currentHP -= myFlow.currentHP;
                myFlow.dealLocalDamage(myFlow.getHP());
                if (effectsObj != null)
                {
                    effectsObj.GetComponent <Light>().enabled = false;
                }
                //Debug.Log("Rocket HP after impact: " + myFlow.currentHP);
            }
        }
    }
Beispiel #7
0
    public void killIfBelowFloor()
    {
        CombatFlow combatFlow = GetComponent <CombatFlow>();

        if (transform.position.y < 0f && combatFlow.localOwned)
        {
            combatFlow.dealDamage(combatFlow.getHP());

            //combatFlow.currentHP -= combatFlow.currentHP;
        }
    }
Beispiel #8
0
 public void killIfLifetimeOver()
 {
     if (launched)
     {
         if (projectileLifetime > 0f)
         {
             projectileLifetime -= Time.deltaTime;
         }
         else // timer ran out
         {
             // Not bothering to check if null because all Weapons should contain a CombatFlow object
             CombatFlow myFlow = GetComponent <CombatFlow>();
             //myFlow.currentHP -= myFlow.currentHP;
             myFlow.dealLocalDamage(myFlow.getHP());
         }
     }
 }