void CreateManagerQuest()
    {
        Dictionary <string, int> questItems = new Dictionary <string, int>();
        List <Item> items = ItemManager.instance.itemsData.Items.FindAll((item) => item.Unlocked && item.IsSellable());

        for (int i = 0; i < ManagerQuest.amountOfItems; i++)
        {
            int  randomIndex = UnityEngine.Random.Range(0, items.Count);
            Item item        = items[randomIndex];
            while (questItems.ContainsKey(item.ItemNameKey))
            {
                randomIndex = (randomIndex + 1) % items.Count;
                item        = items[randomIndex];
            }

            questItems.Add(item.ItemNameKey, UnityEngine.Random.Range(1, ManagerQuest.maxItemQuantity));
        }

        managerQuest = new ManagerQuest(questItems, DateTime.Today.ToString(dateFormat));

        LogsManager.SendLogDirectly(new Log(
                                        LogType.ManagerQuestCreated,
                                        new Dictionary <string, string>()
        {
            { "itemsToSell", JsonConvert.SerializeObject(questItems) }
        }
                                        ));
    }
Exemplo n.º 2
0
    public void SendNewOracleData()
    {
        oracleDataLog.Add(oracleData);
        LogsManager.SendLogDirectly(new Log(
                                        LogType.GotOracleInfo,
                                        new Dictionary <string, string>()
        {
            { "itemName", oracleData.itemName },
            { "hour", (oracleData.bestPriceIndex * 3).ToString() },
            { "maxHour", (oracleData.bestPriceIndex * 3 + 3).ToString() }
        }
                                        ));

        string json = JsonConvert.SerializeObject(oracleDataLog);

        FirebaseCommunicator.instance.SendObject(json, new string[] { oracleReferenceName, FirebaseCommunicator.instance.FamilyId.ToString(), DateTime.Today.ToString(dateFormat) }, (task) =>
        {
            if (task.IsFaulted)
            {
                Debug.LogError("Failed to send oracle data: " + task.Exception.Message);
            }
            else if (task.IsCompleted)
            {
                Debug.Log("yey sent oracle data");
            }
        });
    }
Exemplo n.º 3
0
    protected override void ActivateZone()
    {
        base.ActivateZone();

        LogsManager.SendLogDirectly(new Log(
                                        LogType.SecretDoorInteracted,
                                        null
                                        ));

        if (!doorTime.IsDecrypted())
        {
            // Door still hasn't been requested or expired
            if (!doorTime.IsValid() || doorTime.HasExpired())
            {
                CreateNewRequest();

                SendDoorTime(doorTime);
            }
            else
            {
                Debug.Log("Already requested!");
            }
        }

        if (!doorTime.unlocked)
        {
            secretDoorUI.Init(this);
        }
    }
Exemplo n.º 4
0
 private void OnSceneUnloaded(Scene arg0)
 {
     LogsManager.SendLogDirectly(new Log(
                                     LogType.SceneUnloaded,
                                     new Dictionary <string, string>()
     {
         { "scene", arg0.name }
     }
                                     ));
 }
Exemplo n.º 5
0
    public void SuccessfulMission()
    {
        LogsManager.SendLogDirectly(new Log(LogType.MissionSuccess, null));
        UpdateBaseDifficulty(difficultyWinModifier);

        stats.stats.numberOfMissions++;
        stats.stats.numberOfSuccessfulMissions++;

        UpdateStats();
    }
Exemplo n.º 6
0
    public void FailedMission()
    {
        LogsManager.SendLogDirectly(new Log(LogType.MissionFail, null));
        UpdateBaseDifficulty(difficultyDeathModifier);

        stats.stats.numberOfMissions++;
        stats.stats.numberOfDeaths++;

        UpdateStats();
    }
    IEnumerator LateStart()
    {
        yield return(new WaitForSeconds(0.1f));

        LogsManager.SendLogDirectly(new Log(LogType.MissionStart, new Dictionary <string, string>()
        {
            { "Class", GameManager.instance.currentSelectedClass.ClassName }
        }));
        MissionStarted.Invoke(LanternTimeLimit);
    }
 private void OnPlayerEnteredRoomFirstTime()
 {
     LogsManager.SendLogDirectly(new Log(
                                     LogType.RoomExplored,
                                     new Dictionary <string, string>()
     {
         { "RoomName", gameObject.name },
         { "RoomType", type.ToString() }
     }
                                     ));
 }
    public void Logout()
    {
        PlayerPrefs.DeleteKey(PlayerSettingsKeys.familyId);
        FileUtils.DeleteFile(FileUtils.GetPathToPersistent(FirebaseCommunicator.familyIDSavePath));

        IsLoggedIn = false;
        LogsManager.SendLogDirectly(new Log(
                                        LogType.LoggedOut,
                                        null
                                        ));
    }
Exemplo n.º 10
0
 internal void Check()
 {
     IsChecked = true;
     LogsManager.SendLogDirectly(new Log(
                                     LogType.ManagerQuestChecked,
                                     new Dictionary <string, string>()
     {
         { "StartDay", StartDay }
     }
                                     ));
 }
Exemplo n.º 11
0
    private void Start()
    {
        LogsManager.SendLogDirectly(new Log(
                                        LogType.GameStarted,
                                        new Dictionary <string, string>(),
                                        DateTime.Now
                                        ));

        // Setup listener for new missions
        FirebaseCommunicator.instance.SetupListenForChildAddedEvents(new string[] { Mission.firebaseReferenceName, FirebaseCommunicator.instance.FamilyId.ToString() }, OnMissionAdded);
    }
    private void OnApplicationQuit()
    {
#if UNITY_EDITOR
        var db = FirebaseDatabase.DefaultInstance;
        db.SetPersistenceEnabled(false);
#endif

        LogsManager.SendLogDirectly(new Log(
                                        LogType.GameQuit,
                                        null
                                        ));
    }
Exemplo n.º 13
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (targetHealth == null)
        {
            targetHealth = other.GetComponent <Health>();
        }

        LogsManager.SendLogDirectly(new Log(
                                        LogType.HealingReceived,
                                        null
                                        ));
    }
Exemplo n.º 14
0
    public void Interact()
    {
        if (anim.GetCurrentAnimatorStateInfo(0).shortNameHash == animInteractedClipHash)
        {
            return;
        }

        Debug.Log("Interacted!");
        interactionsLeft--;
        if (interactionsLeft <= 0)
        {
            string itemName;

            if (gatherableItem == null)
            {
                itemName = "Basic Mushroom";
            }
            else
            {
                itemName = gatherableItem.ItemNameKey;
            }

            LogsManager.SendLogDirectly(new Log(
                                            LogType.MushroomCollected,
                                            new Dictionary <string, string> {
                { "ItemName", itemName }
            }
                                            ));

            if (DiseasedManager.instance.DiseasedItem != null)
            {
                if (DiseasedManager.instance.DiseasedItem.ItemNameKey == itemName)
                {
                    LogsManager.SendLogDirectly(new Log(
                                                    LogType.DiseasedItemCollected,
                                                    new Dictionary <string, string> {
                        { "ItemName", itemName }
                    }
                                                    ));
                }
            }

            InventoryManager.instance.AddItem(itemName, 1);
            Debug.Log("Collected gatherable!");
            Destroy(gameObject);
        }
        else
        {
            Debug.Log($"Got interacted once! {interactionsLeft} interactions left");
            anim.SetTrigger(animInteractedClipHash);
        }
    }
Exemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Player1_Shoot") && !MoreMountains.TopDownEngine.GameManager.Instance.Paused)
     {
         LogsManager.SendLogDirectly(new Log(
                                         LogType.AttackPerformed,
                                         new Dictionary <string, string>()
         {
             { "Attacker", character.name }
         }
                                         ));
     }
 }
Exemplo n.º 16
0
    public void CompleteQuest()
    {
        LogsManager.SendLogDirectly(new Log(
                                        LogType.AdventurerQuestSuccess,
                                        new Dictionary <string, string>()
        {
            { "questItems", JsonConvert.SerializeObject(itemQuantity) }
        }
                                        ));

        IsCompleted = true;
        IsChecked   = false;
    }
    private void OnEnable()
    {
        // exitButton.gameObject.SetActive(true);
        foreach (Transform child in layoutGroup)
        {
            Destroy(child.gameObject);
        }

        foreach (var characterClass in possibleStartingClasses)
        {
            var classSelect = Instantiate(classSelectButton, layoutGroup);

            var toggle = classSelect.GetComponent <Toggle>();
            if (!characterClass.Unlocked)
            {
                classSelect.Init(characterClass.ClassName, lockedClassSprite, lockedIconColor);
                toggle.interactable = false;
            }
            else
            {
                classSelect.Init(characterClass.ClassName, characterClass.initialWeapon.GetComponentInChildren <SpriteRenderer>().sprite);
                toggle.interactable = true;

                if (GameManager.instance.currentSelectedClass == characterClass)
                {
                    toggle.isOn = true;
                }
            }

            toggle.group = layoutGroup.GetComponent <ToggleGroup>();

            toggle.onValueChanged.AddListener((isOn) =>
            {
                if (isOn)
                {
                    LogsManager.SendLogDirectly(new Log(
                                                    LogType.ClassSelected,
                                                    new Dictionary <string, string>()
                    {
                        { "Class", characterClass.ClassName }
                    }
                                                    ));

                    GameManager.instance.currentSelectedClass = characterClass;
                }
            });
        }

        classSelectTitleText.text = Localisation.Get(classSelectTitleTextKey);
    }
Exemplo n.º 18
0
    protected override void Pick(GameObject picker)
    {
        LogsManager.SendLogDirectly(new Log(
                                        LogType.BuffCollected,
                                        new Dictionary <string, string>()
        {
            { "buff", buffToGive.name }
        }
                                        ));

        CharacterClass characterClass = picker.GetComponent <CharacterClass>();

        characterClass.AddBuff(buffToGive);
    }
Exemplo n.º 19
0
 private void Update()
 {
     // very lazy way to do this.
     if (MoreMountains.TopDownEngine.GameManager.Instance.Paused && !alreadyDetectedPause)
     {
         alreadyDetectedPause = true;
         LogsManager.SendLogDirectly(new Log(
                                         LogType.Paused
                                         ));
     }
     else if (!MoreMountains.TopDownEngine.GameManager.Instance.Paused)
     {
         alreadyDetectedPause = false;
     }
 }
Exemplo n.º 20
0
    private void OnEnable()
    {
        closeButton.gameObject.SetActive(true);

        LogsManager.SendLogDirectly(new Log(
                                        LogType.NotebookInteracted,
                                        null
                                        ));

        HandleShowDailyQuest();

        HandleShowKingOffering();

        // ShowOracleInfo(); // Can't be here the it is implemented
    }
    private void OnEnable()
    {
        newUnlocksTitleImage.sprite = newUnlocksTitleImageSprites[Localisation.currentLanguage];

        if (unlockLogs != null && unlockLogs.Count > 0)
        {
            LogsManager.SendLogDirectly(new Log(
                                            LogType.AdventurerNewsSeen,
                                            new Dictionary <string, string>()
            {
                { "news", string.Join(",", unlockLogs.Select((log) => log.UnlockableName)) }
            }
                                            ));
        }
    }
Exemplo n.º 22
0
    private void HandleShowKingOffering()
    {
        kingsOfferingTitleImage.sprite = kingsOfferingTitleSprites[Localisation.currentLanguage];

        // destroy childs of offeringLayout
        foreach (Transform item in offeringLayout.transform)
        {
            Destroy(item.gameObject);
        }

        if (OfferingManager.instance != null && OfferingManager.instance.OfferingExists())
        {
            //Show current offering
            Offering offering = OfferingManager.instance.GetCurrentOffering();

            if (offering.offeringMade || offering.HasExpired())
            {
                // TODO: Hide offering
                return;
            }

            string offeringListLog = "";
            foreach (var offeringItem in offering.itemsToOffer)
            {
                offeringListLog += offeringItem + ", ";
            }
            LogsManager.SendLogDirectly(new Log(
                                            LogType.KingOfferingChecked,
                                            new Dictionary <string, string>()
            {
                { "offering", offeringListLog },
                { "endDay", DateTime.Today.ToString("dd-MM-yyyy") }
            }
                                            ));

            foreach (var itemName in offering.itemsToOffer)
            {
                Item        itemToOffer = ItemManager.instance.itemsData.GetItemByName(itemName);
                ItemSmallUI itemUI      = Instantiate(kingsOfferingItemSmallUIPrefab);
                itemUI.transform.SetParent(offeringLayout.transform, false);
                itemUI.InitWithoutQuantity(itemToOffer);
            }
        }
        else
        {
            //Show offering not available info
        }
    }
Exemplo n.º 23
0
    // private void Start()
    // {
    // }

    protected override void Pick(GameObject picker)
    {
        base.Pick(picker);
        InventoryManager.instance.AddItem(item.ItemNameKey, amount);

        LogsManager.SendLogDirectly(new Log(
                                        LogType.LootCollected,
                                        new Dictionary <string, string>()
        {
            { "Item", item.ItemNameKey },
            { "Amount", amount.ToString() }
        }
                                        ));

        Destroy(gameObject);
    }
Exemplo n.º 24
0
    // Start is called before the first frame update
    public void Interact()
    {
        if (wasOpened)
        {
            return;
        }

        Debug.Log("Interacted!");

        LogsManager.SendLogDirectly(new Log(
                                        LogType.LootChestCollected,
                                        null
                                        ));

        InventoryManager.instance.AddItem(chestLoot.ItemNameKey, itemQuantity);
        Debug.Log("Collected chest!");
        chestClosed.SetActive(false);
        chestOpen.SetActive(true);
    }
Exemplo n.º 25
0
    private void OnSceneLoaded(Scene scene, LoadSceneMode arg1)
    {
        LogsManager.SendLogDirectly(new Log(
                                        LogType.SceneLoaded,
                                        new Dictionary <string, string>()
        {
            { "scene", scene.name }
        }
                                        ));

        if (scene.buildIndex == 1)
        {
            if (justFinishedMission)
            {
                Debug.Log("Arrived from mission");
                justFinishedMission = false;
                MenuManager.instance.ShowUnlocksProgessPopup();
            }
        }
    }
Exemplo n.º 26
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        LogsManager.SendLogDirectly(new Log(
                                        LogType.OracleInteracted,
                                        new Dictionary <string, string>()
        {
            { "itemName", data.itemName },
            { "hour", (data.bestPriceIndex * 3).ToString() },
            { "maxHour", (data.bestPriceIndex * 3 + 3).ToString() }
        }
                                        ));

        // SHow tooltip
        tooltip.Show(data);
        OracleManager.Instance.SendNewOracleData();


        // Play sound
        AudioSource.PlayClipAtPoint(onOracleActivatedSound, transform.position);
    }
Exemplo n.º 27
0
    private void OnPlayerEnteredRoom()
    {
        LogsManager.SendLogDirectly(new Log(
                                        LogType.RoomEntered,
                                        new Dictionary <string, string>()
        {
            { "RoomName", gameObject.name },
            { "RoomType", type.ToString() }
        }
                                        ));

        if (Type == RoomType.Enemies && closeDoorsUntilRoomIsCleared && !roomCleared)
        {
            foreach (var exit in activeExits)
            {
                exit.gameObject.SetActive(false);
            }
        }

        RoomEntered.Invoke(this);
    }
Exemplo n.º 28
0
    private void SubmitCode(string codeText)
    {
        if (secretDoor != null)
        {
            // Parse arg0 to int
            int code = 0;
            if (int.TryParse(codeText, out code))
            {
                if (secretDoor.SubmitCode(code))
                {
                    // Success
                    LogsManager.SendLogDirectly(new Log(
                                                    LogType.CorrectCodeInserted,
                                                    null
                                                    ));

                    DisableAll();
                }
                else
                {
                    // Failed
                    LogsManager.SendLogDirectly(new Log(
                                                    LogType.WrongCodeInserted,
                                                    null
                                                    ));

                    passCodeField.text = "";
                }
            }
            else
            {
                LogsManager.SendLogDirectly(new Log(
                                                LogType.WrongCodeInserted,
                                                null
                                                ));
                passCodeField.text = "";
            }
        }
    }
    public IEnumerator LoginAnonymously()
    {
        var task = new YieldTask <Firebase.Auth.FirebaseUser>(auth.SignInAnonymouslyAsync());

        yield return(task);

        if (task.Task.IsCanceled)
        {
            Debug.LogError("Sign in canceled");
            yield break;
        }

        if (task.Task.IsFaulted)
        {
            Debug.LogError("Error Signing in: " + task.Task.Exception);
            yield break;
        }

        var user = task.Task.Result;

        if (user == null)
        {
            Debug.LogError("Unknown error signing in!");
            yield break;
        }

        User = user;

        Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
        IsLoggedIn = true;
        LoggedIn.Invoke();

        LogsManager.SendLogDirectly(new Log(
                                        LogType.LoggedIn,
                                        null
                                        ));

        yield break;
    }
Exemplo n.º 30
0
    private void ShowOfferingIfNotNotified()
    {
        OfferingManager.Offering offering = OfferingManager.instance.GetCurrentOffering();

        if (!offering.wasNotified)
        {
            string offeringListLog = "";
            foreach (var offeringItem in offering.itemsToOffer)
            {
                offeringListLog += offeringItem + ", ";
            }
            LogsManager.SendLogDirectly(new Log(
                                            LogType.KingOfferingReceived,
                                            new Dictionary <string, string>()
            {
                { "offering", offeringListLog },
                { "endDay", DateTime.Today.ToString("dd-MM-yyyy") }
            }
                                            ));

            offeringParent.gameObject.SetActive(true);

            foreach (Transform child in offeringLayout)
            {
                Destroy(child.gameObject);
            }

            foreach (string itemName in offering.itemsToOffer)
            {
                Item item = ItemManager.instance.itemsData.GetItemByName(itemName);
                Instantiate(itemUIPrefab, offeringLayout).Init(item.sprite, item.ItemNameKey, 1);
            }
        }
        else
        {
            offeringParent.gameObject.SetActive(false);
        }
    }