public void CompleteExploration(bool success)
    {
        UnityEngine.Debug.Log("Starting to mark active zone complete. [Act " + Zone.Act + " Zone " + Zone.Zone + "]");
        if (success)
        {
            if (Zone.ActZoneID > PlayerManager.Instance.ActZoneCompleted)
            {
                PlayerManager.Instance.ActZoneCompleted = Zone.ActZoneID;
                GameAPIManager.API.Users.ActZoneComplete(Zone.ActZoneID);
            }
        }

        API.Explorations.Remove(Zone.ActZoneID)
        .Then(res => {
            Tracer.trace("Removed Exploration successfully!");
            Tracer.trace(res.pretty);

            foreach (Hero hero in Party)
            {
                hero.ExploringActZone = 0;
            }

            UnityEngine.Debug.Log("Zone is complete. [Act " + Zone.Act + " Zone " + Zone.Zone + "]");
            dataMan.allExplorationsList.Remove(this);
        })
        .Catch(err => {
            Tracer.traceError("Could not remove the exploration: " + GameAPIManager.GetErrorMessage(err));
        });
    }
    public void Btn_BoostsAddSlot()
    {
        if (BoostCanvasGroup.alpha != 1)
        {
            return;
        }

        var cost = CurrencyManager.ParseToCost(GlobalProps.BOOST_SLOT_COST.GetString());

        if (cost.type.GetAmount() < cost.amount)
        {
            TimelineTween.ShakeError(btnBoostAddSlot.gameObject);
            return;
        }

        BoostCanvasGroup.alpha = 0.5f;

        API.Users.BoostAddSlot(cost)
        .Then(res => {
            trace("Boost slot added successfully.");
            RefreshBoostSlots();
            BoostCanvasGroup.alpha = 1;
        })
        .Catch(err => {
            BoostCanvasGroup.alpha = 1;
            TimelineTween.ShakeError(btnBoostAddSlot.gameObject);
            traceError("Could not add new boost slot: " + GameAPIManager.GetErrorMessage(err));
        });
    }
    public static NodePromise GenerateLootCrate(LootTableData lootTable, float minItemLevel, float Variance, float magicFind, int activeZoneMongoID = -1, CrateTypeData lootCrateType = null, Action <LootCrate> callback = null)
    {
        LootCrate lootCrate;

        if (lootCrateType == null)
        {
            CrateTypeData ctd = MathHelper.WeightedRandom(lootTable.crateType).Key;
            lootCrate = new LootCrate(lootTable.Identity, minItemLevel, Variance, ctd, magicFind);
        }
        else
        {
            lootCrate = new LootCrate(lootTable.Identity, minItemLevel, Variance, lootCrateType, magicFind);
        }

        lootCrate.ExplorationID = activeZoneMongoID;

        return(API.LootCrates.Add(lootCrate)
               .Then(res => {
            //dataMan.allLootCratesList.Add(lootCrate);
            if (callback != null)
            {
                callback(lootCrate);
            }
        })
               .Catch(err => {
            traceError("Could not generate a new LootCrate: " + GameAPIManager.GetErrorMessage(err));
        }));
    }
Exemple #4
0
    //////////////////////////////////////////////////////////////////////////////////

    private IEnumerator __TryLogin()
    {
        SetBusy(true);

        API.Users.Login(loginUsername.text, loginPassword.text)
        .Then(res => {
            trace("Login Success!!!!!!");
            this.Wait(1.0f, () => {
                SetBusy(false);
                Hide();
            });
        })
        .Catch(err => {
            ShowError("Login Failed!\n" + GameAPIManager.GetErrorMessage(err));
            ShowPanel(loginPanel);
            SetBusy(false);
        });

        while (_isBusy)
        {
            yield return(new WaitForSeconds(1.0f));
        }

        yield break;
    }
    void Update()
    {
        if (_status != ResearchSlotStatus.BUSY || hasErrors)
        {
            return;
        }

        this.btnButton.interactable = !isChangingStatus;
        if (isChangingStatus)
        {
            return;
        }

        DateTime now          = DateTime.Now;
        TimeSpan dateDiff     = dateEnd - now;
        float    progressLeft = (float)(dateDiff.TotalSeconds / _dateDiff);

        if (progressLeft < 0)
        {
            ChangeStatus(ResearchSlotStatus.COMPLETED)
            .Then(slot => {
                trace("Slot should now be set to COMPLETED!");
                trace(slot.status);
            })
            .Catch(err => {
                traceError("Could not mark the slot as COMPLETED: " + GameAPIManager.GetErrorMessage(err));
            });
        }
        else
        {
            txtBottomProgress.text     = dateDiff.TotalSeconds.ToHHMMSS(isMonospaceHTML: true);
            imgCircularFill.fillAmount = progressLeft;
        }
    }
    private void Btn_BusySelectBooster()
    {
        var   costBase       = trayInfo.costToBoostBase;
        float costMultiplier = trayInfo.costToBoostMultiplier;
        int   minutesLeft    = (int)(dateEnd - DateTime.Now).TotalMinutes;

        var gemsType = costBase.type;
        int gemsCost = costBase.amount + Mathf.CeilToInt(minutesLeft * costMultiplier);
        int gemsLeft = gemsType.GetAmount();

        //int cost
        ConfirmYesNoInterface.Ask(
            "Instant Identify",
            "How would you".JoinNewLines(
                "like to instantly",
                "identify this item?\n",
                "<size=+10><color=#4286f4>{0} {1}</color></size>",
                "<size=-3>({2} remaining)</size>",
                "-or-",
                "<size=+10><color=#f4eb41>1 Identify Scrolls</color></size>",
                "<size=-3>({3} remaining)</size>"
                ).Format2(gemsCost, gemsType, gemsLeft, CurrencyTypes.SCROLLS_IDENTIFY.GetAmount()),
            "USE\n" + gemsType, "USE\nSCROLLS"
            ).Then(answer => {
            if (answer.Contains(gemsType.ToString()))
            {
                AudioManager.Instance.Play(SFX_UI.ShardsChing);
                return(ChangeStatus(ResearchSlotStatus.COMPLETED, gemsType, gemsCost));
            }

            if (!CurrencyTypes.SCROLLS_IDENTIFY.HasEnough(1))
            {
                TimelineTween.ShakeError(this.gameObject);
                traceError("Unsufficient Identify Scrolls.");
                return(null);
            }

            AudioManager.Instance.Play(SFX_UI.PageFlip);

            return(ChangeStatus(ResearchSlotStatus.COMPLETED, CurrencyTypes.SCROLLS_IDENTIFY, 1));
        }).Then(slot => {
            if (slot == null)
            {
                return;
            }
            trace("Slot should now be set to COMPLETED!");
            trace(slot.status);

            Btn_CompletedIdentifying();
        })
        .Catch(err => {
            traceError("Could not mark the slot as COMPLETED: " + GameAPIManager.GetErrorMessage(err));
        });
    }
Exemple #7
0
 public void Btn_Back()
 {
     API.Explorations.Update(data)
     .Then(res => {
         trace("Successfully updated ActiveExploration!");
         trace(res.pretty);
         BackToCamp();
     })
     .Catch(err => {
         traceError("Error updating the ActiveExploration: " + GameAPIManager.GetErrorMessage(err));
         BackToCamp();
     });
 }
    void ActivateBoost(HeaderBoostDisplay boostChoice)
    {
        if (BoostCanvasGroup.alpha != 1)
        {
            return;
        }

        var slots      = PlayerManager.Instance.BoostsSlotsActive;
        var slotUnused = slots.Find(slot => slot.data == null);

        //Do an early currency check (client-side), it also checks server-side for HACKERZ! :D
        var boostCurrency = boostChoice.boostData.ToCurrencyType();
        int boostAmount   = boostCurrency.GetAmount();

        if (slotUnused == null || boostAmount <= 0)
        {
            TimelineTween.ShakeError(boostChoice.gameObject);
            return;
        }

        trace("Activating boost!");
        trace(boostChoice.boostData);

        BoostCanvasGroup.alpha = 0.5f;

        API.Users.BoostActivate(slotUnused.slotID, boostChoice.boostData)
        .Then(res => {
            boostChoice.UpdateNumLeft();
            BoostCanvasGroup.alpha = 1;
            RefreshBoostSlots();
        })
        .Catch(err => {
            traceError("Could not activate boost: " + GameAPIManager.GetErrorMessage(err));
            TimelineTween.ShakeError(boostChoice.gameObject);
            BoostCanvasGroup.alpha = 1;
        });
    }
    public void Btn_Explore()
    {
        Debug.Log("Explore Act " + act.ActNumber + " Zone " + _currentZone);
        ZoneData data = DataManager.Instance.GetZonesByActAndZoneID(act.ActNumber, _currentZone + 1, btnDifficulty.selected.AsEnum <ZoneDifficulty>());

        if (selectedPartyMembers.Count < 1)
        {
            TimelineTween.ShakeError(btnExplore.gameObject);
            traceError("No party selected.");
            return;
        }
        else if (data == null)
        {
            TimelineTween.ShakeError(btnExplore.gameObject);
            traceError("No Zone Data or Zone Data is Null.");
            return;
        }

        PlayerManager.Instance.StartExplore(data, selectedPartyMembers)
        .Then(res => {
            buttonLabel.text        = "Active";
            btnExplore.interactable = false;
        })
        .Catch(err => {
            traceError(GameAPIManager.GetErrorMessage(err));
            TimelineTween.ShakeError(btnExplore.gameObject);
        });

        HideParty();
        if (BackButton != null)
        {
            BackButton.interactable = true;
        }

        exploreInterface.HideZoneDetails();
    }
    public IPromise <NodeResponse> StartExplore(ZoneData zone, List <Hero> party)
    {
        return(API.Explorations.StartExploring(zone, party, DateTime.Now)
               .Then(res => {
            foreach (Hero hero in party)
            {
                if (hero == null)
                {
                    continue;
                }
                hero.ExploringActZone = zone.ActZoneID;
            }

            //This should add the explorations to the DataManager's allExplorationList automatically.
            var exploration = dataMan.ProcessExplorationData(res["exploration"]);

            if (signals.OnExploreStarted != null)
            {
                signals.OnExploreStarted(exploration);
            }
        })
               .Catch(err => {
            traceError("Failed to Start Exploring ActZoneID #" + zone.ActZoneID + ": " + GameAPIManager.GetErrorMessage(err));
            traceError(err.StackTrace);
        }));
    }