예제 #1
0
    //update player quest when they are completed
    private IEnumerator UpdatePlayerQuests(QuestPlayerData q)
    {
        PlayerQuestUpdateInProgress = true;
        string playerQuestToJson = q.SaveToString();
        //Debug.Log(playerQuestToJson);

        WWWForm form = new WWWForm();

        form.AddField("myform_hash", hash);
        form.AddField("myform_playerquest", playerQuestToJson);

        using (WWW w = new WWW(website + updatePlayerQuestUrl, form))
        {
            yield return(w);

            if (w.error != null)
            {
                Debug.Log(w.error); //if there is an error, tell us
            }
            else
            {
                //Debug.Log("www player quest update ok");
                //Debug.Log("php: " + w.text); //here we return the data our PHP told us
            }
        }
        PlayerQuestUpdateInProgress = false;
    }
예제 #2
0
    private IEnumerator AddNewPlayerQuests(QuestPlayerData q)
    {
        string playerQuestToJson = q.SaveToString();
        //Debug.Log(playerQuestToJson);

        WWWForm form = new WWWForm();

        form.AddField("myform_hash", hash);
        form.AddField("myform_playerquest", playerQuestToJson);

        using (WWW w = new WWW(website + addPlayerQuestUrl, form))
        {
            yield return(w);

            if (w.error != null)
            {
                Debug.Log(w.error); //if there is an error, tell us
            }
            else
            {
                Debug.Log("www player quest addition in the database ok");
                Debug.Log("php: " + w.text); //here we return the data our PHP told us

                //reload players quests in order to get proper id.
                StartGettingPlayerQuestId(q);
            }
        }
    }
예제 #3
0
        private void InitializeClasses()
        {
            try
            {
                Equipment     = new Equipment(this);
                Statistics    = World.DatabaseManager.LoadStatistics(this);
                Information   = new Information(this);
                State         = new State(this);
                Storage       = new Storage(this);
                Boosters      = World.DatabaseManager.LoadBoosters(this);
                Abilities     = Hangar.Ship.Abilities(this);
                Settings      = new Settings(this);
                Skylab        = World.DatabaseManager.LoadSkylab(this);
                Pet           = World.DatabaseManager.LoadPet(this);
                QuestData     = new QuestPlayerData(this);
                Announcements = new Announcements(this);
                Gates         = new PlayerGates(this);
                World.DatabaseManager.SavePlayerHangar(this, Hangar);
            }
            catch (Exception exception)
            {
                // getting rid of user
                Console.WriteLine("Exception found.. Disconnecting user");
                Console.WriteLine("Exception: " + exception + ";" + exception.StackTrace + ";" + exception.Message);

                var session = GetGameSession();
                if (session != null)
                {
                    session.Kick();
                }
                else
                {
                    Invalidate();
                }
            }
        }
예제 #4
0
    //update player quest when they are completed
    private IEnumerator GettingPlayerQuestId(QuestPlayerData q)
    {
        WWWForm form = new WWWForm();

        form.AddField("myform_hash", hash);
        form.AddField("myform_playerid", q.player_id);
        form.AddField("myform_idquest", q.id_quest);

        using (WWW w = new WWW(website + getPlayerQuestId, form))
        {
            yield return(w);

            if (w.error != null)
            {
                Debug.Log(w.error); //if there is an error, tell us
            }
            else
            {
                Debug.Log("www get quest id ok");
                Debug.Log("php: " + w.text); //here we return the data our PHP told us
                q.id_quest_player = int.Parse(w.text);
            }
        }
    }
예제 #5
0
    //new version edited by Edwige
    void initiateQuest()
    {
        int questID = 0;

        //make quest text box appear
        txtBox.GetComponent <Image>().enabled = true;

        //if this is a not a new player (else questID stays to 0)
        if (myQuestPlayerData.Count == 0)
        {
            questID = 0;
            //Debug.Log("new player, quest id=0");
        }
        else
        {
            bool activeQuest = false;
            //check if there is an active quest
            for (int i = 0; i < myQuestPlayerData.Count; i++)
            {
                if (!myQuestPlayerData[i].quest_completed)
                {
                    questID     = myQuestPlayerData[i].id_quest;
                    activeQuest = true;
                    //Debug.Log("we found an active quest, displaying it");
                }
            }

            if (!activeQuest)
            {
                //Debug.Log("no active quest, finding next appropriate one");

                //are we still doing tutorial? if yes, which quest
                bool tutorialFinished = false;
                int  currentTuto      = 0;
                int  tempTuto         = 0;

                for (int i = 0; i < myQuestPlayerData.Count; i++)
                {
                    //check if last tutorial quest is finished
                    //# to change if we add tutorial quest
                    if (myQuestPlayerData[i].id_quest == 4 && myQuestPlayerData[i].quest_completed)
                    {
                        tutorialFinished = true;
                        //Debug.Log("tutorialFinished");
                    }
                    else
                    {
                        for (int j = 0; j < quests.Count; j++)
                        {
                            //looking for highest tutorial quest completed
                            if (quests[j].id_quest == myQuestPlayerData[i].id_quest && quests[j].tutorialQuestNumber > currentTuto && myQuestPlayerData[i].quest_completed)
                            {
                                tempTuto = quests[j].id_quest;
                                currentTuto++;
                            }
                        }
                    }
                }

                if (!tutorialFinished)
                {
                    questID = tempTuto + 1;
                    //Debug.Log("tutorial not finished, giving quest questID");
                }
                else
                {
                    //gives other quests
                    //# caution: doesn't check the player has the right object in the inventory nor a way to get it
TryAgain:
                    questID = Random.Range(0, quests.Count);
                    //Debug.Log("giving random later quest");
                    if (quests[questID].tutorialQuestNumber != 0)
                    {
                        //Debug.Log("still tuto, trying again");
                        goto TryAgain;
                    }
                }
            }
        }

        //Ed: add new quest of type questID to the myQuestPlayerData list.
        ConnectionInfosObject = GameObject.Find("ConnectionInfos");
        if (ConnectionInfosObject)
        {
            QuestPlayerData q = new QuestPlayerData();
            q.player_id       = ConnectionInfosObject.GetComponent <ConnectionInfo>().myPlayersData.playerId;
            q.id_quest        = quests[questID].id_quest;
            q.quest_completed = false;
            q.begin_date      = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            myQuestPlayerData.Add(q);
            //save to DB
            ConnectionInfosObject.GetComponent <Connecting>().StartAddNewPlayerQuests(q);
        }

        //check what kind of quest is it

        //get item?
        if (quests[questID].kindOfQuest == 0)
        {
            //Debug.Log("get stuff");
            ItemQuest(questID);
        }
        //get to ratio?
        if (quests[questID].kindOfQuest == 1)
        {
            //Debug.Log("get ratio");
            RatioQuest(questID);
        }
        //get to level?
        if (quests[questID].kindOfQuest == 2)
        {
            Debug.LogError("get to level quests not implemented yet");
            LevelQuest(questID);
        }
        //use item?
        if (quests[questID].kindOfQuest == 3)
        {
            if (quests[questID].objectiveItem == "Inspector")
            {
                inspectorUsed = false;
                newQuest      = false;
                questText.GetComponent <Text>().enabled = true;
                questText.text = quests[questID].questLore + "\n\nUse <b>" + System.Text.RegularExpressions.Regex.Replace(quests[questID].objectiveItem, "[A-Z]", " $0") + ".</b>";

                quests[questID].active = true;
                //Debug.LogError("You forgot to put reference to function in inspector use function in UIManager... probably.\nMay God have mercy on you, wretched creature.");
                return;
            }

            /*check if there's another type 3 quest active, if there is, everything goes to shit, so it just sends an error ¯\_(ツ)_/¯
             * TODO find a way to have multiple type 3 quests active at the same time*/
            foreach (var quest in quests)
            {
                if (quest.active && quest.kindOfQuest == 3)
                {
                    Debug.LogError("EVERYTHING IS BROKEN!!!\n RUUUUUUN!!!\n There are too many (more then one) 'use item' quests active. The time has come to figure out how to have more then one at the same time.");
                }
            }
            //Debug.Log("use items");
            UseItemsQuest(questID);
        }
        newQuest = false;
        //Debug.Log(newQuest);
    }
예제 #6
0
 public void StartGettingPlayerQuestId(QuestPlayerData q)
 {
     Debug.Log("StartGettingPlayerQuestId began");
     StartCoroutine(GettingPlayerQuestId(q));
 }
예제 #7
0
 public void StartUpdatePlayerQuests(QuestPlayerData q)
 {
     Debug.Log("StartUpdatePlayerQuests began");
     StartCoroutine(UpdatePlayerQuests(q));
 }
예제 #8
0
 public void StartAddNewPlayerQuests(QuestPlayerData q)
 {
     Debug.Log("StartAddNewPlayerQuests began");
     StartCoroutine(AddNewPlayerQuests(q));
 }