void SetAttackPoint() { // Set the ranges attackPointLeft = new Vector2(transform.position.x - attackRange - 0.3f, transform.position.y); attackPointRight = new Vector2(transform.position.x + attackRange + 0.3f, transform.position.y); attackPointUp = new Vector2(transform.position.x, transform.position.y + attackRange); attackPointDown = new Vector2(transform.position.x, transform.position.y - attackRange); if (transform.tag == "Player") { playerIsLooking = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>().looking; switch (playerIsLooking) { default: throw new System.Exception("looking in unknown direction"); case PlayerMovement.Looking.Up: attackPoint = attackPointUp; break; case PlayerMovement.Looking.Down: attackPoint = attackPointDown; break; case PlayerMovement.Looking.Left: attackPoint = attackPointLeft; break; case PlayerMovement.Looking.Right: attackPoint = attackPointRight; break; } } }
public void Update() { playerIsLooking = GameObject.FindGameObjectWithTag("Player") .GetComponent <PlayerMovement>() .playerIsLooking(); var GS = GameObject.Find("GameManager").GetComponent <GameManager>(); if (rangedWeaponEquipped == true && GS.getArrowCount() > 0) { if (Time.time > rangedCooldown + rangedAttackDelay) { canShoot = true; rangedCooldown = Time.time; } } SetCurrentSprite(); GetCurrentSprite(); mouseClickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { Attack(); } }
void Start() { itemName = "Gold Bow"; damage = 25; attackDelay = 1.0f; speed = 10; player = GameObject.Find("Player"); playerCombat = player.GetComponent <PlayerCombat>(); playerIsLooking = GameObject.Find("Player") .GetComponent <PlayerMovement>() .playerIsLooking(); }
public void KnockBack(PlayerMovement.Looking direction) { var knockDirection = ""; if (direction == PlayerMovement.Looking.Left) { knockDirection = "Left"; } if (direction == PlayerMovement.Looking.Right) { knockDirection = "Right"; } if (direction == PlayerMovement.Looking.Up) { knockDirection = "Up"; } if (direction == PlayerMovement.Looking.Down) { knockDirection = "Down"; } StartCoroutine(Knock(knockDirection)); }
void Update() { playerIsLooking = player.GetComponent <PlayerMovement>().playerIsLooking(); }