public override void Awake() { base.Awake(); curKey = -1; _adsrInterface = GetComponentInChildren <adsrInterface>(); octaveToggle = GetComponentInChildren <basicSwitch>(); freqSignal = GetComponent <keyFrequencySignalGenerator>(); adsrSignal = GetComponent <adsrSignalGenerator>(); freqoutput.homesignal = freqSignal; ampoutput.homesignal = adsrSignal; keys = new key[keyCount]; adsrSignal.durations = _adsrInterface.durations; adsrSignal.volumes = _adsrInterface.volumes; SpawnKeys(); for (int i = 0; i < 25; i++) { keyStates[i] = new keyState(false); } }
// Update is called once per frame void Update() { if (Input.GetKey("d") | Input.GetKey("1")) { if (leftKey == keyState.up) { leftKey = keyState.down; leftTimeDown = Time.time; } if (leftKey == keyState.down && (Time.time >= (leftTimeDown + holdDelay))) { leftKey = keyState.hold; } } else { leftKey = keyState.up; } if (Input.GetKey("k") | Input.GetKey("2")) { if (rightKey == keyState.up) { rightKey = keyState.down; rightTimeDown = Time.time; } if (rightKey == keyState.down && (Time.time >= (rightTimeDown + holdDelay))) { rightKey = keyState.hold; } } else { rightKey = keyState.up; } if (leftKey != keyState.up && rightKey != keyState.up) { if (bothKey == keyState.up) { bothKey = keyState.down; bothTimeDown = Time.time; } if (bothKey == keyState.down && Time.time >= bothTimeDown + holdDelay) { bothKey = keyState.hold; } } else { bothKey = keyState.up; } }
void turnleft() { if (leftKey == keyState.up) { leftKey = keyState.down; rightKey = keyState.up; bothKey = keyState.up; } }
void turnright() { if (rightKey == keyState.up) { rightKey = keyState.down; leftKey = keyState.up; bothKey = keyState.up; } }
void gostraight() { if (leftKey != keyState.up || rightKey != keyState.up || bothKey != keyState.up) { leftKey = keyState.up; rightKey = keyState.up; bothKey = keyState.up; } }
void shoot() { if (bothKey == keyState.up) { bothKey = keyState.down; bothDownTime = Time.time; } if (Time.time > bothDownTime + holdDelay) { bothKey = keyState.up; } }
// Update is called once per frame void Update() { if (Input.GetKey("d") | Input.GetKey("1")) { if (leftKey == keyState.up) { leftKey = keyState.down; leftTimeDown = Time.time; } if (leftKey == keyState.down && (Time.time >= (leftTimeDown+holdDelay))) { leftKey = keyState.hold; } } else leftKey = keyState.up; if (Input.GetKey("k") | Input.GetKey("2")) { if (rightKey == keyState.up) { rightKey = keyState.down; rightTimeDown = Time.time; } if (rightKey == keyState.down && (Time.time >= (rightTimeDown+holdDelay))) { rightKey = keyState.hold; } } else rightKey = keyState.up; if (leftKey != keyState.up && rightKey != keyState.up) { if (bothKey == keyState.up) { bothKey = keyState.down; bothTimeDown = Time.time; } if (bothKey == keyState.down && Time.time >= bothTimeDown+holdDelay) bothKey = keyState.hold; } else bothKey = keyState.up; }
public bool getKey(SettingFunction.key keyName, keyState ks) { if (!mobile) { switch (ks) { case keyState.down: return(Input.GetKeyDown(Setting.current.key[(int)keyName])); case keyState.hold: return(Input.GetKey(Setting.current.key[(int)keyName])); case keyState.up: return(Input.GetKeyUp(Setting.current.key[(int)keyName])); default: return(false); } } else { return(key[(int)keyName, (int)ks]); } }
public override void Awake() { base.Awake(); _beatManager = ScriptableObject.CreateInstance <beatTracker>(); sticks = GetComponentsInChildren <drumstick>(); signal = GetComponent <xylorollSignalGenerator>(); _adsrInterface = GetComponentInChildren <adsrInterface>(); inputSwitch = GetComponentInChildren <basicSwitch>(); signal.spawnVoices(voiceCount, _adsrInterface.volumes, _adsrInterface.durations); SpawnKeys(); oscBank.SetActive(inputVal); sampleBank.SetActive(!inputVal); _timeline.setStartTracks(24); for (int i = 0; i < 24; i++) { keyStates[i] = new keyState(false); } }
void setKeyFeedbackState(keyState s) { switch (s) { case keyState.off: rend.material = offMat; break; case keyState.touched: rend.material = glowMat; setKeyColor(.65f, .3f); break; case keyState.grabbedOn: rend.material = glowMat; setKeyColor(.4f, .4f); break; case keyState.grabbedOff: rend.material = glowMat; setKeyColor(.65f, .4f); break; case keyState.selectedOff: rend.material = glowMat; setKeyColor(.4f, .3f); break; case keyState.selectedOn: rend.material = glowMat; setKeyColor(.5f, .4f); break; default: break; } }
public static char ToChar(this keyState source) { return((char)((int)source)); }
// Update is called once per frame void Update() { this.gameObject.transform.Translate(transform.forward * (Time.deltaTime * Stats.moveFactor), Space.World); if (Time.time > playerlossTime + playerLifeLossInt) { Stats.Health = Stats.Health - playerLifeLoss; playerlossTime = Time.time; } #region Key Commands //Define Keys leftKey = (keyState)gameObject.GetComponent <NewInput>().leftKey; rightKey = (keyState)gameObject.GetComponent <NewInput>().rightKey; bothKey = (keyState)gameObject.GetComponent <NewInput>().bothKey; //Prime Commands if (!isDead) { if (rightKey == keyState.down) { rightReady = true; } if (leftKey == keyState.down) { leftReady = true; } if (bothKey == keyState.down) { fireReady = true; } if (bothKey == keyState.hold) { chargeReady = true; } } else { rightKey = keyState.up; leftKey = keyState.up; bothKey = keyState.up; } //Execute Commands if (fireReady && bothKey == keyState.up) { fireReady = false; fireActive = true; chargeReady = false; //playerReactor = 0f; nukeReady = false; } if (chargeReady) { if (playerReactor < playerReactorMax) { playerReactor = playerReactor + playerReactorCharge; } if (playerReactor >= playerReactorMax) { if (!nukeReady) { playerNukeTime = Time.time; nukeReady = true; } if (Time.time > playerNukeTime + playerNukeDelay) { nukeNuke = true; //Stats.Health = Stats.Health - 1000f; } } } if (playerReactor != 0 && !GameObject.Find("Gui").GetComponent <AudioSource>().isPlaying) { GameObject.Find("Gui").GetComponent <AudioSource>().Play(); } else if (playerReactor == 0 && GameObject.Find("Gui").GetComponent <AudioSource>().isPlaying) { GameObject.Find("Gui").GetComponent <AudioSource>().Stop(); } if (leftReady && leftKey != keyState.up) { if (turnCurrentLeft < turnFactor) { turnCurrentLeft = turnCurrentLeft + (turnTime / turnFactor); } this.transform.Rotate(Vector3.up, -1 * turnCurrentLeft, Space.World); } else { leftReady = false; if (turnCurrentLeft > 0) { turnCurrentLeft = turnCurrentLeft - (dragFactor); this.transform.Rotate(Vector3.up, -1 * turnCurrentLeft, Space.World); } else { turnCurrentLeft = 0; } } if (rightReady && rightKey != keyState.up) { if (turnCurrentRight < turnFactor) { turnCurrentRight = turnCurrentRight + (turnTime / turnFactor); } this.transform.Rotate(Vector3.up, turnCurrentRight, Space.World); } else { rightReady = false; if (turnCurrentRight > 0) { turnCurrentRight = turnCurrentRight - (dragFactor); this.transform.Rotate(Vector3.up, turnCurrentRight, Space.World); } else { turnCurrentRight = 0; } } #endregion #region Bank Animation //bank animation //if (turnCurrentRight>turnCurrentLeft) //if (leftReady && GameObject.Find("PlayerPivot").gameObject.transform.rotation.x < 50 ) //{ // print("turn"); //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(Vector3.right, (turnCurrentLeft)); //} //if (!leftReady && turnCurrentLeft > 0) //{ // print("Counter turn"); //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(-1*Vector3.right, 1); //} //if (GameObject.Find("PlayerPivot").gameObject.transform.rotation.x > turnCurrentRight*20) //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(Vector3.right, (turnCurrentRight)); //if (turnCurrentRight<turnCurrentLeft) //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(Vector3.right, (turnCurrentLeft)); //death over time #endregion if (fireActive && !isDead) { GameObject lazerSpawn; //Vector3 thisPos = new Vector3(this.gameObject.transform.position.x,this.gameObject.transform.position.y,this.gameObject.transform.position.z); //Quaternion thisRot = new Quaternion(this.gameObject.transform.rotation.x,this.gameObject.transform.rotation.y,this.gameObject.transform.rotation.z,this.gameObject.transform.rotation.w); //Instantiate(gamebits.Lazer,new Vector3(thisPos[0]-0.35f,thisPos[1]+0.1f,thisPos[2]+1.5f),new Quaternion(thisRot[0],0.25f,thisRot[2],thisRot[3])); lazerSpawn = (GameObject)Instantiate(gamebits.Lazer, GameObject.Find("weaponL").gameObject.transform.position, GameObject.Find("weaponL").gameObject.transform.rotation); lazerSpawn.name = ("Lazer" + this.gameObject.name); lazerSpawn.GetComponent <stats>().hitDamage = lazerSpawn.GetComponent <stats>().hitDamage + playerReactor * 2; lazerSpawn.GetComponent <stats>().Health = lazerSpawn.GetComponent <stats>().Health + playerReactor * 2; lazerSpawn.GetComponent <Lazer>().owner = this.gameObject; lazerSpawn = (GameObject)Instantiate(gamebits.Lazer, GameObject.Find("weaponR").gameObject.transform.position, GameObject.Find("weaponR").gameObject.transform.rotation); lazerSpawn.name = ("Lazer" + this.gameObject.name); lazerSpawn.GetComponent <stats>().hitDamage = lazerSpawn.GetComponent <stats>().hitDamage + playerReactor * 2; lazerSpawn.GetComponent <stats>().Health = lazerSpawn.GetComponent <stats>().Health + playerReactor * 2; lazerSpawn.GetComponent <Lazer>().owner = this.gameObject; fireActive = false; playerReactor = 0f; } if (nukeNuke) { Stats.Health = Stats.Health - 1000; nukeNuke = false; nukeReady = false; chargeReady = false; isDead = true; Instantiate(gamebits.nukeExplo, this.gameObject.transform.position, Quaternion.identity); GameObject flameobject; flameobject = (GameObject)Instantiate(gamebits.FlameTrailBig, this.gameObject.transform.position, Quaternion.identity); flameobject.transform.parent = this.transform; gameObject.transform.FindChild("PlayerPivot").gameObject.SetActive(false); playerReactor = 0f; } if (Stats.Health < 1f && !isDead && !nukeNuke) { isDead = true; Instantiate(gamebits.explodeExplo, this.gameObject.transform.position, Quaternion.identity); gameObject.transform.FindChild("PlayerPivot").gameObject.SetActive(false); } if (Stats.Health < 75 && !isDead) { gameObject.transform.FindChild("Explosion01").gameObject.SetActive(true); } if (Stats.Health < 50 && !isDead) { gameObject.transform.FindChild("Explosion02").gameObject.SetActive(true); } if (Stats.Health < 25 && !isDead) { gameObject.transform.FindChild("Explosion03").gameObject.SetActive(true); } if (Stats.Health < 0 && isDead) { gameObject.transform.FindChild("Explosion01").gameObject.SetActive(false); gameObject.transform.FindChild("Explosion02").gameObject.SetActive(false); gameObject.transform.FindChild("Explosion03").gameObject.SetActive(false); } // if (isDead && GameObject.Find("PlayerPivot").activeSelf) // { // GameObject.Find("PlayerPivot").SetActive(false); // } }
void shoot() { if (bothKey == keyState.up) { bothKey = keyState.down; bothDownTime = Time.time; } if (Time.time > bothDownTime+holdDelay) bothKey = keyState.up; }
protected PlayerInputs ReturnPlayerInputs() { currentMouseX = Input.GetAxis(mouseXInput); currentMouseY = Input.GetAxis(mouseYInput); currentMove = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); if (Input.GetButtonDown(jumpInput)) { currentJump = keyState.Down; } else if (Input.GetButtonUp(jumpInput)) { currentJump = keyState.Up; } else { currentJump = keyState.Null; } if (Input.GetButtonDown(runInput)) { currentRun = keyState.Down; } else if (Input.GetButtonUp(runInput)) { currentRun = keyState.Up; } else { currentRun = keyState.Null; } if (Input.GetButtonDown(crouchInput)) { currentCrouch = keyState.Down; } else if (Input.GetButtonUp(crouchInput)) { currentCrouch = keyState.Up; } else { currentCrouch = keyState.Null; } if (Input.GetButtonDown(interactInput)) { currentInteract = keyState.Down; } else if (Input.GetButtonUp(interactInput)) { currentInteract = keyState.Up; } else { currentInteract = keyState.Null; } currentPlayerInputs = new PlayerInputs() { mouseX = currentMouseX, mouseY = currentMouseY, move = currentMove, jump = currentJump, run = currentRun, crouch = currentCrouch, interact = currentInteract }; return(currentPlayerInputs); }
public static bool SendKeyboardAction(Keys key, keyState state) { return(SendKeyboardAction((byte)key.GetHashCode(), state)); }
public static bool SendKeyboardAction(byte key, keyState state) { return(keybd_event(key, 0, (uint)state, (UIntPtr)0)); }
// Update is called once per frame void Update() { this.gameObject.transform.Translate(transform.forward * (Time.deltaTime *Stats.moveFactor),Space.World); if (Time.time > playerlossTime+playerLifeLossInt) { Stats.Health = Stats.Health - playerLifeLoss; playerlossTime = Time.time; } #region Key Commands //Define Keys leftKey = (keyState)gameObject.GetComponent<NewInput>().leftKey; rightKey = (keyState)gameObject.GetComponent<NewInput>().rightKey; bothKey = (keyState)gameObject.GetComponent<NewInput>().bothKey; //Prime Commands if (!isDead) { if (rightKey == keyState.down) rightReady = true; if (leftKey == keyState.down) leftReady = true; if (bothKey == keyState.down) fireReady = true; if (bothKey == keyState.hold) chargeReady = true; } else { rightKey = keyState.up; leftKey = keyState.up; bothKey = keyState.up; } //Execute Commands if (fireReady && bothKey == keyState.up) { fireReady = false; fireActive = true; chargeReady = false; //playerReactor = 0f; nukeReady = false; } if (chargeReady) { if (playerReactor < playerReactorMax) playerReactor = playerReactor + playerReactorCharge; if (playerReactor >= playerReactorMax) { if (!nukeReady) { playerNukeTime = Time.time; nukeReady = true; } if (Time.time > playerNukeTime + playerNukeDelay) { nukeNuke = true; //Stats.Health = Stats.Health - 1000f; } } } if (playerReactor != 0 && !GameObject.Find("Gui").GetComponent<AudioSource>().isPlaying) GameObject.Find("Gui").GetComponent<AudioSource>().Play(); else if (playerReactor == 0 && GameObject.Find("Gui").GetComponent<AudioSource>().isPlaying) GameObject.Find("Gui").GetComponent<AudioSource>().Stop(); if (leftReady && leftKey != keyState.up) { if (turnCurrentLeft < turnFactor) { turnCurrentLeft = turnCurrentLeft + (turnTime/turnFactor); } this.transform.Rotate(Vector3.up,-1*turnCurrentLeft,Space.World); } else { leftReady = false; if (turnCurrentLeft > 0) { turnCurrentLeft = turnCurrentLeft - (dragFactor); this.transform.Rotate(Vector3.up,-1*turnCurrentLeft,Space.World); } else turnCurrentLeft = 0; } if (rightReady && rightKey != keyState.up) { if (turnCurrentRight < turnFactor) { turnCurrentRight = turnCurrentRight + (turnTime/turnFactor); } this.transform.Rotate(Vector3.up,turnCurrentRight,Space.World); } else { rightReady = false; if (turnCurrentRight > 0) { turnCurrentRight = turnCurrentRight - (dragFactor); this.transform.Rotate(Vector3.up,turnCurrentRight,Space.World); } else turnCurrentRight = 0; } #endregion #region Bank Animation //bank animation //if (turnCurrentRight>turnCurrentLeft) //if (leftReady && GameObject.Find("PlayerPivot").gameObject.transform.rotation.x < 50 ) //{ // print("turn"); //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(Vector3.right, (turnCurrentLeft)); //} //if (!leftReady && turnCurrentLeft > 0) //{ // print("Counter turn"); //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(-1*Vector3.right, 1); //} //if (GameObject.Find("PlayerPivot").gameObject.transform.rotation.x > turnCurrentRight*20) //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(Vector3.right, (turnCurrentRight)); //if (turnCurrentRight<turnCurrentLeft) //GameObject.Find("PlayerPivot").gameObject.transform.Rotate(Vector3.right, (turnCurrentLeft)); //death over time #endregion if (fireActive && !isDead) { GameObject lazerSpawn; //Vector3 thisPos = new Vector3(this.gameObject.transform.position.x,this.gameObject.transform.position.y,this.gameObject.transform.position.z); //Quaternion thisRot = new Quaternion(this.gameObject.transform.rotation.x,this.gameObject.transform.rotation.y,this.gameObject.transform.rotation.z,this.gameObject.transform.rotation.w); //Instantiate(gamebits.Lazer,new Vector3(thisPos[0]-0.35f,thisPos[1]+0.1f,thisPos[2]+1.5f),new Quaternion(thisRot[0],0.25f,thisRot[2],thisRot[3])); lazerSpawn = (GameObject)Instantiate(gamebits.Lazer,GameObject.Find("weaponL").gameObject.transform.position,GameObject.Find("weaponL").gameObject.transform.rotation); lazerSpawn.name = ("Lazer" + this.gameObject.name); lazerSpawn.GetComponent<stats>().hitDamage = lazerSpawn.GetComponent<stats>().hitDamage + playerReactor*2; lazerSpawn.GetComponent<stats>().Health = lazerSpawn.GetComponent<stats>().Health + playerReactor*2; lazerSpawn.GetComponent<Lazer>().owner = this.gameObject; lazerSpawn = (GameObject)Instantiate(gamebits.Lazer,GameObject.Find("weaponR").gameObject.transform.position,GameObject.Find("weaponR").gameObject.transform.rotation); lazerSpawn.name = ("Lazer" + this.gameObject.name); lazerSpawn.GetComponent<stats>().hitDamage = lazerSpawn.GetComponent<stats>().hitDamage + playerReactor*2; lazerSpawn.GetComponent<stats>().Health = lazerSpawn.GetComponent<stats>().Health + playerReactor*2; lazerSpawn.GetComponent<Lazer>().owner = this.gameObject; fireActive=false; playerReactor = 0f; } if (nukeNuke) { Stats.Health = Stats.Health - 1000; nukeNuke = false; nukeReady = false; chargeReady = false; isDead = true; Instantiate(gamebits.nukeExplo,this.gameObject.transform.position,Quaternion.identity); GameObject flameobject; flameobject = (GameObject)Instantiate(gamebits.FlameTrailBig,this.gameObject.transform.position,Quaternion.identity); flameobject.transform.parent = this.transform; gameObject.transform.FindChild("PlayerPivot").gameObject.SetActive(false); playerReactor = 0f; } if (Stats.Health < 1f && !isDead && !nukeNuke) { isDead = true; Instantiate(gamebits.explodeExplo,this.gameObject.transform.position,Quaternion.identity); gameObject.transform.FindChild("PlayerPivot").gameObject.SetActive(false); } if (Stats.Health < 75 && !isDead) gameObject.transform.FindChild("Explosion01").gameObject.SetActive(true); if (Stats.Health < 50 && !isDead) gameObject.transform.FindChild("Explosion02").gameObject.SetActive(true); if (Stats.Health < 25 && !isDead) gameObject.transform.FindChild("Explosion03").gameObject.SetActive(true); if (Stats.Health < 0 && isDead) { gameObject.transform.FindChild("Explosion01").gameObject.SetActive(false); gameObject.transform.FindChild("Explosion02").gameObject.SetActive(false); gameObject.transform.FindChild("Explosion03").gameObject.SetActive(false); } // if (isDead && GameObject.Find("PlayerPivot").activeSelf) // { // GameObject.Find("PlayerPivot").SetActive(false); // } }