//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //************************************************************** // Methods used by script: // ACtually to be called by other scripts public void RepairMachine(GameObject machine) { // Reference to machine that called this method machineCalled = machine; // Reference to the script on the said machine machineCalledScript = machine.gameObject.GetComponent <machine_fsm>(); state = WorkerState.needRepair; }
void pInUse(GameObject machineSelected) { // References the script component on the machine object machine = machineSelected.GetComponent <machine_fsm>(); // Checks if there is a machine script reference if (machine) { // Checks if the machine is in use. if (machine.CheckState() == machine_fsm.MachineState.InUse) { // Activates the UI IsInUse.SetActive(true); // The state transition state = PlayerState.Standby; } // Checks if the machine is under repair or broken else if (machine.CheckState() == machine_fsm.MachineState.Repair || machine.CheckState() == machine_fsm.MachineState.Broken) { state = PlayerState.Standby; } else { // Checks if the machine has been used by the player if (machine.player_used) { // Activates the UI AlreadyUsed.SetActive(true); state = PlayerState.Standby; } else { // Moves the character to the machine Moving(machineSelected); state = PlayerState.UseMachine; } } } }
void nInUse() { machineScript = machineChosen.GetComponent <machine_fsm>(); // Checks if current state of machine is "InUse", if it is, npc can't use, else use the machine if (machineScript.CheckState() == machine_fsm.MachineState.InUse) { state = NPCState.Standby; } // Checks if the machine is under repair or broken else if (machineScript.CheckState() == machine_fsm.MachineState.Repair || machineScript.CheckState() == machine_fsm.MachineState.Broken) { state = NPCState.Standby; } else { // Moves the NPC to the machine to be used Moving(machineChosen); // State transition to useMachine state state = NPCState.UseMachine; } }