void OnEnable() { weaponMods = GetComponent <WeaponMods>(); if (weapon == null) { weapon = WeaponType.GetWeapon(weaponMods, "SimpleGun", true); } timeSinceLastFire = weapon.minFireInterval; }
private void Start() { mods = GetComponent <WeaponMods>(); if (player == null) { player = GameObject.FindGameObjectWithTag("Player"); } weapon = new SimpleGun(mods, false); weapon.minFireInterval = 0.5f; }
void OnEnable() { weaponMods = GetComponent <WeaponMods>(); if (weapon == null) { weapon = (ChargeWeaponBase)WeaponType.GetWeapon(weaponMods, "ChargeGun", true); } currentChargeLevel = 0; timeSinceLastFire = weapon.minFireInterval; }
public ChargeGun(WeaponMods weaponMods, bool isPlayerControlled) { minFireInterval = 0; mods = weaponMods; numLevels = 3; bulletLevel1 = Resources.Load <GameObject>("Prefabs/PlayerBullet"); bulletLevel2 = Resources.Load <GameObject>("Prefabs/PlayerBulletLevel2"); bulletLevel3 = Resources.Load <GameObject>("Prefabs/PlayerBulletLevel3"); allBullets = new GameObject[] { bulletLevel1, bulletLevel2, bulletLevel3 }; }
void Start() { mods = GetComponent <WeaponMods>(); if (player == null) { player = GameObject.FindGameObjectWithTag("Player"); } weapon = new OctoShot(mods, false); body = GetComponent <Rigidbody2D>(); moving = true; }
public MiniGun(WeaponMods weaponMods, bool isPlayerControlled) { minFireInterval = baseFireInterval; mods = weaponMods; if (isPlayerControlled) { bulletPrefab = Resources.Load <GameObject>("Prefabs/PlayerBullet"); } else { bulletPrefab = Resources.Load <GameObject>("Prefabs/EnemyBullet"); } }
public OctoShot(WeaponMods weaponMods, bool isPlayerControlled) { minFireInterval = 0.25f; mods = weaponMods; if (isPlayerControlled) { bulletPrefab = Resources.Load <GameObject>("Prefabs/PlayerBullet"); } else { //TODO put this prefab in bulletPrefab = Resources.Load <GameObject>("Prefabs/EnemyBullet"); } }
public GrenadeLauncher(WeaponMods weaponMods, bool isPlayerControlled) { minFireInterval = 0.75f; baseWeaponDamage = 2; mods = weaponMods; isPlayerOwned = isPlayerControlled; if (isPlayerOwned) { grenadePrefab = Resources.Load <GameObject>("Prefabs/Grenade"); } else { //TODO enemy grenades? } }
public static void ExecuteItem(Item item) { GameObject player = GameObject.Find("Player"); if (item.type == ItemEffectType.HEAL) { PlayerHealth playerHealth = player.GetComponent <PlayerHealth>(); playerHealth.GainHealth(item.itemEffectQuantity); } if (item.type == ItemEffectType.BUFFDAMAGE) { WeaponMods mods = player.GetComponent <WeaponMods>(); mods.damageBuffs += 1; } if (item.type == ItemEffectType.WEAPON) { PlayerChargeWeaponControl chargeControl = player.GetComponent <PlayerChargeWeaponControl>(); PlayerWeaponControl weaponControl = player.GetComponent <PlayerWeaponControl>(); // add new weapon Type weaponType = WeaponParser.GetWeaponScriptFromName(item.name); if (weaponType.IsSubclassOf(typeof(ChargeWeaponBase))) // charge based weapon { chargeControl.enabled = true; weaponControl.enabled = false; chargeControl.SetWeapon(item.name); } else // normal weapon { chargeControl.enabled = false; weaponControl.enabled = true; weaponControl.SetWeapon(item.name); } } if (item.type == ItemEffectType.PET) { // TODO remove current pet ever? // spawn new pet GameObject petPrefab = Resources.Load <GameObject>("Prefabs/" + item.name); GameObject.Instantiate(petPrefab, player.transform.position, player.transform.rotation); } // TODO other item types }
public static WeaponBase GetWeapon(WeaponMods mods, string weaponName, bool isPlayerControlled) { switch (weaponName) { case "SimpleGun": return(CreateSimpleGun(mods, isPlayerControlled)); case "ChargeGun": return(CreateChargeGun(mods, isPlayerControlled)); case "GrenadeLauncher": return(CreateGrenadeLauncher(mods, isPlayerControlled)); case "MiniGun": return(CreateMiniGun(mods, isPlayerControlled)); // default to simple gun default: return(CreateSimpleGun(mods, isPlayerControlled)); } }
private static WeaponBase CreateMiniGun(WeaponMods mods, bool isPlayerControlled) { return(new MiniGun(mods, isPlayerControlled)); }
private static WeaponBase CreateGrenadeLauncher(WeaponMods mods, bool isPlayerControlled) { return(new GrenadeLauncher(mods, isPlayerControlled)); }