Example #1
0
 public static void explode(Vector3 position, float range, int damage)
 {
     Collider[] colliderArray = Physics.OverlapSphere(position, range, RayMasks.ATTACKABLE);
     for (int i = 0; i < (int)colliderArray.Length; i++)
     {
         if (RayMasks.isVisible(position, colliderArray[i].transform.position + Vector3.up))
         {
             if (colliderArray[i].tag == "Player")
             {
                 if (ServerSettings.pvp)
                 {
                     colliderArray[i].GetComponent <Life>().damage(damage, "You were blown up by an explosion.", -2, "");
                     NetworkEffects.askEffect("Effects/flesh", colliderArray[i].transform.position + Vector3.up, Quaternion.identity, -1f);
                 }
             }
             else if (colliderArray[i].tag == "Enemy")
             {
                 if (ServerSettings.pvp)
                 {
                     GameObject owner = OwnerFinder.getOwner(colliderArray[i].gameObject);
                     owner.GetComponent <Life>().damage(damage, "You were blown up by an explosion.", -2, "");
                     NetworkEffects.askEffect("Effects/flesh", colliderArray[i].transform.position + Vector3.up, Quaternion.identity, -1f);
                 }
             }
             else if (colliderArray[i].tag == "Animal")
             {
                 GameObject gameObject = OwnerFinder.getOwner(colliderArray[i].gameObject);
                 gameObject.GetComponent <AI>().damage(damage);
                 NetworkEffects.askEffect("Effects/flesh", colliderArray[i].transform.position + Vector3.up, Quaternion.identity, -1f);
             }
             else if (colliderArray[i].tag == "Barricade")
             {
                 if (ServerSettings.pvp)
                 {
                     SpawnBarricades.damage(colliderArray[i].transform.parent.position, damage);
                 }
             }
             else if (colliderArray[i].tag == "Structure")
             {
                 if (ServerSettings.pvp)
                 {
                     // FIXME: explosion to structures?
                     //SpawnStructures.damage(colliderArray[i].transform.parent.position, damage);
                 }
             }
             else if (colliderArray[i].tag == "Vehicle" && ServerSettings.pvp)
             {
                 colliderArray[i].GetComponent <Vehicle>().damage(damage);
             }
         }
     }
     SpawnAnimals.attract(position + Vector3.up, 64f);
 }
Example #2
0
 public void attract()
 {
     SpawnAnimals.attract(base.transform.position + Vector3.up, 30f);
 }
Example #3
0
 public void drive(float turn, float thrust)
 {
     if (this.real)
     {
         this.frontLeft.steerAngle  = Mathf.Lerp(this.frontLeft.steerAngle, turn * (float)this.maxTurn, 4f * Time.deltaTime);
         this.frontRight.steerAngle = Mathf.Lerp(this.frontRight.steerAngle, turn * (float)this.maxTurn, 4f * Time.deltaTime);
         if (thrust != -1000f)
         {
             if (this.fuel <= 0 || this.health < 5)
             {
                 this.backLeft.motorTorque  = Mathf.Lerp(this.backLeft.motorTorque, 0f, 4f * Time.deltaTime);
                 this.backRight.motorTorque = Mathf.Lerp(this.backRight.motorTorque, 0f, 4f * Time.deltaTime);
             }
             else if (thrust > 0f)
             {
                 if (base.rigidbody.velocity.magnitude >= (float)this.maxSpeed)
                 {
                     this.backLeft.motorTorque  = Mathf.Lerp(this.backLeft.motorTorque, 0f, 4f * Time.deltaTime);
                     this.backRight.motorTorque = Mathf.Lerp(this.backRight.motorTorque, 0f, 4f * Time.deltaTime);
                 }
                 else
                 {
                     this.backLeft.motorTorque  = Mathf.Lerp(this.backLeft.motorTorque, thrust * (float)this.maxSpeed, 4f * Time.deltaTime);
                     this.backRight.motorTorque = Mathf.Lerp(this.backRight.motorTorque, thrust * (float)this.maxSpeed, 4f * Time.deltaTime);
                 }
             }
             else if (base.rigidbody.velocity.magnitude >= (float)(this.maxSpeed / 2))
             {
                 this.backLeft.motorTorque  = Mathf.Lerp(this.backLeft.motorTorque, 0f, 4f * Time.deltaTime);
                 this.backRight.motorTorque = Mathf.Lerp(this.backRight.motorTorque, 0f, 4f * Time.deltaTime);
             }
             else
             {
                 this.backLeft.motorTorque  = Mathf.Lerp(this.backLeft.motorTorque, thrust * (float)this.maxSpeed / 2f, 4f * Time.deltaTime);
                 this.backRight.motorTorque = Mathf.Lerp(this.backRight.motorTorque, thrust * (float)this.maxSpeed / 2f, 4f * Time.deltaTime);
             }
             this.backLeft.brakeTorque  = Mathf.Lerp(this.backLeft.brakeTorque, 2f, 4f * Time.deltaTime);
             this.backRight.brakeTorque = Mathf.Lerp(this.backRight.brakeTorque, 2f, 4f * Time.deltaTime);
         }
         else
         {
             this.backLeft.motorTorque  = Mathf.Lerp(this.backLeft.motorTorque, 0f, 4f * Time.deltaTime);
             this.backRight.motorTorque = Mathf.Lerp(this.backRight.motorTorque, 0f, 4f * Time.deltaTime);
             this.backLeft.brakeTorque  = Mathf.Lerp(this.backLeft.brakeTorque, 20f, 4f * Time.deltaTime);
             this.backRight.brakeTorque = Mathf.Lerp(this.backRight.brakeTorque, 20f, 4f * Time.deltaTime);
         }
         if (this.fuel > 0 && this.health >= 5 && Screen.lockCursor)
         {
             if (Input.GetMouseButtonDown(0) && (double)(Time.realtimeSinceStartup - this.lastHorn) > 0.25)
             {
                 this.lastHorn = Time.realtimeSinceStartup;
                 NetworkSounds.askSound("Sounds/Vehicles/horn", base.transform.position + (base.transform.right * 3f), 1f, 1.25f, 2f);
                 SpawnAnimals.attract(base.transform.position, 64f);
             }
             if (Input.GetMouseButtonDown(1))
             {
                 base.networkView.RPC("tellHeadlights", RPCMode.All, new object[] { !this.headlights });
                 NetworkSounds.askSound("Sounds/General/firemode", base.transform.position, 0.1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
             }
             if (Input.GetKeyDown(InputSettings.otherKey) && base.transform.FindChild("siren") != null)
             {
                 base.networkView.RPC("tellSirens", RPCMode.All, new object[] { !this.sirens });
                 NetworkSounds.askSound("Sounds/General/firemode", base.transform.position, 0.1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
             }
         }
         if (Mathf.Abs(this.lastSpeed) != (int)base.rigidbody.velocity.magnitude)
         {
             base.networkView.RPC("updateSpeed", RPCMode.All, new object[] { (thrust < 0f ? -(int)base.rigidbody.velocity.magnitude : (int)base.rigidbody.velocity.magnitude) });
         }
         this.steerer.localRotation = Quaternion.Euler(0f, -75f, Viewmodel.swayRoll);
         if (this.lastTurn != (int)Viewmodel.swayRoll)
         {
             base.networkView.RPC("updateTurn", RPCMode.All, new object[] { (int)Viewmodel.swayRoll });
         }
         if ((double)(Time.realtimeSinceStartup - this.lastTick) > 0.2)
         {
             this.lastTick = Time.realtimeSinceStartup;
             if ((base.transform.position - this.lastPosition).sqrMagnitude > 1f)
             {
                 this.lastPosition = this.position;
                 base.networkView.RPC("updatePosition", RPCMode.All, new object[] { base.transform.position, base.transform.rotation });
             }
         }
     }
 }