public void PlayerFire(Ammo currentAmmo) { foreach (Transform weaponFireSpawPoint in player.findChildByTag(PlayerGlobalStatus.getCurrentWeaponUpgradeTag())) { try{ if (IsValidAmmoFireSpawnPoint(currentAmmo, weaponFireSpawPoint)) { if (PlayerGlobalStatus.isAmmoDiretionalFire(currentAmmo)) { diretionalFire(currentAmmo, weaponFireSpawPoint); } else if (PlayerGlobalStatus.isAmmoTrackerFire(currentAmmo)) { fireDirectionalTracker(currentAmmo, weaponFireSpawPoint);//diretionalFire(currentAmmo, WeaponFireSpawPoint); } else { linearFire(currentAmmo, weaponFireSpawPoint); } } }catch (System.Exception e) { Debug.LogWarning(e); } } }
public void BuyItem() { /*chamado dps que o item fom comprado efetivamente!! */ /* se a arma nao for repetida ( conseguiu adicionar ), incremente o lvl dela * e atualize na variavel local itemUpgradeLevel*/ if (PlayerGlobalStatus.AddPlayerItem(item)) { if (item.CompareTag(Constantes.WEAPON)) { itemUpgradeLevel = item.GetComponent <Weapon>().GetWeaponLevel(); } else if (item.CompareTag(Constantes.BOMB)) { itemUpgradeLevel = item.GetComponent <Bomb>().GetBombLevel(); } else if (item.CompareTag(Constantes.SHIELD)) { itemUpgradeLevel = item.GetComponent <Shield>().GetShieldLevel(); } } UpdateItemPricesAndSetFactor(); UpdateUpgradePanelStatus(); CheckChildsTags(); }
private void CheckCash(string action) { if (action == Constantes.UPGRADE) { if (PlayerGlobalStatus.getPlayerCash() >= upgradeCurrentPrice) { if (PlayerHaveItem() || !item.CompareTag(Constantes.WEAPON)) { globalPanel.GetComponent <PurchaseStatusPanelManager>().OptionManager(gameObject, action); } else { globalPanel.GetComponent <PurchaseStatusPanelManager>().NoWeaponText(); } } else { globalPanel.GetComponent <PurchaseStatusPanelManager>().NoCashText(upgradeCurrentPrice, action); } } //comprar else { if (PlayerGlobalStatus.getPlayerCash() >= itemPrice) { globalPanel.GetComponent <PurchaseStatusPanelManager>().OptionManager(gameObject, action); } else { globalPanel.GetComponent <PurchaseStatusPanelManager>().NoCashText(itemPrice, action); } } }
private void SetCash() { PlayerGlobalStatus.addPlayerCash(CASH); GameObject cashPanel = transform.Find(Constantes.CASH_PANEL).gameObject; cashPanel.GetComponentInChildren <TextMeshProUGUI>().text = Constantes.CASH + "\n" + PlayerGlobalStatus.getPlayerCash().ToString("C2"); }
public void LoadStartMenuPosFade() { SetTimeScale(); PlayerGlobalStatus.resetPlayerStatus(); NextLevelLoader.ResetLevelsIndex(); SceneManager.LoadScene(Constantes.START_MENU); }
/* assim garante que mesmo que o player aperte o mouse * que nem um louco, o tempo entre os tiros será respeitado */ private void fire() { try{ if (Input.GetButton("Fire1")) { playerFireManager.Fire(); } if (Input.GetKeyDown(KeyCode.G)) { GL.Clear(true, true, Color.black); } if (Input.GetKeyDown(KeyCode.Space)) { if (PlayerGlobalStatus.changeWeapon()) { playerFireManager.ManageAmmoVector(); uiManagement.UpdateWeaponIcon(); } } if (Input.GetKeyDown(KeyCode.E)) { //playerItensManager.TrowBombIfExists(); playerItensManager.ChangeItem(); } if (Input.GetKeyDown(KeyCode.R)) { playerItensManager.UseItem(); } }catch (System.Exception e) { Debug.Log(e); } }
private void manageDefaultWeaponAndUpgradeParts() { PlayerGlobalStatus.CountPlayerUpgradePartsSize(); GameObject playerDefaultLaser = Resources.Load <GameObject>(Constantes.DEFAULT_PLAYER_WEAPON_PATH); AddWeaponAndManageAmmoVector(playerDefaultLaser); setDefaultWeaponUpgradePart(playerDefaultLaser); }
private void UseBomb() { GameObject bomb = Instantiate(PlayerGlobalStatus.GetBomb(), transform.position, Quaternion.identity); bomb.GetComponent <Rigidbody2D>().velocity = Vector2.up * 5f; bomb.GetComponent <Bomb>().TriggerExplosionCoroutine(); PlayerGlobalStatus.RemoveBomb(); uiManagement.UpdateItenIcon(currentItenIndex); }
private void restoreUpgradeParts() { List <GameObject> playerWeapons = PlayerGlobalStatus.GetPlayerWeapons(); foreach (GameObject weapom in playerWeapons) { checkplayerUpgradePart(weapom); } }
private void AddCash() { /* só existira a referencia se o valor do objeto for maior que zero hee */ if (uiManagement) { PlayerGlobalStatus.addPlayerCash(cash); uiManagement.UpdateScoreText(); } }
private void updatePlayerStatus() { audioManager.play_die_audio(); playerHealthManager.checkPlayerHealth(); checkChancesAndRemoveIt(); PlayerGlobalStatus.SetPlayerWeaponIndex(0); uiManagement.UpdateChancesText(); uiManagement.UpdateScoreText(); }
/*lembre, uso as tags de bomba shield e arma mas o objeto * que usa essa classe nao tem/carrega nada disso! só serve * como indicativo pro metodo que chamo no plauerglobal status * saber o que adicionar e pra qual lista! */ private void TryAddItem() { if (gameObject.CompareTag(Constantes.BOMB)) { /*se retornou true é pq n ultrapassou a qtdade limite e adicionou com sucesso */ if (PlayerGlobalStatus.AddCollectedItem(Constantes.BOMB)) { uiManagement.UpdateItenIcon(0); /*lembre zero é bomb 1 é shield */ if (player) { player.GetComponent <PlayerItensManager>().SetItenIndex(0); } else { Debug.LogWarning(Constantes.MISSING_REF); } } } else if (gameObject.CompareTag(Constantes.SHIELD)) { /*se retornou true é pq n ultrapassou a qtdade limite e adicionou com sucesso */ if (PlayerGlobalStatus.AddCollectedItem(Constantes.SHIELD)) /*1 é shield lembre */ { uiManagement.UpdateItenIcon(1); if (player) { player.GetComponent <PlayerItensManager>().SetItenIndex(1); } else { Debug.LogWarning(Constantes.MISSING_REF); } } } /*pra ter ctz, msm que por engano alguem marque algo que nao devia como weapon, ele checará se tem o script da arma associado...isso garante que só tentara adicionar uma arma de fato */ else if (gameObject.CompareTag(Constantes.WEAPON) && weapon.GetComponent <Weapon>()) { if (weapon) { if (PlayerGlobalStatus.AddCollectedItem(weapon)) { /*fundamental..se n checar as partes e só adicionar a arma..cracrah tudo! */ player.GetComponent <PlayerWeaponsPartsManager>().checkplayerUpgradePart(weapon); uiManagement.UpdateWeaponIcon(); } } else { Debug.LogWarning(Constantes.MISSING_REF); } } else { Debug.LogWarning(Constantes.NO_TAG_MATCHED); } }
private void checkChancesAndRemoveIt() { /* como as partes upgrade também sao da layer "Player", sem esse controle, * tem a chance de ser removida mais de uma chance por tentativa, o que nao é legal*/ if (!alreadyMissedChanceOnScene) { PlayerGlobalStatus.removeChance(); } alreadyMissedChanceOnScene = true; }
public void UpdateWeaponIcon() { try{ weaponIcon.sprite = PlayerGlobalStatus.getPlayerWeaponByIndex(PlayerGlobalStatus.GetPlayerWeaponIndex()).GetComponent <Weapon>().getWeaponIcon(); } catch (System.Exception e) { Debug.LogWarning("PATH DOS ÍCONES NÃO ENCONTRADO...CHEQUE O PATH EM <Constantes.cs>"); Debug.LogWarning(e); } }
public void SucessFullyPurchasedText(float boughPrice) { EnablePurchaseStatusPanel(); SetUpgradeInfoPanel(false); SetCancelButtonVisibility(false); SetPanelAtributes(true, false); textReference.text = purchaseTexts[2].ToString(); PlayerGlobalStatus.decreaseCash(boughPrice); UpdateCash(); }
public void SucessUpgradedPurchasedText() { EnablePurchaseStatusPanel(); SetUpgradeInfoPanel(false); SetCancelButtonVisibility(false); SetPanelAtributes(true, false); textReference.text = purchaseTexts[4].ToString(); // Debug.LogWarning("vai descontar " + callerRef.GetComponent<ItemManager>().GetUpgradePriceAux() ); PlayerGlobalStatus.decreaseCash(callerRef.GetComponent <ItemManager>().GetUpgradePriceAux()); UpdateCash(); }
private void UseShield() { canUseShieldAgain = false; GameObject shieldAura = Instantiate(PlayerGlobalStatus.GetShieldAura(), transform.position, Quaternion.identity); StartCoroutine(ShieldAuraDelay()); shieldAura.GetComponent <ShieldAura>().StartAuraProtection(gameObject.GetComponent <Player>()); shieldAura.transform.SetParent(GetComponent <Player>().transform); PlayerGlobalStatus.RemoveShield(); uiManagement.UpdateItenIcon(currentItenIndex); }
public void LoadStarMenuFromTryAgainPosFade() { try{ SetTimeScale(); PlayerGlobalStatus.resetPlayerStatus(); NextLevelLoader.ResetLevelsIndex(); SceneManager.LoadScene(Constantes.START_MENU); }catch (System.Exception e) { Debug.LogWarning(e); } }
public bool PlayerHaveItem() { if (PlayerGlobalStatus.PlayerHaveItem(item)) { return(true); } else { return(false); } }
public void SucessSoldPurchasedText(float soldPrice) { EnablePurchaseStatusPanel(); SetUpgradeInfoPanel(false); SetCancelButtonVisibility(false); SetPanelAtributes(true, false); string texto = string.Format(purchaseTexts[3].ToString() + "{0,24}", soldPrice.ToString("C2")); textReference.text = texto; PlayerGlobalStatus.addPlayerCash(soldPrice); UpdateCash(); }
private void AddCash() { if (uiManagement) { PlayerGlobalStatus.addPlayerCash(GetCash()); uiManagement.UpdateScoreText(); } else { Debug.LogWarning(Constantes.MISSING_REF); } }
public void Fire() { foreach (Ammo ammo in PlayerGlobalStatus.getWeaponAmmos()) { if (ammosFireFlags[counter] && ammo.GetAmmoStatus()) { StartCoroutine(PlayerFireCoroutine(ammo, counter)); } counter++; } ResetCounter(); }
public void loadNextGameScene() { SetScreenFaderRef(); PlayerGlobalStatus.UpdateSpendedCash(); if (fadeScreenManager) { fadeScreenManager.MotherFade(0.1f, this, false, Constantes.NEXT_LEVEL); } else { Debug.LogWarning(Constantes.MISSING_REF); } }
IEnumerator StarAuraProtectionCoroutine(Player playerRef) { if (playerRef) { playerRef.IsPlayerImortal(true); } yield return(new WaitForSeconds(PlayerGlobalStatus.GetShieldAuraCurrentDuration())); if (playerRef) { playerRef.IsPlayerImortal(false); } Destroy(gameObject); }
public void UseItem() { if (currentItenIndex == 0) { if (PlayerGlobalStatus.IsThereBomb()) { UseBomb(); } } else if (currentItenIndex == 1) { if (PlayerGlobalStatus.IsThereShield() && canUseShieldAgain) { UseShield(); } } }
public void checkplayerUpgradePart(GameObject weapon) { try{ //que local do player a parte continda na arma deverá ser spawnada/encaixada nele string playerSpawPointTag = weapon.GetComponent <Weapon>().playerSpawPointTag(); Transform spawPoint = player.findChildByTag(playerSpawPointTag); GameObject newPart = weapon.GetComponent <Weapon>().getWeaponUpgradePart(); if (!partWithTagAlreadyExists(newPart))//SERVE PRA LIDAR COM O CASO DA PARTE DA ARMA DEFAULT, APENAS { GameObject UpgradePart = Instantiate(newPart, spawPoint.position, Quaternion.identity); UpgradePart.transform.parent = player.transform; PlayerGlobalStatus.addPlayerUpgradePart(newPart); } }catch (System.Exception e) { Debug.LogWarning(e); } }
public void UpdateItenIcon(int itenIndex) { /*indice 0 é bomba, 1 e shield */ Transform itemUIRef = gameObject.transform.GetChild(0).transform.Find(Constantes.PLAYER_PANEL).transform.Find(Constantes.ITEM_UI); if (itemUIRef) { if (itenIndex == 0) { itemUIRef.Find(Constantes.ITEM_IMAGE).gameObject.GetComponent <Image>().sprite = bombIcon; amountText.text = "X " + PlayerGlobalStatus.GetPlayerBombsNumber().ToString(); } else if (itenIndex == 1) { itemUIRef.Find(Constantes.ITEM_IMAGE).gameObject.GetComponent <Image>().sprite = shieldIcon; amountText.text = "X " + PlayerGlobalStatus.GetPlayerShieldsNumber().ToString(); } } else { Debug.LogWarning(Constantes.MISSING_COMPONENT_NAME); } }
public void NoCashText(float itemPrice, string action) { EnablePurchaseStatusPanel(); SetUpgradeInfoPanel(false); SetCancelButtonVisibility(false); SetPanelAtributes(true, false); string keyWord; if (action == Constantes.UPGRADE) { keyWord = "UPGRADE PRICE:"; } else { keyWord = "ITEM PRICE:"; } string preco = (itemPrice).ToString("C2"); string playerCash = PlayerGlobalStatus.getPlayerCash().ToString("C2"); string texto = string.Format(purchaseTexts[0].ToString() + keyWord + " {0}\nYOU HAVE: {1}", preco, playerCash); textReference.text = texto; }
public void UpdateScoreText() { cashText.text = "CASH: " + PlayerGlobalStatus.getPlayerCash().ToString("0.00"); }
public void UpdateChancesText() { chancesText.text = "CHANCES: " + PlayerGlobalStatus.getPlayerChances().ToString(); }