public override void Interact() { base.Interact(); playerCombat.Attack(myStats); // The player attacks the stats of this object(the enemy). }
// Update is called once per frame void Update() { if (Player.dead) { btnAttack.SetActive(false); playerTurn = false; enemyTurn = false; Invoke("BattleLost", 4.0f); } if (Enemy.dead) { playerTurn = false; enemyTurn = false; Invoke("BattleWon", 4.0f); } if (playerTurn && attackReady && !Player.dead) { Player.Attack(); playerTurn = false; Invoke("EnemyTurn", 3.0f); } if (enemyTurn && !Enemy.dead) { Enemy.Attack(); enemyTurn = false; Invoke("PlayerTurn", 3.0f); } }
IEnumerator Normal() { while (state == State.Normal) { var direction = new Vector3(Horizontal, 0f, Vertical).normalized; if (direction.magnitude >= 0.1f) { var targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + camera.eulerAngles.y; Movement.Move(targetAngle, speed * Time.deltaTime); } if (Crouch) { Movement.ToggleCrouch(crouchMultiplier); } if (gameManager.playerAttack && Attack) { PlayerCombat.Attack(collider => collider.GetComponent <EnemyManager>()?.Die()); } yield return(null); } }
public void ApplyCollision(GameObject collider, bool overrideDash = false) //overrideDash - if an enemy is already in the trigger, don't dash at all { if (movement.isDashing || overrideDash) { TimeManager.Instance.DoFreezeTime(); combat.OnSuccessfulBash(); movement.CancelDash(); combat.Attack(); //apply damage/aoe to enemies near stunned if (collider.GetComponent <BaseEnemyClass>() != null) { collider.GetComponent <BaseEnemyClass>().GetStunned(); //collider.GetComponent<EnemyController>().CheckParry(); } //////////////////////////////////////////////// ///////////// vvv DELETE ALL vvv /////////////// //if (collider.GetComponent<EnemyBossBandit>() != null) //{ // collider.GetComponent<EnemyBossBandit>().TakeDamage(10); // collider.GetComponent<EnemyBossBandit>().CheckParry(); //} } }
void GetInput() { // Movement _horizontalInput = Input.GetAxisRaw("Horizontal"); _verticalInput = Input.GetAxisRaw("Vertical"); if (Input.anyKey) { _idleTime = 0.0f; } // Jump if (Input.GetButton("Jump") && !_playerCombatScript.AirHeavyAttack) { if (_isGrounded) { _jumpRequest = true; } else { if (Input.GetButtonDown("Jump") && !_playerCombatScript.AirHeavyAttack) { if (_airJumpCount < _airJumpCountMax) { _jumpRequest = true; _airJumpCount++; } } } } // Dash if (Input.GetButton("Dash") && _dashCount < _dashCountMax && Time.time > _dashTimer && !_playerCombatScript.AirHeavyAttack) { _dashRequest = true; } // Attack if (Input.GetButton("Fire1") && !_playerCombatScript.Attacking) { _playerCombatScript.Attack("Light"); } else if (Input.GetButton("Fire2") && !_playerCombatScript.Attacking) { _playerCombatScript.Attack("Heavy"); } }
//Called when the player presses the attack button public void Attack() { if (mDashing) { mDashing = false; mCanDash = false; } combatComponent.Attack(rigidbody.velocity, mGoingRight); }
private void grammarRec_OnPhraseRecognized(PhraseRecognizedEventArgs args) { var message = new StringBuilder(); var meanings = args.semanticMeanings; // Loops through phrases and applies logic based on switch foreach (var meaning in meanings) { var keyString = meaning.key.Trim(); var valueString = meaning.values[0].Trim(); message.Append("Key: " + keyString + ", Out Action: " + valueString + " \n"); _outAction = valueString; // Checks for keywords setup in xml file out.action="" switch (_outAction) { case "Attack": Debug.Log("You said Attack!"); playerCombat.Attack(); break; case "Jump": Debug.Log("You said Jump!"); playerMovement.Jump(); break; case "JumpAttack": Debug.Log("[-----You said JumpAttack!-----]"); playerMovement.Jump(); playerCombat.Attack(); break; default: break; } } Debug.Log(message); }
void Update() { if (animator.GetCurrentAnimatorStateInfo(0).IsName("Sword_slash")) { isAttacking = true; } else { isAttacking = false; } if (GameManager.instance.inputController.primaryAttack) { Debug.Log("Clicked left mouse button"); playerCombat.Attack(null); } }
IEnumerator Chase() { // Don't start until the next frame yield return(null); agent.isStopped = false; agent.speed = chaseSpeed; while (state == State.Chase) { agent.SetDestination(target.position); PlayerCombat.Attack(collider => { collider.GetComponent <PlayerManager>()?.Die(); target = null; }); yield return(null); } }
private void Update() { if (Input.GetButtonDown(GameInput.Fire)) { _combat.Attack(); } if (_charController.isGrounded) { if (_fallTimer != 0) { if (_fallTimer > fallAnimTime) { FallOver(); } _fallTimer = 0; } if (!_fallenOver) { HandleInput(); } } else { _fallTimer += Time.deltaTime; } if (_combat.IsPunching || _bac.IsDrinking || _fallenOver) { return; } Move(); if (Input.GetKeyDown(KeyCode.B)) { Application.Quit(); } }
private void getAttack() { playercombat.attackReady = true; playercombat.Attack(); }
public void HandleAttack() { _player.Attack(); }
void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Left mouse button if (Input.GetMouseButtonDown(0)) { isObject = false; //move to point if (Physics.Raycast(ray, out hit, 1000)) { navMeshAgent.isStopped = false; navMeshAgent.destination = hit.point; if (hit.collider.gameObject.tag == "Chest") { isObject = true; navMeshAgent.destination = hit.point; } if (hit.collider.gameObject.tag == "Enemy") { navMeshAgent.isStopped = false; isEnemy = true; navMeshAgent.destination = hit.point; } if (hit.collider.gameObject.tag == "Human") { navMeshAgent.isStopped = false; isHuman = true; navMeshAgent.destination = hit.point; playerSpeak.human = hit.collider.gameObject; } } } //When object is reached then interact with it if (Vector3.Distance(transform.position, navMeshAgent.destination) <= 1.2f) { if (isObject) { navMeshAgent.isStopped = true; isObject = false; Debug.Log("Open Chest"); } if (isEnemy) { navMeshAgent.isStopped = true; isEnemy = false; playerCombat.Attack(); } if (isHuman) { navMeshAgent.isStopped = true; isHuman = false; playerSpeak.SpeakWithHuman(); } } if (navMeshAgent.remainingDistance > navMeshAgent.stoppingDistance) { isRunning = true; } else { isRunning = false; } }
// Update is called once per frame void Update() { //Check if character just landed on the ground if (!m_grounded && m_groundSensor.State()) { m_grounded = true; m_animator.SetBool("Grounded", m_grounded); } //Check if character just started falling if (m_grounded && !m_groundSensor.State()) { m_grounded = false; m_animator.SetBool("Grounded", m_grounded); } // -- Handle input and movement -- float inputX = Input.GetAxis("Horizontal"); // Swap direction of sprite depending on walk direction if (inputX > 0) { GetComponent <SpriteRenderer>().flipX = true; attackPoint.localPosition = new Vector3(0.1f, 0.25f, 0f); } else if (inputX < 0) { GetComponent <SpriteRenderer>().flipX = false; attackPoint.localPosition = new Vector3(-0.1f, 0.25f, 0f); } // Move m_body2d.velocity = new Vector2(inputX * m_speed, m_body2d.velocity.y); //Set AirSpeed in animator m_animator.SetFloat("AirSpeed", m_body2d.velocity.y); // -- Handle Animations -- //Death if (Input.GetKeyDown("e")) { if (!m_isDead) { m_animator.SetTrigger("Death"); } else { m_animator.SetTrigger("Recover"); } m_isDead = !m_isDead; } //Hurt else if (Input.GetKeyDown("q")) { m_animator.SetTrigger("Hurt"); } //Attack else if (Input.GetMouseButtonDown(0)) { //m_animator.SetTrigger("Attack"); playerCombat.Attack(); } //Change between idle and combat idle else if (Input.GetKeyDown("f")) { m_combatIdle = !m_combatIdle; } //Jump else if (Input.GetKeyDown("space") && m_grounded) { m_animator.SetTrigger("Jump"); m_grounded = false; m_animator.SetBool("Grounded", m_grounded); m_body2d.velocity = new Vector2(m_body2d.velocity.x, m_jumpForce); m_groundSensor.Disable(0.2f); } //Run else if (Mathf.Abs(inputX) > Mathf.Epsilon) { m_animator.SetInteger("AnimState", 2); } //Combat Idle else if (m_combatIdle) { m_animator.SetInteger("AnimState", 1); } //Idle else { m_animator.SetInteger("AnimState", 0); } }
private void Attack() { Debug.Log("BodyAnimations, Dodge"); combat.Attack(); }