void FixedUpdate() { if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Dash")) { _moveBehaviour.Move(_dashDir.normalized); } else if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Run") && (_axis.x != 0f || _axis.y != 0f)) { _animator.SetFloat("X", _axis.x); _animator.SetFloat("Y", _axis.y); if ((_axis.x <= 0) && ((_axis.y <= 0 && (-_axis.x > -_axis.y)) || (_axis.y >= 0 && (-_axis.x > _axis.y)))) { _spriteRenderer.flipX = true; _attackBehaviour.FlipAttack(true); } else { _spriteRenderer.flipX = false; _attackBehaviour.FlipAttack(false); } _moveBehaviour.Move(_axis); } }
void Update() { dist = Vector3.Distance(target.transform.position, transform.position); if (visionRad > dist) { diff = (transform.position - target.transform.position).normalized; _moveBehaviour.Move(-diff); if (diff.x < 0) { _spriterenderer.flipX = false; } else { _spriterenderer.flipX = true; } } else { diff = (transform.position - target2.transform.position).normalized; _moveBehaviour.Move(-diff); if (diff.x <= 0) { _spriterenderer.flipX = false; } } }
public virtual void Update(GameTime gt) { if (moveBehaviour != null) { moveBehaviour.Move(ref position, ref direction); } }
void FixedUpdate() { _moveBehaviour.Move(_dir); if (Vector3.Distance(transform.position, _startPos) > 15) { Destroy(this.gameObject); } }
public virtual void Move(float?speed = null) { if (moveBehaviour == null) { Debug.Log("MoveBehavior가 없습니다"); return; } moveBehaviour.Move(gameObject, speed); }
public void FixedUpdate() { if (_patrol) { _animator.SetBool("Moving", true); if (_prevPos > transform.position.x) { _spriteRenderer.flipX = true; } else if (_prevPos < transform.position.x) { _spriteRenderer.flipX = false; } _routineBehaviour.Route(new Vector3(transform.position.x, transform.position.y, 0)); _prevPos = transform.position.x; } else if (player != null) { if (!_animator.GetCurrentAnimatorStateInfo(0).IsName("Hit") && !_animator.GetCurrentAnimatorStateInfo(0).IsName("Death")) { _animator.SetBool("Moving", true); if (player.transform.position.x - transform.position.x < 0) { _spriteRenderer.flipX = true; } else if (_prevPos < transform.position.x) { _spriteRenderer.flipX = false; } _moveBehaviour.Move(new Vector2(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y).normalized); } } else { _animator.SetBool("Moving", false); } }
public void Route(Vector3 pos) { if (Vector3.Distance(_routes[_next].position, pos) < 0.1f) { if (_next == _routes.Count - 1) { if (_pingPong) { _routes.Reverse(); } _next = 0; } else { _next++; } } else { _moveBehaviour.Move(new Vector2(_routes[_next].position.x - pos.x, _routes[_next].position.y - pos.y).normalized); } }
void FixedUpdate() { if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Run") || _animator.GetCurrentAnimatorStateInfo(0).IsName("Attack")) { if (player.transform.position.x < transform.position.x) { _spriteRenderer.flipX = true; _attackBehaviour.FlipAttack(true); } else if (player.transform.position.x > transform.position.x) { _spriteRenderer.flipX = false; _attackBehaviour.FlipAttack(false); } if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Run")) { _moveBehaviour.Move(new Vector2(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y).normalized); } } }
private void OnCollisionStay2D(Collision2D collision) { _moveBehaviour.Move(); }
public void Move() { MoveBehaviour.Move(); }
private void Move() { moveBehaviour?.Move(rb); }
public virtual void Update(GameTime gt) { #region Strategy Pattern moveBehaviour.Move(ref position, ref direction); #endregion }
void FixedUpdate() { _moveBehaviour.Move(-shot.transform.up); }
void FixedUpdate() { if (Vector3.Distance(transform.position, _player.transform.position) < 4) { //CALCUATE DISTANCE BETWEEN THE PLAYER AND THIS OBJECT _xdist = _player.transform.position.x - transform.position.x; _ydist = _player.transform.position.y - transform.position.y; //FLIP SPRITE if (_xdist > 0) { _spriteRenderer.flipX = false; } else if (_xdir < 0) { _spriteRenderer.flipX = true; } //DECIDE X DIRECTION BASED ON PLAYER'S POSITON if (_xdist >= -0.3f && _xdist <= 0.3f) { _xdir = Mathf.Sign(_player.transform.position.x + 0.30f * -Mathf.Sign(_xdist) - transform.position.x); } else if (_xdist >= -0.31f && _xdist <= 0.31f) { _xdir = 0; } else { _xdir = Mathf.Sign(_player.transform.position.x + 0.30f * Mathf.Sign(_xdist) - transform.position.x); } //DECIDE Y DIRECTION BASED ON PLAYER'S POSITON if (_ydist > -0.30f && _ydist < 0.15f) { _ydir = 0; } else { _ydir = Mathf.Sign(_player.transform.position.y + 0.15f - transform.position.y); } //ATTACK if (Mathf.Abs(_xdist) <= 0.35 && Mathf.Abs(_ydist) <= 0.35 && Time.time > _nextAtk) { _nextAtk = Time.time + _atkCd; _animator.SetTrigger("Attack"); _audio.PlayOneShot(AudioList.Instance.attack, 0.6f); } //DECIDE IF GET HITBOX AND MOVE OR NOT (IF GETS HIT) if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Hit")) { GetComponent <Collider2D>().enabled = false; } else { GetComponent <Collider2D>().enabled = true; if (!_animator.GetCurrentAnimatorStateInfo(0).IsName("Attack")) { _audio.Play(); _moveBehaviour.Move(new Vector2(_xdir, _ydir)); } } } }