Beispiel #1
0
 void FixedUpdate()
 {
     if (Stun)
     {
         if (Attack)
         {
             Attack = false;
         }
         if (StunTime > 0)
         {
             StunTime -= Time.deltaTime;
             GameObject.Find("StunEffect").GetComponent <SpriteRenderer>().enabled = true;
         }
         else
         {
             Stun = false;
             GameObject.Find("StunEffect").GetComponent <SpriteRenderer>().enabled = false;
         }
     }
     ChangeInformation();
     if (!isDialog && !Stun && isGame)
     {
         GroundCheck();
         if (!Attack)
         {
             move = 0f;
             if (GameInput.Key.GetKey("A"))
             {
                 move = -1f;
                 if (isFacingRight)
                 {
                     Flip();
                     isFacingRight = false;
                 }
             }
             if (GameInput.Key.GetKey("D"))
             {
                 move = 1f;
                 if (!isFacingRight)
                 {
                     Flip();
                     isFacingRight = true;
                 }
             }
             wMove();
             if (GameInput.Key.GetKeyUp("A") || GameInput.Key.GetKeyUp("D"))
             {
                 move = 0f;
             }
             if (move == 0)
             {
                 anim.SetBool("Speed", false);
                 Attack = false;
             }
             if (GameInput.Key.GetKey("E") && (!Attack) && grounded && staminaController.ResolutionForAttack())
             {
                 RoosterAttack();
             }
             if (grounded && !isLadder && GameInput.Key.GetKey("Space"))
             {
                 rb.velocity = (new Vector2(0f, PowerJump));
             }
             if (GameInput.Key.GetKey("W"))
             {
                 v = 1f;
             }
             if (GameInput.Key.GetKey("S"))
             {
                 v = -1f;
             }
             if (GameInput.Key.GetKeyUp("W") || GameInput.Key.GetKeyUp("S"))
             {
                 v = 0f;
             }
             if (isLadder)
             {
                 LadderMode(v, move);
                 if (!grounded)
                 {
                     anim.SetBool("IsLadder", true);
                     if (v != 0)
                     {
                         anim.speed = 1;
                     }
                     else
                     {
                         anim.speed = 0;
                     }
                 }
                 else
                 {
                     anim.speed = 1;
                     anim.SetBool("IsLadder", false);
                 }
             }
             else
             {
                 anim.speed = 1;
                 anim.SetBool("IsLadder", false);
             }
         }
     }
     else
     {
         if (Stun)
         {
             anim.SetBool("Speed", false);
             anim.SetBool("Attack", false);
         }
     }
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (Stun)
     {
         if (!Block)
         {
             if (Attack)
             {
                 Attack = false;
             }
             if (StunTime > 0)
             {
                 StunTime -= Time.deltaTime;
                 GameObject.Find("StunEffect").GetComponent <SpriteRenderer>().enabled = true;
             }
             else
             {
                 Stun = false;
                 GameObject.Find("StunEffect").GetComponent <SpriteRenderer>().enabled = false;
             }
         }
         else
         {
             Stun = false;
             GameObject.Find("StunEffect").GetComponent <SpriteRenderer>().enabled = false;
         }
     }
     GroundCheck();
     ChangeInformation();
     move = 0f;
     if (!isDialog && !Stun && isGame)
     {
         if ((Block) && (GameInput.Key.GetKeyUp("Q")))
         {
             anim.SetBool("Block", false);
             componentPlayerHP.isblock = false;
             Block = false;
         }
         if (!Attack)
         {
             if (!GameInput.Key.GetKeyDown("E"))
             {
                 if (GameInput.Key.GetKey("A"))
                 {
                     move          = -1f;
                     isFacingRight = false;
                     Information.Instance.isFacingRight = isFacingRight;
                 }
                 if (GameInput.Key.GetKey("D"))
                 {
                     move          = 1f;
                     isFacingRight = true;
                     Information.Instance.isFacingRight = isFacingRight;
                 }
                 if (GameInput.Key.GetKeyUp("A") || GameInput.Key.GetKeyUp("D"))
                 {
                     move = 0f;
                 }
             }
             anim.SetBool("IsFacingRight", isFacingRight);
             if (!Block)
             {
                 wMove();
                 if (GameInput.Key.GetKey("E") && grounded && staminaController.ResolutionForAttack())
                 {
                     move   = 0f;
                     Attack = true;
                     RoosterAttack();
                 }
                 if ((GameInput.Key.GetKeyDown("Q")) || (GameInput.Key.GetKey("Q")) && grounded)
                 {
                     Block = true;
                     anim.SetBool("Block", true);
                     anim.SetBool("Speed", false);
                     componentPlayerHP.isblock = true;
                 }
                 if (grounded && (GameInput.Key.GetKeyDown("Space")))
                 {
                     rb.velocity = (new Vector2(0f, PowerJump));
                 }
                 if (GameInput.Key.GetKey("W"))
                 {
                     v = 1f;
                 }
                 if (GameInput.Key.GetKey("S"))
                 {
                     v = -1f;
                 }
                 if (GameInput.Key.GetKeyUp("W") || GameInput.Key.GetKeyUp("S"))
                 {
                     v = 0f;
                 }
                 if (isLadder)
                 {
                     LadderMode(v, move);
                     if (!grounded)
                     {
                         anim.SetBool("IsLadder", true);
                         anim.speed = (v != 0) ? 1 : 0;
                     }
                     else
                     {
                         anim.speed = 1;
                         anim.SetBool("IsLadder", false);
                     }
                 }
                 else
                 {
                     anim.SetBool("IsLadder", false);
                     anim.speed = 1;
                 }
             }
         }
         else
         {
             if (Stun)
             {
                 anim.SetBool("Speed", false);
                 anim.SetBool("Attack", false);
             }
         }
     }
 }
Beispiel #3
0
 // Update is called once per frame
 void Update()
 {
     if (Stun)
     {
         if (Attack)
         {
             Attack = false;
         }
         if (StunTime > 0)
         {
             StunTime          -= Time.deltaTime;
             stunObject.enabled = true;
         }
         else
         {
             Stun = false;
             stunObject.enabled = false;
         }
     }
     GroundCheck();
     ChangeInformation();
     if (!isDialog && !Stun && isGame)
     {
         if ((Block) && (GameInput.Key.GetKeyUp("Q")))
         {
             anim.Play("Idle");
             anim.SetBool("Block", false);
             playerHP.isblock = false;
             Block            = false;
         }
         if (!Attack && !Block)
         {
             mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
             if (((mousePos.x > tr.position.x) && isFacingRight) || ((mousePos.x <= tr.position.x) && !isFacingRight))
             {
                 aimSprite.enabled  = true;
                 aimCenter.rotation = Quaternion.Euler(0, 0, -Mathf.Atan2(mousePos.x - tr.position.x, mousePos.y - tr.position.y) * Mathf.Rad2Deg);
             }
             else
             {
                 aimSprite.enabled = false;
             }
             if (GameInput.Key.GetKey("A"))
             {
                 move = -1f;
                 if (isFacingRight)
                 {
                     Flip();
                     isFacingRight = false;
                 }
             }
             if (GameInput.Key.GetKey("D"))
             {
                 move = 1f;
                 if (!isFacingRight)
                 {
                     Flip();
                     isFacingRight = true;
                 }
             }
             if (GameInput.Key.GetKeyUp("A") || GameInput.Key.GetKeyUp("D"))
             {
                 move = 0f;
             }
             wMove();
             if (move == 0 && grounded)
             {
                 anim.SetBool("Speed", false);
             }
             if (GameInput.Key.GetKey("E") && (!Attack) && grounded && staminaController.ResolutionForAttack())
             {
                 move = 0f;
                 anim.SetBool("Attack", true);
                 Attack = true;
                 RoosterAttack();
             }
             if (GameInput.Key.GetKeyDown("Z") && (!Attack) && (MP >= costCold) && !isLadder && aimSprite.enabled && staminaController.ResolutionForAttack())
             {
                 move = 0f;
                 anim.SetBool("Attack", true);
                 Attack = true;
                 RoosterAttackCold();
             }
             if (GameInput.Key.GetKeyDown("X") && (!Attack) && (MP >= costFire) && !isLadder && aimSprite.enabled && staminaController.ResolutionForAttack())
             {
                 move = 0f;
                 anim.SetBool("Attack", true);
                 Attack = true;
                 RoosterAttackFire();
             }
             if (GameInput.Key.GetKeyDown("C") && (!Attack) && (MP >= costNecr) && !isLadder)
             {
                 move = 0f;
                 anim.SetBool("Attack", true);
                 Attack = true;
                 RoosterNecromantsAttack();
             }
             if (((GameInput.Key.GetKeyDown("Q")) || (GameInput.Key.GetKey("Q"))) && (MP >= costBlock) && grounded)
             {
                 move  = 0f;
                 Block = true;
                 anim.SetBool("Speed", false);
                 anim.SetBool("Block", true);
                 playerHP.isblock = true;
             }
             if (grounded && (GameInput.Key.GetKeyDown("Space")))
             {
                 rb.velocity = (new Vector2(0f, PowerJump));
             }
             if (GameInput.Key.GetKey("W"))
             {
                 v = 1f;
             }
             if (GameInput.Key.GetKey("S"))
             {
                 v = -1f;
             }
             if (GameInput.Key.GetKeyUp("W") || GameInput.Key.GetKeyUp("S"))
             {
                 v = 0f;
             }
             if (isLadder)
             {
                 LadderMode(v, move);
                 if (!grounded)
                 {
                     anim.SetBool("IsLadder", true);
                     if (v != 0)
                     {
                         anim.speed = 1;
                     }
                     else
                     {
                         anim.speed = 0;
                     }
                 }
                 else
                 {
                     anim.speed = 1;
                     anim.SetBool("IsLadder", false);
                 }
             }
             else
             {
                 anim.speed = 1;
                 anim.SetBool("IsLadder", false);
             }
         }
     }
     else
     {
         move = 0f;
         if (Stun)
         {
             anim.SetBool("Speed", false);
             anim.SetBool("Attack", false);
         }
     }
 }