Example #1
0
    // Update is called once per frame
    void Update()
    {
        CalcInput();
        VX = VY = 0 < InputArray["Fire3"] ? 2.5f * Time.deltaTime : 7.0f * Time.deltaTime;

        float x = Input.GetAxisRaw("Horizontal");
        float y = Input.GetAxisRaw("Vertical");

        if (x < 0)
        {
            VX = -VX;
        }
        else if (x == 0)
        {
            VX = 0;
        }
        if (y < 0)
        {
            VY = -VY;
        }
        else if (y == 0)
        {
            VY = 0;
        }
        // 斜め方向の速度調節
        if (VX != 0 && VY != 0)
        {
            VX = VX * Sqrt2;
            VY = VY * Sqrt2;
        }
        transform.position = CUtility.ClampPosition(new Vector3(transform.position.x + VX, transform.position.y + VY, 0));

        // Zキー押しっぱなしで6フレームに1度ショットを発射する
        if (0 < InputArray["Fire1"] && InputArray["Fire1"] % 6 == 0)
        {
            CSoundPlayer.PlaySound("cshot", true);
            if (0 < InputArray["Fire3"])//低速移動中なら
            {
                LowerSpeedShot();
            }
            else // 通常移動中なら
            {
                HiSpeedShot();
            }
        }
        _Animator.SetFloat("H", x);
    }
Example #2
0
    private void Move()
    {
        float x = Input.GetAxis(horizontal);
        float y = Input.GetAxis(vertical);

        VX = VY = 0 < InputArray["Fire3"] ? slowMoveSpeed * Time.deltaTime : moveSpeed * Time.deltaTime;
        if (x < 0)
        {
            VX = -VX;
        }
        else if (x == 0)
        {
            VX = 0;
        }
        if (y < 0)
        {
            VY = -VY;
        }
        else if (y == 0)
        {
            VY = 0;
        }
        // 斜め方向の速度調節
        if (VX != 0 && VY != 0)
        {
            VX = VX * Sqrt2;
            VY = VY * Sqrt2;
        }
        transform.position = CUtility.ClampPosition(new Vector3(transform.position.x + VX, transform.position.y + VY, 0));
        animator.SetFloat("H", x);
        //if (x != 0||y!=0)
        //{
        //    if(Input.GetKey(KeyCode.LeftShift)|| Input.GetKey(KeyCode.RightShift))
        //    {
        //        transform.Translate(x * slowMoveSpeed * Time.deltaTime, y * slowMoveSpeed * Time.deltaTime, 0);
        //    }
        //    else
        //    {
        //        transform.Translate(x * moveSpeed * Time.deltaTime, y * moveSpeed * Time.deltaTime, 0);
        //    }
        //    animator.SetFloat("H", x);
        //}
    }