void Update()
 {
     //If outside, count the time
     if (outside)
     {
         curOutsideTime += Time.deltaTime;
         //Check for death
         if (curOutsideTime > maxOutsideTime)
         {
             ObjectSync objSync = this.GetComponent <ObjectSync>();
             ObjectRPC.KillObject(objSync.Owner, objSync.GlobalID);
             Debug.Log("Out of boundary call.");
             //healthControl.Die();
             outside = false;
         }
     }
 }
Esempio n. 2
0
    public virtual void TakeDamage(float hullDamage, float shieldDamage)
    {
        if (this.IsDead)
        {
            return;
        }

        if (Network.peerType != NetworkPeerType.Server && !GlobalSettings.SinglePlayer)
        {
            return;
        }

        currentShieldDelay = ShieldRechargeDelay;
        shieldStrength     = Mathf.Max(0, shieldStrength - shieldDamage);

        health = Mathf.Max(0, health - hullDamage);

        //Debug.Log("Taking damage! " + health + " " + shieldStrength);

        this.objSync.RequestHealthSync();

        if (!this.CheckIfAlive())
        {
            // Notify others that the object should start 'dying'.
            if (!GlobalSettings.SinglePlayer)
            {
                if (!this.IsDead)
                {
                    ObjectRPC.KillObject(this.objSync.Owner, this.objSync.GlobalID);
                }
                // Die() will be called using RPCs on both the client and server.
                //if (this.objSync.IsDisposed)
                //    throw new UnityException("ObjectSync has already been disposed.");
            }
            else
            {
                Die();
            }
        }
    }