Ejemplo n.º 1
0
    public void ListenKeys()
    {
        _model.MoveHorizontal(Input.GetAxisRaw("Horizontal"));

        _model.MoveVertical(Input.GetAxisRaw("Vertical"));

        if (Input.GetKeyDown(KeyCode.Space))
        {
            _model.GroundedJump();
        }
        else if (Input.GetKeyDown(KeyCode.J))
        {
            _model.Attack();
        }
        else if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            _model.ChangeSkin(0);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            _model.ChangeSkin(1);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            _model.ChangeSkin(2);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            _model.ChangeSkin(3);
        }
        else if (Input.GetKeyDown(KeyCode.C))
        {
            _model.ActivateCheat();
        }
    }
Ejemplo n.º 2
0
    public void OnUpdate()
    {
        if (Input.GetMouseButton(0))
        {
            _playerModel.Attack();
        }

        if (Input.GetMouseButtonDown(1))
        {
            _playerModel.StartSpecial();
        }
        if (Input.GetMouseButtonUp(1))
        {
            _playerModel.EndSpecial();
        }

        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            _playerModel.dashInput = true;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            _playerModel.jumpInput = true;
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            _playerModel.SwitchWeapon();
        }
    }
    public void ListenKeys()
    {
        _model.MoveHorizontal(Input.GetAxisRaw("Horizontal"));

        if (Input.GetKeyDown(KeyCode.J))
        {
            _model.Attack();
        }
        else if (Input.GetKey(KeyCode.K))
        {
            _model.SecondAttack();
        }
    }
Ejemplo n.º 4
0
        public void Update()
        {
            if (!Enabled)
            {
                return;
            }

            if (Input.GetMouseButtonUp(MouseButton))
            {
                var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out var hit))
                {
                    if (hit.collider.CompareTag("Red"))
                    {
                        Debug.Log("Red");
                        _targetPosition = hit.rigidbody.position;
                        _target         = hit.collider.gameObject;
                        _state          = PlayerState.Attack;
                    }
                    else
                    {
                        _targetPosition = hit.point;
                        _state          = PlayerState.Move;
                    }
                }
            }

            switch (_state)
            {
            case PlayerState.Idle:
                break;

            case PlayerState.Move:
                _character.Move(_targetPosition);
                break;

            case PlayerState.Attack:
                _character.Attack(_target.transform.position);
                break;
            }
        }
Ejemplo n.º 5
0
    void OnGUI()
    {
        var w = Screen.width * 0.2f;

        GUI.BeginGroup(new Rect(Screen.width - w - 20.0f, 20.0f, w, 550.0f));

        GUI.Box(new Rect(0, 0, w, 550), "Player Animation");

        w -= 40.0f;
        GUI.BeginGroup(new Rect(20.0f, 30.0f, w, 500.0f));

        yPos = 0.0f;
        playerModel.speedOverride.z = Slider("Forward", playerModel.speedOverride.z, -10.0f, 10.0f, w);
        playerModel.speedOverride.x = Slider("Sideward", playerModel.speedOverride.x, -10.0f, 10.0f, w);
        viewOffset.y = Slider("Look Up", viewOffset.y, -10.0f, 10.0f, w);
        viewOffset.x = Slider("Look L/R", viewOffset.x, -10.0f, 10.0f, w);

        yPos += 5.0f;
        int newHoldIndex = (int)Slider("HoldType", (int)holdTypesIndex, 0, (float)holdTypes.Length - 1, w);

        holdType = TextArea("", holdType, w);

        modelState.ducked     = Checkbox("Ducked", modelState.ducked, w);
        modelState.onground   = Checkbox("Grounded", modelState.onground, w);
        modelState.sleeping   = Checkbox("Sleeping", modelState.sleeping, w);
        modelState.waterLevel = Slider("WaterLevel", modelState.waterLevel, 0.0f, 1.0f, w);
        aimAtCamera           = Checkbox("Aim @ Cam", aimAtCamera, w);

        if (Button("Deploy", w))
        {
            playerModel.Deploy();
        }
        if (Button("Attack", w))
        {
            playerModel.Attack();
        }
        if (Button("Reload", w))
        {
            playerModel.Reload();
        }
        if (Button("Holster", w))
        {
            playerModel.Holster();
        }

        int newFlinchTypeIndex = (int)Slider("Flinch Location", (int)flinchTypesIndex, 0.0f, 9.0f, w);

        flinchType = TextArea("", flinchType, w);
        if (Button("Flinch", w))
        {
            playerModel.Flinch();
        }

        int newModelLOD = (int)Slider("LOD", (int)modelLOD, -1, 3, w);



        GUI.EndGroup();

        GUI.EndGroup();


        if (newFlinchTypeIndex != flinchTypesIndex)
        {
            flinchType                = flinchTypes[newFlinchTypeIndex];
            flinchTypesIndex          = newFlinchTypeIndex;
            modelState.flinchLocation = (uint)flinchTypesIndex;
        }

        if (newHoldIndex != holdTypesIndex)
        {
            holdType       = holdTypes[newHoldIndex];
            holdTypesIndex = newHoldIndex;
        }

        if (newModelLOD != modelLOD)
        {
            playerModel.GetComponent <LODGroup>().ForceLOD(newModelLOD);
            modelLOD = newModelLOD;
        }
    }