Beispiel #1
0
    public void Save()
    {
        int saveAmount = int.Parse(m_inputField.text);

        if (saveAmount > m_playerLoots.GetLootCount())
        {
            MessagePanelController.s_instance.SetText(s_kSaveErrorMessage[(int)GameManager.s_instance.gameLanguage]);
            return;
        }

        ChangeLootInBank(saveAmount);
        m_playerLoots.Loot(-saveAmount);
    }
Beispiel #2
0
    //----------------------------------------------------------------------------
    // Collision detected enter trigger
    //----------------------------------------------------------------------------
    protected void OnTriggerEnter(Collider other)
    {
        Player player = other.gameObject.GetComponent <Player>();

        if (player != null &&                                                                                         // Collier is player
            (player.GetComponent <LootComponent>().GetLootCount() < player.GetComponent <LootComponent>().m_maxLoot)) // Player's current loot count has not hit max loot yet
        {
            if (m_LootType == LootType.Treasure)
            {
                LootComponent playerLootComponent = player.GetComponent <LootComponent>();
                if (playerLootComponent != null)
                {
                    playerLootComponent.Loot(m_value);
                    Destroy(this.gameObject);                            // Kill this loot object
                }
            }
            else
            {
                CannonComponent playerCannonComponent = player.GetComponent <CannonComponent>();
                if (playerCannonComponent != null)
                {
                    playerCannonComponent.AddCannon(m_value);
                    Destroy(this.gameObject);                            // Kill this loot object
                }
            }
        }
    }