private Dialouge getDia(Event.Talk curTalk) { if (curDia == null) { curDia = new Dialouge(curTalk.dialouge, curTalk.image, curTalk.pitch); } return(curDia); }
internal override Event ReadEntry(BinaryReaderEx br) { EventType type = br.GetEnum32 <EventType>(br.Position + 0xC); switch (type) { case EventType.Treasure: var treasure = new Event.Treasure(br); Treasures.Add(treasure); return(treasure); case EventType.Generator: var generator = new Event.Generator(br); Generators.Add(generator); return(generator); case EventType.ObjAct: var objAct = new Event.ObjAct(br); ObjActs.Add(objAct); return(objAct); case EventType.MapOffset: var mapOffset = new Event.MapOffset(br); MapOffsets.Add(mapOffset); return(mapOffset); case EventType.WalkRoute: var walkRoute = new Event.WalkRoute(br); WalkRoutes.Add(walkRoute); return(walkRoute); case EventType.GroupTour: var groupTour = new Event.GroupTour(br); GroupTours.Add(groupTour); return(groupTour); case EventType.Event17: var event17 = new Event.Event17(br); Event17s.Add(event17); return(event17); case EventType.Event18: var event18 = new Event.Event18(br); Event18s.Add(event18); return(event18); case EventType.Event20: var event20 = new Event.Event20(br); Event20s.Add(event20); return(event20); case EventType.Event21: var event21 = new Event.Event21(br); Event21s.Add(event21); return(event21); case EventType.PartsGroup: var partsGroup = new Event.PartsGroup(br); PartsGroups.Add(partsGroup); return(partsGroup); case EventType.Talk: var talk = new Event.Talk(br); Talks.Add(talk); return(talk); case EventType.AutoDrawGroup: var autoDrawGroup = new Event.AutoDrawGroup(br); AutoDrawGroups.Add(autoDrawGroup); return(autoDrawGroup); case EventType.Other: var other = new Event.Other(br); Others.Add(other); return(other); default: throw new NotImplementedException($"Unimplemented model type: {type}"); } }
// Update is called once per frame void Update() { if (!fadedIn) { // Fade to screen float theAlpha = blackScreen.GetComponent <SpriteRenderer>().color.a - Time.deltaTime; if (theAlpha < 0) { theAlpha = 0; } speech.color = new Color(1 - theAlpha, 1 - theAlpha, 1 - theAlpha); blackScreen.GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, theAlpha); if (theAlpha == 0) { fadedIn = true; } } // Preform an action until it's done, then move onto the next if (curAction < actionList.Length) { switch (actionList[curAction].getAct()) { case npcAction.TALK: Event.Talk curTalk = actionList[curAction].getTalk(); Dialouge dia = getDia(curTalk); if (dia.isDone()) { dia.resetDia(); delDia(); curAction++; showDisp(); } else { if (Input.GetKeyDown(DataManager.savedOptions.controls[(int)key.B1])) { if (dia.getReadingLine(dia.getLine(), textSpd) == dia.getLine()) { dia.nextLine(); if (!dia.isDone()) { duckSprite[curTalk.duck].GetComponent <SpriteRenderer>().sprite = dia.getSprite(); if (curTalk.animMe != null) { curTalk.animMe.GetComponent <SpriteRenderer>().sprite = dia.getSprite(); } } } else { speech.text = curTalk.name + ": " + dia.getLine(); dia.endLineRead(); } } else { speech.text = curTalk.name + ": " + dia.getReadingLine(dia.getLine(), textSpd); // Play talking sound effect if (dia.IsNewChar()) { mainSFX.GetComponent <AudioSource>().clip = talking[(int)Random.Range(0, talking.Length - 1)]; mainSFX.GetComponent <AudioSource>().pitch = dia.getPitch(); mainSFX.GetComponent <AudioSource>().Play(); } } } break; case npcAction.WALK: Event.Walk curWalk = actionList[curAction].getWalk(); if (moveToTarget(curWalk.walker, curWalk.spot, curWalk.speed)) { curAction++; showDisp(); } else if (curWalk.walker.GetComponent <SpriteRenderer>() != null) { UpdateSprite(curWalk.walker, curWalk.anim, curWalk.fps); } break; case npcAction.ANIM: Event.Anim curAnim = actionList[curAction].getAnim(); if (WaitForXFrames(curAnim.frameAmt)) { curAction++; showDisp(); } else { UpdateSprite(curAnim.animated, curAnim.anim, curAnim.fps); } break; case npcAction.TURN: Event.Turn curTurn = actionList[curAction].getTurn(); curTurn.turner.GetComponent <SpriteRenderer>().sprite = curTurn.theTurn; if (curTurn.flip) { curTurn.turner.transform.localScale = new Vector2(-curTurn.turner.transform.localScale.x, curTurn.turner.transform.localScale.y); } curAction++; showDisp(); break; case npcAction.ENCOUNTER: Event.Encounter curEnc = actionList[curAction].getEnc(); // Play encounter music if (blackScreen.GetComponent <SpriteRenderer>().color.a == 0) { mainSFX.GetComponent <AudioSource>().clip = encMusic; mainSFX.GetComponent <AudioSource>().Play(); } // Fade to black float theAlpha = blackScreen.GetComponent <SpriteRenderer>().color.a + Time.deltaTime; if (theAlpha > 1) { theAlpha = 1; } // Fade text speech.color = new Color(1 - theAlpha, 1 - theAlpha, 1 - theAlpha); blackScreen.GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, theAlpha); if (theAlpha == 1) { if (newPos) { TitleManager.curFile.setLocation(xPos, yPos); } TitleManager.curFile.setScene(nextScene); string foeSetDataPath = curEnc.enemySet; TextAsset set = Resources.Load <TextAsset>(@foeSetDataPath); GameProgress.jankFile setTxt = new GameProgress.jankFile(set); TitleManager.curFile.setEnemySet(readFoes(setTxt)); TitleManager.curFile.setBackground(curEnc.background); TitleManager.curFile.setSound(curEnc.battleMusic); SceneManager.LoadScene("BattleScene", LoadSceneMode.Single); } break; case npcAction.SAVE: saveFile(); curAction++; break; case npcAction.TITLE: if (newPos) { TitleManager.curFile.setLocation(xPos, yPos); } TitleManager.curFile.setScene(nextScene); saveFile(); SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); curAction++; break; case npcAction.PLAYSFX: mainSFX.GetComponent <AudioSource>().clip = actionList[curAction].playSFX; mainSFX.GetComponent <AudioSource>().Play(); curAction++; break; default: break; } } // Load the next scene else { // Fade to black float theAlpha = blackScreen.GetComponent <SpriteRenderer>().color.a + Time.deltaTime; if (theAlpha > 1) { theAlpha = 1; } // Fade text speech.color = new Color(1 - theAlpha, 1 - theAlpha, 1 - theAlpha); blackScreen.GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, theAlpha); if (theAlpha == 1) { DungeonHandler.curState = gameState.OVERWORLD; DungeonHandler.preState = gameState.DIALOUGE; SceneManager.LoadScene(nextScene, LoadSceneMode.Single); } } }