Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        fsm.Update();

        if (this.combo > 1)
        {
            comboKillTimer -= Time.deltaTime;
            //this.comboMeter.fillAmount = MathUtil.Map(this.comboKillTimer, this.comboKillTime, 0, 0, 1);
            if (comboKillTimer <= 0)
            {
                //this.DecrementCombo();
                comboKillTimer = comboKillTime;
            }
        }
        if (GameManager.instance.paused)
        {
            Time.timeScale = 0;
        }
        else
        {
            Time.timeScale = 1;
        }
        if (Sinput.GetButtonDown("Pause"))
        {
            GameManager.instance.pausedForPauseScreen = !GameManager.instance.pausedForPauseScreen;
            GameManager.instance.paused = !GameManager.instance.paused;
        }
        if (Sinput.GetButtonDown("Restart"))
        {
            SceneManager.LoadSceneAsync(0);
        }
    }
        // Update is called once per frame
        void Update()
        {
            //get player input for motion
            Vector3 motionInput = Sinput.GetVector("Horizontal", "", "Vertical", playerSlot);

            //we want to move like, three times as much as this
            motionInput *= 3f;

            //gravity
            yMotion      -= Time.deltaTime * 10f;
            motionInput.y = yMotion;

            //move our character controller now
            characterController.Move(motionInput * Time.deltaTime);

            if (characterController.isGrounded)
            {
                yMotion = -0.05f;

                if (Sinput.GetButtonDown("Jump", playerSlot))
                {
                    yMotion = 5f;
                }
            }
        }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (Sinput.GetButtonDownRepeating("Up"))
        {
            //highlight item above
            currentMenuItem.highlighted = false;
            currentMenuItem             = currentMenuItem.itemAbove;
            currentMenuItem.highlighted = true;
        }
        if (Sinput.GetButtonDownRepeating("Down"))
        {
            //highlight item below
            currentMenuItem.highlighted = false;
            currentMenuItem             = currentMenuItem.itemBelow;
            currentMenuItem.highlighted = true;
        }
        if (Sinput.GetButtonDown("Submit"))
        {
            //select this item
            currentMenuItem.Select();
            Sinput.ResetInputs();
        }

        cam.position = Vector3.Lerp(cam.position, currentMenuItem.camTargetPos.position, Time.deltaTime * 4f);
        cam.rotation = Quaternion.Slerp(cam.rotation, currentMenuItem.camTargetPos.rotation, Time.deltaTime * 4f);

        cursor.position = currentMenuItem.cursorTarget.position;
    }
Exemplo n.º 4
0
 public bool ButtonCheck(ButtonAction bAction, InputDeviceSlot slot)
 {
     if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(positiveControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(negativeControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.HELD && Sinput.GetButton(positiveControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.HELD && Sinput.GetButton(negativeControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.UP && Sinput.GetButtonUp(positiveControl, slot))
     {
         return(true);
     }
     if (bAction == ButtonAction.UP && Sinput.GetButtonUp(negativeControl, slot))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
    void Move(float lh, float lv)
    {
        if (inMenu == false)
        {
            movement.Set(lh, 0f, lv);
            movement   = Camera.main.transform.TransformDirection(movement);
            movement.y = 0f;

            if (Sinput.GetButtonDown("Jump") && isGrounded)
            {
                Jump();
            }

            myRB.AddForce(movement * speed);

            if (lh != 0f || lv != 0f)
            {
                Rotating(lh, lv);
            }
            if (myRB.velocity.magnitude > maxSpeed)
            {
                myRB.velocity = myRB.velocity.normalized * maxSpeed;
            }
        }
    }
Exemplo n.º 6
0
        private bool ButtonCheck(string controlname, ButtonAction bAction)
        {
            Sinput.SinputUpdate();

            for (int i = 0; i < joystickIndeces.Count; i++)
            {
                if (bAction == ButtonAction.DOWN && Sinput.GetButtonDown(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
                if (bAction == ButtonAction.HELD && Sinput.GetButton(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
                if (bAction == ButtonAction.UP && Sinput.GetButtonUp(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
                if (bAction == ButtonAction.REPEATING && Sinput.GetButtonDownRepeating(controlname, (InputDeviceSlot)joystickIndeces[i]))
                {
                    return(true);
                }
            }


            return(false);
        }
Exemplo n.º 7
0
 public static bool IsValidKey()
 {
     return(Input.GetMouseButtonDown(0) || Sinput.GetButtonDown(GetInputName(InputButton.A)) ||
            Sinput.GetButtonDown(GetInputName(InputButton.B)) || Sinput.GetButtonDown(GetInputName(InputButton.X)) ||
            Sinput.GetButtonDown(GetInputName(InputButton.Y)) || Sinput.GetButtonDown(GetInputName(InputButton.DPadLeft)) ||
            Sinput.GetButtonDown(GetInputName(InputButton.DPadRight)) || Sinput.GetButtonDown(GetInputName(InputButton.DPadDown)) ||
            Sinput.GetButtonDown(GetInputName(InputButton.DPadUp)) || Sinput.GetButtonDown("LB") ||
            Sinput.GetButtonDown("RB"));
 }
Exemplo n.º 8
0
    public void Ground_Update()
    {
        PlayerAnim currentAnim = PlayerAnim.Idle;

        if (hInput != 0)
        {
            currentAnim = this.objectBeingCarried ? PlayerAnim.Carry_Walk : PlayerAnim.Walk;
        }
        else
        {
            currentAnim = this.objectBeingCarried ? PlayerAnim.Carry_Idle : PlayerAnim.Idle;
        }

        if (!animator.IsPlaying(animations[currentAnim]))
        {
            PlayAnim(currentAnim);
        }
        //END ANIMATION STUFF

        if (objectBeingCarried)
        {
            HandleObjectThrow();
        }
        else
        {
            CheckGrabs();
        }

        this.currentSpeed = this.speed;

        if (Sinput.GetButtonDown("Jump"))
        {
            SfxManager.instance.PlaySound(SoundType.JUMP);
            Squash(0.05f).Then(() => {
                Stretch();
                velocity.y = jumpSpeed;
            });
        }
        if (Sinput.GetButtonDown("Down"))
        {
            if (groundCollider.CompareTag("OneWay"))
            {
                transform.position += Vector3.down * 0.5f;
            }
        }

        this.currentGravityModifier = this.gravityModifier;

        //STATE CHANGES
        if (!grounded)
        {
            fsm.ChangeState(PlayerState.Air);
        }

        HandleLeftRightMovement();
    }
Exemplo n.º 9
0
 public void Update()
 {
     foreach (var inputNameToCheckFor in INPUT_NAMES_TO_CHECK_FOR)
     {
         if (Sinput.GetButtonDown(inputNameToCheckFor, _playerData.InputDeviceSlot))
         {
             InvokeInputPressed(inputNameToCheckFor);
         }
     }
 }
Exemplo n.º 10
0
    public void Air_Update()
    {
        if (this.velocity.y > 0)
        {
            PlayAnim(this.objectBeingCarried ? PlayerAnim.Carry_Jump : PlayerAnim.Jump);
        }
        else
        {
            PlayAnim(this.objectBeingCarried ? PlayerAnim.Carry_Fall : PlayerAnim.Fall);
        }

        if (Sinput.GetButtonUp("Jump"))
        {
            velocity.y *= 0.5f;
        }

        if (velocity.y > 0)
        {
            this.currentGravityModifier = this.gravityModifier;
        }
        else
        {
            this.currentGravityModifier = this.fallGravityModifier;
        }

        if (grounded)
        {
            fsm.ChangeState(PlayerState.Ground);
        }
        if (Sinput.GetButtonDown("Jump") && !doubleJumped)
        {
            doubleJumped = true;
            SfxManager.instance.PlaySound(SoundType.JUMP);
            Stretch();
            velocity.y = jumpSpeed;
        }

        if (Sinput.GetButtonDown("Down") && objectBeingCarried && objectBeingCarried.GetComponent <Slime>())
        {
            objectBeingCarried.transform.parent    = null;
            objectBeingCarried.transform.position += Vector3.down * (spriteRenderer.bounds.size.y);

            objectBeingCarried.Throw(0);
            objectBeingCarried = null;
            objectToGrab       = null;
        }


        HandleLeftRightMovement();
        HandleObjectThrow();
        if (!objectBeingCarried)
        {
            CheckGrabs();
        }
    }
Exemplo n.º 11
0
 public void HandleObjectThrow()
 {
     if (!objectBeingCarried)
     {
         return;
     }
     if (Sinput.GetButtonDown("Grab"))
     {
         fsm.ChangeState(PlayerState.Throwing);
     }
 }
Exemplo n.º 12
0
 private void Update()
 {
     if (Sinput.GetButtonDown("Menu"))
     {
         // then toggle pause!
         isPaused = !isPaused;
         if (isPaused)
         {
             PauseGame();
         }
         else
         {
             ResumeGame();
         }
     }
 }
Exemplo n.º 13
0
    private IEnumerator CheckPress()
    {
        while (Sinput.GetButton(_button))
        {
            if (Sinput.GetButtonDown("RB"))
            {
                _audioSource.pitch += 0.1f;
            }

            if (Sinput.GetButtonDown("LB"))
            {
                _audioSource.pitch -= 0.1f;
            }

            yield return(null);
        }

        Destroy(gameObject);
    }
Exemplo n.º 14
0
    private void Update()
    {
        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadLeft)))
        {
            CoroutineThing(InputManager.InputButton.DPadLeft, ref _dpadleftCoroutine);
        }

        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadRight)))
        {
            CoroutineThing(InputManager.InputButton.DPadRight, ref _dpadrightCoroutine);
        }

        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadDown)))
        {
            CoroutineThing(InputManager.InputButton.DPadDown, ref _dpaddownCoroutine);
        }

        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadUp)))
        {
            CoroutineThing(InputManager.InputButton.DPadUp, ref _dpadupCoroutine);
        }

        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.A)))
        {
            CoroutineThing(InputManager.InputButton.A, ref _aCoroutine);
        }

        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.B)))
        {
            CoroutineThing(InputManager.InputButton.B, ref _bCoroutine);
        }

        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.X)))
        {
            CoroutineThing(InputManager.InputButton.X, ref _xCoroutine);
        }

        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.Y)))
        {
            CoroutineThing(InputManager.InputButton.Y, ref _yCoroutine);
        }
    }
Exemplo n.º 15
0
    public void CheckGrabs()
    {
        if (Sinput.GetButtonDown("Grab"))
        {
            var results = new Collider2D[10];
            var filter  = new ContactFilter2D();
            filter.useTriggers = true;

            Physics2D.OverlapCollider(collider, filter, results);
            for (int i = 0; i < results.Length; i++)
            {
                if (results[i] && (results[i].GetComponent <Pickup>() || (results[i].transform.parent && results[i].transform.parent.GetComponent <Pickup>())))
                {
                    objectToGrab = results[i].transform.parent ? results[i].transform.parent.GetComponent <Pickup>() : results[i].GetComponent <Pickup>();
                    fsm.ChangeState(PlayerState.Pickup);
                    break;
                }
            }
        }
    }
Exemplo n.º 16
0
    void attacks()
    {
        if (Sinput.GetButtonDown("BasicAttack", slot))
        {
            warrior.startBasicAttack();
        }



        if (Sinput.GetButton("SpecialAttack", slot))
        {
            warrior.startSpecialAttack();
        }


        if (Sinput.GetButtonUp("SpecialAttack", slot))
        {
            warrior.endSpecialAttack();
        }
    }
        private new bool SendSubmitEventToSelectedObject()
        {
            if (eventSystem.currentSelectedGameObject == null)
            {
                return(false);
            }

            var data = GetBaseEventData();

            if (Sinput.GetButtonDown(m_SinputSubmitButton))
            {
                ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler);
            }

            if (Sinput.GetButtonDown(m_SinputCancelButton))
            {
                ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler);
            }
            return(data.used);
        }
        public override bool ShouldActivateModule()
        {
            //Debug.Log("happens");
            if (!base.ShouldActivateModule())
            {
                return(false);
            }

            var shouldActivate = Sinput.GetButtonDown(m_SinputSubmitButton);

            shouldActivate |= Sinput.GetButtonDown(m_SinputCancelButton);
            shouldActivate |= Sinput.GetButtonDownRepeating(m_SinputUpButton);
            shouldActivate |= Sinput.GetButtonDownRepeating(m_SinputDownButton);
            shouldActivate |= Sinput.GetButtonDownRepeating(m_SinputLeftButton);
            shouldActivate |= Sinput.GetButtonDownRepeating(m_SinputRightButton);

            shouldActivate |= (m_MousePos - m_LastMousePos).sqrMagnitude > 0.0f;
            shouldActivate |= Input.GetMouseButtonDown(0);
            return(shouldActivate);
        }
Exemplo n.º 19
0
    private void Update()
    {
        if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadLeft)))
        {
            CreateNoteSound(noteThing.frequencyList[0].frequency, InputManager.GetInputName(InputManager.InputButton.DPadLeft));
        }
        else if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadUp)))
        {
            CreateNoteSound(noteThing.frequencyList[1].frequency, InputManager.GetInputName(InputManager.InputButton.DPadUp));
        }
        else if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadRight)))
        {
            CreateNoteSound(noteThing.frequencyList[2].frequency, InputManager.GetInputName(InputManager.InputButton.DPadRight));
        }
        else if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.DPadDown)))
        {
            CreateNoteSound(noteThing.frequencyList[3].frequency, InputManager.GetInputName(InputManager.InputButton.DPadDown));
        }
        else if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.X)))
        {
            CreateNoteSound(noteThing.frequencyList[4].frequency, InputManager.GetInputName(InputManager.InputButton.X));
        }
        else if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.Y)))
        {
            CreateNoteSound(noteThing.frequencyList[5].frequency, InputManager.GetInputName(InputManager.InputButton.Y));
        }
        else if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.B)))
        {
            CreateNoteSound(noteThing.frequencyList[6].frequency, InputManager.GetInputName(InputManager.InputButton.B));
        }
        else if (Sinput.GetButtonDown(InputManager.GetInputName(InputManager.InputButton.A)))
        {
            CreateNoteSound(noteThing.frequencyList[7].frequency, InputManager.GetInputName(InputManager.InputButton.A));
        }

        //no grips 4 u =(
        //FindObjectOfType<NoiseBgController>().state = FindObjectsOfType<ProceduralAudio>().Length > 0 ? 0 : 1;
    }
Exemplo n.º 20
0
        // Update is called once per frame
        void Update()
        {
            //get player input for motion
            Vector3 motionInput = Sinput.GetVector("Horizontal", "", "Vertical", playerSlot);

            //we want to move like, three times as much as this
            motionInput *= 3f;

            //gravity
            yMotion      -= Time.deltaTime * 10f;
            motionInput.y = yMotion;

            //move our character controller now
            characterController.Move(motionInput * Time.deltaTime);

            //landing/jumping
            if (characterController.isGrounded)
            {
                yMotion = -0.05f;

                if (Sinput.GetButtonDown("Jump", playerSlot))
                {
                    //we pressed jump while on the ground, so we jump!
                    yMotion = 5f;
                }
            }

            //aiming
            Vector3 aimDir = Vector3.zero;

            aimDir.x = Sinput.GetAxisRaw("Horizontal", playerSlot);
            aimDir.z = Sinput.GetAxisRaw("Vertical", playerSlot);
            if (aimDir.magnitude > 0.4f)
            {
                //inputs are strong enough, lets look in the aim direction
                lookDirection = aimDir.normalized;
                Quaternion fromRotation = transform.rotation;
                transform.LookAt(transform.position + lookDirection);
                transform.rotation = Quaternion.Slerp(fromRotation, transform.rotation, Time.deltaTime * 10f);
            }
            //make sure our display text always faces the same way
            playerSlotDisplay.transform.eulerAngles = Vector3.zero;


            //shooting
            bulletCooldown -= Time.deltaTime;
            if (Sinput.GetButton("Fire1", playerSlot) && bulletCooldown <= 0f)
            {
                bulletCooldown = 0.2f;
                GameObject newBullet = (GameObject)GameObject.Instantiate(bulletPrefab);
                newBullet.transform.position = gunTransform.position;
                newBullet.transform.rotation = gunTransform.rotation;
                newBullet.GetComponent <BulletScript>().moveDir = gunTransform.forward;
            }
            if (Sinput.GetButton("Fire2", playerSlot) && bulletCooldown <= 0f)
            {
                bulletCooldown = 0.05f;
                GameObject newBullet = (GameObject)GameObject.Instantiate(bulletPrefab);
                newBullet.transform.position   = gunTransform.position;
                newBullet.transform.rotation   = gunTransform.rotation;
                newBullet.transform.localScale = Vector3.one * 0.3f;
                newBullet.GetComponent <BulletScript>().moveDir   = gunTransform.forward;
                newBullet.GetComponent <BulletScript>().moveSpeed = 30f;
                newBullet.GetComponent <BulletScript>().life      = 0.33f;
            }
        }
    void CheckInput()
    {
        for (int n = 0; n < buttons.Length; n++)
        {
            if (Sinput.GetButtonDown(buttons[n].name))
            {
                buttons[n].SetState(true);
                buttons[n].events.Pressed?.Invoke();
            }

            if (Sinput.GetButtonUp(buttons[n].name))
            {
                buttons[n].SetState(false);
                buttons[n].events.Released?.Invoke();
            }
        }

        for (int n = 0; n < axes.Length; n++)
        {
            bool state = false;
            for (int i = 0; i < axes[n].names.Length; i++)
            {
                float value = Sinput.GetAxis(axes[n].names[i]);
                state = Mathf.Abs(value) > 0f;
                if (axes[n].sendWhenZeroToo || state)
                {
                    axes[n].AxisValue?.Invoke(value);
                    break;
                }
            }

            bool prevState = axes[n].isPressed;
            axes[n].SetState(state);

            if (state)
            {
                if (!prevState)
                {
                    axes[n].events.Pressed?.Invoke();
                }
            }
            else if (prevState)
            {
                axes[n].events.Released?.Invoke();
            }
        }

        for (int n = 0; n < joysticks.Length; n++)
        {
            bool state = false;
            for (int i = 0; i < joysticks[n].names.Length; i++)
            {
                Vector2 value = Sinput.GetVector(joysticks[n].names[i].x, joysticks[n].names[i].y,
                                                 joysticks[n].normalizationMode != NormalizationMode.NotNormalize);
                state = value.sqrMagnitude > 0f;

                if (state && (joysticks[n].normalizationMode == NormalizationMode.NormalizeWithoutPithagoras))
                {
                    if (Mathf.Abs(value.x) > Mathf.Abs(value.y))
                    {
                        value.x = Mathf.Sign(value.x);
                    }
                    else if (Mathf.Abs(value.x) < Mathf.Abs(value.y))
                    {
                        value.y = Mathf.Sign(value.y);
                    }
                    else
                    {
                        value.x = Mathf.Sign(value.x); value.y = Mathf.Sign(value.y);
                    }
                }

                if (joysticks[n].sendWhenZeroToo || state)
                {
                    joysticks[n].JoystickValue?.Invoke(value);
                    joysticks[n].JoystickMagnitude?.Invoke(value.magnitude);
                    break;
                }
            }

            bool prevState = joysticks[n].isPressed;
            joysticks[n].SetState(state);

            if (state)
            {
                if (!prevState)
                {
                    joysticks[n].events.Pressed?.Invoke();
                }
            }
            else if (prevState)
            {
                joysticks[n].events.Released?.Invoke();
            }
        }

        for (int n = 0; n < buttonStates.Length; n++)
        {
            bool state = true;
            foreach (SButtonState button in buttonStates[n].buttonsState)
            {
                if (Sinput.GetButton(button.name) != button.state)
                {
                    state = false;
                    break;
                }
            }

            bool prevState = buttonStates[n].isPressed;
            buttonStates[n].SetState(state);

            if (state)
            {
                if (!prevState)
                {
                    buttonStates[n].events.Pressed?.Invoke();
                }
            }
            else if (prevState)
            {
                buttonStates[n].events.Released?.Invoke();
            }
        }
    }
Exemplo n.º 22
0
    public void Update()
    {
        if (noInput)
        {
            return;
        }

        if (SUSPEND_GAMEPLAY)
        {
            return;
        }

        int mix = 0; int miy = 0;

        if (Sinput.GetButtonDown("UL"))
        {
            mix = -1; miy = 1;
        }
        if (Sinput.GetButtonDown("U"))
        {
            miy = 1;
        }
        if (Sinput.GetButtonDown("UR"))
        {
            mix = 1; miy = 1;
        }
        if (Sinput.GetButtonDown("L"))
        {
            mix = -1;
        }
        if (Sinput.GetButtonDown("R"))
        {
            mix = 1;
        }
        if (Sinput.GetButtonDown("DL"))
        {
            mix = -1; miy = -1;
        }
        if (Sinput.GetButtonDown("D"))
        {
            miy = -1;
        }
        if (Sinput.GetButtonDown("DR"))
        {
            mix = 1; miy = -1;
        }
        if (mix != 0 || miy != 0)
        {
            if (tileSelectionMode)
            {
                tileSelectionSprite.transform.position += GameMap.instance.GetMapOffset(mix, miy);
            }
            else
            {
                ((GambitModel)GambitModel.instance).TryMovePlayerRelative(mix, miy);
            }
        }

        if (Sinput.GetButtonDown("PICKUP"))
        {
            ((GambitModel)GambitModel.instance).PickUpItemHere();
            showingPickScreen = true;
        }
        if (Sinput.GetButtonDown("INVENTORY"))
        {
            ((GambitModel)GambitModel.instance).ShowInventory();
            showingInventory = true;
        }
        for (int i = 1; i < 6; i++)
        {
            if (Sinput.GetButtonDown("" + i))
            {
                if (showingPickScreen)
                {
                    if (((GambitModel)GambitModel.instance).SelectPickup(i))
                    {
                        showingPickScreen = false;
                    }
                }
                if (showingInventory)
                {
                    ((GambitModel)GambitModel.instance).SelectInventoryItem(i);
                }
            }
        }
        if (Sinput.GetButtonDown("Cancel"))
        {
            if (showingPickScreen)
            {
                showingPickScreen = false;
            }
            if (showingInventory)
            {
                showingInventory = false;
            }
            ItemListWindow.instance.CloseWindow();
        }

        if (showingInventory && Sinput.GetButtonDown("EQUIP"))
        {
            ((GambitModel)GambitModel.instance).EquipSelected();
        }
        else if (showingInventory && Sinput.GetButtonDown("UNEQUIP"))
        {
            ((GambitModel)GambitModel.instance).UnequipSelected();
        }
        else if (showingInventory && Sinput.GetButtonDown("DRINK"))
        {
            ((GambitModel)GambitModel.instance).DrinkSelected();
        }
        else if (showingInventory && Sinput.GetButtonDown("THROW"))
        {
            ((GambitModel)GambitModel.instance).ThrowSelected();
        }

        if (Sinput.GetButtonDownRepeating("Up") ||
            Sinput.GetButtonDownRepeating("Down") ||
            Sinput.GetButtonDownRepeating("Right") ||
            Sinput.GetButtonDownRepeating("Left"))
        {
            if (editMode)
            {
                editMode = false;
            }
        }
    }
Exemplo n.º 23
0
    private void FixedUpdate()
    {
        RaycastHit[] hits;
        Ray          ray         = mainCamera.ScreenPointToRay(Input.mousePosition);
        bool         tagDetected = false;

        hits = Physics.RaycastAll(ray, 100);
        if (hits.Length > 0)
        {
            int currentPriority = int.MaxValue;
            foreach (RaycastHit hit in hits)
            {
                int priority = System.Array.IndexOf(interactionTagsInPriorityOrder, hit.transform.tag);
                if (priority >= 0 && priority < currentPriority)
                {
                    currentPriority = priority;
                    tagDetected     = true;
                }
            }
            if (tagDetected)
            {
                string tagPrioritary = null;
                for (int i = 0; i < hits.Length; i++)
                {
                    if (hits[i].transform.tag == interactionTagsInPriorityOrder[currentPriority])
                    {
                        Transform objectHit = hits[i].transform;
                        if (!justChangeCursor)
                        {
                            crosshairInstance.transform.position = hits[i].point;
                        }
                        tagPrioritary = hits[i].transform.tag;

                        if (Sinput.GetButtonDown(leftMouseInput))
                        {
                            crowdSystem.AssignTargetToRandomElement(objectHit);
                            onElementClicked?.Invoke();
                        }
                        break;
                    }
                }
                //Debug.Log(tagPrioritary);
                if (!hovering && tagPrioritary != "RaycastMinion")
                {
                    onElementHover?.Invoke();
                    hovering = true;
                    //Debug.Log("HOVER");
                    if (!justChangeCursor)
                    {
                        crosshairInstance.SetActive(true);
                    }
                    else
                    {
                        Cursor.SetCursor(aimCursor, new Vector2(aimCursor.width / 2, aimCursor.height / 2), CursorMode.Auto);
                    }
                }
            }
            else
            {
                if (hovering)
                {
                    onElementUnhover.Invoke();
                    //Debug.Log("UNHOVER");
                    hovering = false;
                    if (!justChangeCursor)
                    {
                        crosshairInstance.SetActive(false);
                    }
                    else
                    {
                        Cursor.SetCursor(defaultCursor, Vector2.zero, CursorMode.Auto);
                    }
                }
            }
        }
    }