Advertisement
zzosdunk

PrTopDownInventoryController

Jun 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 63.17 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class PrTopDownCharInventory : MonoBehaviour
  6. {
  7.  
  8.     [Header("Visuals")]
  9.  
  10.     public string characterName = "Soldier";
  11.     public bool changeColorsInMultiplayer = true;
  12.  
  13.     [Header("Stats")]
  14.  
  15.     public int Health = 100;
  16.     [HideInInspector] public int ActualHealth = 100;
  17.     public bool oneShotHealth = false;
  18.     public float Stamina = 1.0f;
  19.     public float StaminaRecoverSpeed = 0.5f;
  20.     [HideInInspector] public float ActualStamina = 1.0f;
  21.     public float StaminaRecoverLimit = 0.5f;
  22.     private float ActualStaminaRecover = 0.5f;
  23.  
  24.     [HideInInspector] public bool UsingStamina = false;
  25.     [HideInInspector] public bool isDead = false;
  26.     public bool DestroyOnDead = false;
  27.  
  28.     private bool Damaged = false;
  29.     private float DamagedTimer = 0.0f;
  30.  
  31.     private SphereCollider NoiseTrigger;
  32.     [HideInInspector]
  33.     public float actualNoise = 0.0f;
  34.     private float noiseDecaySpeed = 10.0f;
  35.  
  36.     private int enemyTeam = 1;
  37.  
  38.     [Header("Temperature Settings")]
  39.     public bool useTemperature = true;
  40.     [HideInInspector]
  41.     public float temperature = 1.0f;
  42.     public float temperatureThreshold = 2.0f;
  43.     public int temperatureDamage = 5;
  44.     public float onFireSpeedFactor = 0.5f;
  45.     private float tempTimer = 0;
  46.  
  47.     [Header("Weapons")]
  48.  
  49.     public bool alwaysAim = false;
  50.  
  51.     public int playerWeaponLimit = 2;
  52.  
  53.     public PrWeapon[] InitialWeapons;
  54.  
  55.  
  56.     private float lastWeaponChange = 0.0f;
  57.     [HideInInspector]
  58.     public bool Armed = true;
  59.     [HideInInspector]
  60.     public GameObject[] Weapon;
  61.     [HideInInspector]
  62.     public int[] actualWeaponTypes;
  63.     [HideInInspector]
  64.     public int ActiveWeapon = 0;
  65.     private bool CanShoot = true;
  66.     public PrWeaponList WeaponListObject;
  67.     private GameObject[] WeaponList;
  68.     public Transform WeaponR;
  69.     public Transform WeaponL;
  70.  
  71.     public bool aimingIK = false;
  72.     public bool useArmIK = true;
  73.     //[HideInInspector]
  74.     public int team = 0;
  75.  
  76.     //Grenade Vars
  77.     [Header("Grenades Vars")]
  78.     public float ThrowGrenadeMaxForce = 100f;
  79.     public GameObject grenadesPrefab;
  80.     public int maxGrenades = 10;
  81.     public int grenadesCount = 5;
  82.     private bool isThrowing = false;
  83.  
  84.     [HideInInspector] public bool Aiming = false;
  85.  
  86.     private float FireRateTimer = 0.0f;
  87.     private float LastFireTimer = 0.0f;
  88.  
  89.     private Transform AimTarget;
  90.  
  91.     [Header("VFX")]
  92.     public GameObject DamageFX;
  93.     private Vector3 LastHitPos = Vector3.zero;
  94.     public Renderer[] MeshRenderers;
  95.     [Space]
  96.     public Transform BurnAndFrozenVFXParent;
  97.     public GameObject frozenVFX;
  98.     private GameObject actualFrozenVFX;
  99.     public GameObject burningVFX;
  100.     private GameObject actualBurningVFX;
  101.     [Space]
  102.     public GameObject damageSplatVFX;
  103.     private PrBloodSplatter actualSplatVFX;
  104.     [Space]
  105.     public GameObject deathVFX;
  106.     private GameObject actualDeathVFX;
  107.  
  108.     [Space]
  109.     //Explosive Death VFX
  110.     public bool useExplosiveDeath = true;
  111.     private bool explosiveDeath = false;
  112.     public int damageThreshold = 50;
  113.     public GameObject explosiveDeathVFX;
  114.     private GameObject actualExplosiveDeathVFX;
  115.  
  116.     //Ragdoll Vars
  117.     [Header("Ragdoll setup")]
  118.     public bool useRagdollDeath = false;
  119.     public float ragdollForceFactor = 1.0f;
  120.  
  121.     [Header("Sound FX")]
  122.  
  123.     public float FootStepsRate = 0.4f;
  124.     public float GeneralFootStepsVolume = 1.0f;
  125.     public AudioClip[] Footsteps;
  126.     private float LastFootStepTime = 0.0f;
  127.     private AudioSource Audio;
  128.  
  129.     //USe Vars
  130.     [Header("Use Vars")]
  131.     public float UseAngle = 75.0f;
  132.     [HideInInspector] public GameObject UsableObject;
  133.     [HideInInspector] public bool UsingObject = false;
  134.  
  135.     //Pickup Vars
  136.     private GameObject PickupObj;
  137.     [HideInInspector]
  138.     public int BlueKeys = 0;
  139.     [HideInInspector]
  140.     public int RedKeys = 0;
  141.     [HideInInspector]
  142.     public int YellowKeys = 0;
  143.     [HideInInspector]
  144.     public int FullKeys = 0;
  145.  
  146.     //HuD Vars
  147.     [Header("HUD")]
  148.     public GameObject Compass;
  149.     public TextMesh CompassDistance;
  150.     private bool CompassActive = false;
  151.     private Transform CompassTarget;
  152.  
  153.     public GameObject HUDHealthBar;
  154.     public GameObject HUDStaminaBar;
  155.     public GameObject HUDDamageFullScreen;
  156.  
  157.     [HideInInspector]
  158.     public float HUDDamage;
  159.  
  160.     public GameObject HUDWeaponPicture;
  161.     //public GameObject HUDWeaponName;
  162.     public GameObject HUDWeaponBullets;
  163.     public GameObject HUDWeaponBulletsBar;
  164.     public GameObject HUDWeaponClips;
  165.     public GameObject HUDUseHelper;
  166.     public GameObject HUDColorBar;
  167.  
  168.     public GameObject HUDGrenadesIcon;
  169.     public GameObject HUDGrenadesCount;
  170.  
  171.     [Header("Quick Reload HUD")]
  172.  
  173.     public GameObject quickReloadPanel;
  174.     public GameObject quickReloadMarker;
  175.     public GameObject quickReloadZone;
  176.     [HideInInspector]
  177.     public bool useQuickReload = true;
  178.  
  179.     [Header("Multiplayer HUD")]
  180.     public float multiplayerHUDOffset = 0.0f;//70.0f
  181.     private bool splitScreen = false;
  182.     private int totalPlayers = 1;
  183.     private Vector2 splitOff = new Vector2(200, 112);
  184.     private Vector2 splitMargins = new Vector2(10, 0);
  185.     private float splitScaleFactor = 0.9f;
  186.  
  187.     //Private References
  188.     [HideInInspector]
  189.     public PrTopDownCharController charController;
  190.     [HideInInspector]
  191.     public Animator charAnimator;
  192.  
  193.     private GameObject[] Canvases;
  194.  
  195.     //ArmIK
  196.     private Transform ArmIKTarget = null;
  197.  
  198.     private PrCharacterIK CharacterIKController;
  199.     private int i = 0;
  200.     private int k = 3;
  201.  
  202.     [Header("Aiming")]
  203.     public GameObject AimTargetVisual;
  204.     public Transform AimFinalPos;
  205.     public bool isAim = false;
  206.  
  207.     private Vector3 finalPosition;
  208.     // Use this for initialization
  209.     void Start()
  210.     {
  211.  
  212.         Cursor.visible = false;
  213.         //Creates weapon array
  214.         Weapon = new GameObject[playerWeaponLimit];
  215.         actualWeaponTypes = new int[playerWeaponLimit];
  216.  
  217.         //Load Weapon List from Scriptable Object
  218.         WeaponList = WeaponListObject.weapons;
  219.  
  220.         ActualHealth = Health;
  221.         ActualStamina = Stamina;
  222.         ActualStaminaRecover = StaminaRecoverLimit;
  223.  
  224.         Audio = GetComponent<AudioSource>() as AudioSource;
  225.         charAnimator = GetComponent<Animator>();
  226.  
  227.         DeactivateCompass();
  228.  
  229.         charController = GetComponent<PrTopDownCharController>();
  230.         AimTarget = charController.AimFinalPos;
  231.         HUDHealthBar.GetComponent<RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f);
  232.  
  233.         CreateNoiseTrigger();
  234.  
  235.         //Start PlayerInfo to Load and Save player Info across levels
  236.         if (GameObject.Find("playerInfo_" + charController.playerNmb) && charController.playerSettings.TypeSelected == PrPlayerSettings.GameMode.SinglePlayer)
  237.         {
  238.             Debug.Log("Player Info already Found");
  239.             charController.LoadPlayerInfo();
  240.             SetHealth(ActualHealth);
  241.         }
  242.  
  243.         //Weapon Instantiate and initialization
  244.         if (InitialWeapons.Length > 0)
  245.         {
  246.             InstantiateWeapons();
  247.  
  248.             Armed = true;
  249.         }
  250.         else
  251.         {
  252.             Armed = false;
  253.         }
  254.  
  255.         Canvases = GameObject.FindGameObjectsWithTag("Canvas");
  256.         if (Canvases.Length > 0)
  257.         {
  258.             foreach (GameObject C in Canvases)
  259.                 UnparentTransforms(C.transform);
  260.         }
  261.  
  262.         if (alwaysAim)
  263.         {
  264.             Aiming = true;
  265.             charAnimator.SetBool("Aiming", true);
  266.         }
  267.  
  268.         InitializeHUD();
  269.  
  270.         //ragdoll Initialization
  271.         gameObject.AddComponent<PrCharacterRagdoll>();
  272.  
  273.  
  274.         if (useExplosiveDeath && explosiveDeathVFX)
  275.         {
  276.             actualExplosiveDeathVFX = Instantiate(explosiveDeathVFX, transform.position, transform.rotation) as GameObject;
  277.             actualExplosiveDeathVFX.SetActive(false);
  278.  
  279.             if (GameObject.Find("VFXBloodParent"))
  280.                 actualExplosiveDeathVFX.transform.parent = GameObject.Find("VFXBloodParent").transform;
  281.             else
  282.             {
  283.                 GameObject VFXParent = new GameObject("VFXBloodParent") as GameObject;
  284.                 actualExplosiveDeathVFX.transform.parent = VFXParent.transform;
  285.             }
  286.         }
  287.  
  288.         if (deathVFX)
  289.         {
  290.             actualDeathVFX = Instantiate(deathVFX, transform.position, transform.rotation) as GameObject;
  291.             actualDeathVFX.SetActive(false);
  292.  
  293.             if (GameObject.Find("VFXBloodParent"))
  294.                 actualDeathVFX.transform.parent = GameObject.Find("VFXBloodParent").transform;
  295.             else
  296.             {
  297.                 GameObject VFXParent = new GameObject("VFXBloodParent") as GameObject;
  298.                 actualDeathVFX.transform.parent = VFXParent.transform;
  299.             }
  300.         }
  301.  
  302.         if (damageSplatVFX)
  303.         {
  304.             GameObject GOactualSplatVFX = Instantiate(damageSplatVFX, transform.position, transform.rotation) as GameObject;
  305.             GOactualSplatVFX.transform.position = transform.position;
  306.             GOactualSplatVFX.transform.parent = transform;
  307.             actualSplatVFX = GOactualSplatVFX.GetComponent<PrBloodSplatter>();
  308.         }
  309.         if (frozenVFX)
  310.         {
  311.             actualFrozenVFX = Instantiate(frozenVFX, transform.position, transform.rotation) as GameObject;
  312.             actualFrozenVFX.transform.position = transform.position;
  313.             actualFrozenVFX.transform.parent = transform;
  314.             if (BurnAndFrozenVFXParent)
  315.                 actualFrozenVFX.transform.parent = BurnAndFrozenVFXParent;
  316.         }
  317.         if (burningVFX)
  318.         {
  319.             actualBurningVFX = Instantiate(burningVFX, transform.position, transform.rotation) as GameObject;
  320.             actualBurningVFX.transform.position = transform.position;
  321.             actualBurningVFX.transform.parent = transform;
  322.             if (BurnAndFrozenVFXParent)
  323.                 actualBurningVFX.transform.parent = BurnAndFrozenVFXParent;
  324.         }
  325.         if (useQuickReload && quickReloadPanel && quickReloadMarker && quickReloadZone)
  326.         {
  327.             QuickReloadActive(false);
  328.         }
  329.  
  330.         //Update players on Enemies
  331.         AIUpdatePlayerCount();
  332.  
  333.         //Update grenades HUD
  334.         if (HUDGrenadesCount)
  335.             HUDGrenadesCount.GetComponent<Text>().text = grenadesCount.ToString();
  336.  
  337.         if (oneShotHealth)
  338.             ApplyOneShotHealth();
  339.  
  340.  
  341.         //Create Player Info object if isn´t there yet
  342.         if (GameObject.Find("playerInfo_" + charController.playerNmb) == null && charController.playerSettings.TypeSelected == PrPlayerSettings.GameMode.SinglePlayer)
  343.         {
  344.             charController.CreatePlayerInfo();
  345.         }
  346.     }
  347.  
  348.     public void LoadBulletsAndClipsState(int weapon)
  349.     {
  350.         Weapon[weapon].GetComponent<PrWeapon>().ActualBullets = PrPlayerInfo.player1.weaponsAmmo[weapon];
  351.         Weapon[weapon].GetComponent<PrWeapon>().ActualClips = PrPlayerInfo.player1.weaponsClips[weapon];
  352.     }
  353.  
  354.     void ApplyOneShotHealth()
  355.     {
  356.         ActualHealth = 1;
  357.         HUDHealthBar.transform.parent.gameObject.SetActive(false);
  358.     }
  359.  
  360.     public void AIUpdatePlayerCount()
  361.     {
  362.         //Send Message to all AI
  363.         GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
  364.         if (enemies.Length > 0)
  365.         {
  366.             foreach (GameObject e in enemies)
  367.             {
  368.                 e.SendMessage("FindPlayers", SendMessageOptions.DontRequireReceiver);
  369.             }
  370.         }
  371.     }
  372.  
  373.     public void UnparentTransforms(Transform Target)
  374.     {
  375.         Target.SetParent(null);
  376.     }
  377.  
  378.     void CreateNoiseTrigger()
  379.     {
  380.         GameObject NoiseGO = new GameObject();
  381.         NoiseGO.name = "Player Noise Trigger";
  382.         NoiseGO.AddComponent<SphereCollider>();
  383.         NoiseTrigger = NoiseGO.GetComponent<SphereCollider>();
  384.         NoiseTrigger.GetComponent<SphereCollider>().isTrigger = true;
  385.         NoiseTrigger.transform.parent = this.transform;
  386.         NoiseTrigger.transform.position = transform.position + new Vector3(0, 1, 0);
  387.         NoiseTrigger.gameObject.tag = "Noise";
  388.     }
  389.  
  390.     void InstantiateWeapons()
  391.     {
  392.         int weapType = 0;
  393.         foreach (PrWeapon Weap in InitialWeapons)
  394.         {
  395.             int weapInt = 0;
  396.             //Debug.Log("Weapon to instance = " + Weap);
  397.  
  398.             foreach (GameObject weap in WeaponList)
  399.             {
  400.  
  401.                 if (Weap.gameObject.name == weap.name)
  402.                 {
  403.                     //Debug.Log("Weapon to pickup = " + weap + " " + weapInt);
  404.                     actualWeaponTypes[weapType] = weapInt;
  405.                     PickupWeapon(weapInt);
  406.                 }
  407.  
  408.                 else
  409.                     weapInt += 1;
  410.             }
  411.  
  412.             if (GameObject.Find("playerInfo_" + charController.playerNmb))
  413.             {
  414.                 LoadBulletsAndClipsState(weapType);
  415.             }
  416.  
  417.             weapType += 1;
  418.         }
  419.  
  420.     }
  421.  
  422.     public void FootStep()
  423.     {
  424.         if (Footsteps.Length > 0 && Time.time >= (LastFootStepTime + FootStepsRate))
  425.         {
  426.             int FootStepAudio = 0;
  427.  
  428.             if (Footsteps.Length > 1)
  429.             {
  430.                 FootStepAudio = Random.Range(0, Footsteps.Length);
  431.             }
  432.  
  433.             float FootStepVolume = charAnimator.GetFloat("Speed") * GeneralFootStepsVolume;
  434.             if (Aiming)
  435.                 FootStepVolume *= 0.5f;
  436.  
  437.             Audio.PlayOneShot(Footsteps[FootStepAudio], FootStepVolume);
  438.  
  439.             MakeNoise(FootStepVolume * 10f);
  440.             LastFootStepTime = Time.time;
  441.         }
  442.     }
  443.  
  444.     public void RollSound(AudioClip SFX)
  445.     {
  446.         if (SFX != null)
  447.             Audio.PlayOneShot(SFX);
  448.     }
  449.  
  450.     //Test Function to Assign a Target to the Compass
  451.     public void TestAssignTarget()
  452.     {
  453.         ActivateCompass(GameObject.Find("PickupExample_RocketLauncher"));
  454.  
  455.     }
  456.  
  457.     public void ActivateCompass(GameObject Target)
  458.     {
  459.         Compass.SetActive(true);
  460.         CompassActive = true;
  461.         CompassTarget = Target.transform;
  462.  
  463.     }
  464.  
  465.     public void DeactivateCompass()
  466.     {
  467.         CompassActive = false;
  468.         Compass.SetActive(false);
  469.  
  470.     }
  471.  
  472.     public void MakeNoise(float volume)
  473.     {
  474.         actualNoise = volume;
  475.     }
  476.  
  477.     public void LoadGrenades(int quantity)
  478.     {
  479.         grenadesCount += quantity;
  480.         if (grenadesCount > maxGrenades)
  481.         {
  482.             grenadesCount = maxGrenades;
  483.         }
  484.         if (HUDGrenadesCount)
  485.             HUDGrenadesCount.GetComponent<Text>().text = grenadesCount.ToString();
  486.     }
  487.  
  488.     void ThrowG()
  489.     {
  490.         GameObject Grenade = Instantiate(grenadesPrefab, WeaponL.position, Quaternion.LookRotation(transform.forward)) as GameObject;
  491.         Grenade.GetComponent<PrBullet>().team = team;
  492.         Vector3 grenadeForce = this.transform.forward * Grenade.GetComponent<PrBullet>().BulletSpeed * 25 + Vector3.up * 2000;
  493.         float targetDistance = Vector3.Distance(AimTarget.transform.position, transform.position);
  494.         Vector3 finalGrenadeForce = grenadeForce * (targetDistance / 20.0f);
  495.         float MaxForce = ThrowGrenadeMaxForce * 17;
  496.         finalGrenadeForce.x = Mathf.Clamp(finalGrenadeForce.x, -MaxForce, MaxForce);
  497.         finalGrenadeForce.y = Mathf.Clamp(finalGrenadeForce.y, -MaxForce, MaxForce);
  498.         finalGrenadeForce.z = Mathf.Clamp(finalGrenadeForce.z, -MaxForce, MaxForce);
  499.         //Debug.Log(finalGrenadeForce);
  500.         Grenade.GetComponent<Rigidbody>().AddForce(finalGrenadeForce);
  501.         Grenade.GetComponent<Rigidbody>().AddRelativeTorque(Grenade.transform.forward * 50f, ForceMode.Impulse);
  502.  
  503.         grenadesCount -= 1;
  504.         if (HUDGrenadesCount)
  505.             HUDGrenadesCount.GetComponent<Text>().text = grenadesCount.ToString();
  506.  
  507.         //Debug.Break();
  508.     }
  509.  
  510.     void EndThrow()
  511.     {
  512.         isThrowing = false;
  513.         EnableArmIK(true);
  514.     }
  515.  
  516.  
  517.     void EnableArmIK(bool active)
  518.     {
  519.         if (CharacterIKController && useArmIK)
  520.             if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().useIK)
  521.                 CharacterIKController.ikActive = active;
  522.             else
  523.                 CharacterIKController.ikActive = false;
  524.     }
  525.  
  526.  
  527.     void WeaponReload()
  528.     {
  529.         if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().ActualBullets < Weapon[ActiveWeapon].GetComponent<PrWeapon>().Bullets && Weapon[ActiveWeapon].GetComponent<PrWeapon>().Reloading == false &&
  530.             Weapon[ActiveWeapon].GetComponent<PrWeapon>().ActualClips > 0)
  531.         {
  532.             Weapon[ActiveWeapon].GetComponent<PrWeapon>().LaserSight.enabled = false;
  533.             Weapon[ActiveWeapon].GetComponent<PrWeapon>().Reload();
  534.             //charAnimator.SetBool("Reloading", true);
  535.             CanShoot = false;
  536.             //Disable Arm IK
  537.             EnableArmIK(false);
  538.  
  539.             if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().useQuickReload)
  540.             {
  541.                 QuickReloadActive(true);
  542.             }
  543.         }
  544.     }
  545.  
  546.     void QuickReloadActive(bool state)
  547.     {
  548.         //Debug.Log("QuickReloading " + state );
  549.         quickReloadPanel.SetActive(state);
  550.     }
  551.  
  552.  
  553.     public void SetPlayerColors(int mode, int team, PrPlayerSettings playerSettings)
  554.     {
  555.         if (changeColorsInMultiplayer)
  556.         {
  557.             if (mode == 0)
  558.             {
  559.                 //Singleplayer Colors
  560.                 if (playerSettings.useSinglePlayerColor)
  561.                 {
  562.                     foreach (Renderer rend in MeshRenderers)
  563.                     {
  564.                         rend.material.SetColor("_MaskedColorA", playerSettings.singlePlayerColor);
  565.                     }
  566.                 }
  567.  
  568.             }
  569.             else if (mode == 1)
  570.             {
  571.                 //Deathmatch Colors
  572.                 foreach (Renderer rend in MeshRenderers)
  573.                 {
  574.                     rend.material.SetColor("_MaskedColorA", playerSettings.playerColor[team]);
  575.                 }
  576.             }
  577.             else if (mode == 2)
  578.             {
  579.                 //Coop Colors
  580.                 if (playerSettings.useCoopPlayerColor)
  581.                 {
  582.                     foreach (Renderer rend in MeshRenderers)
  583.                     {
  584.                         rend.material.SetColor("_MaskedColorA", playerSettings.coopPlayerColor[team]);
  585.                     }
  586.                 }
  587.             }
  588.             else if (mode == 3)
  589.             {
  590.                 //Team DeathMatch Colors
  591.                 foreach (Renderer rend in MeshRenderers)
  592.                 {
  593.                     Debug.Log(team);
  594.                     rend.material.SetColor("_MaskedColorA", playerSettings.teamColor[team]);
  595.  
  596.                 }
  597.  
  598.             }
  599.         }
  600.  
  601.     }
  602.  
  603.     void EndMelee()
  604.     {
  605.         charController.useRootMotion = false;
  606.         charController.Rolling = false;
  607.         charController.EndRoll();
  608.     }
  609.  
  610.     void MeleeEvent()
  611.     {
  612.         //this event comes from animation, the exact moment of HIT
  613.         Weapon[ActiveWeapon].GetComponent<PrWeapon>().AttackMelee();
  614.  
  615.     }
  616.  
  617.  
  618.  
  619.     // Update is called once per frame
  620.     void Update()
  621.     {
  622.  
  623.  
  624.  
  625.         if (Damaged && MeshRenderers.Length > 0)
  626.         {
  627.             DamagedTimer = Mathf.Lerp(DamagedTimer, 0.0f, Time.deltaTime * 10);
  628.  
  629.             if (Mathf.Approximately(DamagedTimer, 0.0f))
  630.             {
  631.                 DamagedTimer = 0.0f;
  632.                 Damaged = false;
  633.             }
  634.  
  635.             foreach (Renderer Mesh in MeshRenderers)
  636.             {
  637.                 if (Mesh.material.HasProperty("_DamageFX"))
  638.                     Mesh.material.SetFloat("_DamageFX", DamagedTimer);
  639.             }
  640.  
  641.             foreach (SkinnedMeshRenderer SkinnedMesh in MeshRenderers)
  642.             {
  643.                 if (SkinnedMesh.material.HasProperty("_DamageFX"))
  644.                     SkinnedMesh.material.SetFloat("_DamageFX", DamagedTimer);
  645.             }
  646.  
  647.             if (HUDDamageFullScreen)
  648.                 HUDDamageFullScreen.GetComponent<UnityEngine.UI.Image>().color = new Vector4(1, 1, 1, DamagedTimer * 0.5f);
  649.  
  650.         }
  651.  
  652.         if (!isDead)
  653.         {
  654.             //Calculates Temperature and damage
  655.             ApplyTemperature();
  656.  
  657.             if (ActualHealth <= 20f)
  658.             {
  659.                 LowHPWarning();
  660.             }
  661.  
  662.             // Equip Weapon
  663.             if (Input.GetButtonUp(charController.playerCtrlMap[6]) && Aiming == false && charController.Sprinting == false && charController.Rolling == false && isThrowing == false)
  664.             {
  665.                 Weapon[ActiveWeapon].GetComponent<PrWeapon>().CancelReload();
  666.  
  667.                 if (Armed)
  668.                     Armed = false;
  669.                 else
  670.                     Armed = true;
  671.                 EquipWeapon(Armed);
  672.             }
  673.             // Throw grenades
  674.             if (Input.GetButton(charController.playerCtrlMap[14]))
  675.             {
  676.                 if (grenadesCount > 0 && isThrowing == false && charController.Rolling == false && charController.Sprinting == false && Armed)
  677.                 {
  678.                     Weapon[ActiveWeapon].GetComponent<PrWeapon>().CancelReload();
  679.                     isThrowing = true;
  680.                     charAnimator.SetTrigger("ThrowG");
  681.                     Weapon[ActiveWeapon].GetComponent<PrWeapon>().LaserSight.enabled = false;
  682.                     EnableArmIK(false);
  683.  
  684.                 }
  685.             }
  686.             _Aiming();
  687.  
  688.             // Shoot Weapons
  689.             if (Input.GetAxis(charController.playerCtrlMap[4]) >= 0.5f || Input.GetButton(charController.playerCtrlMap[15]))
  690.             {
  691.                 if (charController.Rolling == false && charController.Sprinting == false && isThrowing == false)
  692.                 {
  693.                     if (CanShoot && Weapon[ActiveWeapon] != null && Time.time >= (LastFireTimer + FireRateTimer))
  694.                     {
  695.                         //Melee Weapon
  696.                         if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Type == global::PrWeapon.WT.Melee)
  697.                         {
  698.                             charController.Rolling = true;
  699.                             LastFireTimer = Time.time;
  700.                             charAnimator.SetTrigger("AttackMelee");
  701.                             //charAnimator.SetInteger("MeleeType", Random.Range(0, 3));
  702.  
  703.                             charAnimator.SetInteger("MeleeType", i);
  704.                             i++;
  705.                             if (i == 3)
  706.                             {
  707.                                 i = 0;
  708.                             }
  709.                             charController.useRootMotion = true;
  710.                             charController.CantRotate();
  711.                         }
  712.                         //Ranged Weapon
  713.                         else
  714.                         {
  715.                             if (Aiming)
  716.                             {
  717.                                 LastFireTimer = Time.time;
  718.                                 Weapon[ActiveWeapon].GetComponent<PrWeapon>().Shoot();
  719.                                 if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Reloading == false)
  720.                                 {
  721.  
  722.                                     if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().ActualBullets > 0)
  723.                                         charAnimator.SetTrigger("Shoot");
  724.  
  725.                                     else
  726.                                         WeaponReload();
  727.                                 }
  728.                             }
  729.  
  730.                         }
  731.  
  732.                     }
  733.                 }
  734.             }
  735.             /////////////////////////////////////////////////////////////////////////////////
  736.             if (Input.GetButtonDown("Fire1"))
  737.             {
  738.                 _Aiming();
  739.                 Debug.Log("FIRE 1");
  740.                 StartCoroutine(Timer());
  741.                 if (charController.Rolling == false && charController.Sprinting == false && isThrowing == false)
  742.                 {
  743.                     if (CanShoot && Weapon[ActiveWeapon] != null && Time.time >= (LastFireTimer + FireRateTimer))
  744.                     {
  745.                         //Melee Weapon
  746.                         if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Type == global::PrWeapon.WT.Melee)
  747.                         {
  748.                             //if (!alwaysAim)
  749.                             //{
  750.                             charController.Rolling = true;
  751.                             LastFireTimer = Time.time;
  752.                             charAnimator.SetTrigger("AttackMelee");
  753.                             //charAnimator.SetInteger("MeleeType", Random.Range(3, 6));
  754.                             charAnimator.SetInteger("MeleeType", k);
  755.                             k++;
  756.                             if (k == 6)
  757.                             {
  758.                                 k = 3;
  759.                             }
  760.  
  761.                             charController.useRootMotion = true;
  762.                             charController.CantRotate();
  763.                             //}
  764.  
  765.                         }
  766.                         //Ranged Weapon
  767.  
  768.                     }
  769.                 }
  770.             }
  771.             /////////////////////////////////////////////////////////////////////////
  772.  
  773.  
  774.  
  775.             // Reload Weapon
  776.             if (Input.GetButtonDown(charController.playerCtrlMap[5]))
  777.             {
  778.                 if (charController.Rolling == false && charController.Sprinting == false && isThrowing == false)
  779.                 {
  780.                     WeaponReload();
  781.                 }
  782.                 if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Reloading == true)
  783.                 {
  784.                     Weapon[ActiveWeapon].GetComponent<PrWeapon>().TryQuickReload();
  785.                 }
  786.             }
  787.  
  788.  
  789.  
  790.  
  791.             //USE
  792.             if (Input.GetButtonDown(charController.playerCtrlMap[11]) && UsableObject && !UsingObject && isThrowing == false)
  793.             {
  794.                 if (UsableObject.GetComponent<PrUsableDevice>().IsEnabled)
  795.                 {
  796.                     Weapon[ActiveWeapon].GetComponent<PrWeapon>().CancelReload();
  797.                     StartUsingGeneric("Use");
  798.  
  799.                     UsableObject.GetComponent<PrUsableDevice>().User = this.gameObject;
  800.                     UsableObject.GetComponent<PrUsableDevice>().Use();
  801.                 }
  802.  
  803.             }
  804.             //Pickup
  805.             else if (Input.GetButtonDown(charController.playerCtrlMap[11]) && !UsableObject && !UsingObject && PickupObj && isThrowing == false)
  806.             {
  807.                 Weapon[ActiveWeapon].GetComponent<PrWeapon>().CancelReload();
  808.  
  809.                 StartUsingGeneric("Pickup");
  810.  
  811.                 PickupItem();
  812.  
  813.  
  814.             }
  815.             // Change Weapon
  816.             if (Input.GetButtonDown(charController.playerCtrlMap[13]) || Input.GetAxis(charController.playerCtrlMap[9]) >= 0.5f || Input.GetAxis(charController.playerCtrlMap[16]) != 0f)
  817.             {
  818.  
  819.                 if (isThrowing == false && Time.time >= lastWeaponChange + 0.25f && Armed)
  820.                 {
  821.                     Weapon[ActiveWeapon].GetComponent<PrWeapon>().CancelReload();
  822.                     ChangeWeapon();
  823.                 }
  824.  
  825.             }
  826.  
  827.             if (alwaysAim)
  828.             {
  829.                 if (!UsingObject && !charController.Sprinting)
  830.                     Aiming = true;
  831.                 else
  832.                     Aiming = false;
  833.             }
  834.  
  835.             if (HUDUseHelper && UsableObject)
  836.             {
  837.                 HUDUseHelper.transform.rotation = Quaternion.identity;
  838.             }
  839.  
  840.  
  841.  
  842.             if (ActualStaminaRecover >= StaminaRecoverLimit)
  843.             {
  844.  
  845.                 if (UsingStamina)
  846.                 {
  847.                     if (ActualStamina > 0.05f)
  848.                         ActualStamina -= Time.deltaTime;
  849.                     else if (ActualStamina > 0.0f)
  850.                     {
  851.                         ActualStamina = 0.0f;
  852.                         ActualStaminaRecover = 0.0f;
  853.                     }
  854.  
  855.  
  856.                 }
  857.                 else if (!UsingStamina)
  858.                 {
  859.                     if (ActualStamina < Stamina)
  860.                         ActualStamina += Time.deltaTime * StaminaRecoverSpeed;
  861.                     else
  862.                         ActualStamina = Stamina;
  863.                 }
  864.             }
  865.             else if (ActualStaminaRecover < StaminaRecoverLimit)
  866.             {
  867.                 ActualStaminaRecover += Time.deltaTime;
  868.             }
  869.  
  870.             HUDStaminaBar.GetComponent<RectTransform>().localScale = new Vector3((1.0f / Stamina) * ActualStamina, 1.0f, 1.0f);
  871.  
  872.  
  873.  
  874.             if (UsingObject && UsableObject)
  875.             {
  876.                 Quaternion EndRotation = Quaternion.LookRotation(UsableObject.transform.position - transform.position);
  877.                 transform.rotation = Quaternion.Lerp(transform.rotation, EndRotation, Time.deltaTime * 5);
  878.                 transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0);
  879.             }
  880.  
  881.             //Noise Manager
  882.             if (actualNoise > 0.0f)
  883.             {
  884.                 actualNoise -= Time.deltaTime * noiseDecaySpeed;
  885.                 NoiseTrigger.radius = actualNoise;
  886.             }
  887.  
  888.         }
  889.  
  890.     }
  891.  
  892.  
  893.     private void MouseTargetPos()
  894.     {
  895.         Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  896.         RaycastHit hit;
  897.         if (Physics.Raycast(ray, out hit, 2000f, 9))
  898.         {
  899.             //Debug.Log("---------- Hit Something------------");
  900.             finalPosition = new Vector3(hit.point.x, 0, hit.point.z);
  901.  
  902.             AimTargetVisual.transform.position = finalPosition;
  903.             AimTargetVisual.transform.LookAt(transform.position);
  904.  
  905.         }
  906.     }
  907.     private IEnumerator Timer()
  908.     {
  909.         print("FIRE 1 ACTION WAIITNG");
  910.         yield return new WaitForSeconds(3);
  911.         print("END");
  912.     }
  913.     public void _Aiming()
  914.     {
  915.  
  916.         // Aim
  917.         if (Input.GetButton(charController.playerCtrlMap[8]) || Mathf.Abs(Input.GetAxis(charController.playerCtrlMap[2])) > 0.3f || Mathf.Abs(Input.GetAxis(charController.playerCtrlMap[3])) > 0.3f)
  918.         {
  919.  
  920.             if (charController.Rolling == false && charController.Sprinting == false && !UsingObject && Armed && isThrowing == false)
  921.             {
  922.                 if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Type != global::PrWeapon.WT.Melee)
  923.                 {
  924.                     if (!alwaysAim)
  925.                     {
  926.                         Aiming = true;
  927.                         if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Reloading == true || isThrowing == true)
  928.                             Weapon[ActiveWeapon].GetComponent<PrWeapon>().LaserSight.enabled = false;
  929.                         else
  930.                             Weapon[ActiveWeapon].GetComponent<PrWeapon>().LaserSight.enabled = true;
  931.                         charAnimator.SetBool("RunStop", false);
  932.                         charAnimator.SetBool("Aiming", true);
  933.                     }
  934.  
  935.                 }
  936.                 else
  937.                 {
  938.  
  939.                     isAim = true;
  940.                     Aim(isAim);
  941.                 }
  942.             }
  943.  
  944.         }
  945.         //Stop Aiming
  946.         else if (Input.GetButtonUp(charController.playerCtrlMap[8]) || Mathf.Abs(Input.GetAxis(charController.playerCtrlMap[2])) < 0.3f || Mathf.Abs(Input.GetAxis(charController.playerCtrlMap[3])) < 0.3f)
  947.         {
  948.             isAim = false;
  949.             Aim(isAim);
  950.             if (!alwaysAim)
  951.             {
  952.                 Aiming = false;
  953.                 charAnimator.SetBool("Aiming", false);
  954.                 Weapon[ActiveWeapon].GetComponent<PrWeapon>().LaserSight.enabled = false;
  955.             }
  956.         }
  957.     }
  958.  
  959.     void LateUpdate()
  960.     {
  961.         if (CompassActive && !isDead)
  962.         {
  963.             if (CompassTarget)
  964.             {
  965.                 Compass.transform.LookAt(CompassTarget.position);
  966.                 CompassDistance.text = "" + (Mathf.RoundToInt(Vector3.Distance(CompassTarget.position, transform.position))) + " Mts";
  967.  
  968.                 if (Vector3.Distance(CompassTarget.position, transform.position) <= 2.0f)
  969.                 {
  970.                     CompassTarget = null;
  971.                     DeactivateCompass();
  972.                 }
  973.             }
  974.             else
  975.             {
  976.                 DeactivateCompass();
  977.             }
  978.  
  979.         }
  980.  
  981.         if (aimingIK && !isDead)
  982.         {
  983.             if (Aiming && !Weapon[ActiveWeapon].GetComponent<PrWeapon>().Reloading && !isThrowing && !charController.Rolling && !charController.Jumping && !charController.Sprinting)
  984.             {
  985.                 WeaponR.parent.transform.LookAt(AimTarget.position, Vector3.up);
  986.             }
  987.         }
  988.     }
  989.  
  990.     void Aim(bool isAimed)
  991.     {
  992.         if (isAimed == true)
  993.         {
  994.             alwaysAim = true;
  995.         }
  996.         else
  997.         {
  998.             alwaysAim = false;
  999.         }
  1000.     }
  1001.  
  1002.  
  1003.     void EquipWeapon(bool bArmed)
  1004.     {
  1005.         charAnimator.SetBool("Armed", bArmed);
  1006.         Weapon[ActiveWeapon].SetActive(bArmed);
  1007.         Weapon[ActiveWeapon].GetComponent<PrWeapon>().UpdateWeaponGUI(HUDWeaponPicture);
  1008.  
  1009.         if (!bArmed)
  1010.         {
  1011.             int PistolLayer = charAnimator.GetLayerIndex("PistolLyr");
  1012.             charAnimator.SetLayerWeight(PistolLayer, 0.0f);
  1013.             int PistoActlLayer = charAnimator.GetLayerIndex("PistolActions");
  1014.             charAnimator.SetLayerWeight(PistoActlLayer, 0.0f);
  1015.             int RifleActlLayer = charAnimator.GetLayerIndex("RifleActions");
  1016.             charAnimator.SetLayerWeight(RifleActlLayer, 0.0f);
  1017.             int PartialActions = charAnimator.GetLayerIndex("PartialActions");
  1018.             charAnimator.SetLayerWeight(PartialActions, 0.0f);
  1019.  
  1020.             if (CharacterIKController)
  1021.                 CharacterIKController.enabled = false;
  1022.         }
  1023.         else
  1024.         {
  1025.             if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Type == global::PrWeapon.WT.Pistol)
  1026.             {
  1027.                 int PistolLayer = charAnimator.GetLayerIndex("PistolLyr");
  1028.                 charAnimator.SetLayerWeight(PistolLayer, 1.0f);
  1029.                 int PistoActlLayer = charAnimator.GetLayerIndex("PistolActions");
  1030.                 charAnimator.SetLayerWeight(PistoActlLayer, 1.0f);
  1031.                 int RifleActlLayer = charAnimator.GetLayerIndex("RifleActions");
  1032.                 charAnimator.SetLayerWeight(RifleActlLayer, 0.0f);
  1033.             }
  1034.             else if (Weapon[ActiveWeapon].GetComponent<PrWeapon>().Type == global::PrWeapon.WT.Rifle)
  1035.             {
  1036.                 int PistolLayer = charAnimator.GetLayerIndex("PistolLyr");
  1037.                 charAnimator.SetLayerWeight(PistolLayer, 0.0f);
  1038.                 int PistoActlLayer = charAnimator.GetLayerIndex("PistolActions");
  1039.                 charAnimator.SetLayerWeight(PistoActlLayer, 0.0f);
  1040.                 int RifleActlLayer = charAnimator.GetLayerIndex("RifleActions");
  1041.                 charAnimator.SetLayerWeight(RifleActlLayer, 1.0f);
  1042.             }
  1043.  
  1044.             int PartAct = charAnimator.GetLayerIndex("PartialActions");
  1045.             charAnimator.SetLayerWeight(PartAct, 1.0f);
  1046.  
  1047.             if (CharacterIKController)
  1048.                 CharacterIKController.enabled = true;
  1049.         }
  1050.  
  1051.         EnableArmIK(bArmed);
  1052.  
  1053.     }
  1054.  
  1055.     void StartUsingGeneric(string Type)
  1056.     {
  1057.         Aiming = false;
  1058.         UsingObject = true;
  1059.  
  1060.         charController.m_CanMove = false;
  1061.         charAnimator.SetTrigger(Type);
  1062.  
  1063.         Weapon[ActiveWeapon].GetComponent<PrWeapon>().LaserSight.enabled = false;
  1064.  
  1065.         EnableArmIK(false);
  1066.     }
  1067.  
  1068.     void PickupItem()
  1069.     {
  1070.         transform.rotation = Quaternion.LookRotation(PickupObj.transform.position - transform.position);
  1071.         transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0);
  1072.  
  1073.         PickupObj.SendMessage("PickupObjectNow", ActiveWeapon);
  1074.     }
  1075.  
  1076.     public void SpawnTeleportFX()
  1077.     {
  1078.         Damaged = true;
  1079.         DamagedTimer = 1.0f;
  1080.     }
  1081.  
  1082.     public void PickupWeapon(int WeaponType)
  1083.     {
  1084.         GameObject NewWeapon = Instantiate(WeaponList[WeaponType], WeaponR.position, WeaponR.rotation) as GameObject;
  1085.         NewWeapon.transform.parent = WeaponR.transform;
  1086.         NewWeapon.transform.localRotation = Quaternion.Euler(90, 0, 0);
  1087.         NewWeapon.name = "Player_" + NewWeapon.GetComponent<PrWeapon>().WeaponName;
  1088.         actualWeaponTypes[ActiveWeapon] = WeaponType;
  1089.  
  1090.         //New multi weapon system
  1091.         bool replaceWeapon = true;
  1092.  
  1093.         for (int i = 0; i < playerWeaponLimit; i++)
  1094.         {
  1095.             if (Weapon[i] == null)
  1096.             {
  1097.                 //Debug.Log(i + " " + NewWeapon.name);
  1098.  
  1099.                 Weapon[i] = NewWeapon;
  1100.                 replaceWeapon = false;
  1101.  
  1102.                 if (ActiveWeapon != i)
  1103.                 {
  1104.                     // ChangeWeapon();
  1105.                     ChangeToWeapon(i);
  1106.                 }
  1107.                 break;
  1108.             }
  1109.  
  1110.         }
  1111.         if (replaceWeapon)
  1112.         {
  1113.             //Debug.Log("Replacing weapon" + Weapon[ActiveWeapon].name + " using " + NewWeapon.name);
  1114.             DestroyImmediate(Weapon[ActiveWeapon]);
  1115.             Weapon[ActiveWeapon] = NewWeapon;
  1116.  
  1117.         }
  1118.  
  1119.         InitializeWeapons();
  1120.  
  1121.     }
  1122.  
  1123.     public void PickupKey(int KeyType)
  1124.     {
  1125.         if (KeyType == 0)
  1126.             BlueKeys += 1;
  1127.         else if (KeyType == 1)
  1128.             YellowKeys += 1;
  1129.         else if (KeyType == 2)
  1130.             RedKeys += 1;
  1131.         else if (KeyType == 3)
  1132.             FullKeys += 1;
  1133.     }
  1134.  
  1135.     void InitializeWeapons()
  1136.     {
  1137.         PrWeapon ActualW = Weapon[ActiveWeapon].GetComponent<PrWeapon>();
  1138.         Weapon[ActiveWeapon].SetActive(true);
  1139.         HUDWeaponPicture.GetComponent<UnityEngine.UI.Image>().sprite = ActualW.WeaponPicture;
  1140.         //
  1141.  
  1142.         ActualW.ShootTarget = AimTarget;
  1143.         ActualW.Player = this.gameObject;
  1144.         FireRateTimer = ActualW.FireRate;
  1145.  
  1146.         ActualW.HUDWeaponBullets = HUDWeaponBullets;
  1147.         ActualW.HUDWeaponBulletsBar = HUDWeaponBulletsBar;
  1148.         ActualW.HUDWeaponClips = HUDWeaponClips;
  1149.  
  1150.         useQuickReload = ActualW.useQuickReload;
  1151.  
  1152.         ActualW.HUDquickRelaodMarker = quickReloadMarker;
  1153.         ActualW.HUDquickRelaodZone = quickReloadZone;
  1154.         ActualW.SetupQuickReload();
  1155.  
  1156.         //ArmIK
  1157.         if (useArmIK)
  1158.         {
  1159.             if (ActualW.gameObject.transform.Find("ArmIK"))
  1160.             {
  1161.                 ArmIKTarget = ActualW.gameObject.transform.Find("ArmIK");
  1162.                 if (GetComponent<PrCharacterIK>() == null)
  1163.                 {
  1164.                     gameObject.AddComponent<PrCharacterIK>();
  1165.                     CharacterIKController = GetComponent<PrCharacterIK>();
  1166.                 }
  1167.                 else if (GetComponent<PrCharacterIK>())
  1168.                 {
  1169.                     CharacterIKController = GetComponent<PrCharacterIK>();
  1170.                 }
  1171.  
  1172.                 if (CharacterIKController)
  1173.                 {
  1174.                     CharacterIKController.leftHandTarget = ArmIKTarget;
  1175.                     CharacterIKController.ikActive = true;
  1176.                 }
  1177.  
  1178.             }
  1179.             else
  1180.             {
  1181.                 if (CharacterIKController != null)
  1182.                     CharacterIKController.ikActive = false;
  1183.             }
  1184.         }
  1185.  
  1186.  
  1187.         ActualW.Audio = WeaponR.GetComponent<AudioSource>();
  1188.  
  1189.         if (ActualW.Type == global::PrWeapon.WT.Pistol)
  1190.         {
  1191.             int PistolLayer = charAnimator.GetLayerIndex("PistolLyr");
  1192.             charAnimator.SetLayerWeight(PistolLayer, 1.0f);
  1193.             int PistolActLayer = charAnimator.GetLayerIndex("PistolActions");
  1194.             charAnimator.SetLayerWeight(PistolActLayer, 1.0f);
  1195.             charAnimator.SetBool("Armed", true);
  1196.         }
  1197.         else if (ActualW.Type == global::PrWeapon.WT.Rifle)
  1198.         {
  1199.             int PistolLayer = charAnimator.GetLayerIndex("PistolLyr");
  1200.             charAnimator.SetLayerWeight(PistolLayer, 0.0f);
  1201.             int PistolActLayer = charAnimator.GetLayerIndex("PistolActions");
  1202.             charAnimator.SetLayerWeight(PistolActLayer, 0.0f);
  1203.             charAnimator.SetBool("Armed", true);
  1204.         }
  1205.         else if (ActualW.Type == global::PrWeapon.WT.Melee)
  1206.         {
  1207.             int PistolLayer = charAnimator.GetLayerIndex("PistolLyr");
  1208.             charAnimator.SetLayerWeight(PistolLayer, 0.0f);
  1209.             int PistolActLayer = charAnimator.GetLayerIndex("PistolActions");
  1210.             charAnimator.SetLayerWeight(PistolActLayer, 0.0f);
  1211.             charAnimator.SetBool("Armed", false);
  1212.         }
  1213.         else if (ActualW.Type == global::PrWeapon.WT.Laser)
  1214.         {
  1215.             int PistolLayer = charAnimator.GetLayerIndex("PistolLyr");
  1216.             charAnimator.SetLayerWeight(PistolLayer, 0.0f);
  1217.             int PistolActLayer = charAnimator.GetLayerIndex("PistolActions");
  1218.             charAnimator.SetLayerWeight(PistolActLayer, 0.0f);
  1219.             charAnimator.SetBool("Armed", true);
  1220.         }
  1221.  
  1222.         Weapon[ActiveWeapon].GetComponent<PrWeapon>().UpdateWeaponGUI(HUDWeaponPicture);
  1223.     }
  1224.  
  1225.     void InitializeHUD()
  1226.     {
  1227.         if (HUDDamageFullScreen)
  1228.             HUDDamageFullScreen.GetComponent<UnityEngine.UI.Image>().color = new Vector4(1, 1, 1, 0);
  1229.  
  1230.         if (charController.playerNmb > 0)
  1231.         {
  1232.             RectTransform HUDHealtRect = HUDHealthBar.transform.parent.GetComponent<RectTransform>();
  1233.             RectTransform HUDWeaponRect = HUDWeaponBulletsBar.transform.parent.GetComponent<RectTransform>();
  1234.             //RectTransform HUDQuickReloadPanel = quickReloadPanel.transform.GetComponent<RectTransform>();
  1235.  
  1236.             //FOR MULTIPLAYER PURPOSES
  1237.             float XPos = HUDHealtRect.localPosition.x;
  1238.             float YPos = HUDHealtRect.localPosition.y;
  1239.  
  1240.             float XWeapPos = HUDWeaponRect.localPosition.x;
  1241.             float YWeapPos = HUDWeaponRect.localPosition.y;
  1242.  
  1243.             //float XQRPos = HUDQuickReloadPanel.localPosition.x;
  1244.             //float YQRPos = HUDQuickReloadPanel.localPosition.y;
  1245.  
  1246.             //Debug.Log(XPos);
  1247.  
  1248.             if (splitScreen)
  1249.             {
  1250.  
  1251.                 //Scale HUDS
  1252.                 //HUDHealtRect.localScale *= splitScaleFactor;
  1253.                 HUDWeaponRect.localScale *= splitScaleFactor;
  1254.  
  1255.                 //Apply Split Screen Margins
  1256.                 //XPos = XPos - splitMargins.x;
  1257.                 //YPos = YPos - splitMargins.y;
  1258.                 XWeapPos = XWeapPos - splitMargins.x;
  1259.                 YWeapPos = YWeapPos - splitMargins.y;
  1260.                 //XQRPos = XQRPos - splitMargins.x;
  1261.                 //YQRPos = YQRPos - splitMargins.y;
  1262.  
  1263.                 //Damage Rect
  1264.                 Vector3 damageScale = HUDDamageFullScreen.GetComponent<RectTransform>().localScale * 1.01f;
  1265.                 Vector3 damagePos = HUDDamageFullScreen.GetComponent<RectTransform>().localPosition;
  1266.  
  1267.                 if (totalPlayers == 2)
  1268.                 {
  1269.                     //Set Damage HUD size
  1270.                     HUDDamageFullScreen.GetComponent<RectTransform>().localScale =
  1271.                         new Vector3(damageScale.x * 0.5f, damageScale.y, damageScale.z);
  1272.  
  1273.                     if (charController.playerNmb == 1)
  1274.                     {
  1275.                         // HUDHealtRect.localPosition = new Vector3(XPos , YPos, 0);
  1276.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos, YWeapPos, 0);
  1277.                         //HUDQuickReloadPanel.localPosition = new Vector3(XQRPos, YQRPos, 0);
  1278.  
  1279.                         //Damage Position
  1280.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos - new Vector3((splitOff.x * 0.5f), 0, 0);
  1281.                     }
  1282.                     else if (charController.playerNmb == 2)
  1283.                     {
  1284.                         charController.CamScript.GetComponentInChildren<AudioListener>().enabled = false;
  1285.                         // HUDHealtRect.localPosition = new Vector3(XPos + splitOff.x, YPos, 0);
  1286.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos + splitOff.x, YWeapPos, 0);
  1287.                         // HUDQuickReloadPanel.localPosition = new Vector3(XQRPos + splitOff.x, YQRPos, 0);
  1288.                         //Damage Position
  1289.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos + new Vector3((splitOff.x * 0.5f), 0, 0);
  1290.                     }
  1291.                 }
  1292.                 else if (totalPlayers == 3)
  1293.                 {
  1294.                     //Set Damage HUD size
  1295.                     HUDDamageFullScreen.GetComponent<RectTransform>().localScale =
  1296.                         new Vector3(damageScale.x * 0.5f, damageScale.y * 0.5f, damageScale.z);
  1297.  
  1298.                     if (charController.playerNmb == 1)
  1299.                     {
  1300.                         //HUDHealtRect.localPosition = new Vector3(XPos + (splitOff.x * 0.5f), YPos + splitOff.y, 0);
  1301.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos + (splitOff.x * 0.5f), YWeapPos + splitOff.y, 0);
  1302.                         //HUDQuickReloadPanel.localPosition = new Vector3(XQRPos + (splitOff.x * 0.5f), YQRPos + splitOff.y, 0);
  1303.  
  1304.                         //Damage Position
  1305.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos + new Vector3(0, splitOff.y * 0.5f, 0);
  1306.                     }
  1307.                     else if (charController.playerNmb == 2)
  1308.                     {
  1309.                         charController.CamScript.GetComponentInChildren<AudioListener>().enabled = false;
  1310.                         //HUDHealtRect.localPosition = new Vector3(XPos, YPos, 0);
  1311.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos, YWeapPos, 0);
  1312.                         //HUDQuickReloadPanel.localPosition = new Vector3(XQRPos, YQRPos, 0);
  1313.                         //Damage Position
  1314.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos - new Vector3((splitOff.x * 0.5f), splitOff.y * 0.5f, 0);
  1315.                     }
  1316.                     else if (charController.playerNmb == 3)
  1317.                     {
  1318.                         charController.CamScript.GetComponentInChildren<AudioListener>().enabled = false;
  1319.                         //HUDHealtRect.localPosition = new Vector3(XPos + splitOff.x, YPos, 0);
  1320.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos + splitOff.x, YWeapPos, 0);
  1321.                         //HUDQuickReloadPanel.localPosition = new Vector3(XQRPos + splitOff.x, YQRPos, 0);
  1322.                         //Damage Position
  1323.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos + new Vector3((splitOff.x * 0.5f), -splitOff.y * 0.5f, 0);
  1324.                     }
  1325.                 }
  1326.                 else if (totalPlayers == 4)
  1327.                 {
  1328.                     //Set Damage HUD size
  1329.                     HUDDamageFullScreen.GetComponent<RectTransform>().localScale =
  1330.                         new Vector3(damageScale.x * 0.5f, damageScale.y * 0.5f, damageScale.z);
  1331.  
  1332.                     if (charController.playerNmb == 1)
  1333.                     {
  1334.                         //HUDHealtRect.localPosition = new Vector3(XPos, YPos + splitOff.y, 0);
  1335.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos, YWeapPos + splitOff.y, 0);
  1336.                         // HUDQuickReloadPanel.localPosition = new Vector3(XQRPos, YQRPos + splitOff.y, 0);
  1337.                         //Damage Position
  1338.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos - new Vector3((splitOff.x * 0.5f), splitOff.y * 0.5f, 0);
  1339.                     }
  1340.  
  1341.                     else if (charController.playerNmb == 2)
  1342.                     {
  1343.                         charController.CamScript.GetComponentInChildren<AudioListener>().enabled = false;
  1344.                         //HUDHealtRect.localPosition = new Vector3(XPos + splitOff.x, YPos + splitOff.y, 0);
  1345.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos + splitOff.x, YWeapPos + splitOff.y, 0);
  1346.                         // HUDQuickReloadPanel.localPosition = new Vector3(XQRPos + splitOff.x, YQRPos + splitOff.y, 0);
  1347.                         //Damage Position
  1348.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos + new Vector3((splitOff.x * 0.5f), splitOff.y * 0.5f, 0);
  1349.                     }
  1350.  
  1351.                     else if (charController.playerNmb == 3)
  1352.                     {
  1353.                         charController.CamScript.GetComponentInChildren<AudioListener>().enabled = false;
  1354.                         //HUDHealtRect.localPosition = new Vector3(XPos, YPos, 0);
  1355.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos, YWeapPos, 0);
  1356.                         //HUDQuickReloadPanel.localPosition = new Vector3(XQRPos, YQRPos, 0);
  1357.                         //Damage Position
  1358.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos - new Vector3((splitOff.x * 0.5f), splitOff.y * 0.5f, 0);
  1359.                     }
  1360.  
  1361.                     else if (charController.playerNmb == 4)
  1362.                     {
  1363.                         charController.CamScript.GetComponentInChildren<AudioListener>().enabled = false;
  1364.                         //HUDHealtRect.localPosition = new Vector3(XPos + splitOff.x, YPos, 0);
  1365.                         HUDWeaponRect.localPosition = new Vector3(XWeapPos + splitOff.x, YWeapPos, 0);
  1366.                         //HUDQuickReloadPanel.localPosition = new Vector3(XQRPos + splitOff.x, YQRPos, 0);
  1367.                         //Damage Position
  1368.                         HUDDamageFullScreen.GetComponent<RectTransform>().localPosition = damagePos + new Vector3((splitOff.x * 0.5f), -splitOff.y * 0.5f, 0);
  1369.                     }
  1370.  
  1371.                 }
  1372.             }
  1373.             else
  1374.             {
  1375.                 //HUDHealthBar.transform.parent.GetComponent<RectTransform>().localPosition = new Vector3(XPos + (multiplayerHUDOffset * (charController.playerNmb - 1)), YPos, 0);
  1376.  
  1377.                 YPos = HUDWeaponBulletsBar.transform.parent.GetComponent<RectTransform>().localPosition.y;
  1378.                 XPos = HUDWeaponBulletsBar.transform.parent.GetComponent<RectTransform>().localPosition.x;
  1379.  
  1380.                 HUDWeaponBulletsBar.transform.parent.GetComponent<RectTransform>().localPosition = new Vector3(XPos + (multiplayerHUDOffset * (charController.playerNmb - 1)), YPos, 0);
  1381.  
  1382.                 //YPos = HUDQuickReloadPanel.transform.GetComponent<RectTransform>().localPosition.y;
  1383.                 //XPos = HUDQuickReloadPanel.transform.GetComponent<RectTransform>().localPosition.x;
  1384.  
  1385.                 //HUDQuickReloadPanel.transform.GetComponent<RectTransform>().localPosition = new Vector3(XPos + (multiplayerHUDOffset * (charController.playerNmb - 1)), YPos, 0);
  1386.             }
  1387.  
  1388.             //SET HUD COLOR ACCORDING TO PLAYER COLOR
  1389.             if (HUDColorBar)
  1390.                 HUDColorBar.GetComponent<UnityEngine.UI.Image>().color = charController.playerSettings.playerColor[charController.playerNmb - 1];
  1391.         }
  1392.     }
  1393.  
  1394.     public void SetSplitScreen(bool active, int tPlayers)
  1395.     {
  1396.         splitScreen = active;
  1397.         totalPlayers = tPlayers;
  1398.     }
  1399.  
  1400.     void ChangeToWeapon(int weaponInt)
  1401.     {
  1402.         lastWeaponChange = Time.time;
  1403.  
  1404.         int nextWeapon = weaponInt;
  1405.  
  1406.         //Debug.Log("Changing Weapon " + Weapon[ActiveWeapon]);
  1407.  
  1408.         //New Multiple weapon system
  1409.         if (Weapon[nextWeapon] != null)
  1410.         {
  1411.             //Debug.Log("Testing");
  1412.             foreach (GameObject i in Weapon)
  1413.             {
  1414.                 if (i != null)
  1415.                 {
  1416.                     i.GetComponent<PrWeapon>().LaserSight.enabled = false;
  1417.                     i.SetActive(false);
  1418.                 }
  1419.                 //Debug.Log("Deactivating Weapon " + Weapon[ActiveWeapon]);
  1420.             }
  1421.             //Debug.Log(ActiveWeapon + " " + nextWeapon);
  1422.  
  1423.             ActiveWeapon = nextWeapon;
  1424.             Weapon[ActiveWeapon].SetActive(true);
  1425.  
  1426.             InitializeWeapons();
  1427.             Weapon[ActiveWeapon].GetComponent<PrWeapon>().UpdateWeaponGUI(HUDWeaponPicture);
  1428.  
  1429.  
  1430.         }
  1431.     }
  1432.  
  1433.     void ChangeWeapon()
  1434.     {
  1435.         lastWeaponChange = Time.time;
  1436.  
  1437.         int nextWeapon = ActiveWeapon + 1;
  1438.         if (nextWeapon >= playerWeaponLimit)
  1439.             nextWeapon = 0;
  1440.  
  1441.         //New Multiple weapon system
  1442.         if (Weapon[nextWeapon] != null)
  1443.         {
  1444.             //Debug.Log(ActiveWeapon + " " + nextWeapon);
  1445.             foreach (GameObject i in Weapon)
  1446.             {
  1447.                 if (i != null)
  1448.                 {
  1449.                     i.GetComponent<PrWeapon>().LaserSight.enabled = false;
  1450.                     i.SetActive(false);
  1451.                 }
  1452.                 //Debug.Log("Deactivating Weapon " + Weapon[ActiveWeapon]);
  1453.             }
  1454.  
  1455.             ActiveWeapon = nextWeapon;
  1456.  
  1457.             Weapon[ActiveWeapon].SetActive(true);
  1458.  
  1459.             InitializeWeapons();
  1460.             Weapon[ActiveWeapon].GetComponent<PrWeapon>().UpdateWeaponGUI(HUDWeaponPicture);
  1461.  
  1462.  
  1463.         }
  1464.         else
  1465.         {
  1466.             for (int i = nextWeapon; i < playerWeaponLimit; i++)
  1467.             {
  1468.                 if (Weapon[i] != null)
  1469.                 {
  1470.                     ActiveWeapon = i - 1;
  1471.                     ChangeWeapon();
  1472.                     break;
  1473.                 }
  1474.             }
  1475.  
  1476.             ActiveWeapon = playerWeaponLimit - 1;
  1477.             //Debug.Log(playerWeaponLimit);
  1478.             ChangeWeapon();
  1479.  
  1480.         }
  1481.     }
  1482.  
  1483.     public void StopUse()
  1484.     {
  1485.         charController.m_CanMove = true;
  1486.         charAnimator.SetTrigger("StopUse");
  1487.         UsingObject = false;
  1488.  
  1489.         EnableArmIK(true);
  1490.  
  1491.     }
  1492.     public void EndPickup()
  1493.     {
  1494.         charController.m_CanMove = true;
  1495.         UsingObject = false;
  1496.  
  1497.         EnableArmIK(true);
  1498.     }
  1499.  
  1500.     public void PlayerTeam(int enTeam)
  1501.     {
  1502.         enemyTeam = enTeam;
  1503.         if (enemyTeam == team)
  1504.         {
  1505.             enemyTeam += 1;
  1506.             enemyTeam *= -1;
  1507.         }
  1508.         //Debug.Log("EnemyTeam " + enemyTeam);
  1509.     }
  1510.  
  1511.     public void BulletPos(Vector3 BulletPosition)
  1512.     {
  1513.         LastHitPos = BulletPosition;
  1514.         LastHitPos.y = 0;
  1515.     }
  1516.  
  1517.     public void SetNewSpeed(float speedFactor)
  1518.     {
  1519.         charController.m_MoveSpeedSpecialModifier = speedFactor;
  1520.     }
  1521.  
  1522.     public void SetHealth(int HealthInt)
  1523.     {
  1524.         ActualHealth = HealthInt;
  1525.         //Debug.Log(ActualHealth);
  1526.  
  1527.         if (ActualHealth > 1)
  1528.         {
  1529.             HUDHealthBar.GetComponent<RectTransform>().localScale = new Vector3(Mathf.Clamp((1.0f / Health) * ActualHealth, 0.1f, 1.0f), 1.0f, 1.0f);
  1530.         }
  1531.         else
  1532.         {
  1533.             HUDHealthBar.GetComponent<RectTransform>().localScale = new Vector3(0.0f, 1.0f, 1.0f);
  1534.         }
  1535.  
  1536.     }
  1537.  
  1538.     void ApplyTemperature()
  1539.     {
  1540.         if (temperature > 1.0f || temperature < 1.0f)
  1541.         {
  1542.             if (tempTimer < 1.0f)
  1543.                 tempTimer += Time.deltaTime;
  1544.             else
  1545.             {
  1546.                 tempTimer = 0.0f;
  1547.                 applyTemperatureDamage();
  1548.             }
  1549.         }
  1550.  
  1551.         foreach (Renderer Mesh in MeshRenderers)
  1552.         {
  1553.             if (Mesh.material.HasProperty("_FrozenMix"))
  1554.                 Mesh.material.SetFloat("_FrozenMix", Mathf.Clamp(1.0f - temperature, 0.0f, 1.0f));
  1555.             if (Mesh.material.HasProperty("_BurningMix"))
  1556.                 Mesh.material.SetFloat("_BurningMix", Mathf.Clamp(temperature - 1.0f, 0.0f, 1.0f));
  1557.         }
  1558.  
  1559.         foreach (SkinnedMeshRenderer SkinnedMesh in MeshRenderers)
  1560.         {
  1561.             if (SkinnedMesh.material.HasProperty("_FrozenMix"))
  1562.                 SkinnedMesh.material.SetFloat("_FrozenMix", Mathf.Clamp(1.0f - temperature, 0.0f, 1.0f));
  1563.             if (SkinnedMesh.material.HasProperty("_BurningMix"))
  1564.                 SkinnedMesh.material.SetFloat("_BurningMix", Mathf.Clamp(temperature - 1.0f, 0.0f, 1.0f));
  1565.         }
  1566.  
  1567.         if (actualFrozenVFX)
  1568.         {
  1569.             if (temperature < 1.0f)
  1570.                 actualFrozenVFX.SetActive(true);
  1571.             else
  1572.             {
  1573.                 actualFrozenVFX.SetActive(false);
  1574.             }
  1575.         }
  1576.         if (actualBurningVFX)
  1577.         {
  1578.             if (temperature > 1.0f)
  1579.                 actualBurningVFX.SetActive(true);
  1580.             else
  1581.             {
  1582.                 actualBurningVFX.SetActive(false);
  1583.             }
  1584.         }
  1585.     }
  1586.  
  1587.     void applyTemperatureDamage()
  1588.     {
  1589.         if (temperature < 1.0f)
  1590.         {
  1591.             ApplyDamagePassive(temperatureDamage);
  1592.         }
  1593.         else if (temperature > 1.0f)
  1594.         {
  1595.             ApplyDamagePassive(temperatureDamage);
  1596.         }
  1597.     }
  1598.  
  1599.     void ApplyDamagePassive(int damage)
  1600.     {
  1601.         if (!isDead)
  1602.         {
  1603.             SetHealth(ActualHealth - damage);
  1604.  
  1605.             if (ActualHealth <= 0)
  1606.             {
  1607.                 if (actualSplatVFX)
  1608.                     actualSplatVFX.transform.parent = null;
  1609.  
  1610.                 Die(true);
  1611.             }
  1612.         }
  1613.     }
  1614.  
  1615.     void ApplyTempMod(float temperatureMod)
  1616.     {
  1617.         temperature += temperatureMod;
  1618.         temperature = Mathf.Clamp(temperature, 0.0f, temperatureThreshold);
  1619.     }
  1620.  
  1621.     public void ApplyDamage(int Damage)
  1622.     {
  1623.         if (ActualHealth > 0 && !charController.Rolling)
  1624.         {
  1625.             //Here you can put some Damage Behaviour if you want
  1626.             SetHealth(ActualHealth - Damage);
  1627.  
  1628.             Damaged = true;
  1629.             DamagedTimer = 1.0f;
  1630.  
  1631.             if (actualSplatVFX)
  1632.             {
  1633.                 actualSplatVFX.transform.LookAt(LastHitPos);
  1634.                 actualSplatVFX.Splat();
  1635.             }
  1636.  
  1637.             if (ActualHealth <= 0)
  1638.             {
  1639.                 if (actualSplatVFX)
  1640.                     actualSplatVFX.transform.parent = null;
  1641.                 if (Damage >= damageThreshold)
  1642.                     explosiveDeath = true;
  1643.                 Die(false);
  1644.             }
  1645.  
  1646.         }
  1647.  
  1648.     }
  1649.     void LowHPWarning()
  1650.     {
  1651.         Debug.Log("Warning, you have " + ActualHealth + " hp remaining");
  1652.     }
  1653.  
  1654.     public void ApplyDamageNoVFX(int Damage)
  1655.     {
  1656.         if (ActualHealth > 0)
  1657.         {
  1658.             //Here you can put some Damage Behaviour if you want
  1659.             SetHealth(ActualHealth - Damage);
  1660.  
  1661.             Damaged = true;
  1662.             DamagedTimer = 1.0f;
  1663.  
  1664.             if (ActualHealth <= 0)
  1665.             {
  1666.                 if (actualSplatVFX)
  1667.                     actualSplatVFX.transform.parent = null;
  1668.                 if (Damage >= damageThreshold)
  1669.                     explosiveDeath = true;
  1670.                 Die(true);
  1671.             }
  1672.  
  1673.         }
  1674.  
  1675.     }
  1676.  
  1677.  
  1678.     public void Die(bool temperatureDeath)
  1679.     {
  1680.         //Send last position
  1681.         //SendMessageUpwards("UpdateLastPlayerPos", charController.playerNmb, SendMessageOptions.DontRequireReceiver);
  1682.  
  1683.         DeactivateCompass();
  1684.         EnableArmIK(false);
  1685.         isDead = true;
  1686.         charAnimator.SetBool("Dead", true);
  1687.  
  1688.         charController.m_isDead = true;
  1689.         Weapon[ActiveWeapon].GetComponent<PrWeapon>().TurnOffLaser();
  1690.  
  1691.         //Set invisible to Bullets
  1692.         GetComponent<Rigidbody>().isKinematic = true;
  1693.         GetComponent<Collider>().enabled = false;
  1694.  
  1695.         this.tag = "Untagged";
  1696.         charController.playerSelection.enabled = false;
  1697.  
  1698.         DestroyHUD();
  1699.  
  1700.         if (useRagdollDeath)
  1701.         {
  1702.             Vector3 ragdollDirection = transform.position - LastHitPos;
  1703.             ragdollDirection = ragdollDirection.normalized;
  1704.             if (!temperatureDeath)
  1705.                 GetComponent<PrCharacterRagdoll>().SetForceToRagdoll(LastHitPos + new Vector3(0, 1.5f, 0), ragdollDirection * (ragdollForceFactor * Random.Range(0.8f, 1.2f)), BurnAndFrozenVFXParent);
  1706.         }
  1707.  
  1708.         //Send Message to Game script to notify Dead
  1709.         SendMessageUpwards("PlayerDied", charController.playerNmb, SendMessageOptions.DontRequireReceiver);
  1710.         SendMessageUpwards("NewFrag", enemyTeam, SendMessageOptions.DontRequireReceiver);
  1711.         GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
  1712.         foreach (GameObject i in enemies)
  1713.         {
  1714.             i.SendMessage("FindPlayers", SendMessageOptions.DontRequireReceiver);
  1715.         }
  1716.  
  1717.         if (explosiveDeath && actualExplosiveDeathVFX)
  1718.         {
  1719.             actualExplosiveDeathVFX.transform.position = transform.position;
  1720.             actualExplosiveDeathVFX.transform.rotation = transform.rotation;
  1721.             actualExplosiveDeathVFX.SetActive(true);
  1722.             actualExplosiveDeathVFX.SendMessage("SetExplosiveForce", LastHitPos + new Vector3(0, 1.5f, 0), SendMessageOptions.DontRequireReceiver);
  1723.  
  1724.             Destroy(this.gameObject);
  1725.         }
  1726.  
  1727.         else
  1728.         {
  1729.             if (deathVFX && actualDeathVFX)
  1730.             {
  1731.                 if (temperatureDeath)
  1732.                 {
  1733.                     //Freezing of Burning Death VFX...
  1734.                 }
  1735.                 else
  1736.                 {
  1737.                     actualDeathVFX.transform.position = new Vector3(transform.position.x, 0.0f, transform.position.z);
  1738.                     actualDeathVFX.transform.LookAt(LastHitPos);
  1739.                     actualDeathVFX.transform.position = new Vector3(transform.position.x, 0.05f, transform.position.z);
  1740.  
  1741.                     actualDeathVFX.SetActive(true);
  1742.  
  1743.                     ParticleSystem[] particles = actualDeathVFX.GetComponentsInChildren<ParticleSystem>();
  1744.  
  1745.                     if (particles.Length > 0)
  1746.                     {
  1747.                         foreach (ParticleSystem p in particles)
  1748.                         {
  1749.                             p.Play();
  1750.                         }
  1751.                     }
  1752.                 }
  1753.             }
  1754.  
  1755.         }
  1756.  
  1757.         AIUpdatePlayerCount();
  1758.  
  1759.         Destroy(charController);
  1760.         Destroy(GetComponent<Collider>());
  1761.         //Destroy(this);
  1762.  
  1763.         GameManager.Instance.EndGame();
  1764.     }
  1765.  
  1766.     public void DestroyHUD()
  1767.     {
  1768.         if (Weapon[ActiveWeapon] != null)
  1769.         {
  1770.             //Destroy GUI
  1771.             Weapon[ActiveWeapon].GetComponent<PrWeapon>().updateHUD = false;
  1772.         }
  1773.  
  1774.         if (HUDDamageFullScreen != null)
  1775.         {
  1776.             if (HUDDamageFullScreen.transform.parent.gameObject != null)
  1777.                 Destroy(HUDDamageFullScreen.transform.parent.gameObject);
  1778.         }
  1779.         if (HUDWeaponPicture != null)
  1780.         {
  1781.             if (HUDWeaponPicture.transform.parent.parent.gameObject != null)
  1782.                 Destroy(HUDWeaponPicture.transform.parent.parent.gameObject);
  1783.         }
  1784.     }
  1785.  
  1786.     public void EndReload()
  1787.     {
  1788.         CanShoot = true;
  1789.         charAnimator.SetBool("Reloading", false);
  1790.         if (useQuickReload && quickReloadPanel && quickReloadMarker && quickReloadZone)
  1791.         {
  1792.             QuickReloadActive(false);
  1793.         }
  1794.         EnableArmIK(true);
  1795.     }
  1796.  
  1797.     void OnTriggerStay(Collider other)
  1798.     {
  1799.  
  1800.         if (other.CompareTag("Usable") && UsableObject == null)
  1801.         {
  1802.             if (other.GetComponent<PrUsableDevice>().IsEnabled)
  1803.                 UsableObject = other.gameObject;
  1804.         }
  1805.         else if (other.CompareTag("Pickup") && PickupObj == null)
  1806.         {
  1807.             PickupObj = other.gameObject;
  1808.  
  1809.         }
  1810.  
  1811.  
  1812.     }
  1813.  
  1814.     void OnTriggerExit(Collider other)
  1815.     {
  1816.  
  1817.         if (other.CompareTag("Usable") && UsableObject != null)
  1818.         {
  1819.             UsableObject = null;
  1820.             HUDUseHelper.SetActive(false);
  1821.         }
  1822.         if (other.CompareTag("Pickup") && PickupObj != null)
  1823.         {
  1824.  
  1825.             PickupObj = null;
  1826.  
  1827.         }
  1828.  
  1829.     }
  1830.  
  1831. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement