예제 #1
0
 private void processWeaponInput() {
     // Attack with primary
     if (!aimMode && usePrimaryWeapon) {
         // New behavior
         if (isWeaponActive(inventory.primaryWeapon)) {
             mecanim.SetBool(State.STEADY, true);
             if (inventory.primaryWeapon.canUseWeapon()) mecanim.SetBool(State.TRIGGER, true);
             else mecanim.SetBool(State.TRIGGER, false);
         }
         else {
             drawPrimary();
         }
     }
     // Attack with secondary
     else if (!aimMode && useSecondaryWeapon) {
         if (isHero()) {
             shield.Charge();
             if (OnSecondaryUp == null) {
                 secondaryUp = delegate () {
                     shield.Exile();
                     OnSecondaryUp -= secondaryUp;
                 };
                 OnSecondaryUp += secondaryUp;
             }
         }
         else {
             if (isWeaponActive(inventory.secondaryWeapon)) {
                 mecanim.SetBool(State.STEADY, true);
                 if (inventory.secondaryWeapon.canUseWeapon()) mecanim.SetBool(State.TRIGGER, true);
                 else mecanim.SetBool(State.TRIGGER, false);
             }
             else {
                 drawSecondary();
             }
         }
     }
     // No attacking at all
     else {
         mecanim.SetBool(State.STEADY, false);
         mecanim.SetBool(State.TRIGGER, false);
     }
 }
예제 #2
0
        // Reading weapon input
        private void readInput() {
            bool primaryDown, primaryHold, primaryUp;
            bool secondaryDown, secondaryHold, secondaryUp;
            switch (player.inputType) {
                case InputType.KEYBOARD:
                    // For processing
                    usePrimaryWeapon = Input.GetButton(Control.LeftMouse);
                    useSecondaryWeapon = Input.GetButton(Control.RightMouse);
                    useFirstItem = Input.GetButtonUp(Control.Q);
                    useSecondItem = Input.GetButtonUp(Control.E);

                    // For firing events
                    primaryDown = Input.GetButtonDown(Control.LeftMouse);
                    primaryHold = usePrimaryWeapon;
                    primaryUp = Input.GetButtonUp(Control.LeftMouse);
                    secondaryDown = Input.GetButtonDown(Control.RightMouse);
                    secondaryHold = useSecondaryWeapon;
                    secondaryUp = Input.GetButtonUp(Control.RightMouse);
                    requestTeleport = Input.GetButtonDown(Control.LeftAlt);
                    dodge = Input.GetButtonDown(Control.Space);

                    break;
                case InputType.GAMEPAD:
                    float rightTrigger = Input.GetAxis(Utils.getControlForPlayer(Control.RightTrigger, player.gamepadNumber));
                    float leftTrigger = Input.GetAxis(Utils.getControlForPlayer(Control.LeftTrigger, player.gamepadNumber));

                    primaryDown = (!usePrimaryWeapon && (rightTrigger > 0f));
                    primaryHold = (rightTrigger > 0f);
                    primaryUp = (usePrimaryWeapon && (rightTrigger <= 0.1f));
                    secondaryDown = (!useSecondaryWeapon && (leftTrigger > 0f));
                    secondaryHold = (leftTrigger > 0f);
                    secondaryUp = (useSecondaryWeapon && (leftTrigger <= 0.1f));

                    usePrimaryWeapon = primaryHold;
                    useSecondaryWeapon = secondaryHold;
                    useFirstItem = Input.GetButtonUp(Utils.getControlForPlayer(Control.LeftBumper, player.gamepadNumber));
                    useSecondItem = Input.GetButtonUp(Utils.getControlForPlayer(Control.RightBumper, player.gamepadNumber));
                    requestTeleport = Input.GetButtonDown(Utils.getControlForPlayer(Control.X, player.gamepadNumber));
                    dodge = Input.GetButtonDown(Utils.getControlForPlayer(Control.B, player.gamepadNumber));

                    break;
                default:
                    usePrimaryWeapon = false;
                    useSecondaryWeapon = false;
                    useFirstItem = false;
                    useSecondItem = false;
                    primaryDown = false;
                    primaryHold = false;
                    primaryUp = false;
                    secondaryDown = false;
                    secondaryHold = false;
                    secondaryUp = false;
                    requestTeleport = false;
                    dodge = false;
                    break;
            }
            // Firing freakin events
            if (primaryDown && OnPrimaryDown != null) OnPrimaryDown();
            if (primaryHold && OnPrimaryHold != null) OnPrimaryHold();
            if (primaryUp && OnPrimaryUp != null) OnPrimaryUp();
            if (secondaryDown && OnSecondaryDown != null) OnSecondaryDown();
            if (secondaryHold && OnSecondaryHold != null) OnSecondaryHold();
            if (secondaryUp && OnSecondaryUp != null) OnSecondaryUp();
        }