Ejemplo n.º 1
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
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void Buy()
    {
        int index       = (int)GameManager.s_instance.gameLanguage;
        int numLanguage = (int)Language.kTotalNumLanguage;

        int enterAmount = int.Parse(m_inputField.text);

        if (tradeCost > m_playerLoot.GetSpendableLootCount())
        {
            MessagePanelController.s_instance.SetText(s_kBuyErrorMessage[0 * numLanguage + index]);
            return;
        }

        if (enterAmount + m_playerCannon.cannonballCount > m_playerCannon.GetMaxCannonCount())
        {
            MessagePanelController.s_instance.SetText(s_kBuyErrorMessage[1 * numLanguage + index]);
            return;
        }

        m_playerLoot.SpendLoot(tradeCost);
        m_playerCannon.AddCannon(enterAmount);
    }