private void Awake() { _baseTransform = transform.Find("Base"); if (spriteRenderer != null) { _tintMaterial = spriteRenderer.material; } if (_shieldCollier != null && GetShield() > 0) { _shieldCollier.enabled = true; } if (_collider != null) { _collider.enabled = GetShield() <= 0; } _healthLevel = GameDataController.GetPlayerHealthLevel(); _shieldArmor = GameDataController.GetPlayerShieldArmor(); SetHealthLevel(_healthLevel); SetEquippedShieldArmor(_shieldArmor); }
private void RefreshUI() { _coinAmountText.text = _coins.Value.ToString(); _starAmountText.text = _stars.Value.ToString(); if (_container == null) { return; } for (int i = 0; i < _container.childCount; i++) { GameObject toRemove = _container.GetChild(i).gameObject; Destroy(toRemove); } switch (GameDataController.GetPlayerHealthLevel()) { case PlayerHealthShield.HealthLevel.Level_1: CreateItemButton(ShopItem.ShopItemType.Health_2, ShopItem.GetSprite(ShopItem.ShopItemType.Health_2), "HEALTH [LEVEL 2]", "Increases player's health by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Health_2)); break; case PlayerHealthShield.HealthLevel.Level_2: CreateItemButton(ShopItem.ShopItemType.Health_3, ShopItem.GetSprite(ShopItem.ShopItemType.Health_3), "HEALTH [LEVEL 3]", "Increases player's health by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Health_3)); break; case PlayerHealthShield.HealthLevel.Level_3: CreateItemButton(ShopItem.ShopItemType.Health_4, ShopItem.GetSprite(ShopItem.ShopItemType.Health_4), "HEALTH [LEVEL 4]", "Increases player's health by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Health_4)); break; } switch (GameDataController.GetPlayerShieldArmor()) { case PlayerHealthShield.ShieldArmor.None: CreateItemButton(ShopItem.ShopItemType.Shield_1, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_1), "SHIELD [LEVEL 1]", "Adds shield to the player.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_1)); break; case PlayerHealthShield.ShieldArmor.Tier_1: CreateItemButton(ShopItem.ShopItemType.Shield_2, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_2), "SHIELD [LEVEL 2]", "Increases player's shield by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_2)); break; case PlayerHealthShield.ShieldArmor.Tier_2: CreateItemButton(ShopItem.ShopItemType.Shield_3, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_3), "SHIELD [LEVEL 3]", "Increases player's shield by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_3)); break; case PlayerHealthShield.ShieldArmor.Tier_3: CreateItemButton(ShopItem.ShopItemType.Shield_4, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_4), "SHIELD [LEVEL 4]", "Increases player's shield by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_4)); break; } switch (GameDataController.GetSpeedLevel()) { case 0: CreateItemButton(ShopItem.ShopItemType.Speed_1, ShopItem.GetSprite(ShopItem.ShopItemType.Speed_1), "SPEED [LEVEL 2]", "Increases player's speed by 10%.", ShopItem.GetCost(ShopItem.ShopItemType.Speed_1)); break; case 1: CreateItemButton(ShopItem.ShopItemType.Speed_2, ShopItem.GetSprite(ShopItem.ShopItemType.Speed_2), "SPEED [LEVEL 3]", "Increases player's speed by 10%.", ShopItem.GetCost(ShopItem.ShopItemType.Speed_2)); break; case 2: CreateItemButton(ShopItem.ShopItemType.Speed_3, ShopItem.GetSprite(ShopItem.ShopItemType.Speed_3), "SPEED [LEVEL 4]", "Increases player's speed by 10%.", ShopItem.GetCost(ShopItem.ShopItemType.Speed_3)); break; } switch (GameDataController.GetShotLevel()) { case 0: CreateItemButton(ShopItem.ShopItemType.Shot_1, ShopItem.GetSprite(ShopItem.ShopItemType.Shot_1), "SHOT [LEVEL 2]", "Increases player's shot by 1.", ShopItem.GetCost(ShopItem.ShopItemType.Shot_1)); break; case 1: CreateItemButton(ShopItem.ShopItemType.Shot_2, ShopItem.GetSprite(ShopItem.ShopItemType.Shot_2), "SHOT [LEVEL 3]", "Increases player's shot by 1.", ShopItem.GetCost(ShopItem.ShopItemType.Shot_2)); break; } #if UNITY_ANDROID if (!GameDataController.IsBombAbilityEnable()) { CreateItemButton(ShopItem.ShopItemType.Bomb, ShopItem.GetSprite(ShopItem.ShopItemType.Bomb), "BOMB", "Gives player ability to spawn a bomb to damage close enemies.", ShopItem.GetCost(ShopItem.ShopItemType.Bomb)); } #endif if (!GameDataController.IsTimePickupEnable()) { CreateItemButton(ShopItem.ShopItemType.Time, ShopItem.GetSprite(ShopItem.ShopItemType.Time), "SLOWMO [PICKUP]", "Snipe your enemies one by one in an awesome slowmo sequence.", ShopItem.GetCost(ShopItem.ShopItemType.Time)); } if (!GameDataController.IsVoidPickupEnable()) { CreateItemButton(ShopItem.ShopItemType.Void, ShopItem.GetSprite(ShopItem.ShopItemType.Void), "VOID [PICKUP]", "Gives player ability to spawn a void vortex to attract and damage enemies.", ShopItem.GetCost(ShopItem.ShopItemType.Void)); } if (!GameDataController.IsRepairPickupEnable()) { CreateItemButton(ShopItem.ShopItemType.Repair, ShopItem.GetSprite(ShopItem.ShopItemType.Repair), "REPAIR [PICKUP]", "Repairs player's spaceship to full health and shield.", ShopItem.GetCost(ShopItem.ShopItemType.Repair)); } }