예제 #1
0
    public override void Mode()
    {
        #region FlightMode
        if (!MActive)//MActive = true -> GroundMode, MActive = false -> FlightMode (Override from ReFlightMode.cs)
        {
            ForceShield.regenRate = 3f;

            if (FirstFlight)                         //Run only FirstTime on ModeChage
            {
                StartCoroutine(FlightFirstmethod()); //Take off (Make player up to the sky when FirstTime FlightMode Active)
                anima.SetBool("GroundMode", false);
                anima.SetTrigger("FlightMode");
            }
            if (ChangeModeBool)
            {
                ChangeModeBool = !ChangeModeBool;
                Thuster.SetActive(true);
                anima.SetFloat("Walk", 0f);
                anima.SetFloat("Run", 0f);
            }

            #region Control Player, Aniamtion
            //Control Player
            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

            Vector3 inputVector = this.transform.TransformDirection(h, 0, v);
            inputVector *= Fspeed * Time.deltaTime;

            rg.MovePosition(rg.position + inputVector);

            //Run - Jump
            if (Input.GetKeyDown(KeyCode.Space) && DashGauge.value > 0) //Dash FlightSpeed FirstTime
            {
                DashGauge.value -= 20f;
                Fspeed          += PlusSpeed;
                rg.velocity      = (inputVector.normalized * FDash);
            }
            if (Input.GetKey(KeyCode.Space) && DashGauge.value <= 200 && DashGauge.value > 0)
            {
                anima.SetFloat("Fly_Run", 1f);
                DashGauge.value -= 20f * Time.deltaTime;

                if (nextRotSpace < 15 && Input.GetKey(KeyCode.W))
                {
                    nextRotSpace += 45f * Time.deltaTime;
                    Thuster.transform.localRotation = Quaternion.Euler(nextRotSpace, 0f, 0f);
                }
                if (nextRotSpace > 15)
                {
                    nextRotSpace = 15f;
                }
            }
            else if (!Input.GetKey(KeyCode.Space) || DashGauge.value <= 0)
            {
                anima.SetFloat("Fly_Run", 0f);

                if (!(Input.GetKey(KeyCode.W)))
                {
                    if (nextRotSpace > 0)
                    {
                        nextRotSpace -= 45f * Time.deltaTime;
                        Thuster.transform.localRotation = Quaternion.Euler(nextRotSpace, 0f, 0f);
                    }
                    if (nextRotSpace <= 0)
                    {
                        nextRotSpace = 0f;
                    }
                }
                else
                {
                    if (nextRotSpace > 4)
                    {
                        nextRotSpace -= 45f * Time.deltaTime;
                        Thuster.transform.localRotation = Quaternion.Euler(nextRotSpace, 0f, 0f);
                    }
                    if (nextRotSpace <= 4)
                    {
                        nextRotSpace = 4f;
                    }
                }
            }
            if (Input.GetKeyUp(KeyCode.Space) || DashGauge.value <= 0) //Decress Flight Speed
            {
                Fspeed = Mathf.Pow(rg.mass, 5);
            }
            if (Input.GetKey(KeyCode.E) && DashGauge.value <= 200 && DashGauge.value > 0) //Incress Flight Height
            {
                anima.SetFloat("Fly_Incress", 1f);
                DashGauge.value -= 20f * Time.deltaTime;
                rg.AddForce(rg.velocity.x, FlightAcc * Time.deltaTime, rg.velocity.z, ForceMode.Acceleration);

                if (Input.GetKeyDown(KeyCode.Space) && DashGauge.value > 0) //Dash Up
                {
                    DashGauge.value -= 20f;
                    rg.velocity      = Vector3.up * FDash;
                }
            }
            else if (!Input.GetKey(KeyCode.E) || DashGauge.value <= 0)
            {
                anima.SetFloat("Fly_Incress", 0f);
            }
            if (Input.GetKey(KeyCode.C) && !onGroundF && DashGauge.value <= 200 && DashGauge.value > 0) //Decress Flight Height
            {
                anima.SetFloat("Fly_Decress", 1f);
                rg.AddForce(rg.velocity.x, -FlightAcc * Time.deltaTime, rg.velocity.z, ForceMode.Acceleration);

                if (Input.GetKeyDown(KeyCode.Space) && DashGauge.value > 0) //Dash Down
                {
                    DashGauge.value -= 20f;
                    rg.velocity      = Vector3.down * FDash;
                }
            }
            else if (!Input.GetKey(KeyCode.C))
            {
                anima.SetFloat("Fly_Decress", 0f);
            }
            if ((!Input.GetKey(KeyCode.Space) && !Input.GetKey(KeyCode.E) && !Input.GetKey(KeyCode.C)) && DashGauge.value <= 200)
            {
                DashGauge.value += 10f * Time.deltaTime;
            }
            else
            {
                rg.velocity = new Vector3(rg.velocity.x, rg.velocity.y, rg.velocity.z);
            }
            #endregion

            #region Animation
            //Animation
            if (Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.Space))
            {
                anima.SetFloat("Fly_Walk", 1f);
                if (nextRotW < 4 && !Input.GetKey(KeyCode.E) && !Input.GetKey(KeyCode.C))
                {
                    nextRotW += 12f * Time.deltaTime;
                    Thuster.transform.localRotation = Quaternion.Euler(nextRotW, 0f, 0f);
                }
                else
                {
                    nextRotW -= 12f * Time.deltaTime;
                    Thuster.transform.localRotation = Quaternion.Euler(nextRotW, 0f, 0f);
                    if (nextRotW <= 0)
                    {
                        nextRotW = 0f;
                    }
                }
                if (nextRotW > 4)
                {
                    nextRotW = 4f;
                }
            }
            if (Input.GetKey(KeyCode.S))
            {
                anima.SetFloat("Fly_Walk", -1f);
            }
            else if (!(Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S)))
            {
                anima.SetFloat("Fly_Walk", 0f);
                if (nextRotW > 0)
                {
                    nextRotW -= 12f * Time.deltaTime;
                    Thuster.transform.localRotation = Quaternion.Euler(nextRotW, 0f, 0f);
                }
                if (nextRotW <= 0)
                {
                    nextRotW = 0f;
                }
            }
            #endregion
        }
        #endregion
    }
예제 #2
0
    public virtual void Mode()
    {
        #region GroundMode
        if (MActive)//MActive = true -> GroundMode, MActive = false -> FlightMode (Override from ReFlightMode.cs)
        {
            ForceShield.regenRate = 7f;

            if (ChangeModeBool) //Run only FirstTime on ModeChage
            {
                anima.SetBool("GroundMode", true);
                anima.SetBool("FlightMode", false);
                ChangeModeBool = !ChangeModeBool;
                onGround       = false;
                anima.SetFloat("Fly_Walk", 0f);
                anima.SetFloat("Fly_Run", 0f);
                anima.SetFloat("Fly_Incress", 0f);;
                Thuster.SetActive(false);
                FlightM.FirstFlight = true;
            }

            #region Control Player
            //Control Player
            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

            Vector3 inputVector = this.transform.TransformDirection(h, transform.position.y, v);
            inputVector  *= Gspeed * Time.deltaTime;
            inputVector.y = 0;
            rg.MovePosition(rg.position + inputVector);

            //Run - Jump
            if (Input.GetKeyDown(KeyCode.Space) && jumpCount > 0 && jump && DashGauge.value > 0) //Jump
            {
                jump = !jump;
                anima.SetTrigger("Jump");
                Invoke("ResetJump", 0.1f);
                rg.AddForce(rg.velocity.x, rg.velocity.y + JumpForce * Time.deltaTime, rg.velocity.z, ForceMode.Impulse);
                DashGauge.value -= 20f;
                jumpCount--;
            }
            if (!Input.GetKey(KeyCode.S) && (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.S)))
            {
                if (Input.GetKeyDown(KeyCode.LeftShift) && DashGauge.value > 0) //Incress Gspeed
                {
                    Gspeed += PlusSpeed;
                }
                if (Input.GetKey(KeyCode.LeftShift) && DashGauge.value <= 200 && DashGauge.value > 0)
                {
                    DashGauge.value -= 20f * Time.deltaTime;
                    anima.SetFloat("Run", 1f);
                }
                else if (DashGauge.value <= 0)
                {
                    anima.SetFloat("Run", 0f);
                }
            }
            if (!Input.GetKey(KeyCode.LeftShift) && DashGauge.value <= 200)
            {
                anima.SetFloat("Run", 0f);
                DashGauge.value += 15f * Time.deltaTime;
            }
            if (Input.GetKeyUp(KeyCode.LeftShift) || DashGauge.value <= 0) //Decress Gspeed
            {
                Gspeed = Mathf.Pow(rg.mass, 4);
            }
            #endregion

            #region Animation
            //Animation
            if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D))
            {
                anima.SetFloat("Walk", 1f);
            }
            if (Input.GetKey(KeyCode.S))
            {
                anima.SetFloat("Walk", -1f);
            }
            else if (!(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.S)))
            {
                anima.SetFloat("Walk", 0f);
            }
            #endregion
        }
        #endregion
    }