public void BlockInput(bool block) { input_blocked = block; rb.velocity = Vector2.zero; player_state = Player_States.IDLE; shadow.localScale = new Vector3(2.75f, 1, 0.8f); anim.SetInteger("State", (int)player_state); }
public void SetPlayerInPause() { if (Time.timeScale == 1) { current_state = Player_States.IN_MENU_PLAYER; Time.timeScale = 0; } }
void OnEnable() { //get the Game_Controller script if (playerStates == null) { playerStates = gameObject.GetComponent <Player_States> (); } }
void OnEnable() { if (gameController == null) { gameController = GameObject.Find("Game Controller").GetComponent <Game_Controller> (); } if (playerState == null) { playerState = gameObject.GetComponentInParent <Player_States> (); } }
public void GetDamage(Transform enemy_push, bool realDamage = true) { Set_Enemy_Pushback(enemy_push); noNeedInvulnerable = !realDamage; current_state = Player_States.PUSHBACK_PLAYER; fader_scr.Fade_image.enabled = true; fader_scr.FadeOut(false, true); if (realDamage) { live_manager_scr.DetectedDamage(); } }
void OnEnable() { if (gameController == null) { gameController = GameObject.Find("Game Controller").GetComponent <Game_Controller> (); } //get the Game_Controller script if (playerStates == null) { playerStates = gameObject.GetComponent <Player_States> (); } }
// Use this for initialization private void Start() { movement_script = GetComponent <Collision_Movement>(); slash_attack_script = GetComponent <Slash_Attack>(); pushback_script = GetComponent <Player_PushBack>(); anim = GetComponent <Animator>(); sprite_rend = GetComponent <SpriteRenderer>(); timer_dash = 0.0f; current_state = Player_States.IDLE_PLAYER; strengthText.text = "Strenght lvl " + player_stats.Right_Hand_Object.damage; }
void OnEnable() { if (gameController == null) { gameController = GameObject.Find("Game Controller").GetComponent <Game_Controller> (); } if (playerState == null) { playerState = gameObject.GetComponentInParent <Player_States> (); } //subscribe to this delegate Laser_Controller.onHit += TakeDamage; }
// Update is called once per frame void FixedUpdate() { if (!input_blocked) { // Get Input Vector2 KB_direction = HandleKeyboardMovement(); Vector2 GP_direction = HandleControllerMovement(); Vector2 GP_Arrows_direction = HandleGPArrowsMovement(); direction = new Vector2(KB_direction.x + GP_direction.x + GP_Arrows_direction.x, KB_direction.y + GP_direction.y + GP_Arrows_direction.y).normalized *speed; // Flip Sprites if (direction.x < 0 && !engineer_sprite.flipX) { engineer_sprite.flipX = true; } else if (direction.x > 0 && engineer_sprite.flipX) { engineer_sprite.flipX = false; } // Animations Control if (direction != Vector2.zero && player_state != Player_States.RUN) { player_state = Player_States.RUN; Vector3 scale = originalShadowScale; scale.x *= 1.05f; shadow.localScale = scale; } else if (direction == Vector2.zero && player_state != Player_States.IDLE) { player_state = Player_States.IDLE; shadow.localScale = originalShadowScale; } anim.SetInteger("State", (int)player_state); rb.velocity = direction; } }
public void DisablePause() { current_state = Player_States.IDLE_PLAYER; Time.timeScale = 1; }
// Update is called once per frame private void Update() { if (Input.GetKeyDown(KeyCode.I)) { _inmortalMode = !_inmortalMode; inmortalText.SetActive(_inmortalMode); } if (_inmortalMode) { combat_collider.enabled = false; } if (is_invulnerable && !noNeedInvulnerable) { combat_collider.enabled = false; timer_invulerable += Time.deltaTime; //Maybe Here alpha effect Color temp = sprite_rend.color; sprite_rend.color = new Color(temp.r, temp.g, temp.b, Mathf.Sin(Time.time * speed_invulerable)); if (timer_invulerable >= total_time_invulnerable) { sprite_rend.color = new Color(temp.r, temp.g, temp.b, 255); timer_invulerable = 0; combat_collider.enabled = true; is_invulnerable = false; } } if ((Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("Abutton")) && current_state != Player_States.MID_STUNNED_PLAYER && current_state != Player_States.PUSHBACK_PLAYER && current_state != Player_States.SLASHING_PLAYER && current_state != Player_States.IDLE_PLAYER && Time.timeScale == 1) { slash_attack_script.Update_Attack_Colliders_To_None_Active(); current_state = Player_States.DASHING_PLAYER; } else if ((Input.GetKeyDown(KeyCode.T) || Input.GetButtonDown("Xbutton")) && current_state != Player_States.PUSHBACK_PLAYER && current_state != Player_States.DASHING_PLAYER && Time.timeScale == 1 && current_state != Player_States.MID_STUNNED_PLAYER) { if (!in_mine) { //int dir = anim.GetInteger("player_direction"); //anim.Rebind(); // anim.SetInteger("player_direction", dir); anim.SetBool("player_idle", false); //slash_attack_script.timer_slash = 0; //slash_attack_script.is_slash_done = false; current_state = Player_States.SLASHING_PLAYER; } else { //Functionality in mine } } else if ((Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown("MenuButton")) && current_state != Player_States.PUSHBACK_PLAYER) { if (Time.timeScale == 1) { current_state = Player_States.IN_MENU_PLAYER; Time.timeScale = 0; Menu.SetActive(true); } else if (Time.timeScale == 0 && !ImproveMenu.activeSelf) { current_state = Player_States.IDLE_PLAYER; Time.timeScale = 1; Menu.SetActive(false); } } if (current_state == Player_States.DASHING_PLAYER && timer_dash <= time_dashing) { anim.SetBool("player_roll", true); timer_dash += Time.deltaTime; time_dashing = anim.GetCurrentAnimatorClipInfo(0)[0].clip.length; movement_script.Movement_Update(dash_speed, true); } else if (current_state == Player_States.SLASHING_PLAYER) { slash_attack_script.Attack_Slash_Update(); } else if (current_state == Player_States.MID_STUNNED_PLAYER) { movement_script.StopMoving(); movement_script.SpriteDir(); string[] temp = Input.GetJoystickNames(); if (temp != null && temp.Length > 0 && temp[0] != "") { AnyInputController(); if (numOfInput >= 50) { numOfInput = 0; current_state = Player_States.IDLE_PLAYER; } } else { if (Input.anyKeyDown) { numOfInput++; if (numOfInput >= 5) { numOfInput = 0; current_state = Player_States.IDLE_PLAYER; } } } } else if (current_state == Player_States.FALLING_PLAYER) { //todo /* * * if (noNeedInvulnerable) * { * is_invulnerable = false; * noNeedInvulnerable = false; * } * else * */ is_invulnerable = true; //Start Animation anim.SetBool("player_fall", true); if (timer_fall >= anim.GetCurrentAnimatorClipInfo(0)[0].clip.length) { timer_fall = 0.0f; Vector3 temp_vect = new Vector3(-25.0f, 2.0f, 0.0f); transform.position = temp_vect; anim.SetBool("player_fall", false); current_state = Player_States.IDLE_PLAYER; } else { timer_fall += Time.deltaTime; } } else if (current_state == Player_States.PUSHBACK_PLAYER) { is_invulnerable = true; anim.SetBool("player_attack", false); slash_attack_script.Update_Attack_Colliders_To_None_Active(); pushback_script.PushBack_Update(); } else if (current_state == Player_States.IN_MENU_PLAYER) { } else { anim.SetBool("player_roll", false); timer_dash = 0.0f; lastInput = -1; movement_script.Movement_Update(movement_speed); } }