public override void OnInspectorGUI() { DrawDefaultInspector(); m_fieldName = EditorGUILayout.TextField("Field Name", m_fieldName); if (GUILayout.Button("Save Input")) { if (Application.isPlaying) { InputCapture capture = (InputCapture)target; if (capture.DoesFileExist(m_fieldName)) { int option = EditorUtility.DisplayDialogComplex("File exists.", "The file needs to be deleted", "Delete", "Cancel", ""); if (option != 0) { capture.SaveEvents(m_fieldName); } } else { capture.SaveEvents(m_fieldName); } } else { Debug.Log("Saving only works in play mode"); } } }
// Movement public void BlockDodgeCheck () { float xDodge = InputCapture.hThrow; float yDodge = InputCapture.vThrow; bool blockDodge = InputCapture.block; activeDodge = false; activeBlock = false; //stationary is found in the movement check if (blockDodge && stationary) { activeBlock = true; if (xDodge != 0 || yDodge != 0) { activeBlock = false; activeDodge = true; print ("block into dodge"); } } if (blockDodge && !stationary && !activeDodge) { //tie running dodge into animation } if (activeDodge) { if (dodgeAvailable && InputCapture.JoystickOverThreshold (0.5f)) { CalcDodge (); dodgeAvailable = false; activeDodge = false; print ("Dodging"); //set this to have a proper cooldown } } }
// Update is called once per frame void Update () { if (RoomManager.gameSetupComplete && !roLo.dead) { if (GameManager.mouseInput) { InputCapture.MouseAim (MouseDistanceFromPlayer ()); } else { InputCapture.ControllerAim (); } if (!GameManager.paused && !ItemWheel.active) { BlockDodgeCheck (); if (!activeBlock && !activeDodge && !roLo.stopped) { MovementCheck (); AimAndFireCheck (); } } } if (roLo.dead && !playerDead) { Invoke ("LoadToHub", 2); playerDead = true; } }
public void CalcDodge () { Facing moveDir = InputCapture.JoystickDirection (); float dodgeRoll = 200f; print (moveDir); if (moveDir == Facing.right) { //right dodge StartCoroutine (PerformDodge (new Vector2 (dodgeRoll, 0))); } if (moveDir == Facing.upperRight) { //upright dodge StartCoroutine (PerformDodge (new Vector2 (dodgeRoll, dodgeRoll))); } if (moveDir == Facing.lowerRight) { //downright dodge StartCoroutine (PerformDodge (new Vector2 (dodgeRoll, -dodgeRoll))); } if (moveDir == Facing.left) { //left dodge StartCoroutine (PerformDodge (new Vector2 (-dodgeRoll, 0))); } if (moveDir == Facing.upperLeft) { //upleft dodge StartCoroutine (PerformDodge (new Vector2 (-dodgeRoll, dodgeRoll))); } if (moveDir == Facing.lowerLeft) { //downleft dodge StartCoroutine (PerformDodge (new Vector2 (-dodgeRoll, -dodgeRoll))); } if (moveDir == Facing.up) { //up dodge StartCoroutine (PerformDodge (new Vector2 (0, dodgeRoll))); } if (moveDir == Facing.down) { //down dodge StartCoroutine (PerformDodge (new Vector2 (0, -dodgeRoll))); } }