public void Refresh(PlayerUpgrade upgrade)
    {
        GameObject icon = Instantiate(Resources.Load(upgrade.icon, typeof(GameObject)) as GameObject);
        this.Upgrade = upgrade;
        upgradeName.text = upgrade.itemName;
        upgradeDescription.text = upgrade.description;

        icon.transform.SetParent(spritePivot);
        icon.transform.ResetLocal();

        Utils.ReplaceSpritesWithUiImages(gameObject, false);

        spritePivot.transform.localScale = Vector3.one * upgrade.wardrobeScale;
        spritePivot.transform.Translate(upgrade.wardrobePivotOffset);

        images = spritePivot.GetComponentsInChildren<Image>();

        if (upgrade.Locked)
        {
            ShowAsLocked();
        }
        else if (PersistentData.IsHavingUpgrade(upgrade.itemName))
        {
            ShowAsBought();
        }
    }
Ejemplo n.º 2
0
    //업그레이드 파트, 정보 저장하기
    public void SavePlayerUpgradeInfo(PlayerUpgrade playerUpgrade)
    {
        string key = playerUpgrade.upgradeName;

        PlayerPrefs.SetInt(key + "_clickLevel", playerUpgrade.clickLevel);
        PlayerPrefs.SetString(key + "_addDamageUpgrade", playerUpgrade.addDamageUpgrade.ToString());
        PlayerPrefs.SetString(key + "_cost", playerUpgrade.currentCost.ToString());
    }
Ejemplo n.º 3
0
 public SavedData()
 {
     SavedInPath = new Dictionary();
     upgrades    = new PlayerUpgrade();
     SavedInPath.Add(SavedAreaPath, GameManager.StartingLevelPath);
     SavedInPath.Add(SavedGameName, "New Game");
     scans = new Godot.Collections.Array();
 }
Ejemplo n.º 4
0
 public void CreateSlot(PlayerUpgrade _upgrade)
 {
     if (_upgrade != null)
     {
         upgrade              = _upgrade;
         image.enabled        = true;
         image.overrideSprite = _upgrade.sprite;
     }
 }
 public void OnPlayerUpgradeBought(PlayerUpgrade upgrade)
 {
     if (this.Upgrade.baseUpgrade != null && this.Upgrade.baseUpgrade.itemName == upgrade.itemName)
     {
         ShowAsUnlocked();
     }
     else if (this.Upgrade.itemName == upgrade.itemName)
     {
         ShowAsBought();
     }
 }
Ejemplo n.º 6
0
    //업그레이드 파트, 저장된 업그레이드 정보 가져오기
    public void LoadPlayerUpgradeInfo(PlayerUpgrade playerUpgrade)
    {
        //저장된 값을 가져오기 위해 key값을 받아온다.
        string key = playerUpgrade.upgradeName;

        //사용자 탭 레벨 저장
        playerUpgrade.clickLevel = PlayerPrefs.GetInt(key + "_clickLevel", 1);
        //사용자 탭 최대 공격력 증가량
        playerUpgrade.addDamageUpgrade = long.Parse(PlayerPrefs.GetString(key + "_addDamageUpgrade", playerUpgrade.startGoldDamageUpgrade.ToString()));
        //사용자 탭 최대 공격력 업그레이드 비용 저장
        playerUpgrade.currentCost = long.Parse(PlayerPrefs.GetString(key + "_cost", playerUpgrade.startCurrentCost.ToString()));
    }
Ejemplo n.º 7
0
 public UpgradeEntity(Texture2D texture, PlayerUpgrade upgrade)
 {
     addComponent(new Sprite(texture));
     addComponent(new SnapToGroundComponent()
     {
     });
     addComponent(new UpgradeComponent(upgrade));
     addComponent(new BoxCollider()
     {
         collidesWithLayers = 1 << 1,
             isTrigger      = true
     });
 }
Ejemplo n.º 8
0
    public override void _Ready()
    {
        string upgrade = PlayerUpgrade.EnumToStringUpgrades(upgradeName);

        if (WorldManager.instance.WorldInfoHas(upgrade))
        {
            if (WorldManager.instance.GetWorldInfoData <bool>(upgrade))
            {
                QueueFree();
                return;
            }
        }
        GetChild <Area>(0).Connect("body_entered", this, nameof(UpgradeCollected));
        GetChild <AnimationPlayer>(2).CurrentAnimation = "Hovering";
    }
Ejemplo n.º 9
0
    public void AddUpgrade(PlayerUpgrade playerUpgrade)
    {
        if (playerUpgrade == PlayerUpgrade.SpellslignersGloves)
        {
            this.Fireball.Cooldown /= 2f;
        }

        if (this.UpgradesCollection.ContainsKey(playerUpgrade))
        {
            this.UpgradesCollection[playerUpgrade]++;
        }
        else
        {
            this.UpgradesCollection.Add(playerUpgrade, 1);
        }
    }
Ejemplo n.º 10
0
 private void UpgradeCollected(Node body)
 {
     if (body.Name.Equals("Player"))
     {
         string upgrade = PlayerUpgrade.EnumToStringUpgrades(upgradeName);
         if (PlayerController.Instance.upgrades.GetUpgrade(upgrade))
         {
             QueueFree();
             return;
         }
         PlayerController.Instance.upgrades.SetUpgradeTo(upgrade, true);
         WorldManager.instance.AddToWorldInfo(upgrade, true);
         InGameMenu.Instance.GetUpgrade(name, description);
         QueueFree();
     }
 }
Ejemplo n.º 11
0
 public SavedData(Dictionary playerUpgrades, Dictionary additionalInfo, Godot.Collections.Array scans)
 {
     upgrades    = new PlayerUpgrade(playerUpgrades);
     SavedInPath = additionalInfo;
     this.scans  = scans;
 }
Ejemplo n.º 12
0
 public void ClearSlot()
 {
     upgrade = null;
     image.overrideSprite = null;
     image.enabled        = false;
 }
Ejemplo n.º 13
0
    public void OnBuyButtonPressed()
    {
        bool bought = false;

        if (lastOutfitSkinSelected != null && BuyItem(lastOutfitSkinSelected))
        {
            AnalyticsManager.OnOutfitSkinBought(lastOutfitSkinSelected.itemName);
            PersistentData.IsHavingBodySkin(lastOutfitSkinSelected.itemName, true);
            PostOffice.PostPlayerBodySkinBought(lastOutfitSkinSelected);
            unlockLabel.text = Strings.Wardrobe.skinUnlocked;
            bought = true;
        }
        else if (lastParachuteSkinSelected != null && BuyItem(lastParachuteSkinSelected))
        {
            AnalyticsManager.OnParachuteSkinBought(lastParachuteSkinSelected.itemName);
            PersistentData.IsHavingParachuteSkin(lastParachuteSkinSelected.itemName, true);
            PostOffice.PostPlayerParachuteSkinBought(lastParachuteSkinSelected);
            unlockLabel.text = Strings.Wardrobe.skinUnlocked;
            bought = true;
        }
        else if (lastHatSkinSelected != null && BuyItem(lastHatSkinSelected))
        {
            AnalyticsManager.OnHatSkinBought(lastHatSkinSelected.itemName);
            SocialManager.IncrementAchievement(SocialManager.Achievements.hatsUnlocked);
            PersistentData.IsHavingHatSkin(lastHatSkinSelected.itemName, true);
            PostOffice.PostPlayerHatSkinBought(lastHatSkinSelected);
            unlockLabel.text = Strings.Wardrobe.skinUnlocked;
            bought = true;
        }
        else if (lastUpgradeSelected != null && BuyItem(lastUpgradeSelected))
        {
            AnalyticsManager.OnUpgradeBought(lastUpgradeSelected.itemName);
            PersistentData.IsHavingUpgrade(lastUpgradeSelected.itemName, true);
            lastUpgradeSelected.OnBought();
            PostOffice.PostPlayerUpgradeBought(lastUpgradeSelected);
            lastUpgradeSelected = null;
            unlockLabel.text = Strings.Wardrobe.upgradeUnlocked;
            bought = true;
        }

        if (bought)
        {
            RefreshButton(true, false);
            OnEquipButtonPressed();
            buyEffect.SetTrigger(buyAnimHash);
        }
        else
        {
        #if !UNITY_EDITOR && UNITY_ANDROID
            Android.ShowToast(Strings.Toasts.needMoreGems);
        #endif
        }
    }
Ejemplo n.º 14
0
    void ResetSelection()
    {
        lastOutfitSkinSelected = null;
        lastParachuteSkinSelected = null;
        lastHatSkinSelected = null;
        lastUpgradeSelected = null;

        buyButton.SetActive(false);
        equipButton.SetActive(false);
    }
Ejemplo n.º 15
0
    void OnUpgradeSelected(PlayerUpgrade upgrade)
    {
        lastOutfitSkinSelected = null;
        lastParachuteSkinSelected = null;
        lastHatSkinSelected = null;
        lastUpgradeSelected = upgrade;
        priceLabel.text = upgrade.price.ToString();

        RefreshButton(PersistentData.IsHavingUpgrade(upgrade.itemName), false);
    }
Ejemplo n.º 16
0
    void OnParachuteSelected(PlayerParachuteSkin skin)
    {
        lastOutfitSkinSelected = null;
        lastParachuteSkinSelected = skin;
        lastHatSkinSelected = null;
        lastUpgradeSelected = null;
        priceLabel.text = skin.price.ToString();

        RefreshButton(PersistentData.IsHavingParachuteSkin(skin.itemName), PersistentData.PlayerParachuteSkin == skin.itemName);
        dogePreview.SetSkin(skin);
    }
Ejemplo n.º 17
0
 public void EquipUpgrade(PlayerUpgrade newUpgrade, int slot)
 {
     upgrades.Remove(newUpgrade);
     equippedUpgrades[slot] = newUpgrade;
     UpgradesChanged?.Invoke();
 }
Ejemplo n.º 18
0
 public UpgradeComponent(PlayerUpgrade upgrade)
 {
     Upgrade = upgrade;
 }
Ejemplo n.º 19
0
 public bool HasUpgrade(PlayerUpgrade playerUpgrade)
 {
     return(this.UpgradesCollection.ContainsKey(playerUpgrade));
 }
Ejemplo n.º 20
0
 public void EquipUpgrade(PlayerUpgrade upgrade, UIEquippedUpgradeSlot slot)
 {
     PlayerUpgrades.instance.EquipUpgrade(upgrade, Array.FindIndex(equippedUpgradeSlots, w => w == slot));
 }
Ejemplo n.º 21
0
 public static void PostPlayerUpgradeBought(PlayerUpgrade upgrade)
 {
     if (playerUpgradeBought != null)
     {
         playerUpgradeBought(upgrade);
     }
 }
 public void AddUpgrade(PlayerUpgrade upgrade)
 {
     _upgrades.Add(upgrade);
 }
 public void RemoveUpgrade(PlayerUpgrade upgrade)
 {
     _upgrades.Remove(upgrade);
 }