/// <summary> /// Player shoot /// </summary> public override void Shoot() { if (!m_IsGunReloaded) { return; } m_IsGunReloaded = false; Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); m_Gun.transform.rotation = Quaternion.LookRotation(Vector3.forward, mousePos - transform.position); GameObject bullet = BulletController.Instance.GetBullet(BulletOwner.player); bullet.transform.SetParent(m_Gun); bullet.transform.localPosition = Vector3.zero; bullet.transform.localRotation = Quaternion.identity; bullet.layer = 10; bullet.tag = "PlayerBullet"; int currentGunLvl = GameManager.Instance.GetCurrentAmorData().GunLevel; int bulletDamage = DataBank.GetGunPowerDamageByLevel(currentGunLvl); bullet.GetComponent <Bullet>().Program(10, bulletDamage, BulletOwner.player); bullet.SetActive(true); StartCoroutine(ReloadGun()); }
/// <summary> /// Initialized the shop data /// </summary> void Init() { int coinsInHand = GameManager.Instance.GetCoinsInHand(); m_ShooterAmor = GameManager.Instance.GetCurrentAmorData(); m_Coins.text = coinsInHand.ToString(); int nextGunPowerCost = GetNextGunCost(m_ShooterAmor.GunLevel); int nextMissileMagCost = GetNextMissileMagazineCost(m_ShooterAmor.MissileMagazineLvl); ////// // Set Gun Power Related Stuff ////// m_GunPowerSlider.maxValue = DataBank.GetGunPowerData().Count(); m_GunPowerSlider.value = m_ShooterAmor.GunLevel; m_GunUpgradeBtn.interactable = SetButtonIntractable(nextGunPowerCost, coinsInHand); m_GunPowerInfo.text = GetGunPowerInfoText(m_ShooterAmor.GunLevel); ////// // Set Missile Magazine Related Stuff ////// m_MagazineSlider.maxValue = DataBank.GetMissileMagazineData().Count(); m_MagazineSlider.value = m_ShooterAmor.MissileMagazineLvl; m_MagazineUpgrdBtn.interactable = SetButtonIntractable(nextMissileMagCost, coinsInHand); m_MagazineInfo.text = GetMagazineInfoText(m_ShooterAmor.MissileMagazineLvl); ////// // Set Missile Related Stuff ////// int missileCount = m_ShooterAmor.MissileCount; int missileCap = m_ShooterAmor.MagazineCapacity; m_MissileSlider.maxValue = missileCap; m_MissileSlider.value = missileCount; m_MissileCount.text = "Missile Count:" + missileCount + "/" + missileCap; m_MissileAddBtn.interactable = SetButtonIntractable(m_MissileCost, coinsInHand); m_MissileInfoText.text = GetMissileCapacityInfoText(); ////// // Set Shield Related Stuff ////// int shieldLvl = GetCurrentShieldLevel(GameManager.Instance.GetCurrentShield().Duration); int shieldCost = GetNextShieldCost(shieldLvl); m_ShiledSlider.maxValue = DataBank.GetShieldData().Count(); m_ShiledSlider.value = shieldLvl; m_ShieldInfo.text = GetShieldInfoText(shieldLvl); m_ShieldBtn.interactable = SetButtonIntractable(shieldCost, coinsInHand); ////// // Set Life Related Stuff ////// m_LifeSlider.value = GameManager.Instance.LifesLeft(); m_LifeBtn.interactable = SetButtonIntractable(m_LifeCost, coinsInHand); m_LifeInfo.text = GetLifeInfoText(GameManager.Instance.LifesLeft()); }
/// <summary> /// Get next shield data by level /// </summary> /// <param name="lvl"></param> /// <returns></returns> public static Shield GetNextShieldDataByLvl(int lvl) { if (lvl == DataBank.GetShieldData().OrderByDescending(x => x.Key).First().Key) { return(new Shield(-1, -1)); } return(DataBank.GetShieldData()[lvl + 1]); }
/// <summary> /// Get next missile magazine level /// </summary> /// <param name="lvl"></param> /// <returns></returns> public static int GetNextMissileMagLvl(int lvl) { if (lvl == DataBank.GetMissileMagazineData().OrderByDescending(x => x.Key).First().Key) { return(-1); } return(lvl + 1); }
/// <summary> /// Get next gun level /// </summary> /// <param name="lvl"></param> /// <returns></returns> public static int GetNextGunLevel(int lvl) { if (lvl == DataBank.GetGunPowerData().OrderByDescending(x => x.Key).First().Key) { return(-1); } return(lvl + 1); }
/// <summary> /// Get Shield Cost /// </summary> /// <param name="curLevel"></param> /// <returns></returns> int GetNextShieldCost(int curLevel) { if (curLevel == DataBank.GetShieldData().OrderByDescending(x => x.Value.Cost).First().Key) { return(-1); } return(DataBank.GetShieldData()[curLevel + 1].Cost); }
/// <summary> /// Get missile magazine cost /// </summary> /// <param name="curLevel"></param> /// <returns></returns> int GetNextMissileMagazineCost(int curLevel) { if (curLevel == DataBank.GetMissileMagazineData().OrderByDescending(x => x.Value.Cost).First().Key) { return(-1); } return(DataBank.GetMissileMagazineData()[curLevel + 1].Cost); }
/// <summary> /// Get the next gun levels cost /// </summary> /// <param name="curLevel"></param> /// <returns></returns> int GetNextGunCost(int curLevel) { if (curLevel == DataBank.GetGunPowerData().OrderByDescending(x => x.Value).First().Key) { return(-1); } return(DataBank.GetGunPowerData()[curLevel + 1]); }
/// <summary> /// Get Magazine capacity by level /// </summary> /// <param name="lvl"></param> /// <returns></returns> public static int GetMagazineCapacityByLvl(int lvl) { if (DataBank.GetMissileMagazineData().ContainsKey(lvl)) { return(DataBank.GetMissileMagazineData()[lvl].Capacity); } return(-1); }
/// <summary> /// Get Missile magazine upgrade cost /// </summary> /// <param name="lvl"></param> /// <returns></returns> public static int GetMissileMagUpgrdCost(int lvl) { if (DataBank.GetMissileMagazineData().ContainsKey(lvl)) { return(DataBank.GetMissileMagazineData()[lvl].Cost); } return(-1); }
/// <summary> /// Get the gun upgrade cost /// </summary> /// <param name="lvl"></param> /// <returns></returns> public static int GetGunUpgradeCost(int lvl) { if (DataBank.GetGunPowerData().ContainsKey(lvl)) { return(DataBank.GetGunPowerData()[lvl]); } return(-1); }
/// <summary> /// Get Magazine information text /// </summary> /// <param name="currentLvl"></param> /// <returns></returns> string GetMagazineInfoText(int currentLvl) { if (currentLvl == DataBank.GetMissileMagazineData().OrderByDescending(x => x.Key).First().Key) { m_MagazineUpgrdBtn.interactable = false; return("<color=#fd0000>Already Upgraded to MAX level</color>"); } return("<color=#cfd2d4> Upgrade to Lvel " + (currentLvl + 1) + " for: </color>" + GetCostString(DataBank.GetMissileMagazineData()[currentLvl + 1].Cost)); }
/// <summary> /// Get the gun power information text /// </summary> /// <param name="currentLvl"></param> /// <returns></returns> string GetGunPowerInfoText(int currentLvl) { if (currentLvl == DataBank.GetGunPowerData().OrderByDescending(x => x.Value).First().Key) { m_GunUpgradeBtn.interactable = false; return("<color=#fd0000>Already Upgraded to MAX level</color>"); } return("<color=#cfd2d4> Upgrade to Lvel " + (currentLvl + 1) + " for: </color>" + GetCostString(DataBank.GetGunPowerData()[currentLvl + 1])); }
/// <summary> /// Get Shield infomation text /// </summary> /// <param name="currentLvl"></param> /// <returns></returns> string GetShieldInfoText(int currentLvl) { int shieldLvl = GetCurrentShieldLevel(GameManager.Instance.GetCurrentShield().Duration); int shieldCost = GetNextShieldCost(shieldLvl); if (currentLvl == DataBank.GetShieldData().OrderByDescending(x => x.Key).First().Key) { m_ShieldBtn.interactable = false; return("<color=#fd0000>Already Upgraded to MAX level</color>"); } return("<color=#cfd2d4> Upgrade to " + DataBank.GetShieldData()[(currentLvl + 1)].Duration + " sec. for :</color>" + GetCostString(shieldCost)); }
/// <summary> /// Get Current shiled level by duration /// </summary> /// <param name="duration"></param> /// <returns></returns> public static int GetCurrentShieldLevel(int duration) { return(DataBank.GetShieldData().FirstOrDefault(x => x.Value.Duration == duration).Key); }