Ejemplo n.º 1
0
 public void BuyBoat(Boat b)
 {
     if (MainGameController.instance.player.Gold >= b.Price)
     {
         Boat previousBoat = MainGameController.instance.databaseController.connection.Table <Boat>().Where(x => x.Active).FirstOrDefault();
         if (previousBoat != null)
         {
             previousBoat.Active = false;
             previousBoat.Save();
             Sail activeSail = previousBoat.GetSailsBought().Where(x => x.Active).First();
             if (!b.GetSailsBought().Contains(activeSail))
             {
                 activeSail.Active = false;
                 activeSail.Save();
                 Sail s = b.GetSailsBought().Where(x => x.Bought).First();
                 s.Active = true;
                 s.Save();
             }
         }
         MainGameController.instance.achievementManager.AddAchievementProperty(AchievementProperties.BoatsBought, 1);
         b.Bought = true;
         b.Active = true;
         b.Save();
         UpdateBoatBuyPanels();
         MainGameController.instance.player.GiveGold(-b.Price);
         MainGameController.instance.player.Save();
         _goldText.text = "Gold: " + MainGameController.instance.player.Gold;
     }
     else
     {
         Debug.LogError("Not enough gold to buy boat!");
     }
 }
Ejemplo n.º 2
0
    public static void CompleteRequest(Request r)
    {
        r.Completed = true;

        object o          = r.GetReward();
        string rewardType = MainGameController.instance.localizationManager.GetLocalizedValue(r.RewardType);
        string athing     = MainGameController.instance.localizationManager.GetLocalizedValue("a_text");

        switch (o.GetType().Name)
        {
        case "Int32":
            int reward = (int)o;
            MainGameController.instance.player.GiveGold(reward);
            break;

        case "Boat":
            Boat b = (Boat)o;
            b.Bought = true;
            b.Save();
            rewardType = athing + " " + rewardType;
            break;

        case "Sail":
            Sail s = (Sail)o;
            s.Bought = true;
            s.Save();
            rewardType = athing + " " + rewardType;
            break;

        case "Upgrade":
            Upgrade u = (Upgrade)o;
            u.Bought = true;
            u.Save();
            rewardType = athing + " " + rewardType;
            break;

        case "Item":
            Item i = (Item)o;
            i.InInventory++;
            i.Save();
            rewardType = athing + " " + rewardType;
            break;

        default:
            Debug.LogWarning("Unknown reward type: " + o.GetType().Name);
            break;
        }

        r.Save();
        string popupText = string.Format(MainGameController.instance.localizationManager.GetLocalizedValue("completed_request_text"), rewardType);

        MainGameController.instance.popupManager.ViewPopup(popupText, null, 10);
    }
Ejemplo n.º 3
0
    public void UseSail(Sail s)
    {
        TableQuery <Sail> activeSails = MainGameController.instance.databaseController.connection.Table <Sail>().Where(x => x.Active == true);

        if (activeSails.Count() > 0)
        {
            Sail curActive = activeSails.First();
            curActive.Active = false;
            curActive.Save();
        }
        s.Active = true;
        s.Save();
        UpdateSailBuyPanels();
    }
Ejemplo n.º 4
0
    public void ChangeSail(Sail sail)
    {
        Sail s = MainGameController.instance.player.GetActiveBoat().GetSailsBought().Where(x => x.Active).First();

        s.Active = false;
        s.Save();
        sail.Active = true;
        sail.Save();

        List <Sail> sails = MainGameController.instance.player.GetActiveBoat().GetSailsBought().ToList();

        for (int i = 0; i < sails.Count; i++)
        {
            _sailChangePanels[i].GetComponent <SailChangePanel>().SetData(sails[i]);
        }
    }
Ejemplo n.º 5
0
    public void UseBoat(Boat b)
    {
        TableQuery <Boat> activeBoats = MainGameController.instance.databaseController.connection.Table <Boat>().Where(x => x.Active == true);

        if (activeBoats.Count() > 0)
        {
            Boat curActive = activeBoats.First();
            curActive.Active = false;
            curActive.Save();
            Sail activeSail = curActive.GetSailsBought().Where(x => x.Active).First();
            if (!b.GetSailsBought().Contains(activeSail))
            {
                activeSail.Active = false;
                activeSail.Save();
                Sail s = b.GetSailsBought().Where(x => x.Bought).First();
                s.Active = true;
                s.Save();
            }
        }
        b.Active = true;
        b.Save();
        UpdateBoatBuyPanels();
    }
Ejemplo n.º 6
0
    public void BuySail(Sail s)
    {
        if (MainGameController.instance.player.Gold >= s.Price)
        {
            Sail previousSail = MainGameController.instance.databaseController.connection.Table <Sail>().Where(x => x.Active).FirstOrDefault();
            if (previousSail != null)
            {
                previousSail.Active = false;
                previousSail.Save();
            }

            s.Bought = true;
            s.Active = true;
            s.Save();
            UpdateSailBuyPanels();
            MainGameController.instance.player.GiveGold(-s.Price);
            MainGameController.instance.player.Save();
            _goldText.text = MainGameController.instance.localizationManager.GetLocalizedValue("gold_text") + ": " + MainGameController.instance.player.Gold;
        }
        else
        {
            Debug.LogError("Not enough gold to buy sail!");
        }
    }