static void Main() { int index = 11; //int index = Convert.ToInt32(ConfigurationManager.AppSettings["game"]); GameDictionary obj = new GameDictionary(); IDictionary <int, Game> dictionary = obj.GetGameDictionary(); Game game = null; try { game = dictionary[index]; game.Window.Title = $"Demo{index}Game"; game.IsMouseVisible = true; game.Run(); } finally { if (null != game) { game.Dispose(); } } }
void Start() { if (!Debugger.IsSpawn) { DeployDebugger(); } if (!PopupUI.IsInit) { DeployPopupUI(); } if (!GameDictionary.IsInit) { GameDictionary.InitDic(); } if (IsInit) { return; } MyAudio.PlayLoopSound(BGM, "bgm"); Player.Init(); DontDestroyOnLoad(gameObject); SR.Init(); Player.AutoLogin(); IsInit = true; }
void Start() { if (!GameDictionary.IsInit) { GameDictionary.InitDic(); } MyRecordUI.Init(); Start_Title.text = GameDictionary.String_UIDic["Start"].GetString(Player.UseLanguage); }
public Server() { clients = new List <SocketState>(); playerDic = new Dictionary <SocketState, Player>(); NetworkController.ServerAwaitingClientLoop(FirstContact); GameDic = JsonConvert.DeserializeObject <GameDictionary>(JToken.Parse(File.ReadAllText("GameDic.json")).ToString()); GameDictionary.GameDic = GameDic; sqlConnectionString = ConfigurationManager.ConnectionStrings["MyCardGameServer.Properties.Settings.GameDatabaseConnectionString"].ConnectionString; Console.WriteLine("Waiting for first connection..."); }
internal static void RunGame() { int index = 11; GameDictionary obj = new GameDictionary(); IDictionary <int, Game> dictionary = obj.GetGameDictionary(); Game game = dictionary[index]; game.Window.Title = $"Demo{index}Game"; game.IsMouseVisible = true; game.Run(); }
/// <summary> /// 起始設定 /// </summary> void SetData() { //字典 GameDictionary.InitDic(); //Player PlayerTrans[0].GetComponent <PlayerChara>().IniChara(0, GameDictionary.TmpChara1Dic); PlayerTrans[1].GetComponent <PlayerChara>().IniChara(1, GameDictionary.TmpChara2Dic); PlayerTrans[2].GetComponent <PlayerChara>().IniChara(2, GameDictionary.TmpChara3Dic); //Timer IniTimer(); //場景 IniScene(); }
private static GameDictionary SetDictionary() { string GameDicString = PlayerPrefs.GetString("GameDic"); if (GameDicString == "") { var dic = new GameDictionary(); dic.ingredientDic = new Dictionary <int, Ingredient>(); dic.foodHolderDic = new Dictionary <int, FoodHolder>(); dic.foodMakerDic = new Dictionary <int, FoodMaker>(); dic.foodDic = new Dictionary <int, Food>(); dic.shopDic = new Dictionary <int, Shop>(); dic.levelDic = new Dictionary <string, Level>(); foreach (var item in JsonConvert.DeserializeObject <List <IngredientFromJson> >(Resources.Load <TextAsset>(@"Data/Ingredient").text)) { var temp = new Ingredient(item); dic.ingredientDic.Add(temp.ID, temp); } foreach (var item in JsonConvert.DeserializeObject <List <FoodHolderFromJson> >(Resources.Load <TextAsset>(@"Data/FoodHolder").text)) { var temp = new FoodHolder(item); dic.foodHolderDic.Add(temp.ID, temp); } foreach (var item in JsonConvert.DeserializeObject <List <FoodMakerFromJson> >(Resources.Load <TextAsset>(@"Data/FoodMaker").text)) { var temp = new FoodMaker(item); dic.foodMakerDic.Add(temp.ID, temp); } foreach (var item in JsonConvert.DeserializeObject <List <FoodFromJson> >(Resources.Load <TextAsset>(@"Data/Food").text)) { var temp = new Food(item); dic.foodDic.Add(temp.ID, temp); } foreach (var item in JsonConvert.DeserializeObject <List <ShopFromJson> >(Resources.Load <TextAsset>(@"Data/Shop").text)) { var temp = new Shop(item); dic.shopDic.Add(temp.ID, temp); } foreach (var item in JsonConvert.DeserializeObject <List <LevelFromJson> >(Resources.Load <TextAsset>(@"Data/Level").text)) { var temp = new Level(item); dic.levelDic.Add(temp.ID, temp); } return(dic); } else { return(JsonConvert.DeserializeObject <GameDictionary>(GameDicString)); } }
//there are two possible ways to save //1. calling save() //2. automatically save if the element gets destroyed public bool SaveEntry() { string input = inputField.text; if (allowEmptyString == false) { if (string.IsNullOrEmpty(input)) { return(false); } } GameDictionary.SetEntry(DictionaryKey, input); return(true); }
public main() { Game = new GameDictionary(); //fileDictonary = @"D:\TestFolder\wordsEn.txt"; OpenFileDialog op = new OpenFileDialog(); op.ShowDialog(); fileDictonary = op.FileName; string[] lines = System.IO.File.ReadAllLines(fileDictonary); foreach (string line in lines) { Game.Add(line, null); } InitializeComponent(); }
protected override void OnCreate(Bundle bundle) { int index = 11; base.OnCreate(bundle); GameDictionary obj = new GameDictionary(); IDictionary <int, Game> dictionary = obj.GetGameDictionary(); Game game = dictionary[index]; game.Window.Title = $"Demo{index}Game"; game.IsMouseVisible = true; SetContentView((View)game.Services.GetService(typeof(View))); game.Run(); }
void Awake() { if (!Debugger.IsSpawn) { DeployDebugger(); } if (!GameDictionary.IsInit) { GameDictionary.InitDic(); } IsRevived = false; IsPause = false; CanPressSettingBtn = true; MySelf = transform.GetComponent <BattleManager>(); HideBounceWall(); SetNormanWall(); StartGame(); }
static void executeExtraChanges(C_AdditionalModifiers[] extras) { foreach (C_AdditionalModifiers addModifier in extras) { switch (addModifier.targetType) { case E_ModifierTargetType.item: Inventory_ChangeItem.executeItemChange(addModifier.itemChange); break; case E_ModifierTargetType.dictionary: GameDictionary.executeDictionaryResult(addModifier.dictionaryChange); break; case E_ModifierTargetType.timeline: if (Timeline.instance != null && addModifier.historyEvent != null) { Timeline.instance.AddHistoryEvent(addModifier.historyEvent); } break; case E_ModifierTargetType.gamelog: if (GameLogger.instance != null) { GameLogger.instance.addGameLog(addModifier.newGameLog.text, addModifier.newGameLog.subLogSelection); } break; case E_ModifierTargetType.quest: if (Quests.instance != null) { Quests.instance.computeQuestChange(addModifier.questChange); } break; default: Debug.LogWarning("Modification for Type '" + addModifier.targetType.ToString() + "' is not implemented yet."); break; } } }
//Test a condition for a card. Example condition: draw this card only, if the age (or any other value) inside the game is between 10-16. //the methode returns true, if the condition is met. False if not. public bool getConditionMet(EventScript.condition cond, bool showDebug = false) { foreach (ValueScript vs in values) { //get the matching value for the value if (vs.valueType == cond.value) { //condition evalution is depending on type of condition switch (cond.type) { case EventScript.E_ConditionType.standard: if ((vs.value <= cond.valueMax && vs.value >= cond.valueMin)) { if (showDebug == true) { Debug.Log("True: " + cond.valueMin.ToString() + " " + vs.value.ToString() + " " + cond.valueMax.ToString()); Debug.Log(vs.gameObject.name); } return(true); } else { if (showDebug == true) { Debug.Log("False: " + cond.valueMin.ToString() + " " + vs.value.ToString() + " " + cond.valueMax.ToString()); Debug.Log(vs.gameObject.name); } return(false); } //break; case EventScript.E_ConditionType.compareValues: //for the value compare the second value (=rValue) is needed. ValueScript rValue = getFirstFittingValue(cond.rValue); //The condition is false, if value was not found. if (rValue == null) { if (showDebug == true) { Debug.LogError("The value '" + cond.rValue.ToString() + "' is null."); } return(false); } //compare value to value depending on compare type switch (cond.compareType) { case EventScript.E_ConditionCompareType.greaterThan: if (vs.value > rValue.value) { return(true); } else { return(false); } case EventScript.E_ConditionCompareType.greaterThanOrEqual: if (vs.value >= rValue.value) { return(true); } else { return(false); } case EventScript.E_ConditionCompareType.equals: if (vs.value == rValue.value) { return(true); } else { return(false); } case EventScript.E_ConditionCompareType.equalsAsInt: if (Mathf.RoundToInt(vs.value) == Mathf.RoundToInt(rValue.value)) { return(true); } else { return(false); } case EventScript.E_ConditionCompareType.lessThan: if (vs.value < rValue.value) { return(true); } else { return(false); } case EventScript.E_ConditionCompareType.lessThanOrEqual: if (vs.value <= rValue.value) { return(true); } else { return(false); } } break; case EventScript.E_ConditionType.items: int itemCnt = Inventory.instance.GetItemCount(cond.item); switch (cond.itemCompareType) { case EventScript.E_ItemCompareType.greaterThan: if (itemCnt > cond.itemCmpValue) { return(true); } else { return(false); } case EventScript.E_ItemCompareType.lessThan: if (itemCnt < cond.itemCmpValue) { return(true); } else { return(false); } case EventScript.E_ItemCompareType.equals: if (itemCnt == cond.itemCmpValue) { return(true); } else { return(false); } } break; case EventScript.E_ConditionType.dictionaryEquals: return(GameDictionary.EqualsValue(cond.gamedictionary_key, cond.gamedictionary_comparer)); default: Debug.LogError("The evaluation type '" + cond.type.ToString() + "' for the condition is not implemented yet."); break; } } } return(false); }
public TheBoogle(GameDictionary _Game) { Game = _Game; rs = new GameDictionary(); InitializeComponent(); }
private GameClient() { GameDic = JsonConvert.DeserializeObject <GameDictionary>(JToken.Parse(File.ReadAllText("GameDic.json")).ToString()); GameDictionary.GameDic = GameDic; }
public TheMysteryWord(GameDictionary _Game) { Game = _Game; InitializeComponent(); }
void SetData() { GameDictionary.InitDic(); Player.Init(); }
public TheHungman(GameDictionary _Game) { Game = _Game; InitializeComponent(); }
public TheLongestWord(GameDictionary _Game) { Game = _Game; InitializeComponent(); }
/// <summary> /// Enhance a string by replacing place holders with values. /// This should be done after translations, else the translation term is not recognized anymore. /// To enshure the correct order use 'TranslateAndReplace(string txt)' instead of this method. /// /// Actual keywords are: /// item /// - can be followed by format /// - should not be followed by preview (not supported yet, gives wrong results) /// value /// - can be followed by preview, format /// dictionary /// - replaces dictionary entry with string, format is not supported /// change /// - similar to preview but shows the change of the value /// - value should be declared first /// - can have the parameters: /// * up,down,left,right,add0,add1 /// - can differ from value preview because an other method for determing randomness for the value is used /// result /// - similar to change but shows the possible result of the value /// - value should be declared first /// - can have the parameters: /// * up,down,left,right,add0,add1 /// - can differ from value preview because an other method for determing randomness for the value is used /// format /// - can be used every time and defines the formatter of the string cast e.g. '0.0', '##' etc. /// /// /// Examples for place holders: /// {value=army} -> is replaced by the actual value of army (if defined in value definitions), e.g. 75 /// {value=army,format=0.0} -> is replace like before but with formatting, e.g. 75.0 /// {value=army,preview=up} -> is replaced by the preview for army when swiping up /// {item=sword} -> is replaced by the number of swords in the inventory /// {dictionary=name} -> is replaced by the value for the key 'name'. /// </summary> /// <param name="input">Input string with place holder(s).</param> /// <returns>String with replaced parts.</returns> public static string ReplaceStringPlaceHolders(string input) { string output = string.Copy(input); string query = input; string match = ""; string matchNoSpace = ""; string pattern = @"\{(.*?)\}"; string[] commandSeqences; string[] commandSplit; var matches = Regex.Matches(query, pattern); //e.g. "your army strenth is {army,format=0.0}." returns "army,format=0.0" in the first element (not a string yet) foreach (Match m in matches) { //found a command/place holder match = m.Groups[1].ToString(); //remove space characters matchNoSpace = match.Replace(" ", string.Empty); commandSeqences = matchNoSpace.Split(','); //e.g. "army,format=0.0" is split into "army" and "format=0.0" //variables resulting from different commands string format = ""; ValueScript vs = null; bool valueChangePreviewRequested = false; bool valueResultPreviewRequested = false; bool randomIndependent = true; float previewValue = 0f; EventScript es = null; string SwipeDirectionString = ""; string dictionaryValue = ""; bool dictionaryRequested = false; Inventory.C_ItemAmount ia = null; int itemAmount = 0; bool itemAmountRequested = false; //parse the parameters foreach (string parameter in commandSeqences) { commandSplit = parameter.Split('='); //e.g. split "format=0.0" into "format" and "0.0". Can't use ':' here, because this can also be within the string format. switch (commandSplit[0]) { case "value": if (commandSplit.Length > 1) { //parse the matching value if (valueDefinitions.values.IsDefined(typeof(valueDefinitions.values), commandSplit[1])) { //matching place holder was found valueDefinitions.values valueType = (valueDefinitions.values)System.Enum.Parse(typeof(valueDefinitions.values), commandSplit[1], true); vs = valueManager.instance.getFirstFittingValue(valueType); } else { //command/place holder is unknown Debug.LogWarning("The value '" + commandSplit[1] + "' for the place holder {" + match + "} is unknown."); } } else { Debug.LogWarning("The keyword 'value' for the place holder {" + match + "} is not followed by a selections, e.g. 'value=years'"); } break; case "format": if (commandSplit.Length > 1) { format = commandSplit[1]; } else { Debug.LogWarning("Command 'format' in text '" + match + "' is not followed by a valid parameter, e.g. format=0.0."); } break; case "item": itemAmountRequested = true; if (commandSplit.Length > 1) { //find the matching item if (Inventory.instance != null) { ia = Inventory.instance.GetItemByKey(commandSplit[1]); //command/place holder is unknown if (ia != null) { itemAmount = ia.amount; } else { //if the item is not within the inventory it still can be in the catalog (amount is 0) InventoryItem item = Inventory.instance.GetItemFromCatalogByKey(commandSplit[1]); itemAmount = 0; if (item != null) { //item is ok an known, amount is 0 } else { Debug.LogWarning("The item '" + commandSplit[1] + "' for the place holder {" + match + "} is unknown."); } } } else { Debug.LogWarning("The item '" + commandSplit[1] + "' for the place holder {" + match + "} can't be searched because there is no script 'LocalInventory.cs' found in the scene."); } } else { Debug.LogWarning("The keyword 'item' for the place holder {" + match + "} is not followed by a selections, e.g. 'item=sword'"); } break; case "dict": /*short writing for dictionary is the same case as */ case "dictionary": dictionaryRequested = true; dictionaryValue = GameDictionary.GetValue(commandSplit[1]); break; case "change": if (vs != null && commandSplit.Length > 1) { //get the reference to the actual card if (CardStack.instance != null) { if (CardStack.instance.spawnedCard != null) { es = CardStack.instance.spawnedCard.GetComponent <EventScript>(); if (es != null) { SwipeDirectionString = commandSplit[1]; //Debug.Log("Card is " + CardStack.instance.spawnedCard.name); if (!string.IsNullOrEmpty(SwipeDirectionString)) { es.computeTextPreview(SwipeDirectionString, vs.valueType, ref previewValue, ref randomIndependent); valueChangePreviewRequested = true; } else { Debug.LogWarning("Command 'direction' in text '" + match + "' is not defined yet, e.g. 'direction=left'."); } } else { Debug.LogWarning("The preview for value '" + commandSplit[1] + "' for the place holder {" + match + "} can't be searched because there is no 'EventScrip' attached to the actual spawned card."); } } else { Debug.LogWarning("The preview for value '" + commandSplit[1] + "' for the place holder {" + match + "} can't be searched because there is no actual spawned card."); } } else { Debug.LogWarning("The preview for value '" + commandSplit[1] + "' for the place holder {" + match + "} can't be searched because there is no script 'CardStack.cs' found in the scene."); } } else { Debug.LogWarning("The keyword 'preview' for the place holder {" + match + "} is not followed by a selections or no value was defined yet."); } break; case "result": if (vs != null && commandSplit.Length > 1) { //get the reference to the actual card if (CardStack.instance != null) { if (CardStack.instance.spawnedCard != null) { es = CardStack.instance.spawnedCard.GetComponent <EventScript>(); if (es != null) { SwipeDirectionString = commandSplit[1]; //Debug.Log("Card is " + CardStack.instance.spawnedCard.name); if (!string.IsNullOrEmpty(SwipeDirectionString)) { es.computeTextPreview(SwipeDirectionString, vs.valueType, ref previewValue, ref randomIndependent); //calculate the result previewValue += vs.value; if (previewValue < vs.limits.min) { previewValue = vs.limits.min; } if (previewValue > vs.limits.max) { previewValue = vs.limits.max; } valueResultPreviewRequested = true; } else { Debug.LogWarning("Command 'direction' in text '" + match + "' is not defined yet, e.g. 'direction=left'."); } } else { Debug.LogWarning("The preview for value '" + commandSplit[1] + "' for the place holder {" + match + "} can't be searched because there is no 'EventScrip' attached to the actual spawned card."); } } else { Debug.LogWarning("The preview for value '" + commandSplit[1] + "' for the place holder {" + match + "} can't be searched because there is no actual spawned card."); } } else { Debug.LogWarning("The preview for value '" + commandSplit[1] + "' for the place holder {" + match + "} can't be searched because there is no script 'CardStack.cs' found in the scene."); } } else { Debug.LogWarning("The keyword 'preview' for the place holder {" + match + "} is not followed by a selections or no value was defined yet."); } break; default: Debug.LogWarning("Command '" + commandSplit[0] + "' in place holder '" + match + "' is not recognized."); break; } } //replace the original match if (valueChangePreviewRequested == true) { //replace place holder with change preview if (randomIndependent == true) { output = output.Replace("{" + match + "}", previewValue.ToString(format)); } else { output = output.Replace("{" + match + "}", "?"); } } else if (valueResultPreviewRequested == true) { //replace place holder with result preview if (randomIndependent == true) { output = output.Replace("{" + match + "}", previewValue.ToString(format)); } else { output = output.Replace("{" + match + "}", "?"); } } else if (dictionaryRequested == true) { //repalce place holder with dictionary entry output = output.Replace("{" + match + "}", dictionaryValue); } else if (vs != null) { //replace place holder with value output = output.Replace("{" + match + "}", vs.value.ToString(format)); } else if (itemAmountRequested == true) { //replace place holder with item amount output = output.Replace("{" + match + "}", itemAmount.ToString(format)); } else { //If nothing matches: replace placeholder with escape-string. User should not see internal structure like {value:....}. output = output.Replace("{" + match + "}", "<?>"); } } return(output); }