void Start() { rb = GetComponent <Rigidbody>(); this.dir = Direction.UP; this.inFrontOf = new List <GameObject>(); trackingKeyPress = false; this.trackedEnum = SmokerAttack.None; }
private void processKeys() { // If the user presses "1" and we're not tracking a key press if (!trackingKeyPress) { // IF we're not currently tracking a down key press if (Input.GetKeyDown("1")) { // Record when the button was pressed this.trackingKeyPress = true; this.trackedEnum = SmokerAttack.PUFF; // Puff smoke to all infront of you } // End Input.GetKeyDown("1"); // Reload key if (Input.GetKeyDown("r")) { this.trackingKeyPress = true; this.trackedEnum = SmokerAttack.RELOAD; } // NEW SKILL/ KEY DOWN EVENTS GO HERE if (trackingKeyPress) { // If we started tracking a new key this.buttonDownTime = Time.time; } } if (Input.GetKeyUp("1") && this.trackedEnum == SmokerAttack.PUFF) { float buttonUpTime = Time.time; this.trackingKeyPress = false; this.trackedEnum = SmokerAttack.None; // Less than the number implies a quick attack if (buttonUpTime - this.buttonDownTime < 0.5f) { // Do a small puff attack; float puffCost = 10.0f; foreach (GameObject go in inFrontOf) { if (this.energyBar.getCurrentFill() <= puffCost) { break; // Out of energy } go.GetComponent <Renderer>().material.color = new Color(0, 0, 200); this.energyBar.reduceFill(puffCost); } } else { // Do a large puff attack } } // End Input.GetKeyUp("1") }