void preAction(string actionName) { AttackedController c = GameObject.Find("bigzhangjiao (1)").GetComponent <AttackedController>(); string[] arr = actionName.Split('|'); string name = arr[0]; switch (name) { case AnimationName.Attack: if (attackBullet != null) { GameObject obj = GameObject.Instantiate(attackBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect1; bullet.bulleting(); } break; case AnimationName.Magic: if (magicBullet != null) { GameObject obj = GameObject.Instantiate(magicBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect2; bullet.bulleting(); } StartCoroutine(delayBullet()); StartCoroutine(delayBullet1()); break; case AnimationName.Magic2: if (magic2Bullet != null) { GameObject obj = GameObject.Instantiate(magic2Bullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect2; bullet.bulleting(); } break; case AnimationName.Ultimate: if (damageEffect3 != null) { GameObject obj1 = GameObject.Instantiate(damageEffect3); ParticlesEffect effect = obj1.AddComponent <ParticlesEffect>(); Transform target = GameObject.Find("bigzhangjiao (1)").transform; effect.transform.position = MathUtil.findChild(target, "attackedPivot").position; effect.play(); } c.attacked(); break; } }
private void Shoot() { GameObject BulletGO = (GameObject)Instantiate(ArrowPrefab, FirePoint.position, FirePoint.rotation); if (gameObject.tag == "ArcherTower") { NormalBullet _Bullet = BulletGO.GetComponent <NormalBullet>(); if (_Bullet != null) { _Bullet.seek(target, TargetGO); _Bullet.GetDamage(Damage, PhysicalDamage, MagicalDamage); } } if (gameObject.tag == "BomberTower") { BulletSc _Bullet = BulletGO.GetComponent <BulletSc>(); if (_Bullet != null) { _Bullet.seek(target, TargetGO); _Bullet.GetDamage(Damage, PhysicalDamage, MagicalDamage); _Bullet.GetTowerPosition(gameObject.transform.position); } } if (gameObject.tag == "CrystalTower") { NormalBullet _Bullet = BulletGO.GetComponent <NormalBullet>(); if (_Bullet != null) { _Bullet.seek(target, TargetGO); _Bullet.GetDamage(Damage, PhysicalDamage, MagicalDamage); _Bullet.GetTowerPosition(gameObject.transform.position); } } }
/// <summary> Coroutine that starts firing poison darts. /// when the coroutine is called it will invoke "Die" method when shootDuration is 0. /// </summary> protected override IEnumerator UseCoroutine() { Invoke("Die", shootDuration); while (true) { if (shootEffect != null) { shootEffect.Play(); } if (shootDropEffect != null) { shootDropEffect.Play(); } for (int i = 0; i < 3; i++) { NormalBullet b = Instantiate(bulletPrefab, bulletSpawnpoint.position, transform.root.rotation); b.BulletRotation(Random.Range(minStrayFactor, maxStrayFactor)); } shootSound.PlayAudio(); yield return(new WaitForSeconds(1 / usesPerSecond)); } }
private void OnTriggerEnter2D(Collider2D other) { switch (other.tag) { case "NormalBullet": NormalBullet normalBullet = other.gameObject.GetComponent <NormalBullet>(); string bulletColor = normalBullet.GetBulletColor(); Destroy(other.gameObject); if (_bodyColor == bulletColor) { Instantiate(prefabDiminishEffect, transform.position, new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)); Destroy(gameObject); _mainGameStateManager.AddScore(1000); } else { Instantiate(prefabIncreaseSound); for (int i = 1; i <= 3; i++) { float positionX = transform.position.x; float positionY = transform.position.y; float speedX = _speedX; float speedY = Random.Range(-100.0f, 100.0f); _enemyManager.GenerateEnemyCorona(_bodyColor, positionX, positionY, speedX, speedY, i); } Destroy(gameObject); _mainGameStateManager.AddScore(10); } break; } }
void FireBullet() { Ray bulletDirection = new Ray(m_bulletSpawnPoint.position, (m_target.position - m_bulletSpawnPoint.position).normalized); NormalBullet shotBullet = Instantiate(m_bulletPrefab, bulletDirection.origin, Quaternion.LookRotation(bulletDirection.direction)); shotBullet.GetComponent <Rigidbody>().velocity = bulletDirection.direction * m_bulletSpeed; shotBullet.shooter = transform; }
private void ShootAt(Vector3 pos) { NormalBullet bullet = GameZygote.Instance.AllocBullet(this.side, (int)BulletType.Normal) as NormalBullet; bullet.transform.position = this.transform.Find("point").position; bullet.ShootTo(pos); }
void preAction(string actionName) { string[] arr = actionName.Split('|'); string name = arr[0]; switch (name) { case AnimationName.Attack: if (attackBullet != null) { GameObject obj = GameObject.Instantiate(attackBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect1; bullet.bulleting(); } break; case AnimationName.Magic: if (magicBullet != null) { GameObject obj = GameObject.Instantiate(magicBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect1; bullet.bulleting(); } StartCoroutine(delayBullet()); break; case AnimationName.Magic2: if (magic2Bullet != null) { GameObject obj = GameObject.Instantiate(magic2Bullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect2; bullet.bulleting(); } StartCoroutine(delayBullet()); break; case AnimationName.Ultimate: if (ultimateBullet != null) { StartCoroutine(delayBullet()); StartCoroutine(delayBullet1()); StartCoroutine(delayBullet2()); StartCoroutine(delayBullet3()); } break; } }
public override void Play(ShootHelper user) { AudioHandler audioHandler = user.shooter.GetComponent <AudioHandler>(); audioHandler.PlaySound("Shoot"); Ray bulletDirection = user.GetOffsetRay(); NormalBullet shotBullet = Instantiate(m_bulletPrefab, bulletDirection.origin, Quaternion.LookRotation(bulletDirection.direction)); shotBullet.GetComponent <Rigidbody>().velocity = bulletDirection.direction * m_bulletSpeed; shotBullet.shooter = user.shooter; }
private void OnTriggerEnter2D(Collider2D other) { switch (other.tag) { case "NormalBullet": NormalBullet normalBullet = other.gameObject.GetComponent <NormalBullet>(); string bulletColor = normalBullet.GetBulletColor(); Destroy(other.gameObject); if (_bodyColor == bulletColor) { if (_bodyCount > 1) { Instantiate(prefabCountSound); _bodyCount--; _spriteRenderer.sprite = sprites[_bodyCount]; _mainGameStateManager.AddScore(100); } else { Vector3 currentPosition = transform.position; Instantiate(prefabDiminishEffect, currentPosition, new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)); Destroy(gameObject); _mainGameStateManager.AddScore(2000); } } else if (_bodyCount < 9) { Instantiate(prefabCountSound); _bodyCount++; _spriteRenderer.sprite = sprites[_bodyCount]; _mainGameStateManager.AddScore(10); } else { Instantiate(prefabIncreaseSound); for (int i = 1; i <= 3; i++) { float positionX = transform.position.x; float positionY = transform.position.y; float speedX = _speedX; float speedY = Random.Range(-100.0f, 100.0f); int bodyCount = 5; _enemyManager.GenerateEnemyCount(_bodyColor, positionX, positionY, speedX, speedY, i, bodyCount); } Destroy(gameObject); _mainGameStateManager.AddScore(10); } break; } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "NormalBullet") { if (followEnemy != null) { followEnemy.GetComponent <EnemyHealth>().GetHurt(damage); } NormalBullet sc = other.gameObject.GetComponent <NormalBullet>(); ActivateArea(sc.isFreezed, sc.effectTime, sc.slowArgument); Destroy(other.gameObject); } }
protected virtual void SetVelocity(GameObject bullet) { NormalBullet normalBullet = bullet.GetComponent <NormalBullet>(); normalBullet.ExplodeAfter(aliveTime); normalBullet.dmg = dmgPerBullet; Rigidbody2D cloneRb = bullet.GetComponent <Rigidbody2D>(); cloneRb.velocity = bullet.transform.up.normalized * launchForce; //tyckte detta va smart. Stoppar att de åker igenom saker ifall man skjuter för snabbt if (launchForce >= 10) { cloneRb.collisionDetectionMode = CollisionDetectionMode2D.Continuous; } }
private void OnCollisionEnter(Collision collision) { if (!reflect) //If Not in reflect mode { playerScript.OnChildCollisionEnter(collision); //Then do the logic to absorb the bullet. } else { //If if am in reflect mode if (collision.transform.tag == "Bullet") //And I collided with a bullet { NormalBullet bullet = collision.gameObject.GetComponent <NormalBullet>(); //Then Tell the bullet to speeed up if (bullet != null) { bullet.LVLUpBullet(); } } } }
private void OnTriggerEnter2D(Collider2D other) { switch (other.tag) { case "NormalBullet": NormalBullet normalBullet = other.gameObject.GetComponent <NormalBullet>(); string bulletColor = normalBullet.GetBulletColor(); Destroy(other.gameObject); if (_bodyColor == bulletColor) { Instantiate(prefabDiminishEffect, transform.position, new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)); Destroy(gameObject); _mainGameStateManager.AddScore(10000); } break; } }
private void OnTriggerEnter2D(Collider2D other) { switch (other.tag) { case "NormalBullet": NormalBullet normalBullet = other.gameObject.GetComponent <NormalBullet>(); string bulletColor = normalBullet.GetBulletColor(); Destroy(other.gameObject); if (_bodyColor == bulletColor) { Destroy(gameObject); _mainGameStateManager.AddScore(100); } break; } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Enemy") { other.gameObject.GetComponent <EnemyState>().SlowDown(effectTime, slowArgument); } if (other.gameObject.tag == "NormalBullet") { other.gameObject.GetComponent <Renderer>().material = freezeMaterial; NormalBullet sc = other.gameObject.GetComponent <NormalBullet>(); sc.isFreezed = true; sc.effectTime = effectTime; sc.slowArgument = slowArgument; } if (other.gameObject.tag == "SkillBullet" && other.gameObject.GetComponent <BulletBase>().skillType == 5) { other.gameObject.GetComponent <Renderer>().material = freezeMaterial; SpecialBullet5 sb = other.gameObject.GetComponent <SpecialBullet5>(); sb.isFreezed = true; sb.effectTime = effectTime; sb.slowArgument = slowArgument; } }
private void OnReleaseBullet(NormalBullet bullet) { bullet.gameObject.SetActive(false); bullet.OnDeath -= pool.ReleaseObject; }
private void OnGetBullet(NormalBullet bullet) { bullet.gameObject.SetActive(true); bullet.OnDeath += pool.ReleaseObject; }
public override void Update(IMessage<MessageType> msg, GameTime gameTime) { PlantState = eNormalPlantState.STANDING; // Shoot IDictionary<ulong, ObjectEntity> objs = new Dictionary<ulong, ObjectEntity>(PZObjectManager.Instance.GetObjects()); foreach (var item in objs) { if (item.Value == this.Owner) continue; MoveComponent obj1 = this.Owner.Owner.GetComponent(typeof(MoveComponent)) as MoveComponent; MoveComponent obj2 = item.Value.GetComponent(typeof(MoveComponent)) as MoveComponent; if (obj2.Position.Y == obj1.Position.Y && (obj1.Position.X < obj2.Position.X) && obj2.Position.X < SCSServices.Instance.Game.GraphicsDevice.Viewport.Width && (obj2.Owner as NormalZombie) != null) { // Change to shoot //RenderBehaviorChangeMsg renderMsg = new RenderBehaviorChangeMsg(MessageType.CHANGE_RENDER_BEHAVIOR, this); //renderMsg.RenderBehaviorType = GameComponents.Components.eMoveRenderBehaviorType.PL_SHOOTING; //renderMsg.DestinationObjectId = this.Owner.Owner.ObjectId; //PZObjectManager.Instance.SendMessage(renderMsg, gameTime); PlantState = eNormalPlantState.SHOOTING; } } if (PlantState == eNormalPlantState.SHOOTING) { if (currentTimeShoot > shootTime) { NormalBullet bullet = new NormalBullet(); Vector2 pos = (this.Owner.Owner.GetComponent(typeof(MoveComponent)) as MoveComponent).Position; bullet.SetPosition(new Vector2(pos.X + shootPoint.X, pos.Y - shootPoint.Y)); PZObjectManager.Instance.AddObject(bullet); currentTimeShoot = TimeSpan.Zero; } else currentTimeShoot += gameTime.ElapsedGameTime; } // Die LogicComponent logicCOm = this.Owner as LogicComponent; if (logicCOm == null) throw new Exception("PL_NormalLogicBehavior: Expect Logic Component"); if (logicCOm.Health < 0) { PZObjectManager.Instance.RemoveObject(this.Owner.Owner.ObjectId); } base.Update(msg, gameTime); }
void preAction(string actionName) { string[] arr = actionName.Split('|'); string name = arr[0]; switch (name) { case AnimationName.Attack: if (attackBullet != null) { GameObject obj = GameObject.Instantiate(attackBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect1; bullet.bulleting(); } break; case AnimationName.Magic: if (magicBullet != null) { GameObject obj = GameObject.Instantiate(magicBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect1; bullet.bulleting(); } break; case AnimationName.Magic2: if (magic2Bullet != null) { GameObject obj = GameObject.Instantiate(magic2Bullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect2; bullet.bulleting(); } break; case AnimationName.Ultimate: if (ultimateBullet != null) { GameObject obj = GameObject.Instantiate(ultimateBullet); LightBullet bullet = obj.GetComponent <LightBullet>(); bullet.player = transform; bullet.target = GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect3; bullet.bulleting(); } if (damageEffect3 != null) { GameObject obj = GameObject.Instantiate(damageEffect3); ParticlesEffect effect = obj.AddComponent <ParticlesEffect>(); effect.transform.position = GameObject.Find("bigzhangjiao (1)").transform.position; effect.play(); StartCoroutine(delayAttacked()); } break; } }
void preAction(string actionName) { //AttackedController c = GameObject.Find("bigzhangjiao (1)").GetComponent<AttackedController>(); string[] arr = actionName.Split('|'); string name = arr[0]; switch (name) { case AnimationName.Attack: if (attackBullet != null) { GameObject obj = GameObject.Instantiate(attackBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = m_targetSpellAnimation; //GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect1; bullet.bulleting(); } if (damageEffect1 != null) { GameObject obj = GameObject.Instantiate(damageEffect1); ParticlesEffect effect = obj.AddComponent <ParticlesEffect>(); //Transform target = GameObject.Find("bigzhangjiao (1)").transform; effect.transform.position = m_targetSpellAnimation.position; //MathUtil.findChild(m_target, "attackedPivot").position; effect.play(); } //c.attacked(); break; case AnimationName.Magic: if (magicBullet != null) { GameObject obj = GameObject.Instantiate(magicBullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = m_targetSpellAnimation; //GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect1; bullet.bulleting(); } if (damageEffect3 != null) { GameObject obj = GameObject.Instantiate(damageEffect3); ParticlesEffect effect = obj.AddComponent <ParticlesEffect>(); //Transform target = GameObject.Find("bigzhangjiao (1)").transform; effect.transform.position = m_targetSpellAnimation.position; //MathUtil.findChild(m_target, "attackedPivot").position; effect.play(); } //c.attacked(); break; case AnimationName.Magic2: if (magic2Bullet != null) { GameObject obj = GameObject.Instantiate(magic2Bullet); NormalBullet bullet = obj.GetComponent <NormalBullet>(); bullet.player = transform; bullet.target = m_targetSpellAnimation; //GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect2; bullet.bulleting(); } if (damageEffect2 != null) { GameObject obj = GameObject.Instantiate(damageEffect2); ParticlesEffect effect = obj.AddComponent <ParticlesEffect>(); effect.transform.position = m_targetSpellAnimation.position; //GameObject.Find("bigzhangjiao (1)").transform.position; effect.play(); } //c.attacked(); break; case AnimationName.Ultimate: if (ultimateBullet != null) { GameObject obj = GameObject.Instantiate(ultimateBullet); LightBullet bullet = obj.GetComponent <LightBullet>(); bullet.player = transform; bullet.target = m_targetSpellAnimation; //GameObject.Find("bigzhangjiao (1)").transform; bullet.effectObj = damageEffect3; bullet.bulleting(); } if (damageEffect2 != null) { GameObject obj = GameObject.Instantiate(damageEffect2); ParticlesEffect effect = obj.AddComponent <ParticlesEffect>(); effect.transform.position = m_targetSpellAnimation.position; //GameObject.Find("bigzhangjiao (1)").transform.position; effect.play(); } //c.attacked(); break; } }