IEnumerator SaveConversation(GameObject npc) { AdventureMeta meta = BaseSaver.getAdventure(); //meta.playerPos = new PosMeta(transform.position); NPCMain trainerMain = npc.GetComponent <NPCMain>(); if (trainerMain.meta.infiniteTrainer) { meta.trainer = trainerMain.getInfiniteMeta(meta); } else { meta.trainer = trainerMain.getRefinedMeta(); } meta.trainer.pos = new PosMeta(npc.transform.position); meta.wild = null; meta.isTrainerEncounter = true; Debug.Log(meta.ToString()); Debug.Log(meta.trainer.ToString()); BaseSaver.putAdventure(meta); BaseSaver.putBoard(GameUtilities.getBoardState(BaseSaver.getMap(), new PosMeta(transform.position))); yield return(null); }
public Dialogue(NPCMain npc) { check("|i|", getItem); check("|I|", getItems); check("|t|", getTime); this.npc = npc; }
public void init(Quest quest) { GameObject quest_UI = this.transform.parent.parent.parent.gameObject; questInformationData = quest_UI.transform.GetChild(0).GetComponent <QuestInformationData>(); this.quest = quest; GameObject questInformation = this.transform.parent.parent.parent.GetChild(0).gameObject; this.questObjectiveWrapper = questInformation.transform.GetChild(questInformation.transform.childCount - 1).gameObject; this.questName = questInformation.transform.GetChild(questInformation.transform.childCount - 2).GetChild(1).GetComponent <Text>(); Debug.Log("QNAME: " + questInformation.name); this.questInformationDescription = questInformation.transform.GetChild(1).gameObject; this.questObjective = questObjectiveWrapper.transform.GetChild(0).gameObject; RectTransform r = questObjective.GetComponent <RectTransform>(); for (int i = 0; i < quest.getCompletionData().completionId.Count; i++) { GameObject o = Instantiate(questObjective); o.transform.SetParent(questObjectiveWrapper.transform); RectTransform rectTransform = o.GetComponent <RectTransform>(); rectTransform.localPosition = r.localPosition; rectTransform.localPosition -= new Vector3(0, 40 * i, 0); rectTransform.sizeDelta = r.sizeDelta; Image im = o.GetComponent <Image>(); Sprite[] sprites = Resources.LoadAll <Sprite>("spritesheet_MonsterIcons"); if (sprites[quest.getImageIndex()] != null) { im.sprite = sprites[quest.getImageIndex()]; } im.enabled = false; Text t = o.GetComponentInChildren <Text>(); t.enabled = false; this.questObjectiveImages.Add(im); this.questObjectiveTexts.Add(t); } this.npcController = GameObject.FindWithTag("NPCManager").GetComponent <NPCController>(); this.questGiver = npcController.getNpcWithQuest(this.getQuest()); Destroy(this.questObjective); }
public void initilize(Player player) { this.player = player; UI = player.getUI(); questGiverObject = player.getQuestInformationData().transform.GetChild(3).GetChild(0).gameObject; img = questGiverObject.GetComponent <Image>(); wrapper = player.getQuestInformationData().questWrapper.GetComponent <QuestWrapper>(); for (int i = 0; i < npcs.Length; i++) { NPCMain main = npcs[i].GetComponent <NPCMain>(); main.uniqueId = i; main.dialogueUI_questDescription = this.dialogueUI_questDescription; main.dialogueUI_questGiverFace = this.dialogueUI_questGiverFace; main.dialogueUI_questGiverName = this.dialogueUI_questGiverName; main.dialogueUI = this.dialogueUI; main.gameObject.SetActive(true); npcMain.Add(main); } }
public void setActiveNPC(NPCMain npc) { currentNPC = npc; }
public void startNewDialogue(string fullstring, float delayBetweenCharacters, int type, NPCMain npc) { queuedDialogues.Add(new Message(this, fullstring, delayBetweenCharacters, type, false)); }
void onLoadCharacter(NetworkMessage msg) { Debug.Log("Character pre- loaded"); PlayerInfo m = msg.ReadMessage <PlayerInfo>(); PlayerNetworkObject[] otherPlayers = (PlayerNetworkObject[])Tools.byteArrayToObject(m.otherPlayers); equipOtherPlayers(otherPlayers); PlayerStats stats = (PlayerStats)Tools.byteArrayToObject(m.stats); this.player.updateStats(stats); List <Equip> equipments = (List <Equip>)(Tools.byteArrayToObject(m.equipment)); List <Item> inventory = (List <Item>)(Tools.byteArrayToObject(m.items)); List <string> color = (List <string>)(Tools.byteArrayToObject(m.color)); this.player.setInventory(inventory); this.player.setEquips(equipments); this.player.setColor(color); for (int i = 0; i < equipments.Count; i++) { if (equipments[i] == null) { continue; } if (equipments[i].getID().isItemType(e_itemTypes.HATS) || equipments[i].getID().isItemType(e_itemTypes.WEAPON)) { this.player.setEquipModel(equipments[i]); } else { this.player.setClothesModel(equipments[i]); } } GameObject playerObj = ClientScene.FindLocalObject(m.id); Player player; if (playerObj != null) { player = playerObj.GetComponent <Player>(); } else { player = this.GetComponent <Player>(); } Quest[] questArray = (Quest[])Tools.byteArrayToObjectArray(m.questClasses); QuestJson clientJson = JsonManager.readJson <QuestJson>(e_Paths.JSON_QUESTS); foreach (Quest quest in questArray) { startQuest(quest); } GameObject[] objects = GameObject.FindGameObjectsWithTag("NPC"); foreach (GameObject o in objects) { NPCMain main = o.GetComponent <NPCMain>(); main.setQuestMarker(this.player); } //Initilize skill tree List <Skill> skillsToVerifyFromServer = new List <Skill>(); for (int i = 2; i < m.skillProperties.Length; i += 3) { Skill tempSkill = new Skill(); tempSkill.id = m.skillProperties[i - 2]; //skillId tempSkill.currentPoints = m.skillProperties[i - 1]; //currentPoints tempSkill.maxPoints = m.skillProperties[i]; //maxPoints this.player.skillsToVerifyWithFromServer.Add(tempSkill); } foreach (Skill s in skillsToVerifyFromServer) { this.player.stats.increment(s.str, s.dex, s.intell, 0, 0, 0, 0, 0, 0, 0, this.player.uiStats); } Debug.Log("Character loaded"); skillTree = Instantiate(skillTreePrefab).GetComponent <SkillTree> (); skillTree.initilize(player); this.transform.position = new Vector3(-30, 0, 16); }