예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (_dashState != DashState.NotCloseEnoughToDash)
            DashTimeElapsed += Time.deltaTime;

        switch (_dashState)
        {
            case DashState.NotCloseEnoughToDash:
                if (Vector3.Distance(Target.transform.position, this.transform.position) < BeginDashRange)
                {
                    DashLocation = transform.position + (Target.transform.position - transform.position).normalized * DashRange;

                    if (DisableChaseOnDash)
                        this.GetComponent<Chase>().enabled = false;

                    _agent.enabled = false;

                    _dashState = DashState.ChargingDash;
                    audio.PlayOneShot(_onChargeDashSound);
                }
                break;

            case DashState.ChargingDash:
                if (DashTimeElapsed > DelayBeforeDashInSeconds)
                {
                    _dashState = DashState.Dashing;
                    audio.PlayOneShot(_onDashSound);
                }
                break;

            case DashState.Dashing:
                this.transform.position = Vector3.Lerp(this.transform.position, DashLocation, Time.deltaTime * DashSpeed);

                if (Vector3.Distance(this.transform.position, DashLocation) < 1f)
                {
                    _dashState = DashState.Dashed;
                    DashTimeElapsed = 0f;
                }
                break;

            case DashState.Dashed:
                if (DashTimeElapsed > .5f)
                {
                    this.gameObject.SetActive(false);
                    Destroy(this.gameObject);
                }
                break;
        }
    }
예제 #2
0
    public void reset()
    {
        dashState = DashState.Ready;

        maxTimeSlow = 1f;

        dashTimer = 0;

        smSliderBG.enabled = false;
        smSliderImage.enabled = false;

        dashCDSliderBG.enabled = false;
        dashCDSliderImage.enabled = false;

        Time.timeScale = 1f;
    }
예제 #3
0
파일: Dash.cs 프로젝트: rdshack/CProto
    public override void ActiveUpdate()
    {
        if (state == DashState.DashMain)
        {
            if (Time.time > changeStateTime)
            {
                state = DashState.DashEnd;
                gc.controller.LockY = false;
                dashParticles.emit = false;

                if (gc.IsAirborne)
                {
                    usedInAir = true;
                    animator.CrossFade(HashLookup.loopJumpHash, 0.1f);
                    changeStateTime = Time.time + 0.1f;
                    isActive = false;
                    girlPushField.Active = true;
                }
                else
                {
                    animator.CrossFade(HashLookup.endDashGroundHash, 0.1f);
                    changeStateTime = Time.time + 0.3f;
                    isActive = false;
                    girlPushField.Active = true;
                }
            }
            else
            {
                CharacterController controller = gc.GetComponent<CharacterController>();
                moveVector.x = dashSpeed * Time.deltaTime * gc.controller.FacingValue;

                gc.controller.Move(moveVector, 1 << HashLookup.wallLayer);
            }
        }
        else if (state == DashState.DashEnd)
        {
            if (Time.time > changeStateTime)
            {
                isActive = false;
                girlPushField.Active = true;
            }
        }
    }
예제 #4
0
    void FixedUpdate()
    {
        switch (dashState){
        case DashState.Ready:
            if (Input.GetButtonDown("Trigger")){
                dashState = DashState.Dashing;
            }
            break;
        case DashState.Dashing:
            dashTimer += Time.deltaTime;
            if(dashTimer >= maxDash){
                dashTimer = maxDash;
                dashState = DashState.Cooldown;
            }
            break;
        case DashState.Cooldown:
            dashTimer -= Time.deltaTime;
            if(dashTimer <= -.3f){
                dashTimer = 0;
                dashState = DashState.Ready;
            }
            break;
        }

        if (Input.GetButtonDown ("Fire1")) {
            Vector2 shotdirection = new Vector2(Input.GetAxis("RightStickH"), Input.GetAxis("RightStickV"));
            GameObject projectileobj = (GameObject)Instantiate(projectile, transform.position, transform.rotation);
            //if you're not pointing in a direction
            //shoot forward the way you are moving
            if(shotdirection == new Vector2(0,0)){
                if(direction == new Vector3(0,0,0)){
                    projectileobj.GetComponent<Rigidbody2D>().velocity = new Vector2(10,0);
                }else {
                    projectileobj.GetComponent<Rigidbody2D>().velocity = direction * 10;
                }
            }
            //else shoot in the direction you are holding
            else {
                projectileobj.GetComponent<Rigidbody2D>().velocity = shotdirection * 10;
            }
        }
    }
예제 #5
0
    void Update()
    {
        // Dash State Machine
        switch (dashState)
        {
        case DashState.Ready:
            var isDashKeyDown = Input.GetKeyDown(KeyCode.LeftShift);
            if (isDashKeyDown)
            {
                savedVelocity = GetComponent <Rigidbody2D> ().velocity;

                GetComponent <Rigidbody2D> ().velocity =
                    new Vector2(GetComponent <Rigidbody2D> ().velocity.x * 3f,
                                GetComponent <Rigidbody2D> ().velocity.y);

                dashState = DashState.Dashing;
            }
            break;

        case DashState.Dashing:
            dashTimer += Time.deltaTime * 3;
            if (dashTimer >= maxDash)
            {
                dashTimer = maxDash;
                GetComponent <Rigidbody2D> ().velocity = savedVelocity;
                dashState = DashState.Cooldown;
            }
            break;

        case DashState.Cooldown:
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                dashTimer = 0;
                dashState = DashState.Ready;
            }
            break;
        }
    }
예제 #6
0
    void Dashing()
    {
        switch (dashState)
        {
        case DashState.Ready:
            var isDashKeyDown = Input.GetKey(KeyCode.V);
            if (isDashKeyDown)
            {
                savedVelocity = rb.velocity;
                attack        = true;
                rb.velocity   = new Vector2(rb.velocity.x * 3f, rb.velocity.y * 3f);
                dashState     = DashState.Dashing;
                GameObject.FindGameObjectWithTag("Player").SendMessage("disableInput");
            }
            break;

        case DashState.Dashing:
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                attack      = false;
                dashTimer   = cooldownTimer;
                rb.velocity = savedVelocity;
                dashState   = DashState.Cooldown;
                GameObject.FindGameObjectWithTag("Player").SendMessage("disableInput");
            }
            break;

        case DashState.Cooldown:
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                dashTimer = maxDash;
                dashState = DashState.Ready;
                attack    = false;
            }
            break;
        }
    }
예제 #7
0
    void Dash()
    {
        if (dashState == DashState.Ready)
        {
            if (Input.GetButtonDown("Dash") && rb.velocity != Vector3.zero)
            {
                dashState    = DashState.Dashing;
                dashVelocity = rb.velocity;
                rb.AddForce(dashVelocity * dashForce);
                dashTimer = dashDuration;
                dashTrail.SetActive(true);
                Instantiate(dashParticles, transform.position, Quaternion.identity);
                audioP.PlaySound(AudioToPlay.Dash);
            }
        }
        else if (dashState == DashState.Dashing)
        {
            rb.velocity = dashVelocity * dashForce * Time.deltaTime;

            if (dashTimer <= 0)
            {
                dashState = DashState.Cooldown;
                dashTimer = dashCooldown;
                dashTrail.SetActive(false);
            }

            dashTimer -= Time.deltaTime;
        }
        else if (dashState == DashState.Cooldown)
        {
            if (dashTimer <= 0)
            {
                dashState = DashState.Ready;
            }

            dashTimer -= Time.deltaTime;
        }
    }
예제 #8
0
    // Update is called once per frame
    void Update()
    {
        //input
        movement.x = Input.GetAxisRaw("HorizontalPlayerOne");
        movement.y = Input.GetAxisRaw("VerticalPlayerOne");

        switch (dashState)
        {
        case DashState.Ready:
            var isDashKeyDown = Input.GetButtonDown("P1Dash");
            if (isDashKeyDown)
            {
                dashState = DashState.Dashing;
            }

            break;

        case DashState.Dashing:
            dashTimer += Time.deltaTime;
            if (dashTimer >= maxDash)
            {
                dashTimer = dashCooldown;
                dashState = DashState.Cooldown;
            }

            break;

        case DashState.Cooldown:
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                dashTimer = 0;
                dashState = DashState.Ready;
            }

            break;
        }
    }
예제 #9
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case DashState.Ready:
            bool isDashPressed = Input.GetKeyDown(KeyCode.LeftShift) || Input.GetButtonDown("RB_Button");
            if (isDashPressed)
            {
                savedVel = body.velocity;
                float limitedSpeed = Mathf.Clamp(body.velocity.x * 1.5f, -MaxSpeed, MaxSpeed);
                body.velocity    = new Vector2(limitedSpeed, body.velocity.y);
                state            = DashState.Dashing;
                player.isDashing = true;
            }
            break;

        case DashState.Cooldown:
            dashTimer -= Time.deltaTime * 15;
            if (dashTimer <= 0)
            {
                dashTimer = 0;
                state     = DashState.Ready;
            }
            player.isDashing = false;
            break;

        case DashState.Dashing:
            dashTimer += Time.deltaTime * 90;
            if (dashTimer >= maxDash)
            {
                dashTimer        = maxDash;
                body.velocity    = savedVel;
                state            = DashState.Cooldown;
                player.isDashing = false;
            }
            break;
        }
    }
예제 #10
0
    void DashInput()
    {
        switch (dashState)
        {
        case DashState.Ready:
            var isDashKeyDown = Input.GetKeyDown(KeyCode.LeftShift);
            if (isDashKeyDown && onGround)
            {
                anim.SetTrigger("dash");
                anim.SetBool("dashing", true);
                dashState = DashState.Dashing;
            }
            break;

        case DashState.Dashing:

            dashing = true;
            //Dashing();

            break;

        case DashState.Cooldown:
            dashing = false;
            anim.ResetTrigger("dash");
            anim.SetBool("dashing", false);

            if (dashTimer < dashMaxCD)
            {
                dashTimer += Time.deltaTime;
            }
            else if (dashTimer >= dashMaxCD)
            {
                dashTimer = 0f;
                dashState = DashState.Ready;
            }
            break;
        }
    }
    private void HandleSlapped(SlapMessage message)
    {
        if (message.PlayerNumber == playerNumber)
        {
            _logger.Log($"I slapped at position: ({message.SlapPosition.x}, {message.SlapPosition.y})");
            return;
        }

        Vector2 slapperPosition    = message.SlapPosition;
        Vector2 slapperHitPosition = new Vector2(slapperPosition.x + slapRange, slapperPosition.y);
        Vector3 myPosition         = transform.position;



        if (Vector2.Distance(myPosition, slapperHitPosition) <= slapRadius)
        {
            _messenger.Publish(new WasSlappedMessage(this, playerNumber));

            _slapped          = true;
            dashTimer         = 0;
            dashState         = DashState.Dashing;
            _dashingDirection = FaceDirection.Left;
        }
    }
예제 #12
0
    void FixedUpdate()
    {
        //Switches between three different states of movement
        switch (dashState)
        {
        //Each case is a state in the dashing ability
        case DashState.Ready:
            if (Input.GetKeyDown(KeyCode.Z))
            {
                Debug.Log("Working");
                rb.AddForce(new Vector2(12000, 0));
                dashState = DashState.Dashing;
            }
            break;

        case DashState.Dashing:
            dashTimer += Time.deltaTime * 3;
            if (dashTimer >= maxDash)
            {
                Debug.Log("Working pt 2");
                dashTimer = maxDash;
                dashState = DashState.Cooldown;
            }
            break;

        case DashState.Cooldown:
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                Debug.Log("Done");
                dashTimer = 0;
                dashState = DashState.Ready;
            }
            break;
        }
    }
예제 #13
0
    public void Dash()
    {
        switch (dashState)
        {
        case DashState.DASHREADY:
            bool isDashKeyDown = Input.GetKeyDown(KeyCode.LeftShift);
            if (isDashKeyDown)
            {
                animator.SetBool("isDashing", true);
                dash      = true;
                dashState = DashState.DASHACTIVE;
            }
            break;

        case DashState.DASHACTIVE:
            dashTimer += Time.deltaTime;

            if (dashTimer >= maxDashTime)
            {
                dashTimer = maxDashTime;
                dash      = false;
                animator.SetBool("isDashing", false);
                dashState = DashState.DASHCOOLDOWN;
            }
            break;

        case DashState.DASHCOOLDOWN:
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                dashTimer = 0;
                dashState = DashState.DASHREADY;
            }
            break;
        }
    }
예제 #14
0
 public DashTransition(Player _player)
 {
     player    = _player;
     nextState = new DashState(_player);
 }
예제 #15
0
    private void Dash()
    {
        if (canDash)
        {
            switch (currentMap)
            {
            case CurrentMap.Neutral:
                switch (dashState)
                {
                case DashState.Ready:
                    bool isDashKeyDown = Input.GetButtonDown("Special1");
                    if (isDashKeyDown)
                    {
                        savedVelocity            = new Vector2(myRigidBody.velocity.x, 0f);
                        myRigidBody.velocity     = new Vector2(normalSpeed * this.transform.localScale.x * dashIntensity, 0f);
                        myRigidBody.gravityScale = 0f;
                        dashState = DashState.Dashing;
                    }
                    break;

                case DashState.Dashing:
                    Debug.Log(myRigidBody.velocity);
                    dashTimer += Time.deltaTime;
                    if (dashTimer >= dashDuration)
                    {
                        dashTimer                = dashDuration;
                        myRigidBody.velocity     = savedVelocity;
                        myRigidBody.gravityScale = 1f;
                        dashState                = DashState.Cooldown;
                    }
                    break;

                case DashState.Cooldown:
                    dashTimer -= Time.deltaTime;
                    if (dashTimer <= 0)
                    {
                        dashTimer = 0;
                        dashState = DashState.Ready;
                    }
                    break;
                }
                break;

            case CurrentMap.Air:
                break;

            case CurrentMap.Fire:
                break;

            case CurrentMap.Ice:
                break;

            case CurrentMap.Earth:
                break;

            case CurrentMap.Metal:
                break;

            default:
                break;
            }
        }
    }
예제 #16
0
    void Update()
    {
        switch (dashState)
        {
            case DashState.Dashing:
                //show the player dashing animation
                animator.SetBool("is_dashing", true);

                dashTimer += Time.deltaTime * 5;
                if (dashTimer >= maxDash)
                {
                    //stop the player dashing animation
                    animator.SetBool("is_dashing", false);
                    //changing player state
                    playerStateScript.SetIsDashing(false);

                    dashTimer = maxDash;
                    //r_body.velocity = savedVelocity;
                    dashState = DashState.Cooldown;
                }
                break;

            case DashState.Cooldown:

                dashTimer -= Time.deltaTime;
                if (dashTimer <= 0)
                {
                    dashTimer = 0;
                    dashState = DashState.Ready;
                }
                break;

            case DashState.Ready:
                //if dash button is pressed, set velocity...
                if (dashInputScript.GetDashButton())
                {
                    if (!playerStateScript.GetHasPearl() && !playerStateScript.GetIsHit())
                    {
                       // savedVelocity = r_body.velocity;

                        //find the angle to dash based on the angle player is facing
                        Vector3 dir;
                        if (movingScript.GetFacingRight())
                        {
                            dir = Quaternion.AngleAxis(playerStateScript.GetFacingAngle() - 90f, Vector3.forward) * Vector3.up;
                        }
                        else
                        {
                            dir = Quaternion.AngleAxis(playerStateScript.GetFacingAngle() - 270f, Vector3.forward) * Vector3.up;
                        }

                        //apply force to the player in that direction
                        GetComponent<Rigidbody2D>().AddForce(dir * dashVelocity);

                        //adding the dash burst to the player velocity
                        //r_body.AddForce(new Vector2(dashVelocity * 1f, dashVelocity * 1f));
                        //changing player state
                        playerStateScript.SetIsDashing(true);

                        dashState = DashState.Dashing;

                        //splashSound.Play();
                        soundPlayer.PlayClip(dashSound, 1.0f);
                    }

                }
                break;

        }
    }
예제 #17
0
    void Update()
    {
        if(gameInMenu) {
            return;
        }

        // handles all states of dashing
        switch (dashState)
        {
        //----------------------------------------
        case DashState.Ready:

            bool isDashDown = false;

            if (Application.isMobilePlatform) {
                if(Input.touchCount > 0) {
                    Touch touch = Input.GetTouch (0);
                    if (touch.phase == TouchPhase.Began) {
                        angle = Constants.atan2_ZX (transform.position, Constants.GetWorldPositionOnPlane(touch.position, 0));
                        isDashDown = true;
                    }
                }
            }
            else {
                isDashDown = Input.GetKeyDown(KeyCode.Mouse0);
            }

            if(isDashDown)
            {
                dashState = DashState.TimeSlowStart;
                Time.timeScale = 0.5f;

                smSliderBG.enabled = true;
                smSliderImage.enabled = true;

            }

            break;
            //----------------------------------------
        case DashState.TimeSlowStart:
            timeSlowTimer += Time.deltaTime;
            slowModeSlider.value = timeSlowTimer;

            bool isDashKeyUp = false;

            if (Application.isMobilePlatform) {
                //if there is still a touch on screen
                if(Input.touchCount > 0) {
                    Touch touch = Input.GetTouch (0);

                    if (touch.phase == TouchPhase.Ended) {
                        isDashKeyUp = true;
                    }
                    else {
                        angle = Constants.atan2_ZX (transform.position, Constants.GetWorldPositionOnPlane(touch.position, 0));
                    }

                }
            }
            else {
                isDashKeyUp = Input.GetKeyUp(KeyCode.Mouse0);
            }

            if(isDashKeyUp || timeSlowTimer >= maxTimeSlow)
            {
                dashState = DashState.TimeSlowEnd;

                if (!Application.isMobilePlatform) {
                    angle = Constants.atan2_ZX (transform.position, Constants.GetWorldPositionOnPlane(Input.mousePosition, 0));
                }

                Time.timeScale = 1;
                smSliderBG.enabled = false;
                smSliderImage.enabled = false;
                timeSlowTimer = 0;
            }

            break;
            //----------------------------------------
        case DashState.TimeSlowEnd:

            float xAngle = Mathf.Cos(angle);
            float zAngle = Mathf.Sin(angle);

            float xForce = xAngle * 900;
            float zForce = zAngle * 900;

            rigidBody.AddForce(xForce, 0, zForce);

            dashState = DashState.Dashing;

            break;
            //----------------------------------------
        case DashState.Dashing:
            dashTimer += Time.deltaTime;

            if(dashTimer >= maxDashTime)
            {
                dashState = DashState.Cooldown;
                dashTimer = 0;

                dashCDSliderBG.enabled = true;
                dashCDSliderImage.enabled = true;
            }
            break;
            //----------------------------------------
        case DashState.Cooldown:
            dashCdTimer -= Time.deltaTime;
            dashCDSlider.value = dashCdTimer;

            if(dashCdTimer <= 0)
            {

                dashCDSliderBG.enabled = false;
                dashCDSliderImage.enabled = false;

                dashCdTimer = DASHCD;
                dashState = DashState.Ready;
            }
            break;
        }
    }
예제 #18
0
    private void FixedUpdate()
    {
        Collider2D standingOn = groundDown.DoRaycast(transform.position);
        bool       grounded   = standingOn != null;

        if (grounded && lastGrounded == false)
        {
            audioManager.fx.PlayOneShot(landFX, 0.25f);
        }
        lastGrounded = grounded;

        switch (jumpState)
        {
        case JumpState.None:
            /*if(grounded && jumpStartTimer > 0) {
             *  jumpStartTimer = 0;
             *  jumpState = JumpState.Holding;
             *  jumpHoldTimer = 0;
             *  velocity.y = jumpStartSpeed;
             *  jumpSFX.Play();
             * }*/
            if (!stunned)
            {
                if (jumpStartTimer > 0)
                {
                    jumpStartTimer = 0;
                    jumpState      = JumpState.Holding;
                    jumpHoldTimer  = 0;
                    velocity.y     = jumpStartSpeed;
                    //jumpSFX.Play();
                }
            }
            break;

        case JumpState.Holding:
            jumpHoldTimer += Time.deltaTime;
            if (jumpInputDown == false || jumpHoldTimer >= jumpMaxHoldPeriod)
            {
                jumpState  = JumpState.None;
                velocity.y = Mathf.Lerp(jumpMinSpeed, jumpStartSpeed, jumpHoldTimer / jumpMaxHoldPeriod);

                // Lerp!
                //float p = jumpHoldTimer / jumpMaxHoldPeriod;
                //velocity.y = jumpMinSpeed + (jumpStartSpeed - jumpMinSpeed) * p;
            }
            break;
        }

        switch (dashState)
        {
        case DashState.None:
            if (!stunned)
            {
                if (dashStartTimer > 0)
                {
                    dashStartTimer = 0;
                    dashState      = DashState.Holding;
                    dashHoldTimer  = 0;
                    //dashFX.Play();
                }
            }
            break;

        case DashState.Holding:
            dashHoldTimer += Time.deltaTime;
            if (dashInputDown == false || dashHoldTimer >= dashMaxHoldPeriod)
            {
                dashState = DashState.None;
            }
            break;
        }

        switch (boostState)
        {
        case BoostState.None:
            if (!stunned)
            {
                if (boostStartTimer > 0)
                {
                    boostStartTimer = 0;
                    boostState      = BoostState.Holding;
                    boostHoldTimer  = 0;
                    //boostFX.Play();
                }
            }
            break;

        case BoostState.Holding:
            boostHoldTimer += Time.deltaTime;
            if (boostInputDown == false || boostHoldTimer >= boostMaxHoldPeriod)
            {
                boostState = BoostState.None;
            }
            break;
        }

        switch (eraseState)
        {
        case EraseState.None:
            if (!stunned)
            {
                if (eraseStartTimer > 0)
                {
                    eraseStartTimer = 0;
                    eraseState      = EraseState.Holding;
                    erasehHoldTimer = 0;
                    //eraseFX.Play();
                }
            }
            break;

        case EraseState.Holding:
            erasehHoldTimer += Time.deltaTime;
            if (eraseInputDown == false || erasehHoldTimer >= eraseMaxHoldPeriod)
            {
                eraseState = EraseState.None;
            }
            break;
        }

        switch (crouchState)
        {
        case CrouchState.None:
            if (grounded && !stunned)
            {
                if (crouchStartTimer > 0)
                {
                    crouchStartTimer    = 0;
                    crouchState         = CrouchState.Holding;
                    crouchHoldTimer     = 0;
                    boxCollider.enabled = false;
                }

                if (dropPlatform != null)
                {
                    dropPlatform.enabled = true;
                }
            }
            break;

        case CrouchState.Holding:
            crouchHoldTimer += Time.deltaTime;
            dropPlatform     = lastStandingOn;

            if (dropPlatform.gameObject.tag == "Droppable")
            {
                if (crouchInputDown == false || stunned)
                {
                    crouchState         = CrouchState.None;
                    boxCollider.enabled = true;
                }
                else if (crouchHoldTimer >= crouchDropPeriod)
                {
                    crouchState            = CrouchState.None;
                    boxCollider.enabled    = true;
                    lastStandingOn.enabled = false;
                }
            }
            else
            {
                if (crouchInputDown == false || stunned)
                {
                    crouchState         = CrouchState.None;
                    boxCollider.enabled = true;
                }
            }

            break;
        }

        float horizInput        = Input.GetAxisRaw("Horizontal");
        int   wantedDirection   = GetSign(horizInput);
        int   velocityDirection = GetSign(velocity.x);

        if (wantedDirection != 0)
        {
            if (wantedDirection != velocityDirection)
            {
                if (boost <= 0)
                {
                    velocity.x = horizSnapSpeed * wantedDirection;
                    //audioManager.fx.PlayOneShot(startMoveFX, 0.3f);
                }
                else
                {
                    if (dashState == DashState.Holding)
                    {
                        dash += (int)dashSpeed;

                        if (dash < 32)
                        {
                            if (!spriteRenderer.flipX)
                            {
                                velocity.x = dash;
                            }
                            else if (spriteRenderer.flipX)
                            {
                                velocity.x = -dash;
                            }
                        }
                        else
                        {
                            velocity.x = Mathf.MoveTowards(velocity.x, 0, 75 * Time.deltaTime);
                        }
                    }
                    else
                    {
                        velocity.x = 0;
                    }
                }
            }
            else
            {
                if (!stunned)
                {
                    if (dashState == DashState.Holding)
                    {
                        dash += (int)dashSpeed;

                        if (dash < 32)
                        {
                            if (!spriteRenderer.flipX)
                            {
                                velocity.x = dash;
                            }
                            else if (spriteRenderer.flipX)
                            {
                                velocity.x = -dash;
                            }
                        }
                        else
                        {
                            velocity.x = Mathf.MoveTowards(velocity.x, 0, 75 * Time.deltaTime);
                        }
                    }
                    else if (boostState == BoostState.Holding)
                    {
                        boost     += (int)boostSpeed;
                        velocity.x = 0;

                        if (boost <= 36)
                        {
                            velocity.y = boost;
                        }
                        else
                        {
                            velocity.y = Mathf.MoveTowards(velocity.y, 0, 125 * Time.deltaTime);
                        }
                    }
                    else
                    {
                        if (boost <= 0)
                        {
                            dash       = 0;
                            boost      = 0;
                            velocity.x = Mathf.MoveTowards(velocity.x, horizMaxSpeed * wantedDirection, horizSpeedUpAccel * Time.deltaTime);
                        }
                        else
                        {
                            velocity.x = 0;
                            velocity.y = Mathf.MoveTowards(velocity.y, 0, 200 * Time.deltaTime);
                        }
                    }
                }
            }
        }
        else
        {
            if (dashState == DashState.Holding)
            {
                dash += (int)dashSpeed;

                if (dash < 32)
                {
                    if (!spriteRenderer.flipX)
                    {
                        velocity.x = dash;
                    }
                    else if (spriteRenderer.flipX)
                    {
                        velocity.x = -dash;
                    }
                }
                else
                {
                    velocity.x = Mathf.MoveTowards(velocity.x, 0, 75 * Time.deltaTime);
                }
            }
            else if (boostState == BoostState.Holding)
            {
                boost     += (int)boostSpeed;
                velocity.x = 0;

                if (boost <= 36)
                {
                    velocity.y = boost;
                }
                else
                {
                    velocity.y = Mathf.MoveTowards(velocity.y, 0, 125 * Time.deltaTime);
                }
            }
            else
            {
                if (dash > 0)
                {
                    dash      -= (int)dashSpeed;
                    velocity.x = Mathf.MoveTowards(velocity.x, 0, 150 * Time.deltaTime);
                }
                else
                {
                    if (boost > 0)
                    {
                        velocity.x = 0;
                        velocity.y = Mathf.MoveTowards(velocity.y, 0, 200 * Time.deltaTime);
                    }
                    else
                    {
                        dash       = 0;
                        boost      = 0;
                        velocity.x = Mathf.MoveTowards(velocity.x, 0, horizSpeedDownAccel * Time.deltaTime);
                    }
                }
            }
        }

        if (dashState != DashState.Holding)
        {
            if (jumpState == JumpState.None)
            {
                if (boostState != BoostState.Holding)
                {
                    if (eraseState != EraseState.Holding)
                    {
                        if (boost > 0)
                        {
                            boost      -= (int)boostSpeed / 2;
                            velocity.y -= gravity * Time.deltaTime;
                            velocity.x  = 0;
                        }
                        else
                        {
                            velocity.y -= gravity * Time.deltaTime;

                            if (crouchState == CrouchState.Holding)
                            {
                                velocity.x = 0;
                            }
                        }
                    }
                    else
                    {
                        velocity.x = 0;
                        velocity.y = 0;
                    }
                }
                else if (boostState == BoostState.Holding)
                {
                    velocity.x = 0;
                    stunned    = false;
                }
            }

            if (stunned)
            {
                if (currentX != 0)
                {
                    velocity.x = (currentX * -1) * stunBounce;
                    stunTimer += Time.deltaTime;
                }
                else
                {
                    velocity.x = (enemyX * -3) * stunBounce;
                    stunTimer += Time.deltaTime;
                }

                if (stunTimer >= stunPeriod)
                {
                    stunned    = false;
                    velocity.x = 0;
                }
            }
            else
            {
                currentX  = velocity.x;
                stunTimer = 0;
            }
        }
        else if (dashState == DashState.Holding)
        {
            velocity.y += vertBoost * Time.deltaTime;
            stunned     = false;
        }

        Vector2 displacement = Vector2.zero;
        Vector2 wantedDispl  = velocity * Time.deltaTime;

        if (standingOn != null)
        {
            if (lastStandingOn == standingOn)
            {
                lastStandingOnVel = (Vector2)standingOn.transform.position - lastStandingOnPos;
                wantedDispl      += lastStandingOnVel;
            }
            else if (standingOn == null)
            {
                velocity    += lastStandingOnVel / Time.deltaTime;
                wantedDispl += lastStandingOnVel;
            }
            lastStandingOnPos = standingOn.transform.position;
        }
        lastStandingOn = standingOn;

        if (wantedDispl.x > 0)
        {
            displacement.x = moveRight.DoRaycast(transform.position, wantedDispl.x);
        }
        else if (wantedDispl.x < 0)
        {
            displacement.x = -moveLeft.DoRaycast(transform.position, -wantedDispl.x);
        }
        if (wantedDispl.y > 0)
        {
            displacement.y = moveUp.DoRaycast(transform.position, wantedDispl.y);
        }
        else if (wantedDispl.y < 0)
        {
            displacement.y = -moveDown.DoRaycast(transform.position, -wantedDispl.y);
        }

        if (Mathf.Approximately(displacement.x, wantedDispl.x) == false)
        {
            velocity.x = 0;
        }
        if (Mathf.Approximately(displacement.y, wantedDispl.y) == false)
        {
            velocity.y = 0;
        }

        transform.Translate(displacement);

        if (!stunned)
        {
            if (dashState == DashState.Holding)
            {
                if (playerAnim.cycleCounter != 4)
                {
                    playerAnim.flip         = true;
                    playerAnim.cycleCounter = 4;
                }
            }
            else
            {
                if (jumpState == JumpState.Holding)
                {
                    if (playerAnim.cycleCounter != 3)
                    {
                        playerAnim.flip         = true;
                        playerAnim.cycleCounter = 3;
                    }
                }
                else
                {
                    if (eraseState == EraseState.Holding)
                    {
                        if (playerAnim.cycleCounter != 8)
                        {
                            playerAnim.flip         = true;
                            playerAnim.cycleCounter = 8;
                        }
                    }
                    else
                    {
                        if (grounded)
                        {
                            if (wantedDirection == 0)
                            {
                                if (crouchState == CrouchState.Holding)
                                {
                                    if (playerAnim.cycleCounter != 6)
                                    {
                                        playerAnim.flip         = true;
                                        playerAnim.cycleCounter = 6;
                                    }
                                }
                                else
                                {
                                    if (playerAnim.cycleCounter != 0)
                                    {
                                        playerAnim.flip         = true;
                                        playerAnim.cycleCounter = 0;
                                    }
                                }
                            }
                            else
                            {
                                if (playerAnim.cycleCounter != 1)
                                {
                                    playerAnim.flip         = true;
                                    playerAnim.cycleCounter = 1;
                                }
                            }
                        }
                        else
                        {
                            if (velocity.y < 0)
                            {
                                if (playerAnim.cycleCounter != 2)
                                {
                                    playerAnim.flip         = true;
                                    playerAnim.cycleCounter = 2;
                                }
                            }
                            else
                            {
                                if (boostState == BoostState.Holding)
                                {
                                    if (playerAnim.cycleCounter != 5)
                                    {
                                        playerAnim.flip         = true;
                                        playerAnim.cycleCounter = 5;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        else if (stunned)
        {
            if (playerAnim.cycleCounter != 7)
            {
                playerAnim.flip         = true;
                playerAnim.cycleCounter = 7;
            }
        }

        if (wantedDirection != 0)
        {
            spriteRenderer.flipX = wantedDirection < 0;
            blankSR.flipX        = wantedDirection < 0;
        }
    }
예제 #19
0
    void Update()
    {
        switch (dashState)
        {
        case DashState.Dashing:
            //show the player dashing animation
            animator.SetBool("is_dashing", true);


            dashTimer += Time.deltaTime * 5;
            if (dashTimer >= maxDash)
            {
                //stop the player dashing animation
                animator.SetBool("is_dashing", false);
                //changing player state
                playerStateScript.SetIsDashing(false);

                dashTimer = maxDash;
                //r_body.velocity = savedVelocity;
                dashState = DashState.Cooldown;
            }
            break;

        case DashState.Cooldown:

            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                dashTimer = 0;
                dashState = DashState.Ready;
            }
            break;

        case DashState.Ready:
            //if dash button is pressed, set velocity...
            if (dashInputScript.GetDashButton())
            {
                if (!playerStateScript.GetHasPearl() && !playerStateScript.GetIsHit())
                {
                    // savedVelocity = r_body.velocity;


                    //find the angle to dash based on the angle player is facing
                    Vector3 dir;
                    if (movingScript.GetFacingRight())
                    {
                        dir = Quaternion.AngleAxis(playerStateScript.GetFacingAngle() - 90f, Vector3.forward) * Vector3.up;
                    }
                    else
                    {
                        dir = Quaternion.AngleAxis(playerStateScript.GetFacingAngle() - 270f, Vector3.forward) * Vector3.up;
                    }


                    //apply force to the player in that direction
                    GetComponent <Rigidbody2D>().AddForce(dir * dashVelocity);

                    //adding the dash burst to the player velocity
                    //r_body.AddForce(new Vector2(dashVelocity * 1f, dashVelocity * 1f));
                    //changing player state
                    playerStateScript.SetIsDashing(true);

                    dashState = DashState.Dashing;

                    //splashSound.Play();
                    soundPlayer.PlayClip(dashSound, 1.0f);
                }
            }
            break;
        }
    }
예제 #20
0
    //Execution of Dash ability
    public void Activate(PlayerController controller)
    {
        //TODO functionise indicator updates
        #region Update Indicator
        Vector2 mousedir = controller.PlayerToMouseDir();
        float   angle    = Mathf.Atan2(mousedir.y, mousedir.x) * Mathf.Rad2Deg;

        Indicator.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
        Indicator.transform.position = controller.transform.position;
        #endregion

        //Switch on core state
        switch (_dashState)
        {
            #region Ready
        case DashState.Ready:
            if (_groundReset)
            {
                if (InputController.Instance.Ability.Down)
                {
                    //remove current vertical velocity
                    if (controller.velocity.y < 0f)
                    {
                        controller.SetVerticalVelocity(0f);
                    }

                    //save horizontal velocity
                    _initHorizontalV = controller.velocity.x;

                    _dashDir     = controller.PlayerToMouseDir();
                    _dashState   = DashState.Dashing;
                    _groundReset = false;
                }
            }
            break;

            #endregion
            #region Dashing
        case DashState.Dashing:
            if (_dashTime > 0)
            {
                //Dash vector
                Vector2 dashmove = _dashDir * DashSpeed;

                //set vertical
                controller.SetVerticalVelocity(dashmove.y);
                //set horizontal additively
                controller.SetHorizontalVelocity(dashmove.x + _initHorizontalV);

                _dashTime -= Time.deltaTime;
            }
            else
            {
                _dashTime  = DashCD;
                _dashState = DashState.Cooldown;
            }
            break;

            #endregion
            #region Cooldown
        case DashState.Cooldown:
            if (_dashTime > 0)
            {
                _dashTime -= Time.deltaTime;
            }
            else
            {
                _dashTime  = DashLength;
                _dashState = DashState.Ready;
            }
            break;
            #endregion
        }
    }
예제 #21
0
파일: Dash.cs 프로젝트: pochp/fooziespublic
 public override void SetSpecial(CharacterState _character)
 {
     m_state = DashState.InitialMovement;
     _character.SetCharacterHurtboxStanding(_character.Hitboxes);
 }
예제 #22
0
    void Update()
    {
        xRaw = Input.GetAxisRaw("Horizontal");
        yRaw = Input.GetAxisRaw("Vertical");

        Vector2 dir = new Vector2(xRaw, yRaw);

        Walk(dir);

        //Checking for facing direction
        if (Input.GetAxis("Horizontal") > 0 && facingRight == false)
        {
            Flip();
        }
        else if (Input.GetAxis("Horizontal") < 0 && facingRight == true)
        {
            Flip();
        }

        if (Input.GetKeyDown(KeyCode.UpArrow) && (coll.onGround == true))
        {
            Jump();
            StartCoroutine(DisableGhostEffect());
        }

        if (coll.onGround)
        {
            hasDashed = false;
        }


        //Control Section for Dashing
        switch (dashState)
        {
        case DashState.Ready:

            bool isDashKeyDown = Input.GetKeyDown(KeyCode.Space);
            if (isDashKeyDown && !hasDashed)
            {
                if (xRaw != 0 || yRaw != 0)
                {
                    //Debug.Log("Ready");

                    Dash();
                }
                else if (xRaw == 0)
                {
                    //Debug.Log("ground dash");
                    Dash();
                }

                hasDashed = true;
                dashState = DashState.isDashing;
            }
            break;

        case DashState.isDashing:

            dashTimer += Time.deltaTime + 10;
            if (dashTimer >= maxDash)
            {
                dashTimer = maxDash;

                //Debug.Log("isDashing");

                dashState = DashState.Cooldown;
            }
            break;

        case DashState.Cooldown:

            dashTimer -= Time.deltaTime + 10;

            rb.gravityScale = 1f;

            if (dashTimer <= 0)
            {
                dashTimer = 0;

                //Debug.Log("Cooldown");

                dashState = DashState.Ready;
            }
            //ChromeAberration_Effect.enabled = false;
            break;
        }
    }
예제 #23
0
    // Update is called once per frame
    void FixedUpdate()
    {
        switch (currentState)
        {
        case DashState.Ready:
            if (Input.GetAxis("Dash") > 0)
            {
                savedVelocity = rb2d.velocity;
                dashing       = true;
                currentState  = DashState.Dash;
            }
            break;

        case DashState.Dash:
            dashTime += Time.deltaTime * 9;
            if (!gotDir)
            {
                tempV = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
                //Vector3 mouseWorld = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                //Vector2 vDir = mouseWorld - rb2d.transform.position;
                //tempV = new Vector2(vDir.x, vDir.y);
                tempV.Normalize();
                gotDir = true;
            }
            switch (frame)
            {
            case Frames.WindUp:
                if (dashTime >= windUpTime)
                {
                    frame = Frames.PreDash;
                }
                break;

            case Frames.PreDash:

                rb2d.velocity = tempV * dashVelocity;

                //  rb2d.gameObject.GetComponent<Collider2D>().isTrigger = true;
                frame = Frames.Damage;
                break;

            case Frames.Damage:
                // Damage logic
                if (dashTime >= dmgTime)
                {
                    frame = Frames.PreV;
                }
                break;

            case Frames.PreV:
                //   rb2d.gameObject.GetComponent<Collider2D>().isTrigger = false;
                frame = Frames.Vulnerable;
                break;

            case Frames.Vulnerable:
                // Vulnerability logic
                if (dashTime >= vlnTime)
                {
                    frame = Frames.End;
                }
                break;

            case Frames.End:
                dashTime = cooldownTime;
                if (kill)
                {
                    dashTime = 0f;
                }
                kill          = false;
                frame         = Frames.WindUp;
                gotDir        = false;
                currentState  = DashState.Cooldown;
                rb2d.velocity = savedVelocity;
                break;
            }
            break;

        case DashState.Cooldown:
            dashTime -= Time.fixedDeltaTime;
            dashing   = false;
            if (dashTime <= 0)
            {
                dashTime     = 0;
                currentState = DashState.Ready;
            }
            break;
        }
    }
예제 #24
0
    void Update()
    {
        if (!playerIndexSet || !prevState.IsConnected)
        {
            for (int k = 0; k < 4; ++k)
            {
                PlayerIndex  testPlayerIndex = (PlayerIndex)k;
                GamePadState testState       = GamePad.GetState(testPlayerIndex);
                if (testState.IsConnected)
                {
                    Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
                    playerIndex    = testPlayerIndex;
                    playerIndexSet = true;
                    Debug.Log("Player two Index is: " + playerIndex);
                }
            }
        }

        prevState = state;
        state     = GamePad.GetState(playerIndex);

        if (playerIndex == PlayerIndex.Two)
        {
            if (SceneManager.GetActiveScene().name == "Game (Four player)")
            {
                float moveHorizontal = 0;
                float moveVertical   = state.ThumbSticks.Left.Y * P2Speed * Time.deltaTime;

                this.transform.Translate(new Vector3(moveHorizontal, moveVertical, 0f));
            }

            if (SceneManager.GetActiveScene().name == "Game")
            {
                float moveHorizontal = state.ThumbSticks.Left.X * P2Speed * Time.deltaTime;
                float moveVertical   = state.ThumbSticks.Left.Y * P2Speed * Time.deltaTime;

                this.transform.Translate(new Vector3(moveHorizontal, moveVertical, 0f));

                if (p2power == 0)
                {
                    dash = true;
                }

                if (p2power == 1)
                {
                    shield = true;
                }

                if (p2power == 2)
                {
                    BigShot = true;
                }


                if (dash == true)
                {
                    switch (dashState)
                    {
                    case DashState.Ready:
                        var isDashKeyDown = prevState.Buttons.RightShoulder == ButtonState.Released && state.Buttons.RightShoulder == ButtonState.Pressed;
                        if (isDashKeyDown)
                        {
                            P2savedSpeed = P2Speed;
                            P2Speed      = P2Speed + 400;

                            DashIcon.SetActive(false);
                            DashIconCharging.SetActive(true);

                            dashState = DashState.Dashing;
                        }
                        break;

                    case DashState.Dashing:
                        dashTimer += Time.deltaTime * 3;
                        if (dashTimer >= maxDash)
                        {
                            dashTimer = maxDash;
                            P2Speed   = P2savedSpeed;
                            dashState = DashState.Cooldown;
                        }
                        break;

                    case DashState.Cooldown:
                        dashTimer -= Time.deltaTime;
                        if (dashTimer <= 0)
                        {
                            dashTimer = 0;

                            DashIcon.SetActive(true);
                            DashIconCharging.SetActive(false);

                            dashState = DashState.Ready;
                        }
                        break;
                    }
                }

                if (shield == true)
                {
                    switch (shieldState)
                    {
                    case P2ShieldState.Ready:
                        var P2ShieldKeyDown = prevState.Buttons.RightShoulder == ButtonState.Released && state.Buttons.RightShoulder == ButtonState.Pressed;
                        if (P2ShieldKeyDown)
                        {
                            P2Shield.SetActive(true);

                            ShieldIcon.SetActive(false);
                            ShieldIconCharging.SetActive(true);

                            shieldState = P2ShieldState.Shielding;
                        }
                        break;

                    case P2ShieldState.Shielding:
                        shieldTimer += Time.deltaTime * 3;
                        if (shieldTimer >= maxShield)
                        {
                            shieldTimer = maxShield;

                            P2Shield.SetActive(false);

                            shieldState = P2ShieldState.Cooldown;
                        }
                        break;

                    case P2ShieldState.Cooldown:
                        shieldTimer -= Time.deltaTime;
                        if (shieldTimer <= 0)
                        {
                            shieldTimer = 0;

                            ShieldIcon.SetActive(true);
                            ShieldIconCharging.SetActive(false);


                            shieldState = P2ShieldState.Ready;
                        }
                        break;
                    }
                }

                if (BigShot == true)
                {
                    switch (shootState)
                    {
                    case ShootState.Ready:
                        var P1CloneKeyDown = prevState.Buttons.RightShoulder == ButtonState.Released && state.Buttons.RightShoulder == ButtonState.Pressed;
                        if (P1CloneKeyDown)
                        {
                            BigShotIcon.SetActive(false);
                            BigShotIconCharging.SetActive(true);

                            Audio.PlayOneShot(Fireball);

                            //instantiate the first bullet
                            GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);
                            //bullet01.transform.position = bulletPosition01.transform.position; //set the bullet initial postion

                            bullet01.GetComponent <PlayerBullet>().xspeed = -15.0f;

                            shootState = ShootState.Shooting;
                        }
                        break;

                    case ShootState.Shooting:
                        shootTimer += Time.deltaTime * 3;
                        if (shootTimer >= maxShoot)
                        {
                            shootTimer = maxShoot;

                            shootState = ShootState.Cooldown;
                        }
                        break;

                    case ShootState.Cooldown:
                        shootTimer -= Time.deltaTime;
                        if (shootTimer <= 0)
                        {
                            shootTimer = 0;

                            BigShotIcon.SetActive(true);
                            BigShotIconCharging.SetActive(false);

                            shootState = ShootState.Ready;
                        }
                        break;
                    }
                }
            }
        }
    }
예제 #25
0
 protected void CancelDashing()
 {
     indeterminateState();
     dashTime  = 0; // Reset the dash time.
     dashState = DashState.notDashing;
 }
예제 #26
0
        private void FixedUpdate()
        {
            m_Grounded = false;

            // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground
            // This can be done using layers instead but Sample Assets will not overwrite your project settings.
            Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);
            for (int i = 0; i < colliders.Length; i++)
            {
                if (colliders[i].gameObject != gameObject)
                {
                    m_Grounded = true;
                }
            }
            //FOR ANIMATION WHEN GROUNDED
            m_Anim.SetBool("Ground", m_Grounded);

            //FOR ANIMATION WHEN JUMPING OR FALLING
            m_Anim.SetFloat("vSpeed", m_Rigidbody2D.velocity.y);


            //FOR STICKY AND WALLJUMP//
            //Touching wall right?
            touchingWallRight = Physics2D.OverlapCircle(rightCheck.position, wallTouchRadius, whatIsWall);
            if (touchingWallRight)
            {
                Debug.Log("touching right wall");
                m_Grounded        = false;
                touchingWallRight = true;
                if (isWallHolding = true)
                {
                    Debug.Log("WallHoldingRight");
                }
            }


            //Touching wall left?
            touchingWallLeft = Physics2D.OverlapCircle(leftCheck.position, wallTouchRadius, whatIsWall);
            if (touchingWallLeft)
            {
                Debug.Log("touching left wall");
                m_Grounded       = false;
                touchingWallLeft = true;
                if (isWallHolding = true)
                {
                    Debug.Log("WallHoldingLeft");
                }
            }

            //BLUE TAG//
            if (gameObject.tag == "blue")
            {
                gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
                Debug.Log("tagged as blue");

                gameObject.GetComponent <CircleCollider2D>().sharedMaterial = bouncy;
                //(PhysicsMaterial2D)Resources.Load("PhysicMaterials/Bouncy");


                if (!highJumpKeyPressed && Input.GetKeyDown(KeyCode.LeftShift))
                {
                    highJumpKeyPressed = true;

                    if (highJumpKeyPressed == true)
                    {
                        m_JumpForce = jumpHeightMax;
                    }
                    else
                    {
                        m_JumpForce = jumpHeightFixed;
                    }
                }
                else if (highJumpKeyPressed && Input.GetKeyDown(KeyCode.LeftShift))
                {
                    m_JumpForce        = jumpHeightFixed;
                    highJumpKeyPressed = false;
                }
            }
            //WHITE TAG//
            else if (gameObject.tag == "white")
            {
                Debug.Log("tagged as white");
                m_JumpForce = jumpHeightFixed;
                GetComponent <Rigidbody2D>().gravityScale = 3;
                //			if(Input.GetKeyDown (KeyCode.Space))
                //			{
                //				GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
                //			}
                gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
            }
            else if (gameObject.tag == "Untagged")
            {
                Debug.Log("not tagged yet");
            }
            //RED TAG//
            else if (gameObject.tag == "red")
            {
                Debug.Log("tagged as red");
                //DASH//
                switch (dashState)
                {
                case DashState.Ready:
                    var isDashKeyDown = Input.GetKeyDown(KeyCode.LeftShift);
                    if (isDashKeyDown)
                    {
                        savedVelocity          = m_Rigidbody2D.velocity;
                        m_Rigidbody2D.velocity = new Vector2(m_Rigidbody2D.velocity.x * 20f, m_Rigidbody2D.velocity.y);
                        dashState = DashState.Dashing;
                    }
                    break;

                case DashState.Dashing:
                    dashTimer += Time.deltaTime * 3;
                    if (dashTimer >= maxDash)
                    {
                        dashTimer = maxDash;
                        m_Rigidbody2D.velocity = savedVelocity;
                        dashState = DashState.Cooldown;
                    }
                    break;

                case DashState.Cooldown:
                    dashTimer -= Time.deltaTime;
                    if (dashTimer <= 0)
                    {
                        dashTimer = 0;
                        dashState = DashState.Ready;
                    }
                    break;
                }
            }
            //YELLOW TAG//
            else if (gameObject.tag == "yellow")
            {
                Debug.Log("tagged as yellow");

                if (isWallHolding)
                {
//					m_Rigidbody2D.velocity = new Vector2(
                    amountTomove.x = 0;
                    if (Input.GetAxisRaw("Vertical") != -1)
                    {
                        amountTomove.y = 1;
                    }
                }
                //FOR STICKY AND WALLJUMP//
                if (touchingWallRight && Input.GetButtonDown("Jump"))
                {
                    m_Rigidbody2D.velocity = new Vector2(this.jumpPushForce * -1, this.yellowJump);
                    //m_Rigidbody2D.AddForce (new Vector2(this.jumpPushForce * -1, this.m_JumpForce));
                    jumpDuration    = 0.0f;
                    canVariableJump = true;
                }
                if (touchingWallLeft && Input.GetButtonDown("Jump"))
                {
                    m_Rigidbody2D.velocity = new Vector2(this.jumpPushForce * 1, this.yellowJump);
                    //m_Rigidbody2D.AddForce(new Vector2(this.jumpPushForce * 1, this.m_JumpForce));
                    jumpDuration    = 0.0f;
                    canVariableJump = true;
                }
                else if (canVariableJump)
                {
                    jumpDuration += Time.deltaTime;

                    if (jumpDuration < this.JumpDuration / 1000)
                    {
                        m_Rigidbody2D.velocity = new Vector2(m_Rigidbody2D.velocity.x, this.m_JumpForce);
                    }
                }
            }
            //PURPLE TAG//
            else if (gameObject.tag == "purple")
            {
                Debug.Log("tagged as purple");
                GetComponent <Rigidbody2D>().gravityScale = -3;
                m_JumpForce = jumpHeightFixed;
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, -jumptHeightPurp);
                }
            }
            //ORANGE TAG//
            else if (gameObject.tag == "orange")
            {
                Debug.Log("target is orange");
                GetComponent <Rigidbody2D>().gravityScale = 3;
                gameObject.transform.localScale           = new Vector3(1.25f, 1.25f, 1.25f);
            }
            //GREEN TAG//
            else if (gameObject.tag == "green")
            {
                Debug.Log("tagged as green");
                gameObject.transform.localScale           = new Vector3(0.3f, 0.3f, 0.3f);
                GetComponent <Rigidbody2D>().gravityScale = 3;
                m_JumpForce = jumpHeightFixed;
            }
        }
예제 #27
0
    void Update()
    {
        enemyShooting = false;

        if (controlscript.dead || controlscript.reviving)
        {
            anim.SetBool("Idle", true);
            idle = true;
            anim.SetFloat("Speed", 0f);
        }
        else
        {
            range = Vector2.Distance(transform.position, Player.transform.position);
        }

        Vector3 viewPos = camera.WorldToViewportPoint(gameObject.transform.position);

        if (cameFromSpawner && controlscript.dead == false)
        {
            anim.SetBool("Idle", false);
            idle = false;
            anim.SetFloat("Speed", Mathf.Abs(rb2d.velocity.x) + Mathf.Abs(rb2d.velocity.y));
        }

        else if (viewPos.x > 0 && viewPos.x < 1 && viewPos.y > 0 && viewPos.y < 1 && viewPos.z > 0 && !controlscript.dead && !controlscript.reviving)         //activate enemy
        {
            anim.SetBool("Idle", false);
            idle = false;
            anim.SetFloat("Speed", Mathf.Abs(rb2d.velocity.x) + Mathf.Abs(rb2d.velocity.y));
        }

        if (rangeEnemyAttack == true)
        {
            rb2d.isKinematic = true;
            if (gameObject.name == "MeleeBoss" || gameObject.name == "RangeBoss")
            {
                if (Player.transform.position.x > transform.position.x)
                {
                    //face right
                    transform.localScale = new Vector3(2.5f, 2.5f, 1);
                }
                else if (Player.transform.position.x < transform.position.x)
                {
                    //face left
                    transform.localScale = new Vector3(-2.5f, 2.5f, 1);
                }
            }

            else
            {
                if (Player.transform.position.x > transform.position.x)
                {
                    //face right
                    transform.localScale = new Vector3(1.5f, 1.5f, 1);
                }
                else if (Player.transform.position.x < transform.position.x)
                {
                    //face left
                    transform.localScale = new Vector3(-1.5f, 1.5f, 1);
                }
            }
            anim.SetBool("Attack", true);
        }

        if (gameObject.tag == "Enemy")
        {
            if (cameFromSpawner)
            {
                if (Player.transform.position.x > transform.position.x)
                {
                    //face right
                    transform.localScale = new Vector3(1.5f, 1.5f, 1);
                }
                else if (Player.transform.position.x < transform.position.x)
                {
                    //face left
                    transform.localScale = new Vector3(-1.5f, 1.5f, 1);
                }
            }

            if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack_DeepOnes"))
            {
                attackTrigger.SetActive(false);
            }

            if (range <= minDistance && !idle && !anim.GetBool("Death") == true && Player.transform.position.y >= gameObject.transform.position.y - .2f && Player.transform.position.y <= gameObject.transform.position.y + .2f)
            {
                rb2d.isKinematic = true;
                anim.SetBool("Attack", true);
                anim.SetBool("Dash", false);

                if (dashState == DashState.Cooldown)
                {
                    dashTimer -= Time.deltaTime * .1f;
                }

                if (dashTimer <= 0)
                {
                    dashTimer = 0;
                    dashState = DashState.Ready;
                }
            }

            else if (range <= 1.093846f && !idle && !anim.GetBool("Death") == true && Player.transform.position.y >= gameObject.transform.position.y - .2f && Player.transform.position.y <= gameObject.transform.position.y + .2f)
            {
                //dashState = DashState.Ready;
                anim.SetBool("Attack", false);
                //Debug.Log(dashState);
                switch (dashState)
                {
                case DashState.Ready:
                    savedVelocity = rb2d.velocity;

                    rb2d.velocity = new Vector2(rb2d.velocity.x * 3f, rb2d.velocity.y);

                    dashState = DashState.Dashing;
                    break;

                case DashState.Dashing:

                    if (Player.GetComponent <Player>().dead == true)
                    {
                        anim.SetBool("Dash", false);
                        dashState = DashState.End;
                    }

                    else
                    {
                        rb2d.isKinematic = false;
                        anim.SetBool("Dash", true);

                        dashTimer += Time.deltaTime * 100;
                        //Debug.Log("This is dashtime " + dashTimer);
                        if (dashTimer >= maxDash)
                        {
                            dashTimer     = maxDash;
                            rb2d.velocity = savedVelocity;
                            dashState     = DashState.Cooldown;
                        }
                    }
                    break;

                case DashState.Cooldown:
                    anim.SetBool("Dash", false);
                    transform.position = Vector2.MoveTowards(transform.position, Player.transform.position, speed * Time.deltaTime);
                    dashTimer         -= Time.deltaTime * .1f;

                    if (dashTimer <= 0)
                    {
                        dashTimer = 0;
                        dashState = DashState.Ready;
                    }
                    break;

                default:
                    break;
                }
            }

            else if (range > minDistance && !idle && !anim.GetBool("Death") == true && !anim.GetCurrentAnimatorStateInfo(0).IsName("Dash_DeepOnes"))
            {
                rb2d.isKinematic = false;
                anim.SetBool("Attack", false);
                anim.SetBool("Dash", false);

                if (dashState == DashState.Cooldown)
                {
                    dashTimer -= Time.deltaTime * .1f;
                }

                if (dashTimer <= 0)
                {
                    dashTimer = 0;
                    dashState = DashState.Ready;
                }

                transform.position = Vector2.MoveTowards(transform.position, Player.transform.position, speed * Time.deltaTime);

                if (gameObject.name == "MeleeBoss" || gameObject.name == "RangeBoss")
                {
                    if (Player.transform.position.x > transform.position.x)
                    {
                        //face right
                        transform.localScale = new Vector3(2.5f, 2.5f, 1);
                    }
                    else if (Player.transform.position.x < transform.position.x)
                    {
                        //face left
                        transform.localScale = new Vector3(-2.5f, 2.5f, 1);
                    }
                }

                else
                {
                    if (Player.transform.position.x > transform.position.x)
                    {
                        //face right
                        transform.localScale = new Vector3(1.5f, 1.5f, 1);
                    }
                    else if (Player.transform.position.x < transform.position.x)
                    {
                        //face left
                        transform.localScale = new Vector3(-1.5f, 1.5f, 1);
                    }
                }
            }
        }

        if (gameObject.tag == "RangeEnemy")
        {
            if (!idle && Player.transform.position.y >= gameObject.transform.position.y - .1f && Player.transform.position.y <= gameObject.transform.position.y + .1f)
            {
                rangeEnemyAttack = true;
            }

            else if (!idle && !anim.GetBool("Death") == true && !rangeEnemyAttack && rb2d.isKinematic == false)
            {
                rb2d.isKinematic = false;
                anim.SetBool("Attack", false);

                transform.position = Vector2.MoveTowards(transform.position, Player.transform.position, speed * Time.deltaTime);
                if (gameObject.name == "MeleeBoss" || gameObject.name == "RangeBoss")
                {
                    if (Player.transform.position.x > transform.position.x)
                    {
                        //face right
                        transform.localScale = new Vector3(2.5f, 2.5f, 1);
                    }
                    else if (Player.transform.position.x < transform.position.x)
                    {
                        //face left
                        transform.localScale = new Vector3(-2.5f, 2.5f, 1);
                    }
                }

                else
                {
                    if (Player.transform.position.x > transform.position.x)
                    {
                        //face right
                        transform.localScale = new Vector3(1.5f, 1.5f, 1);
                    }
                    else if (Player.transform.position.x < transform.position.x)
                    {
                        //face left
                        transform.localScale = new Vector3(-1.5f, 1.5f, 1);
                    }
                }
            }
        }

        if (controlscript.bossDead == true)
        {
            gameObject.GetComponent <Animator>().SetBool("Death", true);
        }
    }
예제 #28
0
 void Dash()
 {
     canMove         = false;
     dashState       = DashState.DASH_BEGIN;
     LastDashPressed = Time.time;
 }
예제 #29
0
파일: Dash.cs 프로젝트: rdshack/CProto
    public override void Execute()
    {
        base.Execute();

        isActive = true;
        state = DashState.DashMain;
        changeStateTime = Time.time + dashDuration;

        if (dashDir == DashDirection.Neutral)
        {
            StartCoroutine(EnableTurning(0.05f));
        }
        else if (dashDir == DashDirection.Forward)
        {
            gc.controller.FacingForward = true;
        }
        else
        {
            gc.controller.FacingForward = false;
        }

        dashParticles.emit = true;
        girlPushField.Active = false;

        gc.controller.LockY = true;

        if (gc.IsAirborne)
        {
            animator.CrossFade(HashLookup.dashAirHash, 0.1f);
        }
        else
        {
            animator.CrossFade(HashLookup.dashGroundHash, 0.1f);
        }
    }
예제 #30
0
 // Called during animation
 void DashDone()
 {
     dashState = DashState.Cooldown;
 }
 private void BeginState(DashState state)
 {
     if (state == DashState.Charge)
     {
         m_aiAnimator.LockFacingDirection = true;
         m_aiAnimator.FacingDirection     = m_dashDirection.ToAngle();
         m_aiAnimator.PlayUntilFinished(chargeAnim, true, null, -1f, false);
         m_aiActor.ClearPath();
         if (!m_aiActor.BehaviorOverridesVelocity)
         {
             m_aiActor.BehaviorOverridesVelocity = true;
             m_aiActor.BehaviorVelocity          = Vector2.zero;
         }
     }
     else if (state == DashState.Dash)
     {
         if (bulletScript != null && !bulletScript.IsNull)
         {
             m_shouldFire = true;
         }
         m_aiAnimator.LockFacingDirection = true;
         m_aiAnimator.FacingDirection     = m_dashDirection.ToAngle();
         if (!string.IsNullOrEmpty(dashAnim))
         {
             if (warpDashAnimLength)
             {
                 AIAnimator aiAnimator        = m_aiAnimator;
                 string     name              = dashAnim;
                 bool       suppressHitStates = true;
                 float      warpClipDuration  = dashTime;
                 aiAnimator.PlayUntilFinished(name, suppressHitStates, null, warpClipDuration, false);
             }
             else
             {
                 m_aiAnimator.PlayUntilFinished(dashAnim, true, null, -1f, false);
             }
         }
         if (doDodgeDustUp)
         {
             m_cachedDoDustups   = m_aiActor.DoDustUps;
             m_aiActor.DoDustUps = false;
             GameManager.Instance.Dungeon.dungeonDustups.InstantiateDodgeDustup(m_dashDirection, m_aiActor.specRigidbody.UnitBottomCenter);
             m_cachedGrounded = true;
         }
         if (hideShadow && m_shadowSprite)
         {
             m_shadowSprite.renderer.enabled = false;
         }
         if (hideGun && m_aiShooter)
         {
             m_aiShooter.ToggleGunAndHandRenderers(false, "ExpandDashBehavior");
         }
         if (hideGun && gunHands != null && gunHands.Count > 0)
         {
             foreach (GunHandController gunHand in gunHands)
             {
                 if (gunHand.Gun)
                 {
                     gunHand.Gun.sprite.renderer.enabled = false;
                 }
                 if (gunHand.handObject)
                 {
                     gunHand.handObject.sprite.renderer.enabled = false;
                 }
             }
         }
         if (toggleTrailRenderer && m_trailRenderer)
         {
             m_trailRenderer.enabled = true;
         }
         if (enableShadowTrail)
         {
             m_shadowTrail.spawnShadows = true;
             AkSoundEngine.PostEvent("Play_ENM_highpriest_dash_01", GameManager.Instance.PrimaryPlayer.gameObject);
         }
         float d = dashDistance / dashTime;
         m_dashTimer = dashTime;
         m_aiActor.ClearPath();
         m_aiActor.BehaviorOverridesVelocity = true;
         m_aiActor.BehaviorVelocity          = d * m_dashDirection;
         if (bulletScript != null && !bulletScript.IsNull && fireAtDashStart)
         {
             Fire();
         }
     }
 }
예제 #32
0
    private void Update()
    {
        //else
        //{
        trail.emitting = false;
        particles.SetActive(false);

        jumpStartTimer -= Time.deltaTime;

        bool jumpBtn = Input.GetButton("Jump");


        if (jumpBtn && jumpInputDown == false)
        {
            jumpStartTimer = CoyoteTime;
        }


        //Koden för wallclinging är helt min egen, här kollar den om det finns en vägg till höger eller vänster.

        if (wallRight.RaycastCheckClimbable(transform.position) == true)
        {
            climbDirection = 1;
        }
        else if (wallLeft.RaycastCheckClimbable(transform.position) == true)
        {
            climbDirection = -1;
        }
        else
        {
            climbDirection = 0;
        }


        jumpInputDown = jumpBtn;

        Position.x = transform.position.x;
        Position.y = transform.position.y;
        //}

        //private void FixedUpdate()
        ////{
        //animator.SetFloat("Speed", velocity.magnitude);
        //facingRight = playerSprite.flipX;


        switch (jumpState)
        {
        case JumpState.None:

            //JumpState none är alltså när man inte hoppar
            //den byter till "Holding" när spelaren klickar på den angivna knappen och har jumps kvar

            if (jumps > 0 && jumpStartTimer > 0)
            {
                //jumps = jumps - 1;

                jumpStartTimer = 0;
                jumpState      = JumpState.Holding;
                jumpHoldTimer  = 0;

                //Då ökas även den verikala velocityn.
                velocity.y = jumpStartSpeed;
            }
            break;

        case JumpState.Holding:

            //JumpState Holding stängs av om man släpper knappen eller efter att man har hållt inne för länge.
            jumpHoldTimer += Time.deltaTime;

            //animator.SetBool("IsJumping", true);

            if (jumpInputDown == false || jumpHoldTimer >= jumpMaxHoldPeriod)
            {
                jumps     = jumps - 1;
                jumpState = JumpState.None;

                velocity.y = Mathf.Lerp(jumpMinSpeed, jumpStartSpeed, jumpHoldTimer / jumpMaxHoldPeriod);
            }
            break;
        }

        if (groundDown.DoRaycast(transform.position) == true)
        {
            //animator.SetBool("IsJumping", false);
            jumps = extraJumps + 1;
        }
        else
        {
        }

        float xInput = Input.GetAxisRaw("Horizontal");

        int wantedDirection   = GetSign(xInput);
        int velocityDirection = GetSign(velocity.x);

        moveInput = wantedDirection;

        if (facingRight == false && moveInput > 0) //this part is for flipping the player sprite depending on what direction its moving
        {
            Flip();                                //call flip method
        }
        else if (facingRight == true && moveInput < 0)
        {
            Flip();
        }

        if (wantedDirection != 0)
        {
            //animator.SetFloat("Speed", 1);



            if (wantedDirection != velocityDirection)
            {
                velocity.x = xSnapSpeed * wantedDirection;
            }
            else
            {
                velocity.x = Mathf.MoveTowards(velocity.x, xMaxSpeed * wantedDirection, xSpeedUpAccel * Time.deltaTime);
            }
        }
        else
        {
            //animator.SetFloat("Speed", 0);
            velocity.x = Mathf.MoveTowards(velocity.x, 0, xSpeedDownAccel * Time.deltaTime);
        }



        switch (clingState)
        {
        case ClingState.None:


            if (climbDirection == wantedDirection && climbDirection != 0 && groundDown.DoRaycast(transform.position) != true)
            {
                clingState = ClingState.Holding;
                jumps      = extraJumps + 1;
            }
            break;

        case ClingState.Holding:


            jumpState  = JumpState.None;
            velocity.y = 0f;

            if (wantedDirection == 0 && climbDirection != 0)
            {
                clingState = ClingState.Sliding;
            }
            else if (climbDirection == 1 && wantedDirection < 0 || climbDirection == -1 && wantedDirection > 0)
            {
                clingState = ClingState.None;
            }
            break;

        case ClingState.Sliding:

            velocity.y -= wallSlideAccel * Time.deltaTime;

            if (velocity.y >= gravity || wantedDirection == climbDirection * -1)
            {
                clingState = ClingState.None;
            }
            else if (climbDirection == wantedDirection && climbDirection != 0)
            {
                clingState = ClingState.Holding;
                jumps      = extraJumps + 1;
            }
            break;
        }


        if (jumpState == JumpState.None && clingState == ClingState.None && isPogoing == false)
        {
            velocity.y -= gravity * Time.deltaTime;
        }



        Vector2 displacement       = Vector2.zero;
        Vector2 wantedDisplacement = velocity * Time.deltaTime;



        if (velocity.x > 0)
        {
            displacement.x = moveRight.DoRaycast(transform.position, wantedDisplacement.x);
        }
        else if (velocity.x < 0)
        {
            displacement.x = -moveLeft.DoRaycast(transform.position, -wantedDisplacement.x);
        }

        if (velocity.y > 0)
        {
            displacement.y = moveUp.DoRaycast(transform.position, wantedDisplacement.y);
        }
        else if (velocity.y < 0)
        {
            displacement.y = -moveDown.DoRaycast(transform.position, -wantedDisplacement.y);
        }



        if (Mathf.Approximately(displacement.x, wantedDisplacement.x) == false)
        {
            velocity.x = 0;
        }
        if (Mathf.Approximately(displacement.y, wantedDisplacement.y) == false)
        {
            velocity.y = 0;
        }



        transform.Translate(displacement);


        //}

        switch (dashState)
        {
        case DashState.None:


            if (dashCooldownLeft >= 0)
            {
                dashCooldownLeft -= Time.deltaTime;

                //foreach (var item in outlineShades)
                //{

                //    item.color = new Color(0, 0, 0, 0);

                //}
            }
            else
            {
                foreach (var item in outlineShades)
                {
                    item.color = new Color(0, 0, 0, 255);
                }
            }

            if (Input.GetMouseButtonDown(0) && dashCooldownLeft < 0)
            {
                hurtBox.enabled = false;
                hitBox.enabled  = true;

                foreach (var item in outlineShades)
                {
                    item.color = new Color(0, 0, 0, 0);
                }

                particles.SetActive(true);

                if (facingRight && transform.position.x - dashPosition.x < 0)
                {
                    Flip();
                }
                if (!facingRight && transform.position.x - dashPosition.x > 0)
                {
                    Flip();
                }

                velocity = Vector3.zero;

                dashCooldownLeft = dashCooldown;

                dashPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                dashPosition.z = 0;

                dashTimeLeft = dashTime;

                dashState = DashState.Dashing;
            }



            break;

        case DashState.Dashing:



            if (dashTimeLeft >= 0)
            {
                transform.position = Vector3.Lerp(transform.position, dashPosition, dashTimeLeft);
                dashTimeLeft      -= Time.deltaTime;

                trail.emitting = true;
            }
            else
            {
                hitBox.enabled  = false;
                hurtBox.enabled = true;

                if (killEnemies.enemiesToMurder != null)
                {
                    killEnemies.KillEnemies();
                }

                dashState = DashState.None;
            }

            break;
        }
    }
예제 #33
0
    // Update is called once per frame

    void Update()
    {
        //dash
        if ((playerDevice.GetControl(InputControlType.LeftTrigger).IsPressed) && (playerDevice.GetControl(InputControlType.LeftBumper).WasReleased) && (spawnShield == false))
        {
            Debug.Log("dash");
            dashState = DashState.DASH_BEGIN;
            Dash();
        }



        if (playerDevice == null)
        {
            return;
        }

        if (playerDevice.GetControl(InputControlType.Action1).IsPressed)
        {
            Debug.Log("Coucou j'appuie sur X");
        }

        Debug.Log(playerIndex);
        //if(playerIndex == 1)

        animator.SetFloat("velocity", Mathf.Abs(rigidBody2D.velocity.x));
        //mouvement gauche droite

        float horizontalInput = playerDevice.LeftStickX;
        float verticalInput   = playerDevice.LeftStickY;

        shieldOn = false;
        if (canMove == true)
        {
            Vector2 velocity = new Vector2(horizontalInput * playerVelocity, rigidBody2D.velocity.y);
            rigidBody2D.velocity = velocity;
            //inversion du sprite du personnage
            Vector3 scale = transform.localScale;
            if (rigidBody2D.velocity.x > 0)
            {
                scale.x = Mathf.Abs(scale.x);
            }
            else if (rigidBody2D.velocity.x < 0)
            {
                scale.x = -Mathf.Abs(scale.x);
            }
            transform.localScale = scale;
        }
        else
        {
            //inversion du sprite du personnage
            Vector3 scale = transform.localScale;
            if (horizontalInput > 0)
            {
                scale.x = Mathf.Abs(scale.x);
            }
            else if (horizontalInput < 0)
            {
                scale.x = -Mathf.Abs(scale.x);
            }
            transform.localScale = scale;
        }
        //saut
        bool canJump = Physics2D.OverlapCircle(jumpPosition.position, raycastRadius, mask);

        if (canJump && (playerDevice.GetControl(InputControlType.Action1).IsPressed)) //si appuye sur boutton saut
        {
            rigidBody2D.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);     //donne une impulsion verticale
        }
        //bouclier
        //a mettre dans le code du joueur
        if ((playerDevice.GetControl(InputControlType.RightBumper).IsPressed) && (spawnShield != true))
        {
            shieldThrow = true;
            if (transform.localScale.x > 0)
            {
                GameObject monObject = Instantiate(shieldPrefab, new Vector3(transform.position.x + 5, transform.position.y, -2), Quaternion.identity);
                monObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90));
                monObject.GetComponent <Rigidbody2D>().velocity          = new Vector2(shieldVelocity, verticalInput) * shieldVelocity;
                monObject.GetComponent <shieldMovement>().shieldPlayerId = playerIndex;
            }
            if (transform.localScale.x < 0)
            {
                GameObject monObject = Instantiate(shieldPrefab, new Vector3(transform.position.x - 5, transform.position.y, -2), Quaternion.identity);
                monObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90));
                monObject.GetComponent <Rigidbody2D>().velocity          = new Vector2(-shieldVelocity, verticalInput) * shieldVelocity;
                monObject.GetComponent <shieldMovement>().shieldPlayerId = playerIndex;
            }
            spawnShield = true;
        }
        //levée de bouclier
        if (dashState == DashState.NOT_DASH)
        {
            if ((playerDevice.GetControl(InputControlType.LeftBumper).IsPressed) && (spawnShield == false))
            {
                rigidBody2D.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;

                animator.SetBool("ShieldFlanc", true);
                armorState = ArmorState.SHIELD_UP;
                canMove    = false;
                Debug.Log("boucliers");
                //playerShield.SetActive(true);
                shieldOn = true;
                colliderShieldFlanc.enabled = true;
                colliderShieldTop.enabled   = false;
                colliderShieldDown.enabled  = false;
                if (playerDevice.LeftStickY > 0.2f)
                {
                    Debug.Log("prout");
                    colliderShieldTop.enabled   = true;
                    colliderShieldDown.enabled  = false;
                    colliderShieldFlanc.enabled = false;
                    //playerShield.SetActive(false);
                    shieldDown = false;
                    shieldUP   = true;
                }
                else if (playerDevice.LeftStickY < -0.2f)
                {
                    //playerShield.SetActive(false);
                    colliderShieldDown.enabled  = true;
                    colliderShieldTop.enabled   = false;
                    colliderShieldFlanc.enabled = false;
                    shieldDown = true;
                    shieldUP   = false;
                }
                else
                {
                    colliderShieldTop.enabled   = false;
                    colliderShieldDown.enabled  = false;
                    colliderShieldFlanc.enabled = true;
                    shieldDown = false;
                    shieldUP   = false;
                    //playerShield.SetActive(false);
                }
            }
            else
            {
                rigidBody2D.constraints     = RigidbodyConstraints2D.FreezeRotation;
                colliderShieldTop.enabled   = false;
                colliderShieldDown.enabled  = false;
                colliderShieldFlanc.enabled = false;
                animator.SetBool("ShieldFlanc", false);
                armorState = ArmorState.SHIELD_LESS;
                canMove    = true;
                //playerShield.SetActive(false);
                shieldOn   = false;
                shieldDown = false;
                shieldUP   = false;
            }
        }
        animator.SetBool("shieldDown", shieldDown);
        animator.SetBool("shieldUP", shieldUP);
        animator.SetBool("shieldThrow", shieldThrow);
    }
예제 #34
0
    protected override void ComputeVelocity()
    {
        //input check
        Vector2 move = Vector2.zero;

        move.x = Input.GetAxisRaw("Horizontal");  //Raw to avoid automatic lerp calculation

        //perform jump
        if (Input.GetButtonDown("Jump") && grounded)
        {
            velocity.y = jumpTakeOffSpeed;
        }
        else if (Input.GetButtonUp("Jump"))
        {
            if (velocity.y > 0)
            {
                velocity.y = velocity.y * 0.5f;
            }
        }

        //process axis direction
        if (move.x != oldHDirection) // check if holding
        {
            //when left or right
            if (move.x != 0)      // check if direction or neutral
            {
                if (!isAxisInUse) //check direction
                {
                    if (move.x > 0)
                    {
                        //if previous input was right, perform dash
                        currentAxisDirection = AxisDirection.Right;
                        Debug.Log("Right");

                        if (previousAxisDirection == AxisDirection.Right && keyDuration <= timeForNextKey)
                        {
                            //performDash = true;
                            //Debug.Log("PErform Dash");

                            OnPerformDash();
                            dashState   = DashState.Dashing;
                            orientation = move;
                        }
                        else
                        {
                            //performDash = false;
                        }
                    }
                    else
                    {
                        currentAxisDirection = AxisDirection.Left;
                        Debug.Log("Left");

                        if (previousAxisDirection == AxisDirection.Left && keyDuration <= timeForNextKey)
                        {
                            //performDash = true;
                            //Debug.Log("PErform Dash");

                            OnPerformDash();
                            dashState   = DashState.Dashing;
                            orientation = move;
                        }
                        else
                        {
                            //performDash = false;
                        }
                    }


                    keyDuration = 0f;
                    Debug.Log("Reset key duration");
                    isAxisInUse = true;
                }
            }
            else
            {
                //when neutral
                previousAxisDirection = currentAxisDirection;
                currentAxisDirection  = AxisDirection.None;

                //Debug.Log("None");
                isAxisInUse = false;
            }
        }
        else
        {
            keyDuration += Time.deltaTime;
        }


        //check and perform dash input
        //if (move.x != 0f)
        //{

        /*
         * if (dashState == DashState.Ready)
         * {
         *  bool isDashKeyDown = Input.GetButtonDown("Dash");
         *  if (isDashKeyDown)
         *  {
         *      Debug.Log("Dash mode");
         *      dashState = DashState.Dashing;
         *  }
         *
         * }
         * else if (dashState == DashState.Dashing)*/

        if (dashState == DashState.Ready)
        {
        }
        else if (dashState == DashState.Dashing)
        {
            dashTimer += Time.deltaTime;
            if (dashTimer >= dashDuration)
            {
                dashState = DashState.Cooldown;
                dashTimer = 0f;
            }
        }
        else if (dashState == DashState.Cooldown)
        {
            dashTimer += Time.deltaTime;
            if (dashTimer >= cooldownDuration)
            {
                dashState = DashState.Ready;
                dashTimer = 0f;
            }
        }
        //}


        //check orientation. One shot
        if (move.x != oldHDirection)
        {
            if (move.x > 0)
            {
                orientation          = Vector2.right;
                spriteRenderer.flipX = !inverseFlip? false : true;
            }
            else if (move.x < 0)
            {
                orientation          = Vector2.left;
                spriteRenderer.flipX = !inverseFlip ? true : false;
            }
        }

        //move
        if (dashState == DashState.Dashing)
        {
            targetVelocity = orientation * dashSpeed;
        }
        else
        {
            targetVelocity = move * maxSpeed;
        }

        oldHDirection = move.x;
    }
예제 #35
0
파일: Dash.cs 프로젝트: pochp/fooziespublic
 public override void Initialize()
 {
     m_state = DashState.Inactive;
 }
예제 #36
0
 // Use this for initialization
 void Start()
 {
     dashState = DashState.Ready;
     base.Prepare ();
 }
예제 #37
0
    // Update is called once per frame
    void Update()
    {
        AmmoManager.AmmoCount(Ammo);

        Vector2 movement_vector = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        if (movement_vector != Vector2.zero)
        {
            anim.SetBool("iswalking", true);
            anim.SetFloat("input_x", movement_vector.x);
            anim.SetFloat("input_y", movement_vector.y);
        }
        else
        {
            anim.SetBool("iswalking", false);
        }

        rbody.MovePosition(rbody.position + movement_vector * Speed);


        if (movement_vector.x > 0)
        {
            Dir = Directions.Right;
        }
        else if (movement_vector.x < 0)
        {
            Dir = Directions.Left;
        }
        else if (movement_vector.y > 0)
        {
            Dir = Directions.Up;
        }
        else if (movement_vector.y < 0)
        {
            Dir = Directions.Down;
        }
        else if (movement_vector.y > 0 && movement_vector.x > 0)
        {
            Dir = Directions.UpRight;
        }
        else if (movement_vector.y > 0 && movement_vector.x < 0)
        {
            Dir = Directions.UpLeft;
        }
        else if (movement_vector.y < 0 && movement_vector.x < 0)
        {
            Dir = Directions.DownLeft;
        }
        else if (movement_vector.y < 0 && movement_vector.x > 0)
        {
            Dir = Directions.DownRight;
        }


        //Dashing
        switch (dashState)
        {
        case DashState.Ready:
            var isDashKeyDown = Input.GetKeyDown("z");
            Debug.Log("Start dashstate ready");
            if (isDashKeyDown)
            {
                savedSpeed = Speed;
                Speed      = Speed + 2;

                dashState = DashState.Dashing;
            }
            break;

        case DashState.Dashing:
            Debug.Log("Start dashstate dashing");
            dashTimer += Time.deltaTime * 3;
            if (dashTimer >= maxDash)
            {
                dashTimer = maxDash;
                Speed     = savedSpeed;
                dashState = DashState.Cooldown;
            }
            break;

        case DashState.Cooldown:
            Debug.Log("Start dashstate cooldown");
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                dashTimer = 0;
                dashState = DashState.Ready;
            }
            break;
        }

        // Dashing (Controller)

        switch (dashState)
        {
        case DashState.Ready:
            var isDashKeyDown = Input.GetButtonDown("Dash");
            Debug.Log("Start dashstate ready");
            if (isDashKeyDown)
            {
                savedSpeed = Speed;
                Speed      = Speed + 2;

                dashState = DashState.Dashing;
            }
            break;

        case DashState.Dashing:
            Debug.Log("Start dashstate dashing");
            dashTimer += Time.deltaTime * 3;
            if (dashTimer >= maxDash)
            {
                dashTimer = maxDash;
                Speed     = savedSpeed;
                dashState = DashState.Cooldown;
            }
            break;

        case DashState.Cooldown:
            Debug.Log("Start dashstate cooldown");
            dashTimer -= Time.deltaTime;
            if (dashTimer <= 0)
            {
                dashTimer = 0;
                dashState = DashState.Ready;
            }
            break;
        }



        //fire bullet when the spacebar is pressed
        if (Input.GetKeyDown("space") && Dir == Directions.Right)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                //instantiate the first bullet
                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);
                //bullet01.transform.position = bulletPosition01.transform.position; //set the bullet initial postion

                bullet01.GetComponent <PlayerBullet> ().xspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetKeyDown("space") && Dir == Directions.Left)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                //instantiate the first bullet
                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);
                //bullet01.transform.position = bulletPosition01.transform.position; //set the bullet initial postion

                bullet01.GetComponent <PlayerBullet> ().xspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetKeyDown("space") && Dir == Directions.Up)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().yspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetKeyDown("space") && Dir == Directions.Down)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().yspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetKeyDown("space") && Dir == Directions.UpRight)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = 5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetKeyDown("space") && Dir == Directions.UpLeft)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = -5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetKeyDown("space") && Dir == Directions.DownRight)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = 5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetKeyDown("space") && Dir == Directions.DownLeft)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = -5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }



        // Controller Input
        if (Input.GetButtonDown("Fire1") && Dir == Directions.Right)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                //instantiate the first bullet
                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);
                //bullet01.transform.position = bulletPosition01.transform.position; //set the bullet initial postion

                bullet01.GetComponent <PlayerBullet> ().xspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetButtonDown("Fire1") && Dir == Directions.Left)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                //instantiate the first bullet
                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);
                //bullet01.transform.position = bulletPosition01.transform.position; //set the bullet initial postion

                bullet01.GetComponent <PlayerBullet> ().xspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetButtonDown("Fire1") && Dir == Directions.Up)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().yspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetButtonDown("Fire1") && Dir == Directions.Down)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().yspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetButtonDown("Fire1") && Dir == Directions.UpRight)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = 5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetButtonDown("Fire1") && Dir == Directions.UpLeft)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = -5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = 5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetButtonDown("Fire1") && Dir == Directions.DownRight)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = 5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
        else if (Input.GetButtonDown("Fire1") && Dir == Directions.DownLeft)
        {
            if (Ammo > 0)
            {
                Audio.PlayOneShot(Shoot);

                GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO, transform.position, Quaternion.identity);

                bullet01.GetComponent <PlayerBullet> ().xspeed = -5.0f;
                bullet01.GetComponent <PlayerBullet> ().yspeed = -5.0f;

                Ammo = Ammo - 1;
            }
            else
            {
                Audio.PlayOneShot(NoAmmo);
            }
        }
    }
예제 #38
0
    public override void Begin()
    {
        base.Begin();

        GameSystem.SetTimeMultiplier(GameSystem.GAMEPLAY, 1.0);

        IdleState              idle              = new IdleState(this.listenerId);
        MovingForwardState     movingForward     = new MovingForwardState(this.listenerId);
        MovingBackwardState    movingBackward    = new MovingBackwardState(this.listenerId);
        QuickStepForwardState  quickStepForward  = new QuickStepForwardState(this.listenerId);
        QuickStepBackwardState quickStepBackward = new QuickStepBackwardState(this.listenerId);
        DashChargingState      dashCharging      = new DashChargingState(this.listenerId);
        DashState              dash              = new DashState(this.listenerId);
        FeintState             feint             = new FeintState(this.listenerId);
        ChargingState          charging          = new ChargingState(this.listenerId);
        ChargeRecoveryState    chargeRecovery    = new ChargeRecoveryState(this.listenerId);
        DashRecoveryState      dashRecovery      = new DashRecoveryState(this.listenerId);
        //SpecialActivateState specialActivate = new SpecialActivateState(this.listenerId);
        //SpecialChargingState specialCharging = new SpecialChargingState(this.listenerId);
        CollisionWinCondition  collisionWinCond  = new CollisionWinCondition(this.listenerId);
        CollisionLossCondition collisionLossCond = new CollisionLossCondition(this.listenerId);
        CollisionWinState      collisionWin      = new CollisionWinState(this.listenerId);
        CollisionLossState     collisionLoss     = new CollisionLossState(this.listenerId);

        PlayerReadyState   ready   = new PlayerReadyState(this.listenerId);
        PlayerPlayingState playing = new PlayerPlayingState(this.listenerId);
        PlayerPausedState  paused  = new PlayerPausedState(this.listenerId);
        VictoryState       victory = new VictoryState(this.listenerId);
        DefeatState        defeat  = new DefeatState(this.listenerId);

        //SpecialActivateCondition specialActivateCond = new SpecialActivateCondition(this.listenerId);
        DefeatCondition defeatCond = new DefeatCondition(this.listenerId);

        idle.AddStateChange("moveForward", movingForward);
        idle.AddStateChange("moveBackward", movingBackward);
        idle.AddStateChange("charge", charging);
        idle.AddStateChange("dashCharge", dashCharging);
        idle.AddStateChange("feint", feint);
        idle.AddStateChange("collisionWin", collisionWin);
        idle.AddStateChange("collisionLoss", collisionLoss);
        //idle.AddStateChange("specialActivate", specialActivate);
        idle.AddGameStateCondition(collisionWinCond);
        idle.AddGameStateCondition(collisionLossCond);
        //idle.AddGameStateCondition(specialActivateCond);
        movingForward.AddStateChange("stop", idle);
        movingForward.AddStateChange("quickStep", quickStepForward);
        movingForward.AddStateChange("moveBackward", movingBackward);
        movingForward.AddStateChange("charge", charging);
        movingForward.AddStateChange("dashCharge", dashCharging);
        movingForward.AddStateChange("feint", feint);
        movingForward.AddStateChange("collisionWin", collisionWin);
        movingForward.AddStateChange("collisionLoss", collisionLoss);
        //movingForward.AddStateChange("specialActivate", specialActivate);
        movingForward.AddGameStateCondition(collisionWinCond);
        movingForward.AddGameStateCondition(collisionLossCond);
        //movingForward.AddGameStateCondition(specialActivateCond);
        quickStepForward.AddStateChange("stop", idle);
        quickStepForward.AddStateChange("charge", charging);
        quickStepForward.AddStateChange("dashCharge", dashCharging);
        quickStepForward.AddStateChange("feint", feint);
        quickStepForward.AddStateChange("collisionWin", collisionWin);
        quickStepForward.AddStateChange("collisionLoss", collisionLoss);
        //quickStepForward.AddStateChange("specialActivate", specialActivate);
        quickStepForward.AddGameStateCondition(collisionWinCond);
        quickStepForward.AddGameStateCondition(collisionLossCond);
        //quickStepForward.AddGameStateCondition(specialActivateCond);
        movingBackward.AddStateChange("stop", idle);
        movingBackward.AddStateChange("quickStep", quickStepBackward);
        movingBackward.AddStateChange("moveForward", movingForward);
        movingBackward.AddStateChange("charge", charging);
        movingBackward.AddStateChange("dashCharge", dashCharging);
        movingBackward.AddStateChange("feint", feint);
        movingBackward.AddStateChange("collisionWin", collisionWin);
        movingBackward.AddStateChange("collisionLoss", collisionLoss);
        //movingBackward.AddStateChange("specialActivate", specialActivate);
        movingBackward.AddGameStateCondition(collisionWinCond);
        movingBackward.AddGameStateCondition(collisionLossCond);
        //movingBackward.AddGameStateCondition(specialActivateCond);
        quickStepBackward.AddStateChange("stop", idle);
        quickStepBackward.AddStateChange("charge", charging);
        quickStepBackward.AddStateChange("dashCharge", dashCharging);
        quickStepBackward.AddStateChange("feint", feint);
        quickStepBackward.AddStateChange("collisionWin", collisionWin);
        quickStepBackward.AddStateChange("collisionLoss", collisionLoss);
        //quickStepBackward.AddStateChange("specialActivate", specialActivate);
        quickStepBackward.AddGameStateCondition(collisionWinCond);
        quickStepBackward.AddGameStateCondition(collisionLossCond);
        //quickStepBackward.AddGameStateCondition(specialActivateCond);
        charging.AddStateChange("stop", chargeRecovery);
        charging.AddStateChange("collisionWin", collisionWin);
        charging.AddStateChange("collisionLoss", collisionLoss);
        charging.AddGameStateCondition(collisionWinCond);
        charging.AddGameStateCondition(collisionLossCond);
        dashCharging.AddStateChange("dash", dash);
        dashCharging.AddStateChange("collisionWin", collisionWin);
        dashCharging.AddStateChange("collisionLoss", collisionLoss);
        dashCharging.AddGameStateCondition(collisionWinCond);
        dashCharging.AddGameStateCondition(collisionLossCond);
        dash.AddStateChange("stop", dashRecovery);
        dash.AddStateChange("collisionWin", collisionWin);
        dash.AddStateChange("collisionLoss", collisionLoss);
        dash.AddGameStateCondition(collisionWinCond);
        dash.AddGameStateCondition(collisionLossCond);
        feint.AddStateChange("stop", idle);
        feint.AddStateChange("charge", charging);
        feint.AddStateChange("dashCharge", dashCharging);
        feint.AddStateChange("feint", feint);
        feint.AddStateChange("collisionWin", collisionWin);
        feint.AddStateChange("collisionLoss", collisionLoss);
        feint.AddGameStateCondition(collisionWinCond);
        feint.AddGameStateCondition(collisionLossCond);
        chargeRecovery.AddStateChange("recover", idle);
        chargeRecovery.AddStateChange("collisionWin", collisionWin);
        chargeRecovery.AddStateChange("collisionLoss", collisionLoss);
        chargeRecovery.AddGameStateCondition(collisionWinCond);
        chargeRecovery.AddGameStateCondition(collisionLossCond);
        dashRecovery.AddStateChange("recover", idle);
        dashRecovery.AddStateChange("collisionWin", collisionWin);
        dashRecovery.AddStateChange("collisionLoss", collisionLoss);
        dashRecovery.AddGameStateCondition(collisionWinCond);
        dashRecovery.AddGameStateCondition(collisionLossCond);

        /*specialActivate.AddStateChange("specialCharge", specialCharging);
         * specialActivate.AddStateChange("collisionWin", collisionWin);
         * specialActivate.AddStateChange("collisionLoss", collisionLoss);
         * specialActivate.AddGameStateCondition(collisionWinCond);
         * specialActivate.AddGameStateCondition(collisionLossCond);
         * specialCharging.AddStateChange("stop", idle);
         * specialCharging.AddStateChange("collisionWin", collisionWin);
         * specialCharging.AddStateChange("collisionLoss", collisionLoss);
         * specialCharging.AddGameStateCondition(collisionWinCond);
         * specialCharging.AddGameStateCondition(collisionLossCond);*/
        collisionWin.AddStateChange("recover", idle);
        collisionLoss.AddStateChange("recover", idle);

        ready.AddStateChange("play", playing);
        playing.AddStateChange("pause", paused);
        playing.AddGameStateCondition(defeatCond);
        paused.AddStateChange("play", playing);
        playing.AddStateChange("victory", victory);
        playing.AddStateChange("defeat", defeat);

        this.input = new GameInputState(this.listenerId, 0);
        this.input.SetInputMapping(GameInputState.LEFT_STICK_LEFT_RIGHT, "moveStick");
        this.input.SetInputMapping(GameInputState.D_PAD_LEFT_RIGHT, "moveStick");
        this.input.SetInputMapping(GameInputState.A, "chargeButton");
        this.input.SetInputMapping(GameInputState.B, "quickStepButton");
        this.input.SetInputMapping(GameInputState.X, "dashButton");
        this.input.SetInputMapping(GameInputState.Y, "feintButton");
        this.input.SetInputMapping(GameInputState.START, "start");

        this.AddCurrentState(this.input);
        this.AddCurrentState(idle);
        this.AddCurrentState(ready);
    }