コード例 #1
0
    public override void Update()
    {
        base.Update();

        timer += Time.deltaTime;

        //Adjust value for deadzone of controller (maybe sensitivity meter in options)
        if (Math.Abs(m_HorizontalAxis) >= 0.1f)
        {
            m_NextState = new BattleWalk(m_Character);
        }
        if (m_LightAttackButton == true)
        {

            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleLightAttackDown(m_Character);
            else
                m_NextState = new BattleLightAttackUp(m_Character);
        }

        if (m_HeavyAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleHeavyAttackDown(m_Character);
            else
                m_NextState = new BattleHeavyAttackUp(m_Character);
        }

        if (m_BattleButton == true && timer > 0.5f)
        {
            m_NextState = new MovementIdle(m_Character);
        }
    }
コード例 #2
0
    public override void Update()
    {
        base.Update();

        RaycastHit GroundHitInfo;
        Ray ray = new Ray(m_Character.m_Center, -m_Character.transform.up);
        Physics.Raycast(ray, out GroundHitInfo, m_Character.m_Height /*- m_TotalForce.y*/, 1 << LayerMask.NameToLayer("Terrain"));
        m_Character.transform.position = new Vector3(m_Character.transform.position.x, GroundHitInfo.point.y + m_Character.m_Height / 2, m_Character.transform.position.z);

        if (m_LightAttackButton == true)
        {

            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleLightAttackDown(m_Character);
            else
                m_NextState = new BattleLightAttackUp(m_Character);
        }

        if (m_HeavyAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleHeavyAttackDown(m_Character);
            else
                m_NextState = new BattleHeavyAttackUp(m_Character);
        }

        if (Math.Abs(m_Character.m_TotalForce.x) <= 0.1f)
        {
            m_PlayerController.updatePreviousActions(this.ToString());
            m_NextState = new BattleIdle(m_Character);
        }
    }
コード例 #3
0
    public override void Update()
    {
        base.Update();


        RaycastHit GroundHitInfo;
        Ray        ray = new Ray(m_Character.m_Center, -m_Character.transform.up);

        Physics.Raycast(ray, out GroundHitInfo, m_Character.m_Height /*- m_TotalForce.y*/, 1 << LayerMask.NameToLayer("Terrain"));
        m_Character.transform.position = new Vector3(m_Character.transform.position.x, GroundHitInfo.point.y + m_Character.m_Height / 2, m_Character.transform.position.z);

        if (m_LightAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleLightAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleLightAttackUp(m_Character);
            }
        }

        if (m_HeavyAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleHeavyAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleHeavyAttackUp(m_Character);
            }
        }

        if (Math.Abs(m_Character.m_TotalForce.x) <= 0.1f)
        {
            m_PlayerController.updatePreviousActions(this.ToString());
            m_NextState = new BattleIdle(m_Character);
        }
    }
コード例 #4
0
    public override void Update()
    {
        base.Update();

        timer += Time.deltaTime;

        //Adjust value for deadzone of controller (maybe sensitivity meter in options)
        if (Math.Abs(m_HorizontalAxis) >= 0.1f)
        {
            m_NextState = new BattleWalk(m_Character);
        }
        if (m_LightAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleLightAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleLightAttackUp(m_Character);
            }
        }

        if (m_HeavyAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleHeavyAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleHeavyAttackUp(m_Character);
            }
        }

        if (m_BattleButton == true && timer > 0.5f)
        {
            m_NextState = new MovementIdle(m_Character);
        }
    }
コード例 #5
0
ファイル: BattleIdle.cs プロジェクト: Fensal/FairJudgementBac
    public override void Update()
    {
        base.Update();

        timer += Time.deltaTime;

        if (Math.Abs(m_HorizontalAxis) >= 0.1f)
        {
            if (Math.Sign(m_HorizontalAxis) == m_Ortientation && m_Character is PlayerCharacterController)
            {
                (m_Character as PlayerCharacterController).m_ComboState = new ForwardState(m_Character, (m_Character as PlayerCharacterController).m_ComboState);
            }
            m_NextState = new BattleWalk(m_Character);

            if (Math.Sign(m_HorizontalAxis) != m_Ortientation && m_Character is PlayerCharacterController)
            {
                (m_Character as PlayerCharacterController).m_ComboState = new BackState(m_Character, (m_Character as PlayerCharacterController).m_ComboState);
            }
            m_NextState = new BattleWalk(m_Character);
        }



        if (m_LightAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleLightAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleLightAttackUp(m_Character);
            }
        }

        if (m_HeavyAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleHeavyAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleHeavyAttackUp(m_Character);
            }
        }

        if (m_JumpButton == true)
        {
            if (Math.Sign(m_HorizontalAxis) == Math.Sign(m_Character.transform.localScale.x))
            {
                m_Character.m_CurrentState = new BattleStepBack(m_Character);
            }
            else
            {
                m_Character.m_CurrentState = new BattleDash(m_Character);
            }
        }



        if (m_BlockButton == true)
        {
            m_ButtonTimer += Time.deltaTime;

            if (m_ButtonTimer >= 0.01f)
            {
                if (m_VerticalAxis < -0.1f)
                {
                    m_Character.GetComponent <Animator>().SetBool("BlockDown", true);
                    m_NextState = new BattleBlockDown(m_Character);
                }

                else
                {
                    m_Character.GetComponent <Animator>().SetBool("BlockUp", true);
                    m_NextState = new BattleBlockUp(m_Character);
                }
            }
        }
        if (m_BlockButtonUp)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_Character.GetComponent <Animator>().SetTrigger("ParryDown");
                m_NextState = new BattleParryDown(m_Character);
            }

            else
            {
                m_Character.GetComponent <Animator>().SetTrigger("ParryUp");
                m_NextState = new BattleParryUp(m_Character);
            }
        }

        if (m_Character.m_Opponent == null)
        {
            m_NextState = new MovementIdle(m_Character);
        }
    }
コード例 #6
0
ファイル: BattleIdle.cs プロジェクト: Fensal/FairJudgementBac
    public override void Update()
    {
        base.Update();

        timer += Time.deltaTime;

        if (Math.Abs(m_HorizontalAxis) >= 0.1f)
        {
            if (Math.Sign(m_HorizontalAxis) == m_Ortientation && m_Character is PlayerCharacterController)
            {
                (m_Character as PlayerCharacterController).m_ComboState = new ForwardState(m_Character, (m_Character as PlayerCharacterController).m_ComboState);
            }
            m_NextState = new BattleWalk(m_Character);

            if (Math.Sign(m_HorizontalAxis) != m_Ortientation && m_Character is PlayerCharacterController)
            {
                (m_Character as PlayerCharacterController).m_ComboState = new BackState(m_Character, (m_Character as PlayerCharacterController).m_ComboState);
            }
            m_NextState = new BattleWalk(m_Character);
        }

        if (m_LightAttackButton == true)
        {

            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleLightAttackDown(m_Character);
            else
                m_NextState = new BattleLightAttackUp(m_Character);
        }

        if (m_HeavyAttackButton == true)
        {
            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleHeavyAttackDown(m_Character);
            else
                m_NextState = new BattleHeavyAttackUp(m_Character);
        }

        if (m_JumpButton == true)
        {
            if (Math.Sign(m_HorizontalAxis) == Math.Sign(m_Character.transform.localScale.x))
            {
                m_Character.m_CurrentState = new BattleStepBack(m_Character);
            }
            else
            {
                m_Character.m_CurrentState = new BattleDash(m_Character);
            }
        }

        if (m_BlockButton == true)
        {
            m_ButtonTimer += Time.deltaTime;

            if (m_ButtonTimer >= 0.01f)
            {
                if (m_VerticalAxis < -0.1f)
                {
                    m_Character.GetComponent<Animator>().SetBool("BlockDown", true);
                    m_NextState = new BattleBlockDown(m_Character);
                }

                else
                {
                    m_Character.GetComponent<Animator>().SetBool("BlockUp", true);
                    m_NextState = new BattleBlockUp(m_Character);
                }
            }
        }
        if (m_BlockButtonUp)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_Character.GetComponent<Animator>().SetTrigger("ParryDown");
                m_NextState = new BattleParryDown(m_Character);
            }

            else
            {
                m_Character.GetComponent<Animator>().SetTrigger("ParryUp");
                m_NextState = new BattleParryUp(m_Character);
            }

        }

        if(m_Character.m_Opponent == null)
        {
            m_NextState = new MovementIdle(m_Character);
        }
    }
コード例 #7
0
    public override void Update()
    {
        base.Update();

        m_Character.GetComponent <Animator>().SetFloat("VelocityX", Math.Abs(m_Character.m_TotalForce.x));

        timer += Time.deltaTime;

        if (Math.Sign(m_HorizontalAxis) == 1)
        {
            float maxSpeed = m_Character.m_MaxSpeed / 2;
            //if (m_Character.m_FacingRight)
            //    maxSpeed = m_Character.m_MaxSpeed/4*3;
            //else
            //    maxSpeed = m_Character.m_MaxSpeed / 2;

            if (m_Velocity + m_Character.m_Acceleration < maxSpeed)
            {
                m_Velocity += m_Character.m_Acceleration;
            }
            else
            {
                m_Velocity = maxSpeed;
            }
        }
        else if (Math.Sign(m_HorizontalAxis) == -1)
        {
            float maxSpeed;
            if (!m_Character.m_FacingRight)
            {
                maxSpeed = m_Character.m_MaxSpeed;
            }
            else
            {
                maxSpeed = m_Character.m_MaxSpeed / 2;
            }

            if (Math.Abs(m_Velocity - m_Character.m_Acceleration) < maxSpeed || m_Velocity > 0f)
            {
                m_Velocity -= m_Character.m_Acceleration;
            }
            else
            {
                m_Velocity = (-1) * maxSpeed;
            }
        }
        else
        {
            if (m_Velocity - m_Character.m_Deceleration > 0.0f)
            {
                m_Velocity -= m_Character.m_Deceleration;
            }
            else if (m_Velocity + m_Character.m_Deceleration < 0.0f)
            {
                m_Velocity += m_Character.m_Deceleration;
            }
            else
            {
                m_Velocity = 0.0f;
            }
        }



        if (Math.Abs(m_Velocity) == 0.0f && m_HorizontalAxis == 0.0f)
        {
            m_NextState = new BattleIdle(m_Character);
        }

        if (m_LightAttackButton == true)
        {
            m_Velocity = 0.0f;

            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleLightAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleLightAttackUp(m_Character);
            }
        }

        if (m_HeavyAttackButton == true)
        {
            m_Velocity = 0.0f;

            if (m_VerticalAxis < -0.1f)
            {
                m_NextState = new BattleHeavyAttackDown(m_Character);
            }
            else
            {
                m_NextState = new BattleHeavyAttackUp(m_Character);
            }
        }

        if (m_JumpButton == true)
        {
            if (Math.Sign(m_HorizontalAxis) == Math.Sign(m_Character.transform.localScale.x))
            {
                m_Character.m_CurrentState = new BattleStepBack(m_Character);
            }
            else
            {
                m_Character.m_CurrentState = new BattleDash(m_Character);
            }
        }


        if (m_BlockButton == true)
        {
            m_ButtonTimer += Time.deltaTime;

            if (m_ButtonTimer >= 0.01f)
            {
                if (m_VerticalAxis < -0.1f)
                {
                    m_Character.GetComponent <Animator>().SetBool("BlockDown", true);
                    m_NextState = new BattleBlockDown(m_Character);
                }

                else
                {
                    m_Character.GetComponent <Animator>().SetBool("BlockUp", true);
                    m_NextState = new BattleBlockUp(m_Character);
                }
            }
        }
        if (m_BlockButtonUp)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_Character.GetComponent <Animator>().SetTrigger("ParryDown");
                m_NextState = new BattleParryDown(m_Character);
            }

            else
            {
                m_Character.GetComponent <Animator>().SetTrigger("ParryUp");
                m_NextState = new BattleParryUp(m_Character);
            }
        }

        if (m_BlockButtonUp)
        {
            m_NextState = new BattleParryUp(m_Character);
        }

        if (m_Character.m_Opponent == null)
        {
            m_NextState = new MovementWalk(m_Character);
        }

        m_Character.m_TotalForce = new Vector3(m_Velocity, 0.0f, 0.0f);
    }
コード例 #8
0
ファイル: BattleWalk.cs プロジェクト: Fensal/FairJudgementBac
    public override void Update()
    {
        base.Update();

        m_Character.GetComponent<Animator>().SetFloat("VelocityX", Math.Abs(m_Character.m_TotalForce.x));

        timer += Time.deltaTime;

        if (Math.Sign(m_HorizontalAxis) == 1)
        {
            float maxSpeed = m_Character.m_MaxSpeed / 2;
            //if (m_Character.m_FacingRight)
            //    maxSpeed = m_Character.m_MaxSpeed/4*3;
            //else
            //    maxSpeed = m_Character.m_MaxSpeed / 2;

            if (m_Velocity + m_Character.m_Acceleration < maxSpeed)
            {
                m_Velocity += m_Character.m_Acceleration;
            }
            else
            {
                m_Velocity = maxSpeed;
            }
        }
        else if (Math.Sign(m_HorizontalAxis) == -1)
        {

            float maxSpeed;
            if (!m_Character.m_FacingRight)
                maxSpeed = m_Character.m_MaxSpeed;
            else
                maxSpeed = m_Character.m_MaxSpeed / 2;

            if (Math.Abs(m_Velocity - m_Character.m_Acceleration) < maxSpeed || m_Velocity > 0f)
            {
                m_Velocity -= m_Character.m_Acceleration;
            }
            else
            {
                m_Velocity = (-1) * maxSpeed;
            }
        }
        else
        {
            if (m_Velocity - m_Character.m_Deceleration > 0.0f)
            {
                m_Velocity -= m_Character.m_Deceleration;
            }
            else if (m_Velocity + m_Character.m_Deceleration < 0.0f)
            {
                m_Velocity += m_Character.m_Deceleration;
            }
            else
            {
                m_Velocity = 0.0f;
            }
        }

        if (Math.Abs(m_Velocity) == 0.0f && m_HorizontalAxis == 0.0f)
        {
            m_NextState = new BattleIdle(m_Character);
        }

        if (m_LightAttackButton == true)
        {
            m_Velocity = 0.0f;

            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleLightAttackDown(m_Character);
            else
                m_NextState = new BattleLightAttackUp(m_Character);
        }

        if (m_HeavyAttackButton == true)
        {
            m_Velocity = 0.0f;

            if (m_VerticalAxis < -0.1f)
                m_NextState = new BattleHeavyAttackDown(m_Character);
            else
                m_NextState = new BattleHeavyAttackUp(m_Character);
        }

        if (m_JumpButton == true)
        {
            if (Math.Sign(m_HorizontalAxis) == Math.Sign(m_Character.transform.localScale.x))
            {
                m_Character.m_CurrentState = new BattleStepBack(m_Character);
            }
            else
            {
                m_Character.m_CurrentState = new BattleDash(m_Character);
            }
        }

        if (m_BlockButton == true)
        {
            m_ButtonTimer += Time.deltaTime;

            if (m_ButtonTimer >= 0.01f)
            {
                if (m_VerticalAxis < -0.1f)
                {
                    m_Character.GetComponent<Animator>().SetBool("BlockDown", true);
                    m_NextState = new BattleBlockDown(m_Character);
                }

                else
                {
                    m_Character.GetComponent<Animator>().SetBool("BlockUp", true);
                    m_NextState = new BattleBlockUp(m_Character);
                }
            }
        }
        if (m_BlockButtonUp)
        {
            if (m_VerticalAxis < -0.1f)
            {
                m_Character.GetComponent<Animator>().SetTrigger("ParryDown");
                m_NextState = new BattleParryDown(m_Character);
            }

            else
            {
                m_Character.GetComponent<Animator>().SetTrigger("ParryUp");
                m_NextState = new BattleParryUp(m_Character);
            }

        }

        if (m_BlockButtonUp)
        {
            m_NextState = new BattleParryUp(m_Character);
        }

        if(m_Character.m_Opponent == null)
        {
            m_NextState = new MovementWalk(m_Character);
        }

        m_Character.m_TotalForce = new Vector3(m_Velocity, 0.0f, 0.0f);
    }