public DramaOutcomePrediction(Drama drama, int crewQtyToSacrifice, float currentHope, int initalShipCrewQty) { // F**k Hope, we do not need THAT ! this.drama = drama; this.crewQtyToSacrifice = crewQtyToSacrifice; this.initalShipCrewQty = initalShipCrewQty; }
static void Main(string[] args) { // New instance of MovieList var movieList = new MovieListFunctions(); //////////////////////////////////////////////// /////////// TEST MOVIES /////////////////////// var starWars = new SciFi("Star Wars"); var pokemon = new Animated("Pokemon"); var it = new Horror("IT"); var scream = new Horror("Scream"); var incredibles = new Animated("Incredibles"); var zootopia = new Animated("Zootopia"); var serenity = new SciFi("Serenity"); var theMatrix = new SciFi("The Matrix"); var fightClub = new Drama("Fight Club"); var seven = new Drama("Seven"); //////////////////////////////////////////////// ///////// TEST LIST OF MOVIES ///////////////// movieList.Add(starWars); movieList.Add(pokemon); movieList.Add(it); movieList.Add(scream); movieList.Add(incredibles); movieList.Add(zootopia); movieList.Add(serenity); movieList.Add(theMatrix); movieList.Add(fightClub); movieList.Add(seven); ////////////////////////////////////////////////// // Sort the movie list alphabetically movieList.Sort((a, b) => a.GetTitle().CompareTo(b.GetTitle())); bool isRunning = true; while (isRunning) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Welcome to the Movie List Application!"); Console.WriteLine("There are 10 movies in this list."); movieList.ListMovieCategories(); Console.Write("What category are you interested in?"); var category = Console.ReadLine(); if (int.TryParse(category, out int validOption) && validOption > 0 && validOption < 5) { movieList.MovieCategoryDisplayList(movieList, validOption); } else { Console.WriteLine("Please enter and option from the menu."); } if (!PlayAgain()) { Console.WriteLine("Have a nice day!"); isRunning = false; } } }
static void PolymorphismExample2() { SciFi sciFi1 = new SciFi("Dark Tower", "Stephan King", 500, 9.8); sciFi1.DisplayBook(); Drama drama1 = new Drama("Enimga Otiliei", "George Calinescu", 230, 8.5); drama1.Display(); drama1.DisplayBook(); Console.ReadKey(); }
/////////////////////// DRAMA REGION #region DRAMA REGION // starts random drama, public void StartDrama() { // drama and outcome generation (accessed through ui) CurrentDrama = Drama.CreateRandomOne(worldState.GetRooms()); Debug.Log(CurrentDrama); if (CurrentDrama.Room.numberOfCrew == 0) { AutomaticResolution(); return; } // only sets phase after all drama stuff has been made panelHandler.ShowChoicePanel(); CurrentPhase = TurnPhases.DRAMA; }
// Use this for initialization void Start() { Scene1 = 0; Scene2 = 0; isLoad = false; isReset = false; Favorability = 0; IsTalking = false; HaveTask = false; isCountdown = false; DS = GameObject.Find("DialogueSystem").GetComponent("DialogueSystem") as DialogueSystem; TS = GameObject.Find("TaskSystem").GetComponent("TaskSystem") as TaskSystem; drama = GameObject.Find("Drama").GetComponent("Drama") as Drama; drama2 = GameObject.Find("Drama2").GetComponent("Drama2") as Drama2; Icon_Task = GameObject.Find("Task"); //Timer = GameObject.Find("Timer"); }
public static void SerializeObjects() { Movie spiderMan = new Movie { Director = "Sam Raimi", Lenght = 98, Title = "Spider-Man", Actors = new[] { "Kirsten Dunst", "Tobey Maguire", "Willem Dafoe" } /*Actors = new List<string> { "Kirsten Dunst", "Tobey Maguire", "Willem Dafoe" }*/ /* new Actor { Name = "Kirsten", Surname = "Dunst", Role = "Mary Jan" }, * new Actor { Name = "Tobey", Surname = "Maguire", Role = "Peter Parker" }, * new Actor { Name = "Willem", Surname = "Dafoe", Role = "Norman Osborn" }, * }*/ }; Drama batman = new Drama() { country = "US", description = "SomeDescription", Title = "Batman", Director = "Bill Gates", Lenght = 21 }; SavaData("SpiderManBinary.dat", spiderMan, SerializeFormatter.Binary); SavaData("batmanBinary.dat", batman, SerializeFormatter.Binary); SavaData("SpiderManSoap.xml", spiderMan, SerializeFormatter.Soap); SavaData("batmanSoap.xml", batman, SerializeFormatter.Soap); SavaData("SpiderManXml.xml", spiderMan, SerializeFormatter.Xml); SavaData("batmanXml.xml", batman, SerializeFormatter.Xml); var restoredBin = RestoreData <Movie>("SpiderManBinary.dat", SerializeFormatter.Binary); var restoredSoap = RestoreData <Movie>("SpiderManSoap.xml", SerializeFormatter.Soap); var restoredXml = RestoreData <Movie>("SpiderManXml.xml", SerializeFormatter.Xml); Console.WriteLine($"RestoredBin: {restoredBin.Title}"); Console.WriteLine($"RestoredBin: {restoredSoap.Title}"); Console.WriteLine($"RestoredBin: {restoredXml.Title}"); /* SoapFormatter sp = new SoapFormatter(); * var fs1 = File.Open("E:\\SerialSoap1.txt", FileMode.OpenOrCreate); * var fs2 = File.Open("E:\\SerialSoap2.txt", FileMode.OpenOrCreate); * Console.WriteLine("Start serializing by SoapFormatter" ); * sp.Serialize(fs1, spiderMan); * sp.Serialize(fs2, batman); * fs1.Dispose(); * fs2.Dispose(); * * BinaryFormatter bf = new BinaryFormatter(); * var fsBin1 = File.Open("E:\\SerialBinary1.txt", FileMode.OpenOrCreate); * var fsBin2 = File.Open("E:\\SerialBinary2.txt", FileMode.OpenOrCreate); * Console.WriteLine("Start serializing by SoapFormatter"); * bf.Serialize(fsBin1, spiderMan); * bf.Serialize(fsBin2, batman); * fsBin1.Dispose(); * fsBin2.Dispose(); * * * * Type type = typeof(Movie); * XmlSerializer xf = new XmlSerializer(type); * var fsXml = File.Open("E:\\SerialXml1.txt", FileMode.OpenOrCreate); * * Console.WriteLine("Start serializing by XMLSerializer"); * xf.Serialize(fsXml, spiderMan); * * xf = new XmlSerializer(typeof(Drama)); * fsXml = File.Open("E:\\SerialXml2.txt", FileMode.OpenOrCreate); * xf.Serialize(fsXml, batman); * fsXml.Dispose();*/ }
public static void GameReadExcel() { MyDataBase mdb = ScriptableObject.CreateInstance <MyDataBase>(); mdb.m_EventList = new List <EventData>(); mdb.m_RewardList = new List <EventReward>(); mdb.m_DramaList = new List <Drama>(); FileStream stream = File.Open(Application.dataPath + excelPath, FileMode.Open, FileAccess.Read); IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); DataSet result = excelReader.AsDataSet(); //读表一 int rows = result.Tables[0].Rows.Count;//获取行数 for (int i = 2; i < rows; i++) { string skill = result.Tables[0].Rows[i][0].ToString(); string skillBase = result.Tables[0].Rows[i][1].ToString(); for (int k = 0; k < 3; ++k) { EventData ed = ScriptableObject.CreateInstance <EventData>(); string eventID = result.Tables[0].Rows[i][k * 6 + 0 + 3].ToString(); string eventName = result.Tables[0].Rows[i][k * 6 + 1 + 3].ToString(); string need = result.Tables[0].Rows[i][k * 6 + 2 + 3].ToString(); string needStage = result.Tables[0].Rows[i][k * 6 + 3 + 3].ToString(); string preEvent = result.Tables[0].Rows[i][k * 6 + 4 + 3].ToString(); string eventType = result.Tables[0].Rows[i][k * 6 + 4 + 3].ToString(); ed.MainSkillBase = (Person.SkillType)Enum.Parse(typeof(Person.SkillType), skillBase); ed.MainSkillType = (Person.SkillList)Enum.Parse(typeof(Person.SkillList), skill); ed.EventID = int.Parse(eventID); ed.EventName = eventName; ed.isComplet = false; ed.needRate = float.Parse(need); ed.needStageFlag = stringToFlag(needStage); ed.eventTypeFlag = stringToFlag(eventType); mdb.m_EventList.Add(ed); } } //读表二 rows = result.Tables[1].Rows.Count;//获取行数 for (int i = 1; i < rows; ++i) { EventReward eR = ScriptableObject.CreateInstance <EventReward>(); eR.EventID = int.Parse(result.Tables[1].Rows[i][0].ToString()); string skillR = result.Tables[1].Rows[i][1].ToString(); if (skillR != "") { eR.eventP_Skill = (Person.SkillList)Enum.Parse(typeof(Person.SkillList), skillR); eR.eventP_Age = int.Parse(result.Tables[1].Rows[i][2].ToString()); } else { eR.eventP_Skill = Person.SkillList.None; eR.eventP_Age = 0; } string BaseChangge = result.Tables[1].Rows[i][3].ToString(); if (BaseChangge != "") { eR.eventBaseType = (Person.SkillType)Enum.Parse(typeof(Person.SkillType), BaseChangge); eR.eventBase = float.Parse(result.Tables[1].Rows[i][4].ToString()); } else { eR.eventBaseType = Person.SkillType.None; eR.eventBase = 0; } eR.relationTarget = (EventReward.RelationShipChangeTarget) int.Parse(result.Tables[1].Rows[i][5].ToString()); if ((int)eR.relationTarget < 2) { eR.targetKey1 = int.Parse(result.Tables[1].Rows[i][6].ToString()); } if ((int)eR.relationTarget == 0) { eR.targetKey2 = int.Parse(result.Tables[1].Rows[i][7].ToString()); } if ((int)eR.relationTarget != 4) { eR.relationshipChangeValue = float.Parse(result.Tables[1].Rows[i][8].ToString()); } eR.coreAreaChangge = float.Parse(result.Tables[1].Rows[i][9].ToString()); eR.baseAreaChangge = float.Parse(result.Tables[1].Rows[i][10].ToString()); eR.Goal = int.Parse(result.Tables[1].Rows[i][11].ToString()); eR.Drama = result.Tables[1].Rows[i][12].ToString(); mdb.m_RewardList.Add(eR); } //读表三 rows = result.Tables[2].Rows.Count;//获取行数 for (int i = 1; i < rows; ++i) { Drama d = ScriptableObject.CreateInstance <Drama>(); d.dialoqueList = new List <Dialogue>(); d.skillType = (Person.SkillList)Enum.Parse(typeof(Person.SkillList), result.Tables[2].Rows[i][0].ToString()); string dialoques = result.Tables[2].Rows[i][1].ToString(); for (int s = 0; s < dialoques.Length; ++s) { //寻找标签 while (dialoques[s] != '[') { ++s; } int ns = s; while (dialoques[ns] != ']') { ++ns; } string talker = dialoques.Substring(s + 1, ns - s - 1); Dialogue dia = ScriptableObject.CreateInstance <Dialogue>(); switch (talker) { case "pb": dia.talker = Dialogue.Talker.back; break; case "player": dia.talker = Dialogue.Talker.player; break; case "person": dia.talker = Dialogue.Talker.person; break; default: dia.talker = Dialogue.Talker.none; break; } s = ns; while (dialoques[ns] != '[') { ++ns; if (ns == dialoques.Length) { break; } } string words = dialoques.Substring(s + 1, ns - s - 1); dia.words = words; d.dialoqueList.Add(dia); s = ns - 1; } mdb.m_DramaList.Add(d); } AssetDatabase.CreateAsset(mdb, "Assets/Resources/MyDataBase.asset"); Selection.activeObject = mdb; }
static void LoadScene(string[] sceneData) { currentScene = new Scene (); ParseMode parseMode = ParseMode.None; Character currentCharacter = null; // Quest currentQuest = null; EventBase currentEventBase = null; // Drama currentDrama = null; QuestAction currentQuestAction = null; // Quest currentQuest = null; foreach (string line in sceneData) { if (line.Contains("BG:")){ string[] parts = line.Split(':'); currentScene.bgID = int.Parse(parts[1]); } if (line.Contains ("BGWidth")){ string[] parts = line.Split(':'); currentScene.bgWidth = int.Parse(parts[1]); } if (line.Contains("NextScene:")){ string[] parts = line.Split(':'); currentScene.nextScene = int.Parse(parts[1]); } if (line.Contains("ChangeSequence:")){ string[] parts = line.Split(':'); currentScene.nextSequence = parts[1]; } if (line.Contains("<CharaSetup>")){ parseMode = ParseMode.CharaSetup; continue; } if (line.Contains("<Quest>")){ parseMode = ParseMode.Quest; currentEventBase = new Quest(); // currentQuest = new Quest(); // currentQuest.actionList = new List<QuestAction>(); continue; } if (line.Contains("<Exit>")){ parseMode = ParseMode.Path; currentEventBase = new Exit(); // currentQuest = new Quest(); // currentQuest.actionList = new List<QuestAction>(); continue; } if (line.Contains("<PlayerSetup>")){ parseMode = ParseMode.PlayerSetup; continue; } if (line.Contains("<Drama>")){ parseMode = ParseMode.DramaLocation; // currentDrama = new Drama(); currentEventBase = new Drama(); continue; } if (line.Contains("<DramaEnd>") || line.Contains("<QuestEnd>") || line.Contains("<ExitEnd>")){ // currentScene.dialogList.Add(currentDrama); currentScene.eventList.Add (currentEventBase); } // if (line.Contains("<QuestEnd>")){ // if (currentQuest != null && currentQuestAction != null){ // currentQuest.actionList.Add(currentQuestAction); // } // currentScene.eventList.Add (currentQuest); // } // if (line.Contains("<QuestEvent>")){ // parseMode = ParseMode.QuestAction; // if (currentQuest != null && currentQuestAction != null){ // currentQuest.actionList.Add(currentQuestAction); // } // currentQuestAction = new QuestAction(); // // } switch (parseMode){ case ParseMode.PlayerSetup: if (line.Contains(":")){ string[] parts = line.Split(':'); if (line.Contains("x")){ currentScene.playerPos.x = int.Parse(parts[1]); } if (line.Contains("y")){ currentScene.playerPos.y = int.Parse(parts[1]); } } break; case ParseMode.CharaSetup: if (line.Contains("<Chara>")){ currentCharacter = new Character(currentScene.characterList.Count); } if (line.Contains("<CharaEnd>")){ currentScene.characterList.Add(currentCharacter); } if (line.Contains(":")){ string[] parts = line.Split(':'); if (line.Contains("x:")){ currentCharacter.xpos = int.Parse(parts[1]); } if (line.Contains("y:")){ currentCharacter.ypos = int.Parse(parts[1]); } if (line.Contains("hair:")){ currentCharacter.hairId = int.Parse(parts[1]); } if (line.Contains("clothes:")){ currentCharacter.clothesId = int.Parse(parts[1]); } if (line.Contains("name:")){ currentCharacter._name = parts[1]; } if (line.Contains ("anim:")){ currentCharacter.startAnimation = parts[1]; } if (line.Contains("side:")){ currentCharacter.side = int.Parse(parts[1]); } if (line.Contains ("id:")){ currentCharacter._id = int.Parse (parts[1]); } } break; case ParseMode.DramaLocation: case ParseMode.Quest: case ParseMode.Path: if (line.Contains(":")){ string[] parts = line.Split(':'); if (line.Contains("x:")){ currentEventBase.loc.x = int.Parse(parts[1]); // currentDrama.loc.x = int.Parse(parts[1]); } if (line.Contains("y:")){ currentEventBase.loc.y = int.Parse(parts[1]); // currentDrama.loc.y = int.Parse(parts[1]); } if (line.Contains("filename")){ currentEventBase.file = parts[1]; if (parseMode == ParseMode.Quest){ Quest quest = currentEventBase as Quest; LoadQuest(ref quest ); } // currentDrama.file = parts[1]; } if (line.Contains("next")){ currentEventBase.nextEvent = int.Parse(parts[1]); } if (line.Contains("side")){ currentEventBase.direction = int.Parse(parts[1]); // currentDrama.direction = int.Parse(parts[1]); } if (line.Contains("prereq:")){ currentEventBase.prereq = int.Parse (parts[1]); // currentDrama.prereq = int.Parse (parts[1]); } if (line.Contains ("reqchara:")){ currentEventBase.charaid = int.Parse (parts[1]); } if (line.Contains("id:")){ currentEventBase.id = int.Parse(parts[1]); // currentDrama.id = int.Parse (parts[1]); } if (line.Contains ("bondup:")){ int bond = int.Parse (parts[1]); Drama currentDrama = currentEventBase as Drama; currentDrama.showBond = (bond == 1); } if (line.Contains ("major:")){ int isMajorEvent = int.Parse (parts[1]); currentEventBase.isMajorEvent = (isMajorEvent == 1); } if (line.Contains("AddNews:")){ // Drama currentDrama = currentEventBase as Drama; currentEventBase.addnews = parts[1]; } if (line.Contains("AddNewsIcon:")){ // Drama currentDrama = currentEventBase as Drama; currentEventBase.addnewsIcon = parts[1]; } if (line.Contains("AddNewsImage:")){ // Drama currentDrama = currentEventBase as Drama; currentEventBase.addnewsImage = parts[1]; } if (line.Contains ("gobattle")){ currentEventBase.isBattle = true; } if (line.Contains ("monstername:")){ currentEventBase.monstername = parts[1]; } if (line.Contains ("monsterType:")){ currentEventBase.enemyType = int.Parse (parts[1]); } if (line.Contains ("repeat:")){ currentEventBase.isRepeat = (int.Parse (parts[1]) == 1); } if (line.Contains ("nextscene:") && parseMode == ParseMode.Path){ Exit exit = currentEventBase as Exit; exit.nextScene = int.Parse (parts[1]); } if (line.Contains ("chainstart:")){ currentEventBase.startChain = true; currentEventBase.chain = int.Parse(parts[1]); } else if (line.Contains ("chainend:")){ currentEventBase.endChain = true; } else if (line.Contains ("chain:")){ currentEventBase.chain = int.Parse (parts[1]); } } break; // case ParseMode.Quest: // if (line.Contains(":")){ // string[] parts = line.Split(':'); // if (line.Contains("x:")){ // currentQuest.loc.x = int.Parse(parts[1]); // } // if (line.Contains("y:")){ // currentQuest.loc.y = int.Parse(parts[1]); // } // if (line.Contains("side")){ // currentQuest.direction = int.Parse(parts[1]); // } // if (line.Contains("prereq:")){ // currentQuest.prereq = int.Parse (parts[1]); // } // if (line.Contains("id:")){ // currentQuest.id = int.Parse (parts[1]); // } // if (line.Contains ("filename:")){ // currentQuest.file = parts[1]; // LoadQuest (ref currentQuest); // } // if (line.Contains("id:")){ // currentQuest.id = int.Parse (parts[1]); // } // if (line.Contains ("completion")){ // currentQuest.requiredAmount = int.Parse (parts[1]); // } // if (line.Contains("name")){ // currentQuest.questName = parts[1]; // } // if (line.Contains ("startdesc")){ // int start = line.IndexOf('"') + 1; // string desc = line.Substring (start, line.LastIndexOf('"') - start).Replace("\\n", System.Environment.NewLine) ; // currentQuest.questDesc = desc; // } // if (line.Contains ("finishdesc")){ // int start = line.IndexOf('"') + 1; // string desc = line.Substring (start, line.LastIndexOf('"') - start).Replace("\\n", System.Environment.NewLine) ; // currentQuest.finishDesc = desc; // } // if (line.Contains("nextscene")){ // currentQuest.nextEvent = parts[1]; // } // } break; // case ParseMode.QuestAction: // if (line.Contains(":")){ // string[] parts = line.Split(':'); // if (line.Contains("x:")){ // currentQuestAction.loc.x = int.Parse(parts[1]); // } // if (line.Contains("y:")){ // currentQuestAction.loc.y = int.Parse(parts[1]); // } // if (line.Contains("desc")){ // currentQuestAction.desc = parts[1]; // } // if (line.Contains ("completion")){ // currentQuestAction.completionAmount = int.Parse (parts[1]); // } // if (line.Contains("cost")){ // currentQuestAction.staminaCost = int.Parse (parts[1]); // } // } // // break; } } }
void StartDrama(Drama selectedDrama) { m_hudService.HUDControl.EnableRanking (false); float dialogLoc = selectedDrama.loc.x - 50f; Vector3 pos = scenePanel.transform.localPosition; // float diff = pos.x - dialogLoc; pos.x = -dialogLoc; SpringPanel.Begin (scenePanel.gameObject, pos, 8f); // scenePanel.transform.localPosition = pos; // // Vector4 clipPos = scenePanel.clipRange; // clipPos.x = dialogLoc; // scenePanel.clipRange = clipPos; LoadDialog (selectedDrama.file); // pos = dialogBase.transform.localPosition; // pos.x = dialogLoc; // dialogBase.transform.localPosition = pos; dialogBase.SetActive (true); pos = playerChara.transform.localPosition; pos.x = currentScene.playerPos.x; playerChara.transform.localPosition = pos; Vector3 scale = playerChara.transform.localScale; scale.x *= selectedDrama.direction; playerChara.transform.localScale = scale; currentDialogEvent = openingDialogEvent; //move it to after the event dialog is loaded ShowCurrentDialog (); displayingChoice = false; EnableMapScroll (false); if (questProgress != null) { questProgress.gameObject.SetActive (false); } if (selectedDrama.startChain) PlayerProfile.Get ().currentEventSet = selectedDrama.chain; }