public override void tick() { if (this.swinging && Time.realtimeSinceStartup - this.lastSwing > 0.1f) { this.lastSwing = Time.realtimeSinceStartup; NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Repair.hit, MeleeStats.getRange(Equipment.id) + 0.5f, RayMasks.DAMAGE); if (Repair.hit.collider != null) { NetworkEffects.askEffect("Effects/repair", Repair.hit.point + (Repair.hit.normal * 0.05f), Quaternion.LookRotation(Repair.hit.normal), -1f); if (Repair.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Repair.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Repair.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { if (!Network.isServer) { base.networkView.RPC("swingPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb }); } else { this.swingPlayer(owner.GetComponent <Player>().owner.id, limb); } } } else if (Repair.hit.collider.tag == "Animal") { int num = OwnerFinder.getLimb(Repair.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Repair.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { if (!Network.isServer) { base.networkView.RPC("swingAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, num }); } else { this.swingAnimal(gameObject.networkView.viewID, num); } } } else if (Repair.hit.collider.tag == "Vehicle" && Repair.hit.collider.GetComponent <Vehicle>().health < Repair.hit.collider.GetComponent <Vehicle>().maxHealth&& !Repair.hit.collider.GetComponent <Vehicle>().exploded) { if (!Network.isServer) { base.networkView.RPC("swingVehicle", RPCMode.Server, new object[] { Repair.hit.collider.networkView.viewID }); } else { this.swingVehicle(Repair.hit.collider.networkView.viewID); } } } } }
public override void tick() { if (this.swinging && Time.realtimeSinceStartup - this.lastSwing > 0.1f) { Viewmodel.offset_x = UnityEngine.Random.Range(-0.02f, 0.02f); Viewmodel.offset_y = UnityEngine.Random.Range(-0.02f, 0.02f); Viewmodel.offset_z = UnityEngine.Random.Range(-0.02f, 0.02f); this.lastSwing = Time.realtimeSinceStartup; NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Chainsaw.hit, MeleeStats.getRange(Equipment.id) + 0.5f, RayMasks.DAMAGE); if (Chainsaw.hit.collider != null) { if (Chainsaw.hit.point.y < Ocean.level) { NetworkSounds.askSound("Sounds/Impacts/rock", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/bubbles", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.gameObject.name == "ground" || Chainsaw.hit.collider.material.name.ToLower() == "rock (instance)" || Chainsaw.hit.collider.material.name.ToLower() == "ground (instance)") { NetworkSounds.askSound("Sounds/Impacts/rock", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/rock", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "cloth (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/cloth", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "wood (instance)") { NetworkSounds.askSound("Sounds/Impacts/wood", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/splinters", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "tile (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/tile", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "concrete (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/concrete", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "metal (instance)" || Chainsaw.hit.collider.material.name.ToLower() == "iron (instance)") { NetworkSounds.askSound("Sounds/Impacts/metal", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/sparks", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "flesh (instance)") { NetworkSounds.askSound("Sounds/Impacts/flesh", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } if (Chainsaw.hit.collider.tag == "Resource") { if (Chainsaw.hit.collider.name.Substring(0, 4) != "rock") { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; int num = int.Parse(Chainsaw.hit.collider.transform.parent.name.Substring(Chainsaw.hit.collider.transform.parent.name.IndexOf("_") + 1)); if (!Network.isServer) { base.networkView.RPC("swingResource", RPCMode.Server, new object[] { num }); } else { this.swingResource(num); } } } else if (Chainsaw.hit.collider.tag == "Barricade") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingBarricade", RPCMode.Server, new object[] { Chainsaw.hit.collider.transform.parent.position }); } else { this.swingBarricade(Chainsaw.hit.collider.transform.parent.position); } } else if (Chainsaw.hit.collider.tag == "Structure") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingStructure", RPCMode.Server, new object[] { Chainsaw.hit.collider.transform.parent.position }); } else { // FIXME: client side? //this.swingStructure(Chainsaw.hit.collider.transform.parent.position); } } else if (Chainsaw.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Chainsaw.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Chainsaw.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb }); } else { this.swingPlayer(owner.GetComponent <Player>().owner.id, limb); } } } else if (Chainsaw.hit.collider.tag == "Animal") { int limb1 = OwnerFinder.getLimb(Chainsaw.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Chainsaw.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, limb1 }); } else { this.swingAnimal(gameObject.networkView.viewID, limb1); } } } else if (Chainsaw.hit.collider.tag == "Vehicle" && Chainsaw.hit.collider.GetComponent <Vehicle>().health > 0 && ServerSettings.pvp) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingVehicle", RPCMode.Server, new object[] { Chainsaw.hit.collider.networkView.viewID }); } else { this.swingVehicle(Chainsaw.hit.collider.networkView.viewID); } } } } }
public override void tick() { if (this.swung) { if (Time.realtimeSinceStartup - this.lastSwing > (!this.lastStrong ? Viewmodel.model.animation["swingWeak"].length / 2f : Viewmodel.model.animation["swingStrong"].length / 2f)) { NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); this.swung = false; Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Melee.hit, MeleeStats.getRange(Equipment.id) + 0.5f, RayMasks.DAMAGE); if (Melee.hit.collider != null) { if (Melee.hit.point.y < Ocean.level) { NetworkSounds.askSound("Sounds/Impacts/rock", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/bubbles", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.gameObject.name == "ground" || Melee.hit.collider.material.name.ToLower() == "rock (instance)" || Melee.hit.collider.material.name.ToLower() == "ground (instance)") { NetworkSounds.askSound("Sounds/Impacts/rock", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/rock", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "cloth (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/cloth", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "wood (instance)") { NetworkSounds.askSound("Sounds/Impacts/wood", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/splinters", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "tile (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/tile", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "concrete (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/concrete", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "metal (instance)" || Melee.hit.collider.material.name.ToLower() == "iron (instance)") { NetworkSounds.askSound("Sounds/Impacts/metal", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/sparks", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "flesh (instance)") { NetworkSounds.askSound("Sounds/Impacts/flesh", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } if (Melee.hit.collider.name == "ground" || Melee.hit.collider.tag == "Prop" || Melee.hit.collider.tag == "World" || Melee.hit.collider.tag == "Environment" || Melee.hit.collider.tag == "Global") { NetworkEffects.askEffect("Effects/hole", Melee.hit.point + (Melee.hit.normal * UnityEngine.Random.Range(0.04f, 0.06f)), Quaternion.LookRotation(Melee.hit.normal) * Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(0, 360)), 20f); } if (Melee.hit.collider.tag == "Barricade") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingBarricade", RPCMode.Server, new object[] { Melee.hit.collider.transform.parent.position, this.lastStrong }); } else { this.swingBarricade(Melee.hit.collider.transform.parent.position, this.lastStrong); } } else if (Melee.hit.collider.tag == "Structure") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingStructure", RPCMode.Server, new object[] { Melee.hit.collider.transform.parent.position, this.lastStrong }); } else { // FIXME: client stuff? //this.swingStructure(Melee.hit.collider.transform.parent.position, this.lastStrong); } } else if (Melee.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Melee.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Melee.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb, this.lastStrong }); } else { this.swingPlayer(owner.GetComponent <Player>().owner.id, limb, this.lastStrong); } } } else if (Melee.hit.collider.tag == "Animal") { int num = OwnerFinder.getLimb(Melee.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Melee.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, num, this.lastStrong }); } else { this.swingAnimal(gameObject.networkView.viewID, num, this.lastStrong); } } } else if (Melee.hit.collider.tag == "Vehicle" && Melee.hit.collider.GetComponent <Vehicle>().health > 0 && ServerSettings.pvp) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingVehicle", RPCMode.Server, new object[] { Melee.hit.collider.networkView.viewID, this.lastStrong }); } else { this.swingVehicle(Melee.hit.collider.networkView.viewID, this.lastStrong); } } } } } if (this.swinging && Movement.vehicle == null && (!this.strong || Player.life.stamina >= 10 - (int)(Player.skills.endurance() * 10f))) { if (Time.realtimeSinceStartup - this.lastSwing <= (!this.lastStrong ? Viewmodel.model.animation["swingWeak"].length : Viewmodel.model.animation["swingStrong"].length)) { this.swinging = false; return; } if (this.strong) { Player.life.exhaust(10 - (int)(Player.skills.endurance() * 10f)); } this.lastStrong = this.strong; this.swinging = false; this.lastSwing = Time.realtimeSinceStartup; this.swung = true; if (!this.strong) { Viewmodel.play("swingWeak"); } else { Viewmodel.play("swingStrong"); } if (Stance.state == 0) { Player.play("standMelee"); } else if (Stance.state == 1) { Player.play("crouchMelee"); } else if (Stance.state == 2) { Player.play("proneMelee"); } return; } this.swinging = false; }
public override void tick() { if (this.swung && Time.realtimeSinceStartup - this.lastSwing > Viewmodel.model.animation["swingWeak"].length / 2f) { NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); this.swung = false; Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Flashlight.hit, MeleeStats.getRange(Equipment.id) + 0.5f, RayMasks.DAMAGE); if (Flashlight.hit.collider != null) { if (Flashlight.hit.point.y < Ocean.level) { NetworkSounds.askSound("Sounds/Impacts/rock", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/bubbles", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } else if (Flashlight.hit.collider.gameObject.name == "ground" || Flashlight.hit.collider.material.name.ToLower() == "rock (instance)" || Flashlight.hit.collider.material.name.ToLower() == "ground (instance)") { NetworkSounds.askSound("Sounds/Impacts/rock", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/rock", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } else if (Flashlight.hit.collider.material.name.ToLower() == "cloth (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/cloth", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } else if (Flashlight.hit.collider.material.name.ToLower() == "wood (instance)") { NetworkSounds.askSound("Sounds/Impacts/wood", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/splinters", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } else if (Flashlight.hit.collider.material.name.ToLower() == "tile (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/tile", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } else if (Flashlight.hit.collider.material.name.ToLower() == "concrete (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/concrete", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } else if (Flashlight.hit.collider.material.name.ToLower() == "metal (instance)" || Flashlight.hit.collider.material.name.ToLower() == "iron (instance)") { NetworkSounds.askSound("Sounds/Impacts/metal", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/sparks", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } else if (Flashlight.hit.collider.material.name.ToLower() == "flesh (instance)") { NetworkSounds.askSound("Sounds/Impacts/flesh", Flashlight.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", Flashlight.hit.point + (Flashlight.hit.normal * 0.05f), Quaternion.LookRotation(Flashlight.hit.normal), -1f); } if (Flashlight.hit.collider.name == "ground" || Flashlight.hit.collider.tag == "Prop" || Flashlight.hit.collider.tag == "World" || Flashlight.hit.collider.tag == "Environment" || Flashlight.hit.collider.tag == "Global") { NetworkEffects.askEffect("Effects/hole", Flashlight.hit.point + (Flashlight.hit.normal * UnityEngine.Random.Range(0.04f, 0.06f)), Quaternion.LookRotation(Flashlight.hit.normal) * Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(0, 360)), 20f); } if (Flashlight.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Flashlight.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Flashlight.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { if (!Network.isServer) { base.networkView.RPC("swingPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb }); } else { this.swingPlayer(owner.GetComponent <Player>().owner.id, limb); } } } else if (Flashlight.hit.collider.tag == "Animal") { int num = OwnerFinder.getLimb(Flashlight.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Flashlight.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { if (!Network.isServer) { base.networkView.RPC("swingAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, num }); } else { this.swingAnimal(gameObject.networkView.viewID, num); } } } } } if (!this.swinging || Time.realtimeSinceStartup - this.lastSwing <= Viewmodel.model.animation["swingWeak"].length) { this.swinging = false; } else { this.swinging = false; this.lastSwing = Time.realtimeSinceStartup; this.swung = true; Viewmodel.play("swingWeak"); if (Stance.state == 0) { Player.play("standMelee"); } else if (Stance.state == 1) { Player.play("crouchMelee"); } else if (Stance.state == 2) { Player.play("proneMelee"); } } }
public void Update() { if (base.networkView.isMine) { if ((Player.life.dead || Movement.isSwimming || Movement.isClimbing || Movement.isDriving) && Equipment.model != null) { Equipment.dequip(); } if (Equipment.model != null) { if (!Equipment.ready) { Equipment.ready = true; Equipment.model.transform.FindChild("model").renderer.enabled = true; Equipment.useable.equip(); Equipment.ticking = true; } else if (Equipment.ticking) { if (Equipment.setup) { Equipment.useable.tick(); } else if (Time.realtimeSinceStartup - Equipment.startedEquip > Viewmodel.model.animation["equip"].length) { Equipment.setup = true; } } if (Input.GetKeyDown(InputSettings.dropKey)) { int num = Equipment.equipped.x; int num1 = Equipment.equipped.y; Equipment.dequip(); SpawnItems.dropItem(num, num1, Input.GetKey(InputSettings.otherKey)); } else if (Input.GetKeyDown(InputSettings.itemKey)) { Equipment.dequip(); } } if (Screen.lockCursor && !Player.life.dead) { if (Input.GetKeyDown(KeyCode.Alpha1)) { Equipment.equip(0, 0); } if (Input.GetKeyDown(KeyCode.Alpha2)) { Equipment.equip(1, 0); } if (Input.GetKeyDown(KeyCode.Alpha3)) { Equipment.equip(2, 0); } if (Input.GetKeyDown(KeyCode.Alpha4)) { Equipment.equip(3, 0); } if (Input.GetKeyDown(KeyCode.Alpha5)) { Equipment.equip(4, 0); } if (Input.GetKeyDown(KeyCode.Alpha6)) { Equipment.equip(5, 0); } if (!Equipment.busy && Equipment.setup) { if (Equipment.useable != null) { if (Input.GetKeyDown(InputSettings.shootKey)) { Equipment.useable.startPrimary(); } if (Input.GetKeyUp(InputSettings.shootKey)) { Equipment.useable.stopPrimary(); } if (Input.GetKeyDown(InputSettings.aimKey)) { Equipment.useable.startSecondary(); } if (Input.GetKeyUp(InputSettings.aimKey)) { Equipment.useable.stopSecondary(); } } else if (!Player.life.dead && !Movement.isSwimming && !Movement.isClimbing && Movement.vehicle == null && Stance.state != 2) { if (Input.GetKeyDown(InputSettings.shootKey) && !this.swinging) { this.swinging = true; this.right = false; } if (Input.GetKeyDown(InputSettings.aimKey) && !this.swinging) { this.swinging = true; this.right = true; } } } } if (this.swung && Time.realtimeSinceStartup - this.lastSwing > Viewmodel.model.animation["punchRight"].length / 2f) { NetworkSounds.askSound("Sounds/Items/8001/use", Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); this.swung = false; Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Equipment.hit, 2f, RayMasks.DAMAGE); if (Equipment.hit.collider != null) { if (Equipment.hit.point.y < Ocean.level) { NetworkSounds.askSound("Sounds/Impacts/rock", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/bubbles", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } else if (Equipment.hit.collider.gameObject.name == "ground" || Equipment.hit.collider.material.name.ToLower() == "rock (instance)" || Equipment.hit.collider.material.name.ToLower() == "ground (instance)") { NetworkSounds.askSound("Sounds/Impacts/rock", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/rock", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } else if (Equipment.hit.collider.material.name.ToLower() == "cloth (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/cloth", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } else if (Equipment.hit.collider.material.name.ToLower() == "wood (instance)") { NetworkSounds.askSound("Sounds/Impacts/wood", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/splinters", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } else if (Equipment.hit.collider.material.name.ToLower() == "tile (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/tile", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } else if (Equipment.hit.collider.material.name.ToLower() == "concrete (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/concrete", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } else if (Equipment.hit.collider.material.name.ToLower() == "metal (instance)" || Equipment.hit.collider.material.name.ToLower() == "iron (instance)") { NetworkSounds.askSound("Sounds/Impacts/metal", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/sparks", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } else if (Equipment.hit.collider.material.name.ToLower() == "flesh (instance)") { NetworkSounds.askSound("Sounds/Impacts/flesh", Equipment.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", Equipment.hit.point + (Equipment.hit.normal * 0.05f), Quaternion.LookRotation(Equipment.hit.normal), -1f); } if (Equipment.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Equipment.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Equipment.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { if (!Network.isServer) { base.networkView.RPC("punchPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb }); } else { this.punchPlayer(owner.GetComponent <Player>().owner.id, limb); } } } else if (Equipment.hit.collider.tag == "Animal") { int limb1 = OwnerFinder.getLimb(Equipment.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Equipment.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { if (!Network.isServer) { base.networkView.RPC("punchAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, limb1 }); } else { this.punchAnimal(gameObject.networkView.viewID, limb1); } } } } } if (!this.swinging || Time.realtimeSinceStartup - this.lastSwing <= Viewmodel.model.animation["punchRight"].length) { this.swinging = false; } else { this.swinging = false; this.lastSwing = Time.realtimeSinceStartup; this.swung = true; if (!this.right) { Viewmodel.play("punchLeft"); if (Stance.state == 0) { Player.play("standPunchLeft"); } else if (Stance.state == 1) { Player.play("crouchPunchLeft"); } } else { Viewmodel.play("punchRight"); if (Stance.state == 0) { Player.play("standPunchRight"); } else if (Stance.state == 1) { Player.play("crouchPunchRight"); } } } } }