private IEnumerator AdditionalActionTapCoroutine() { yield return(new WaitForSeconds(additionalActionTapTime)); if (!moved) { ITriggerable t = GetComponent <ITriggerable>(); if (t != null) { GameObject obj = MapObjectUI.CreateMapObject(MapObjectType.Lever); obj.transform.position = transform.position; obj.GetComponent <Lever>().TriggerObj = gameObject; } Enemy e = GetComponent <Enemy>(); if (e != null) { MapMakerController.Instance.MapObjectCommandsEditor.CommandsEditorAim = e; } moved = true; } }
private GameObject SaveStringToMapObject(string str, bool forMapMaker) { try { string[] s = str.Split(','); MapObjectType type = (MapObjectType)Enum.Parse(typeof(MapObjectType), s[0]); GameObject obj; if (forMapMaker) { obj = MapObjectUI.CreateMapObject(type); } else { obj = Instantiate(MapObjectsPrefabs[(int)type], map.transform); } obj.transform.position = new Vector2( Int32.Parse(s[1]), Int32.Parse(s[2]) ); obj.transform.localEulerAngles = new Vector3(0, 0, Int32.Parse(s[3]) * 90); if (type == MapObjectType.Lever && s.Length > 4) { for (int i = 0; i < map.transform.childCount; i++) { Transform t = map.transform.GetChild(i); if (t.GetComponent <ITriggerable>() != null && (Vector2)t.position == new Vector2(Int32.Parse(s[5]), Int32.Parse(s[6]))) { Destroy(t.gameObject); } } int index = str.IndexOf(','); index = str.IndexOf(',', index + 1); index = str.IndexOf(',', index + 1); index = str.IndexOf(',', index + 1); obj.GetComponent <Lever>().TriggerObj = SaveStringToMapObject(str.Substring(index + 1), forMapMaker); } if (type == MapObjectType.Enemy && s[4].Length > 2) { string[] cStrs = s[4].Substring(1, s[4].Length - 2).Split('.'); List <Command> cmds = new List <Command>(); for (int i = 0; i < cStrs.Length; i++) { if (cStrs[i] == Command.Type.GoForward.ToString()) { cmds.Add(new GoForward(obj.gameObject)); } else if (cStrs[i] == Command.Type.TurnLeft.ToString()) { cmds.Add(new TurnLeft(obj.gameObject)); } else if (cStrs[i] == Command.Type.TurnRight.ToString()) { cmds.Add(new TurnRight(obj.gameObject)); } else if (cStrs[i] == Command.Type.Use.ToString()) { cmds.Add(new Use(obj.gameObject)); } } obj.GetComponent <Enemy>().SetCommands(cmds); } return(obj); } catch { return(null); } }