예제 #1
0
    public virtual void Start()
    {
        CursorLock(true);
        pressButton.SetActive(false);

        if (LeftWeapon != null)
        {
            uiController.SlotUpdate(LeftWeapon, 2);
            LeftWeapon.isHave = false;
        }
        if (jobs.Count > 0)
        {
            jobIndex  = -1;
            playerJob = null;
        }
        if (playerJob != null)
        {
            playerJob.player = this;
            playerJob._Start();
        }


        HP = MaxHP;
    }
예제 #2
0
    public virtual void Update()
    {
        //int onObject = 3 << 9;
        RaycastHit objectHit;
        bool       isHit = Physics.Raycast(transform.position, transform.TransformDirection(Vector3.down), out objectHit, OnFloorHeight);

        if (isHit)
        {
            //chargeTimeCnt += Time.deltaTime;

            //if (chargeTimeCnt > 0.1)
            //{
            //    if(Energy<MaxEnergy)
            //        Energy += 1;
            //    chargeTimeCnt = 0;
            //}
            if (Energy < MaxEnergy)
            {
                Energy += 10 * Time.deltaTime;
            }

            if (secondJumpFlg)
            {
                secondJumpFlg = false;
            }
        }
        else
        {
            if (Energy < MaxEnergy)
            {
                Energy += 1 * Time.deltaTime;
            }
        }

        //ChangeEnergyText();


        if (Input.GetButtonDown("Jump"))
        {
            isJumpPressed = true;
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            isSwitchWeaponPressed = true;
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            isPickWeaponPressed = true;
        }
        mouseScrollWheel = Input.GetAxis("Mouse ScrollWheel");


        //gravity,速度制限付き!
        if (rb.velocity.y > -8)
        {
            rb.AddForce(-rb.transform.up * 50, ForceMode.Acceleration);
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            jobIndex++;
            if (playerJob != null)
            {
                playerJob._End();
            }
            if (jobIndex >= jobs.Count)
            {
                jobIndex  = -1;
                playerJob = null;
            }
            else
            {
                playerJob        = jobs[jobIndex];
                playerJob.player = this;
                playerJob._Start();
            }
        }

        if (playerJob != null)
        {
            playerJob._Update();
        }
    }