public Weapon(Kits restriction, string name, WeaponSlots slot, DamageTypes damage) { this.KitRestriction = restriction; this.Name = name; this.Slot = slot; this.Damage = damage; }
void Awake() { weaponSlots = GetComponent <WeaponSlots>(); if (weaponSlots == null) { Debug.Log("No weapon slots found, object can only carry"); } }
public void UnEquipWeapon(WeaponSlots weaponSlot) { if (EquipedWeapons.ContainsKey(weaponSlot)) { EquipedWeapons[weaponSlot].IsEquiped = false; Items.Add(EquipedWeapons[weaponSlot]); EquipedWeapons.Remove(weaponSlot); } }
void Start() { Weapons = WeaponSlots.FISTS; a1 = false; anim.SetBool("Rifle", false); a2 = false; anim = gameObject.GetComponent <Animator>(); cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); }
void Awake() { if (weaponSlots == null) { weaponSlots = GetComponentInChildren <WeaponSlots>(); } if (weaponSlots == null) { Debug.LogError("Primary Weapon Slot not found in object hierarchy"); } }
/// <summary> /// Countdown of the player Life /// </summary> public void LifeTimer() { if (PlayerCurrentHP > 0) { LifeText.text = PlayerCurrentHP.ToString("F0"); PlayerCurrentHP -= Time.deltaTime; //screenNoise.SetActive(false); timeLineScreenNoise.SetActive(false); timeLineScreenNoise_.SetActive(false); //LifeBar - joe LifeBar.maxValue = PlayerStartingHP; LifeBar.value = PlayerCurrentHP; } else { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; //screenNoise.SetActive(true); timeLineScreenNoise.SetActive(true); StartCoroutine(NoiseScreen()); Time.timeScale = 0; //DeathPanel.SetActive(true); //HUD.SetActive(false); //PausePanel.SetActive(false); Destroy(HUD); Destroy(PausePanel); Destroy(comboCounter); Destroy(crosshair); WeaponSlots.SetActive(false); WarningDeactiveted.SetActive(false); EPickUP.SetActive(false); HitContainer.SetActive(false); } //Warning Image_Animation - Joe if (PlayerCurrentHP <= 6) { Warning.enabled = true; } else { Warning.enabled = false; } }
void Start() { // get weapon slot gameobject pointers WeaponSlots ws = GameManager.Instance.HUDCanvas.GetComponentInChildren <WeaponSlots>(); weaponSlots[0] = ws.slots[0].GetComponent <WeaponSlot>(); weaponSlots[1] = ws.slots[1].GetComponent <WeaponSlot>(); weaponSlots[2] = ws.slots[2].GetComponent <WeaponSlot>(); // ammo bar pointer ammoBar = GameManager.Instance.HUDCanvas.transform.Find("Ammo Bar").gameObject; UpdateAmmoBar(); // get player materials for color coding emissionsShader = transform.Find("Emissions").GetComponent <ShaderPropertyControl>(); playerShader = GetComponent <ShaderPropertyControl>(); }
/// <summary> /// Close all weapons /// </summary> public void Close() { //foreach (MySmallShipGunBase gun in GetMountedWeaponstWithHarvesterAndDrill()) //{ // gun.Close(); //} foreach (MyWeaponSlot weaponSlot in WeaponSlots) { if (weaponSlot != null) { weaponSlot.OnWeaponDismouting -= m_weaponDismounting; weaponSlot.OnWeaponMounting -= m_weaponMounting; weaponSlot.Close(); } } WeaponSlots.Clear(); WeaponSlots = null; DrillSlot.OnWeaponDismouting -= m_weaponDismounting; DrillSlot.OnWeaponMounting -= m_weaponMounting; DrillSlot.Close(); DrillSlot = null; HarvestingDeviceSlot.OnWeaponDismouting -= m_weaponDismounting; HarvestingDeviceSlot.OnWeaponMounting -= m_weaponMounting; HarvestingDeviceSlot.Close(); HarvestingDeviceSlot = null; m_allMountedWeapons.Clear(); m_allMountedWeapons = null; AmmoAssignments.Close(); AmmoAssignments = null; AmmoInventoryItems.Close(); AmmoAssignments = null; Ship.Inventory.OnInventoryContentChange -= OnInventoryContentChange; Ship = null; m_helperInventoryItems.Clear(); m_helperInventoryItems = null; m_isClosed = true; }
void GunSwitching() { if (mouseWheel > 0) { if ((int)Weapons != 6) { Weapons += 1; } activateCurrentGuns(); } else if (mouseWheel < 0) { if (Weapons != 0) { Weapons -= 1; } activateCurrentGuns(); } }
/// <summary> /// Creates gun's positions from ship's model. If find preferred position, then mark it as preffered. /// </summary> /// <param name="modelEnum">Ship's model</param> /// <param name="maxSlots">Weapons maximum on ship</param> /// <param name="maxWeapons"> </param> private void AddGunsPositionsFromShipModel(MyModelsEnum modelEnum, int maxSlots) { List <MyModelSubObject> shipsSubObjects = MyModelSubObjects.GetModelSubObjects(modelEnum); if (shipsSubObjects != null) { for (int i = 0; i < maxSlots; i++) { string gunPrefix = GUN_PREFIX_NAME + (i + 1).ToString("##00"); // try find guns subobject by prefix (GUN_XX) MyModelSubObject subObjectGun = shipsSubObjects.Find(x => x.Name.StartsWith(gunPrefix)); // if not found, then stop adding gun's positions, because there are no gun's subobjects if (subObjectGun == null) { return; } // if not exists slot at this index, then create new one if (WeaponSlots.Count <= i) { MyWeaponSlot newWeaponSlot = new MyWeaponSlot(); WeaponSlots.Add(newWeaponSlot); newWeaponSlot.OnWeaponMounting += m_weaponMounting; newWeaponSlot.OnWeaponDismouting += m_weaponDismounting; } WeaponSlots[i].WeaponSubObject = subObjectGun; // if this gun's position is preffered by any gun if (subObjectGun.Name.Length != gunPrefix.Length) { string prefferedGunName = subObjectGun.Name.Substring(gunPrefix.Length + 1, subObjectGun.Name.Length - gunPrefix.Length - 1); MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weaponType; if (m_weaponsModelNames.TryGetValue(prefferedGunName, out weaponType)) { WeaponSlots[i].WeaponSubObject.AuxiliaryParam0 = (int)weaponType; } } } } }
public void UpdateInventory() { if (!Weapon.HasValue || !WeaponSlots.TryGetValue(Weapon.Value, out int selectedSlot)) { selectedSlot = -1; } var temp = new ObservableCollection <Weapon?> { Slot0Weapon, Slot1Weapon, Slot2Weapon, Slot3Weapon, Slot4Weapon, Slot5Weapon, Slot6Weapon, Slot7Weapon, Slot8Weapon, Slot9Weapon }; Inventory = new ObservableCollection <Weapon?>(temp.Except(temp.Where(x => x == null))); if (selectedSlot != -1) { Weapon?w; while ((w = temp[selectedSlot]) == null && selectedSlot > -1) { selectedSlot--; } if (!m_isWritingWeaponSlot) { m_suppressWritingSelectedWeapon = true; Weapon = w; m_suppressWritingSelectedWeapon = false; } else { Weapon = w; } } }
protected virtual void Init(float health,float armor, string bullet_name, string explosion_name, string turName = null) { Turret_Head = this.gameObject; _GM = Camera.main.GetComponent<GameScript>(); #region Resource Load // Resource Load bullet = (GameObject)Resources.Load(bullet_name); explosion = (GameObject)Resources.Load(explosion_name); Turret_Barrel = Turret_Head.transform.GetChild(0).gameObject; death = (AudioClip)Resources.Load(GlobalVars._deathSound); take_Damage = (AudioClip)Resources.Load(GlobalVars._hitSound); armor_Damage = (AudioClip)Resources.Load(GlobalVars._armorSound); bullet_Fired = (AudioClip)Resources.Load(bullet_name + "_Fired"); TurretMesh = (Mesh)Resources.Load(turName,typeof(Mesh)); // #endregion Turret_Head.GetComponent<MeshFilter>().mesh = TurretMesh; if (turretNumber != -999) { Turret_Head.renderer.material = (Material)Resources.Load(GlobalVars._playerColor[turretNumber]); secondaryBullet = (GameObject)Resources.Load(GlobalVars.GetSecondaryBullet(turretNumber)); ChangeTurret(GlobalVars.GetPlayerTurrets(turretNumber)); defaultSlot = GameObject.Find("Default_" + (turretNumber + 1) .ToString()).GetComponent<WeaponSlots>(); secondarySlot = GameObject.Find("Secondary_" + (turretNumber + 1).ToString()).GetComponent<WeaponSlots>(); defaultSlot.Reset(); secondarySlot.Reset(); } else { int random = Random.Range(0,4); switch (random) { case 0: secondaryBullet = (GameObject)Resources.Load("DefaultBullet"); break; case 1: secondaryBullet = (GameObject)Resources.Load("StrongBullet"); break; case 2: secondaryBullet = (GameObject)Resources.Load("StrongerBullet"); break; case 3: secondaryBullet = (GameObject)Resources.Load("SniperBullet"); break; } } turHealth = health; turMaxHealth = health; turArmor = armor; turMaxArmor = armor + 50; animSpeed = Random.Range(1,3); armorBar.renderer.material.color = Color.blue; }
void Awake() { weaponSlots = GetComponent<WeaponSlots>(); if(weaponSlots == null){Debug.Log ("No weapon slots found, object can only carry");} }
void Awake() { if(weaponSlots == null) weaponSlots = GetComponentInChildren<WeaponSlots>(); if(weaponSlots == null){Debug.LogError("Primary Weapon Slot not found in object hierarchy");} }
public bool EquipWeapon(Weapon weapon, WeaponSlots slot) { weapon.IsEquiped = false; weapon.WeaponSlot = WeaponSlots.None; if (slot == WeaponSlots.None) { return(false); } else { switch (weapon.WeaponRestriction) { case WeaponSlotRestriction.None: break; case WeaponSlotRestriction.OffHandOnly: if (slot != WeaponSlots.OffHand) { return(false); } break; case WeaponSlotRestriction.OneHandedOnly: if (slot.HasFlag(WeaponSlots.PrimaryHand) && slot.HasFlag(WeaponSlots.OffHand)) { return(false); } break; case WeaponSlotRestriction.TwoHandedOnly: if (!(slot.HasFlag(WeaponSlots.PrimaryHand) && slot.HasFlag(WeaponSlots.PrimaryHand))) { return(false); } break; default: break; } if (slot.HasFlag(WeaponSlots.PrimaryHand)) { UnEquipWeapon(WeaponSlots.PrimaryHand); } if (slot.HasFlag(WeaponSlots.OffHand)) { UnEquipWeapon(WeaponSlots.OffHand); } if (EquipedWeapons.ContainsKey(WeaponSlots.PrimaryHand | WeaponSlots.OffHand)) { UnEquipWeapon(WeaponSlots.PrimaryHand | WeaponSlots.OffHand); } EquipedWeapons.Add(slot, weapon); weapon.IsEquiped = true; weapon.WeaponSlot = slot; return(true); } }
private void Start() { player = GameObject.Find("Player"); weaponSlots = player.GetComponent <WeaponSlots>(); //inventorySlots = GameObject.FindGameObjectWithTag("Player").GetComponent<InventorySlots>(); }