//My note: if the skill can be s-ed, you use PreCastCo() and override OnFail and OnSuccess protected override void CommonOnCastSuccessfully() { base.CommonOnCastSuccessfully(); GameObject bullet = ShowSkillBullet(mc.transform.position + mc.transform.forward * 0.75f, Quaternion.LookRotation(mc.transform.forward)) as GameObject; //Procudurally do these |OR| manually set up the bullet effect prefab if (bullet.GetComponent <SkillBullet>() == null) { SkillBullet sb = bullet.AddComponent <SkillBullet>(); sb.InitBullet(this); } else { bullet.GetComponent <SkillBullet>().InitBullet(this); } if (bullet.GetComponent <SphereCollider>() == null) { SphereCollider sc = bullet.AddComponent <SphereCollider>(); sc.isTrigger = true; sc.radius = 0.3f; sc.gameObject.layer = LayerMask.NameToLayer("SkillBullet"); } if (bullet.GetComponent <Rigidbody>() == null) { Rigidbody rb = bullet.AddComponent <Rigidbody>(); rb.isKinematic = true; rb.useGravity = false; } }
private void CreateBarrage() { float deltaAngle; if (count > 1) { deltaAngle = angle / (count - 1); } else { deltaAngle = angle; } transform.Rotate(0, 0, -angle / 2); for (int i = 0; i < count; i++) { var bullet = ObjectPool.GetObject(buckshot, "SkillBullets"); SkillBullet skill = bullet.GetComponent <SkillBullet>(); skill.Source = Source; skill.Target = Target; skill.Launch(transform.position, transform.right); transform.Rotate(0, 0, deltaAngle); } }
private IEnumerator HitCorotinue() { WaitForFixedUpdate wait = new WaitForFixedUpdate(); float timer = warningTime; while (timer > 0) { timer -= Time.fixedDeltaTime; yield return(wait); } timer = damageTime; readyToDamage = true; while (timer > 0) { timer -= Time.fixedDeltaTime; yield return(wait); } readyToDamage = false; var obj = ObjectPool.GetObject(bullet, "SkillBullets"); SkillBullet skill = obj.GetComponent <SkillBullet>(); skill.Source = Source; skill.Target = Target; skill.Launch(transform.position, transform.right); ObjectPool.RecycleObject(this.gameObject); }
private IEnumerator ShootCorotinue() { WaitForFixedUpdate wait = new WaitForFixedUpdate(); float timer; for (int i = 0; i < bullets.Length; i++) { transform.position = Source.transform.position; Vector2 direction = (Target.transform.position - transform.position).normalized; transform.right = direction; GameObject prefab = NotionWorld.Worlds.ObjectPool.GetObject(bullets[i], "SkillBullets"); SkillBullet bullet = prefab.GetComponent <SkillBullet>(); bullet.Source = Source; bullet.Target = Target; timer = interval; while (timer > 0) { timer -= Time.fixedDeltaTime; yield return(wait); } bullet.Launch(transform.position, transform.right); } ObjectPool.RecycleObject(this.gameObject); }
protected override void CommonOnCastSuccessfully() { base.CommonOnCastSuccessfully(); GameObject bullet = ShowSkillBullet(mc.transform.position + mc.transform.forward * 0.75f, Quaternion.LookRotation(mc.transform.forward)) as GameObject; //Procudurally do these |OR| manually set up the bullet effect prefab sb = bullet.GetComponent <SkillBullet>(); sb.InitBullet(this, ToxicArrow); }
void bulletProcess(SkillBullet n) { switch (n.target) { case SkillTarget.Target.Unit: { Bullet bt = mUnit.mgr.getUnit(0, UnitType.Bullet, n.id) as Bullet; bt.setParam(mUnit.pos, mUnit.dir, mUnit); bt.mOwner = mUnit.guid; bt.mHarm = n.harm; Vector3 projDir = n.locationDir(mUnit); projDir.y = 0; bt.play(projDir.normalized, mUnit.skill.targetGUID); break; } case SkillTarget.Target.Dir: { Bullet bt = mUnit.mgr.getUnit(0, UnitType.Bullet, n.id) as Bullet; bt.setParam(mUnit.pos, mUnit.dir, mUnit); bt.mOwner = mUnit.guid; bt.mHarm = n.harm; Vector3 projDir = n.locationDir(mUnit); projDir.y = 0; bt.play(projDir.normalized, mUnit.skill.targetGUID); break; } case SkillTarget.Target.Pos: { Bullet bt = mUnit.mgr.getUnit(0, UnitType.Bullet, n.id) as Bullet; bt.setParam(mUnit.pos, mUnit.dir, mUnit); bt.mOwner = mUnit.guid; bt.mHarm = n.harm; bt.play(n.locationPos(mUnit), mUnit.skill.targetGUID); break; } case SkillTarget.Target.Area: { Matrix4x4 mt = Matrix4x4.TRS(mUnit.pos, Quaternion.LookRotation(mUnit.dir), Vector3.one).inverse; List <Unit> units = mUnit.mgr.getUnitInArea(UnitType.Monster | UnitType.Player, n.area, mt); for (int i = 0; i < units.Count; ++i) { Bullet bt = mUnit.mgr.getUnit(0, UnitType.Bullet, n.id) as Bullet; bt.setParam(mUnit.pos, mUnit.dir, mUnit); bt.mOwner = mUnit.guid; bt.mHarm = n.harm; bt.play(units[i].pos, units[i].guid); } break; } } }
public override void Launch(Vector2 position, Vector2 direction) { transform.position = position; for (int i = 0; i < count; i++) { var obj = ObjectPool.GetObject(mortar, "SkillBullets"); SkillBullet skill = obj.GetComponent <SkillBullet>(); skill.Source = Source; skill.Target = Target; Vector2 pos = new Vector2(Random.Range(area.xMin, area.xMax), Random.Range(area.yMin, area.yMax)); skill.Launch(pos, transform.right); } }
private void Skill() { GameObject prefab = NotionWorld.Worlds.ObjectPool.GetObject(skillBullet, "SkillBullets"); SkillBullet bullet = prefab.GetComponent <SkillBullet>(); bullet.Source = Owner.gameObject; bullet.Target = targetGameObject.Value; Vector2 position = animatorModifier.Animator.transform.position; Vector2 direction = ((Vector2)targetGameObject.Value.transform.position - position); direction = direction.normalized; bullet.Launch(position, direction); coldDownTimer = bullet.coldDown; animatorModifier.TakeEffect(); }
public static SkillNode createNode(Type nodeType) { SkillNode n = null; switch (nodeType) { case SkillNode.Type.Action: n = new SkillAction(); break; case SkillNode.Type.Anim: n = new SkillAnim(); break; case SkillNode.Type.Harm: n = new SkillHarm(); break; case SkillNode.Type.Bullet: n = new SkillBullet(); break; case SkillNode.Type.Buff: n = new SkillBuff(); break; case SkillNode.Type.Event: n = new SkillEvent(); break; case SkillNode.Type.Move: n = new SkillMove(); break; case SkillNode.Type.Lua: n = new SkillLua(); break; default: Debug.LogError("unsurpport skillnode type:" + nodeType); return(null); } return(n); }
private void CreateBarrage() { float deltaAngle = Random.Range(minDeltaAngle, maxDeltaAngle); transform.Rotate(0, 0, -deltaAngle * count / 2); for (int i = 0; i < count; i++) { var bullet = ObjectPool.GetObject(buckshot, "SkillBullets"); SkillBullet skill = bullet.GetComponent <SkillBullet>(); skill.Source = Source; skill.Target = Target; skill.Launch(transform.position, transform.right); transform.Rotate(0, 0, deltaAngle); deltaAngle = Random.Range(minDeltaAngle, maxDeltaAngle); } }
void Fire() { fireTimer = 0f; ads.PlayOneShot(shootClip); for (int i = 0; i < dirs.Count; i++) { SkillBullet chilly = bulletPool.GetPooledObj().GetComponent <SkillBullet>(); if (!chilly) { Debug.LogWarning("Add bullet behaviour to PepperCrossbow - Carolina Reaper - Reaper bar's chilly bullet!"); return; } chilly.transform.position = this.transform.position + dirs[i] * 1.7f; chilly.transform.forward = dirs[i]; //TODO multiple hit effect problem chilly.InitBullet(belongedSkill); } }