void Start() { tm = GetComponent <TuringMachine>(); inputField = GameObject.FindGameObjectWithTag("input").GetComponent <InputField>(); startMachineButton = GameObject.FindGameObjectWithTag("startMachineButton").GetComponent <Button>(); stepButtonLight = GameObject.FindGameObjectWithTag("StepButtonLight").GetComponent <Image>(); startButtonLight = GameObject.FindGameObjectWithTag("StartButtonLight").GetComponent <Image>(); processButton = GameObject.FindGameObjectWithTag("processButton").GetComponent <Button>(); stateDisplay = GameObject.FindGameObjectWithTag("stateDisplay").GetComponent <TextMesh>(); /* * if(File.Exists(Application.persistentDataPath + "/Machines/machines.txt")) * LoadAllMachines(File.ReadAllText(Application.persistentDataPath + "/Machines/machines.txt")); * else * { * File.Create(Application.persistentDataPath + "/Machines/machines.txt"); * }*/ if (!Directory.Exists(Application.persistentDataPath + "\\Machines")) { Directory.CreateDirectory(Application.persistentDataPath + "\\Machines"); SaveMachine.WriteIt(Application.persistentDataPath + "\\Machines\\machines.txt", Constants.DEFAULTDESCRIPTIONS()); } LoadAllMachines(File.ReadAllText(Application.persistentDataPath + "\\Machines\\machines.txt")); LoadOptions(); LoadMachine(); }
public void TryInsert() { string desc = File.ReadAllText(Application.persistentDataPath + "/Machines/machines.txt") + textField.text; try { try { LoadMachine(desc); textField.text = ""; SaveMachine.WriteIt(Application.persistentDataPath + "/Machines/machines.txt", desc); } catch (Exception e) { Debug.Log(e); displayer.text = "ERROR"; if (error != null) { StopCoroutine(error); } StartCoroutine(error); } } catch { } }
//TODO: I really hate this, I don't want to have to make a class based on an enum public void AddObjectEntity(ObjectData data) { switch (data.type) { case ObjectType.Chest: Chest temp = new Chest(ScriptableObject.Instantiate(mCurrentMap.Data.chestType)); temp.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.FallingRock: FallingRock temp2 = new FallingRock(Resources.Load("Prototypes/Entity/Objects/FallingRock") as EntityPrototype); temp2.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.FlowerBed: FlowerBed temp3 = new FlowerBed(Resources.Load("Prototypes/Entity/Objects/FlowerBed") as EntityPrototype); temp3.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.Tree: Tree temp4 = new Tree(Resources.Load("Prototypes/Entity/Objects/Tree") as EntityPrototype); temp4.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.Medbay: MedicalBay temp5 = new MedicalBay(Resources.Load("Prototypes/Entity/Objects/Medbay") as EntityPrototype); temp5.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.Door: if (mCurrentMap.mapType != MapType.BossMap) { Door temp6 = new Door(Resources.Load("Prototypes/Entity/Objects/Door") as DoorPrototype); if (mCurrentMap.Data.hasMiniboss) { temp6.locked = true; } temp6.Spawn(GetMapTilePosition(data.TilePosition)); } break; case ObjectType.NavSystem: NavSystem temp7 = new NavSystem(Resources.Load("Prototypes/Entity/Objects/NavSystem") as EntityPrototype); temp7.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.BouncePad: BouncePad temp8 = new BouncePad(Resources.Load("Prototypes/Entity/Objects/BouncePad") as EntityPrototype); temp8.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.Spikes: Spikes temp9 = new Spikes(Resources.Load("Prototypes/Entity/Objects/Spikes") as EntityPrototype); temp9.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.Iceblock: Iceblock temp10 = new Iceblock(Resources.Load("Prototypes/Entity/Objects/Iceblock") as EntityPrototype); temp10.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.AnalysisCom: AnalysisCom temp11 = new AnalysisCom(Resources.Load("Prototypes/Entity/Objects/AnalysisCom") as EntityPrototype); temp11.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.Item: if (data is ItemObjectData itemData) { ItemObject temp12 = new ItemObject(ItemDatabase.GetItem(itemData.itemType), Resources.Load("Prototypes/Entity/Objects/ItemObject") as EntityPrototype); temp12.Spawn(GetMapTilePosition(data.TilePosition)); } break; case ObjectType.SmallGatherable: Gatherable temp13 = new Gatherable(Resources.Load("Prototypes/Entity/Objects/Gatherables/Small Blue Vein") as GatherablePrototype); temp13.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.LargeGatherable: Gatherable temp14 = new Gatherable(Resources.Load("Prototypes/Entity/Objects/Gatherables/Large Blue Vein") as GatherablePrototype); temp14.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.SaveMachine: SaveMachine temp15 = new SaveMachine(Resources.Load("Prototypes/Entity/Objects/SaveMachine") as EntityPrototype); temp15.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.BreakableTile: BreakableTile temp16 = new BreakableTile(Resources.Load("Prototypes/Entity/Objects/BreakableTile") as EntityPrototype); temp16.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.PracticeBot: PracticeBot temp17 = new PracticeBot(Resources.Load("Prototypes/Entity/Objects/PracticeBot") as EntityPrototype); temp17.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.ShipTeleporter: ShipTeleporter temp18 = new ShipTeleporter(Resources.Load("Prototypes/Entity/Objects/ShipTeleporter") as EntityPrototype); temp18.Spawn(GetMapTilePosition(data.TilePosition)); break; case ObjectType.MovingPlatform: MovingPlatform temp19 = new MovingPlatform(Resources.Load("Prototypes/Entity/Objects/MovingPlatform") as EntityPrototype); temp19.Spawn(GetMapTilePosition(data.TilePosition)); break; } }