protected override void Attack(GameObject obj) { if (destroy) { destroy = false; //Debug.Log("MaxWalkingTime: " + (double)maxWalkTime + " | Walking Time: " + (double)walkTime + " | Time-walktime: " + (double)(Time.time - walkTime) + " | startrotate: " + startedRotateAndShoot + " | attacking: " + attacking); if (Time.time - walkTime > maxWalkTime && walkTime != 0 && !startedRotateAndShoot) { //print("Tiro incomum"); seek = false; attacking = false; startedRotateAndShoot = true; walkTime = 0f; StartCoroutine(rotateAndShoot(attackDelay / speed)); } else if (!startedRotateAndShoot && attacking) { //print("Tiro comum"); // GetComponent<Animator> ().SetBool("Shooting",true); seek = true; attacking = false; bullet = prefab.Spawn(); z = this.gameObject.transform.rotation.eulerAngles.z; Vector3 position = transform.position + Quaternion.Euler(0, 0, z) * Vector3.right / 3f; bullet.transform.position = transform.position + direction * 0.36f; bullet.direction = direction; bullet.damage = (int) damage; bullet.speed = bulletSpeed; } } }
public override void OnTakeDamage(ShootMove shoot, Collider2D coll) { base.OnTakeDamage(shoot, coll); if (life > 0 && life <= initLife * BROKEN) { _smoke.gameObject.SetActive(true); } }
protected override void Attack(GameObject obj) { if (obj != null && destroy) { z = transform.rotation.eulerAngles.z; bullet = prefab.Spawn(); Vector3 position = transform.position + Quaternion.Euler(0, 0, z) * -Vector3.right; bullet.transform.position = position; bullet.direction = Quaternion.Euler(0, 0, z) * Vector2.right * -movementDirection; destroy = false; StartCoroutine("changeDestroy", attackDelay); } }
/// <summary> /// Create a button for a shoot move. /// </summary> /// <param name="move">The shoot move to create a button to trigger.</param> private void GenerateShootButton(ShootMove move) { int xPixels = move.def.px + Game.instance.xScroll; int yPixels = move.def.py + Game.instance.yScroll; if (CanMove(move.cost)) { Button select = new Button(new Rectangle(xPixels, yPixels, Tile.TILE_WIDTH, Tile.TILE_HEIGHT), Assets.yellowHighlight); select.RightClick += () => { move.Execute(true); SubtractMove(move.cost); foreach (Button b in movementButtons) { b.Delete(); } }; Game.instance.selectionButtons.Add(select); movementButtons.Add(select); } }
protected IEnumerator rotateAndShoot(float delay) { print("Tiro comum"); for (int i = 0; i < numberofShoots; i++) { // Logica do Meio "de totoro", acho que não ficou muito legal... //int signal = (Mathf.Min(direction.x, direction.y) == direction.y) ? (int)(direction.y / Mathf.Abs(direction.y)) : (int)(direction.x / Mathf.Abs(direction.x)); //transform.Rotate(0, 0, rotateStep * signal); //yield return new WaitForSeconds(delay); //z = transform.rotation.eulerAngles.z; //Rotacionando o inimigo //rigidbody2D.MoveRotation(rotateStep * (i - numberofShoots / 2)); //yield return new WaitForSeconds(delay); //z = transform.rotation.eulerAngles.z; //Rotacionando somente o tiro yield return new WaitForSeconds(delay); z = transform.rotation.eulerAngles.z + rotateStep * (i - numberofShoots / 2); //Debug.Log("Time" + i + ": " + (double)Time.time + " | t: " + (double)(i - numberofShoots / 2) + " | z: " + (double)z); bullet = prefab.Spawn(); //Vector3 position = transform.position + Quaternion.Euler(0, 0, z) * Vector3.right / 3f; bullet.transform.position = transform.position + direction.normalized * 0.36f; bullet.direction = direction; bullet.damage = (int)damage; bullet.speed = bulletSpeed; } walkTime = 0f; seek = true; StopCoroutine("rotateAndShoot"); startedRotateAndShoot = false; }
void Start() { move = GetComponent <ShootMove>(); audioSource = GetComponent <AudioSource>(); }
public void OnGetHit(ShootMove shoot, Collider2D other) { if (afterOnHurt) return; Vector2 d = shoot.direction; OnGetHit((int)shoot.damage, d, other); }
public void OnGetHit(ShootMove shoot, Collider2D other) { OnGetHit((int)shoot.damage, shoot.direction); }
public override void OnTakeDamage(ShootMove shoot, Collider2D coll) { base.OnTakeDamage(shoot, coll); if (life > 0) _sfx.Hit(); }
public virtual void OnTakeDamage(ShootMove shoot, Collider2D coll) { if (impulseTween != null) impulseTween.Kill(); impulseForce = ((Vector3)shoot.direction * shoot.damage * 8) + impulseForce * DAMAGE_INFLUENCE; impulseTween = DOTween.To(() => impulseForce, x => impulseForce = x, Vector3.zero, TIME_IN_DAMAGE).SetEase(Ease.OutCirc).OnComplete(() => impulseTween = null); life -= shoot.damage; if (life <= 0) { OnDestroyIt(); } }