Пример #1
0
    public override void enter(newPlayerController body)
    {
        base.enter(body);

        attack = false;
        body.thisAnimator.Play("player_dash");

        if (Input.GetAxisRaw("Horizontal") != 0)
        {
            body.transform.localScale = new Vector3(body.iniScale.x * Input.GetAxisRaw("Horizontal"), body.iniScale.y, body.iniScale.z);
        }
        body.thisRigidbody2D.velocity = Vector3.zero;
        attack         = false;
        counter        = dashDuration + endDuration;
        travelDistance = maxDistance;
        hitbox.gameObject.SetActive(true);
        //old codes, use raycast to determine attacking or not

        /*RaycastHit2D hit = Physics2D.BoxCast(transform.position, detectionSize, 0,  new Vector2(Mathf.Sign(body.transform.localScale.x),0), maxDistance+detectionSize.x,toDetec);
         * if (!hit)
         * {
         *  travelDistance = maxDistance;
         * }
         * else
         * {
         *  attack = true;
         *  travelDistance = Mathf.Abs(hit.distance-keepDistance);
         * }*/
    }
Пример #2
0
 // Start is called before the first frame update
 void Start()
 {
     player = FindObjectOfType <newPlayerController>();
     hp     = maxhp;
     origin = transform.position;
     myAnimator.keepAnimatorControllerStateOnDisable = true;
 }
Пример #3
0
    public override void loop(newPlayerController body)
    {
        base.loop(body);
        //float dashInput = Input.GetAxisRaw("Fire3");
        //float attackInput = Input.GetAxisRaw("Fire1");

        //change facing accoridngly
        if (body.grounded)
        {
            if (body.energy < body.energyMax)
            {
                body.energy += Time.deltaTime * body.energyMax;
            }
            body.energy = Mathf.Min(body.energyMax, body.energy);
        }

        if (Input.GetAxisRaw("Horizontal") != 0)
        {
            body.transform.localScale = new Vector3(body.iniScale.x * Input.GetAxisRaw("Horizontal"), body.iniScale.y, body.iniScale.z);
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            if (body.grounded)
            {
                body.changeState(body.state_attack1);
            }
            else
            {
                body.changeState(body.state_attackAir);
            }
        }
        body.attempDash();
    }
Пример #4
0
 public override void leave(newPlayerController body)
 {
     base.leave(body);
     hitbox.deactivate();
     body.thisRigidbody2D.velocity = Vector2.zero;
     body.thisAnimator.Play("player_idle");
     myHurtBox.gameObject.SetActive(true);
 }
Пример #5
0
 public override void enter(newPlayerController body)
 {
     base.enter(body);
     counter = duration;
     myHurtBox.gameObject.SetActive(false);
     hitbox.gameObject.SetActive(true);
     body.thisAnimator.Play("player_hurt");
 }
Пример #6
0
 public override void leave(newPlayerController body)
 {
     base.leave(body);
     body.velocity = Vector2.zero;
     hitbox.deactivate();
     hitbox2.deactivate();
     hitbox3.deactivate();
     hitbox3_5.deactivate();
     body.thisAnimator.Play("player_idle");
     //Sp = 0;
 }
Пример #7
0
 public override void loop(newPlayerController body)
 {
     base.loop(body);
     //stop player from moving
     body.velocity = Vector2.zero;
     counter      -= Time.deltaTime;
     if (counter <= 0)
     {
         body.changeState(body.state_neutral);
     }
 }
Пример #8
0
    public override void loop(newPlayerController body)
    {
        base.loop(body);
        //stop player from moving
        body.velocity = Vector2.zero;
        //I added this movement to avoid a very weird bug: if player and the enemy is not moving at all, sometimes the collision just do not happend
        if (counter > duration - 0.6f)
        {
            body.velocity = new Vector2(Mathf.Sign(transform.localScale.x) * 1, 0);
        }
        //if arrive this moment, do something form
        if (At(counter, duration - 0.12f))
        {
            hitbox.gameObject.SetActive(true);
        }

        if (At(counter, duration - 0.22f))
        {
            hitbox.deactivate();
        }


        counter -= Time.deltaTime;

        if (counter <= duration - 0.22f)
        {
            if (Input.GetKey(KeyCode.J))
            {
                body.changeState(body.state_attack2);
            }
        }

        //return to neutral if time up or jump cancel
        if (counter <= 0 || Input.GetAxisRaw("Jump") == 1)
        {
            body.changeState(body.state_neutral);
            body.jump();
        }
        body.attempDash();
        if (hitbox.hit)
        {
            hitbox.hit   = false;
            body.energy += 0.5f;
        }
    }
Пример #9
0
    public override void loop(newPlayerController body)
    {
        base.loop(body);

        if (At(counter, 0.4f))
        {
            hitbox.gameObject.SetActive(true);
        }
        if (At(counter, 0.35f))
        {
            hitbox.deactivate();
        }
        if (At(counter, 0.3f))
        {
            hitbox.gameObject.SetActive(true);
        }
        if (At(counter, 0.25f))
        {
            hitbox.deactivate();
        }
        if (At(counter, 0.2f))
        {
            hitbox.gameObject.SetActive(true);
        }
        if (At(counter, 0.15f))
        {
            hitbox.deactivate();
        }

        counter -= Time.deltaTime;
        //return to neutral if time up or land on ground
        if (counter <= 0 || body.grounded)
        {
            body.changeState(body.state_neutral);
        }

        body.attempDash();
        if (hitbox.hit)
        {
            hitbox.hit   = false;
            body.energy += 0.5f;
        }
    }
Пример #10
0
    public override void loop(newPlayerController body)
    {
        base.loop(body);
        //stop player from moving
        body.velocity = Vector2.zero;

        //if arrive this moment, do something form
        if (At(counter, 0.2f))
        {
            hitbox.gameObject.SetActive(true);
        }

        if (At(counter, 0.1f))
        {
            hitbox.deactivate();
        }

        if (At(counter, duration - 0.16f))
        {
            hitbox.gameObject.SetActive(true);
        }

        if (At(counter, duration - 0.3f))
        {
            hitbox.deactivate();
        }

        counter -= Time.deltaTime;

        //return to neutral if time up or jump cancel
        if (counter <= 0 || Input.GetAxisRaw("Jump") == 1)
        {
            body.changeState(body.state_neutral);
            body.jump();
        }

        body.attempDash();
        if (hitbox.hit)
        {
            hitbox.hit   = false;
            body.energy += 0.5f;
        }
    }
Пример #11
0
    public override void loop(newPlayerController body)
    {
        base.loop(body);
        body.thisRigidbody2D.velocity = Vector3.zero;
        //if normal
        if (!hitbox.hit)
        {
            if (counter > endDuration)
            {
                body.velocity = new Vector2(travelDistance * Mathf.Sign(transform.localScale.x) / dashDuration, 0);
            }
            else
            {
                body.velocity = Vector2.zero;
            }
        }
        else
        {
            if (!attack)
            {
                attack   = true;
                counter += attackDuration;
                Sp++;
                if (Sp == 3)
                {
                    Sp = 1;
                }
            }
            else
            {
                //if (counter < attackDuration && counter > attackDuration - 0.16f)
                //auto push back
                if (counter > attackDuration)
                {
                    body.velocity = new Vector2(Mathf.Sign(transform.localScale.x) * -7, 0);
                }
                else
                {
                    body.velocity = Vector2.zero;
                }
                if (Sp == 2)
                {
                    if (At(counter, attackDuration))
                    {
                        body.thisAnimator.Play("player_sp1");
                    }
                    if (At(counter, attackDuration - 0.1f))
                    {
                        hitbox2.gameObject.SetActive(true);
                    }
                }
                else if (Sp == 1)
                {
                    if (At(counter, attackDuration))
                    {
                        body.thisAnimator.Play("player_sp2");
                    }
                    if (At(counter, attackDuration - 0.1f))
                    {
                        hitbox3.gameObject.SetActive(true);
                    }
                    if (At(counter, attackDuration - 0.13f))
                    {
                        hitbox3.deactivate(); hitbox3_5.gameObject.SetActive(true);
                    }
                    if (At(counter, attackDuration - 0.16f))
                    {
                        hitbox3_5.deactivate(); hitbox3.gameObject.SetActive(true);
                    }
                    if (At(counter, attackDuration - 0.19f))
                    {
                        hitbox3.deactivate(); hitbox3_5.gameObject.SetActive(true);
                    }
                }


                if (counter < attackDuration - 0.22f)
                {
                    body.attempDash();

                    if (Input.GetKeyDown(KeyCode.J))
                    {
                        body.changeState(body.state_attack1);
                    }
                }
            }
        }


        counter -= Time.deltaTime;

        if (counter <= 0 || (Input.GetAxisRaw("Jump") == 1 && body.grounded))
        {
            Sp = 0;
            body.changeState(body.state_neutral);
            body.jump();
        }
    }
Пример #12
0
 // Start is called before the first frame update
 void Start()
 {
     currentState = state_idle;
     player       = FindObjectOfType <newPlayerController>();
 }
Пример #13
0
 public override void enter(newPlayerController body)
 {
     base.enter(body);
 }
Пример #14
0
 public override void leave(newPlayerController body)
 {
     base.leave(body);
 }
Пример #15
0
 public virtual void leave(newPlayerController body)
 {
 }
Пример #16
0
 public override void leave(newPlayerController body)
 {
     base.leave(body);
     hitbox.deactivate();
     body.thisAnimator.Play("player_idle");
 }
Пример #17
0
 public virtual void enter(newPlayerController body)
 {
 }
Пример #18
0
 public override void enter(newPlayerController body)
 {
     base.enter(body);
     counter = duration;
     body.thisAnimator.Play("player_attack2");
 }
Пример #19
0
 public virtual void loop(newPlayerController body)
 {
 }