public void Fire(Destructible target) { if (!available) { return; } var barrel = barrels[currentBarrel]; var m = Missile.Create(missile, barrel.transform.position, barrel.transform.rotation); m.gameObject.layer = gameObject.layer; m.target = target; ++currentBarrel; Messenger.Broadcast(MessageTypes.LaunchMissile); if (empty) { StartCoroutine(Reload()); } else { StartCoroutine(CoolDown()); } }
/// <summary> /// 箱が壊れたときの処理。アイテムミサイルを射出。 /// </summary> /// <param name="box"></param> /// <param name="kicker"></param> private void OnBoxCollapse(Box box, Kicker kicker) { var missile = itemMissilePrefab.Create(box.transform.position); missile.Shoot(kicker.transform, box.effect); missile.onHitTarget.AddListener(OnHitMissile); // ミサイルが当たった }
void Update() { speed += info.accel * Time.deltaTime; float distance = speed * Time.deltaTime; var posDiff = dir * distance; var newPos = iso.pos + posDiff; var hit = CollisionMap.Raycast(iso.pos, newPos, distance, size: info.size, ignore: originator.gameObject); if (hit) { Character hitCharacter = null; if (hit.gameObject != null) { hitCharacter = hit.gameObject.GetComponent <Character>(); if (hitCharacter != null) { int damage = CalcDamage(); hitCharacter.TakeDamage(damage, originator); if (info.progOverlay != null) { Overlay.Create(hitCharacter.gameObject, info.progOverlay); } } } if (info.explosionMissile != null) { Missile.Create(info.explosionMissile, hit.pos, hit.pos, originator); } AudioManager.instance.Play(info.hitSound, Iso.MapToWorld(hit.pos)); AudioManager.instance.Play(SoundInfo.GetHitSound(info.hitClass, hitCharacter), Iso.MapToWorld(hit.pos)); if (info.clientHitFunc == "14") { // glacial spike, freezing arrow Missile.Create(info.clientHitSubMissileId[0], hit.pos, hit.pos, originator); int subMissileCount = Random.Range(3, 5); for (int i = 0; i < subMissileCount; ++i) { var offset = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); Missile.Create(info.clientHitSubMissileId[1], hit.pos, hit.pos - offset, originator); } } // todo pierce is actually is pierce skill with a chance to pierce if ((!info.pierce || hitCharacter == null) && info.collideKill) { Destroy(gameObject); } } iso.pos = newPos; }
static public void CreateRadially(MissileInfo missileInfo, Vector3 start, Character originator, int missileCount) { float angle = 0; float angleStep = 360.0f / missileCount; var dir = new Vector3(1, 0); for (int i = 0; i < missileCount; ++i) { var rot = Quaternion.AngleAxis(angle, new Vector3(0, 0, 1)); Missile.Create(missileInfo, start, start + rot * dir, originator); angle += angleStep; } }
private static void OnMissileHit(Missile missile, Vector2 hitPos, GameObject gameObject) { var info = missile.Info; var originator = missile.Originator; Unit hitUnit = null; if (gameObject != null) { hitUnit = gameObject.GetComponent <Unit>(); if (hitUnit != null) { int damage = CalcDamage(missile); hitUnit.Hit(damage, originator); if (info.progOverlay != null) { Overlay.Create(hitUnit.gameObject, info.progOverlay, false); } } } if (info.explosionMissile != null) { Missile.Create(info.explosionMissile, hitPos, hitPos, originator); } AudioManager.instance.Play(info.hitSound, Iso.MapToWorld(hitPos)); AudioManager.instance.Play(SoundInfo.GetHitSound(info.hitClass, hitUnit), Iso.MapToWorld(hitPos)); if (info.clientHitFunc == "14") { // glacial spike, freezing arrow Missile.Create(info.clientHitSubMissileId[0], hitPos, hitPos, originator); int subMissileCount = Random.Range(3, 5); for (int i = 0; i < subMissileCount; ++i) { var offset = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); Missile.Create(info.clientHitSubMissileId[1], hitPos, hitPos - offset, originator); } } else if (info.serverHitFunc == "29") { // Frozen orb Missile.CreateRadially(info.clientHitSubMissileId[0], missile.Iso.pos, originator, 16); } // todo pierce is actually is pierce skill with a chance to pierce if ((!info.pierce || hitUnit == null) && info.collideKill) { Destroy(missile.gameObject); } }
private static void OnMissileMove(Missile missile) { var info = missile.Info; var lifeTime = missile.LifeTime; var originator = missile.Originator; var pos = missile.Iso.pos; if (missile.Info.serverDoFunc == 15) { // Frozen orb int frequency = info.parameters[0].value * 25; float spawnPeriod = 1.0f / frequency; float directionIncrement = info.parameters[1].value * 25 * Mathf.PI; int missilesToSpawn = (int)((lifeTime + Time.deltaTime) / spawnPeriod) - (int)(lifeTime / spawnPeriod); for (int i = 0; i < missilesToSpawn; ++i) { var dir = new Vector2(1, 0); var rot = Quaternion.AngleAxis(lifeTime * directionIncrement, new Vector3(0, 0, 1)); var offset = (Vector2)(rot * dir); Missile.Create(info.clientSubMissileId[0], pos, pos + offset, originator); } } }
public void Do(Unit self, Unit targetUnit, Vector3 target) { if (srvDoFunc == 27) { // teleport self.InstantMove(target); } if (srvDoFunc == 1) { Item weapon = self.equip == null ? null : self.equip.GetWeapon(); int damage = 10; WeaponHitClass hitClass = WeaponHitClass.HandToHand; bool ranged = false; if (weapon != null) { WeaponInfo weaponInfo = weapon.info.weapon; hitClass = weaponInfo.hitClass; if (weaponInfo.twoHanded) { damage = Random.Range(weaponInfo.twoHandedMinDamage, weaponInfo.twoHandedMaxDamage + 1); } else { damage = Random.Range(weaponInfo.minDamage, weaponInfo.maxDamage + 1); } ranged = weapon.info.type.shoots != null; } if (ranged) { var missile = Missile.Create("arrow", target, self); missile.weaponDamage = damage; } else if (targetUnit != null && IsRangeOk(self, targetUnit, target)) { AudioManager.instance.Play(hitClass.hitSound, targetUnit.transform.position); targetUnit.Hit(damage, self); } } else if (srvDoFunc == 17) { // charged bold, bolt sentry int boltCount = 7; for (int i = 0; i < boltCount; ++i) { var offset = new Vector3(Random.Range(-boltCount / 2f, boltCount / 2f), Random.Range(-boltCount / 2f, boltCount / 2f)); Missile.Create(clientMissileA, self.iso.pos, target + offset, self); } } else if (srvDoFunc == 22) { // nova, poison nova, howl int missileCount = 64; Missile.CreateRadially(clientMissileA, self.iso.pos, self, missileCount); } else if (srvDoFunc == 31) { // raise skeleton, raise skeletal mage var pos = Iso.MapToWorld(target); var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self); monster.overrideMode = summode; Missile.Create(clientMissileA, target, target, self); } else if (srvDoFunc == 45) { // traps var pos = Iso.MapToWorld(target); var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self); monster.overrideMode = summode; Missile.Create(clientMissileA, target, target, self); } else if (srvDoFunc == 56 || srvDoFunc == 57) { // 57 iron golem, 56 other golems var pos = Iso.MapToWorld(target); var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self); monster.overrideMode = summode; } else if (srvDoFunc == 114) { // raven var pos = Iso.MapToWorld(target); var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self); monster.overrideMode = summode; } else if (srvDoFunc == 119) { // summon grizzly, wolves, spirits var pos = Iso.MapToWorld(target); var monster = global::Diablerie.Game.World.WorldBuilder.SpawnMonster(summon, pos, summoner: self); monster.overrideMode = summode; } else if (srvDoFunc == 68) { // barbarian howls int missileCount = 64; Missile.CreateRadially(clientMissileA, self.iso.pos, self, missileCount); } else { if (clientMissileA != null) { Missile.Create(clientMissileA, self.iso.pos, target, self); } } if (clientMissile != null) { Missile.Create(clientMissile, self.iso.pos, target, self); } }
public void Do(Character self, Character targetCharacter, Vector3 target) { if (srvDoFunc == 27) { // teleport self.InstantMove(target); } if (srvDoFunc == 1) { Item weapon = self.equip == null ? null : self.equip.GetWeapon(); int damage = 10; WeaponHitClass hitClass = WeaponHitClass.HandToHand; bool ranged = false; if (weapon != null) { WeaponInfo weaponInfo = weapon.info.weapon; hitClass = weaponInfo.hitClass; if (weaponInfo.twoHanded) { damage = Random.Range(weaponInfo.twoHandedMinDamage, weaponInfo.twoHandedMaxDamage + 1); } else { damage = Random.Range(weaponInfo.minDamage, weaponInfo.maxDamage + 1); } ranged = weapon.info.type.shoots != null; } if (ranged) { var missile = Missile.Create("arrow", target, self); missile.weaponDamage = damage; } else if (targetCharacter != null && IsRangeOk(self, targetCharacter, target)) { AudioManager.instance.Play(hitClass.hitSound, targetCharacter.transform.position); targetCharacter.TakeDamage(damage, self); } } else if (srvDoFunc == 17) { // charged bold, bolt sentry int boltCount = 7; for (int i = 0; i < boltCount; ++i) { var offset = new Vector3(Random.Range(-boltCount / 2f, boltCount / 2f), Random.Range(-boltCount / 2f, boltCount / 2f)); Missile.Create(clientMissileA, self.iso.pos, target + offset, self); } } else { if (clientMissileA != null) { Missile.Create(clientMissileA, self.iso.pos, target, self); } } if (clientMissile != null) { Missile.Create(clientMissile, self.iso.pos, target, self); } }
void Update() { lifeTime += Time.deltaTime; if (lifeTime > info.lifeTime) { if (info.serverHitFunc == "29") { Missile.CreateRadially(info.clientHitSubMissileId[0], iso.pos, originator, 16); } Destroy(gameObject); } speed += Mathf.Clamp(info.accel * Time.deltaTime, 0, info.maxVelocity); float distance = speed * Time.deltaTime; var posDiff = dir * distance; var newPos = iso.pos + posDiff; var hit = CollisionMap.Raycast(iso.pos, newPos, distance, size: info.size, ignore: originator.gameObject); if (hit) { Character hitCharacter = null; if (hit.gameObject != null) { hitCharacter = hit.gameObject.GetComponent <Character>(); if (hitCharacter != null) { int damage = CalcDamage(); hitCharacter.TakeDamage(damage, originator); if (info.progOverlay != null) { Overlay.Create(hitCharacter.gameObject, info.progOverlay, false); } } } if (info.explosionMissile != null) { Missile.Create(info.explosionMissile, hit.pos, hit.pos, originator); } AudioManager.instance.Play(info.hitSound, Iso.MapToWorld(hit.pos)); AudioManager.instance.Play(SoundInfo.GetHitSound(info.hitClass, hitCharacter), Iso.MapToWorld(hit.pos)); if (info.clientHitFunc == "14") { // glacial spike, freezing arrow Missile.Create(info.clientHitSubMissileId[0], hit.pos, hit.pos, originator); int subMissileCount = Random.Range(3, 5); for (int i = 0; i < subMissileCount; ++i) { var offset = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); Missile.Create(info.clientHitSubMissileId[1], hit.pos, hit.pos - offset, originator); } } else if (info.serverHitFunc == "29") { // Frozen orb Missile.CreateRadially(info.clientHitSubMissileId[0], iso.pos, originator, 16); } // todo pierce is actually is pierce skill with a chance to pierce if ((!info.pierce || hitCharacter == null) && info.collideKill) { Destroy(gameObject); } } if (info.serverDoFunc == 15) { // Frozen orb int frequency = info.parameters[0].value * 25; float spawnPeriod = 1.0f / frequency; float directionIncrement = info.parameters[1].value * 25 * Mathf.PI; int missileToSpawn = (int)((lifeTime + Time.deltaTime) / spawnPeriod) - (int)(lifeTime / spawnPeriod); for (int i = 0; i < missileToSpawn; ++i) { var dir = new Vector2(1, 0); var rot = Quaternion.AngleAxis(lifeTime * directionIncrement, new Vector3(0, 0, 1)); var offset = (Vector2)(rot * dir); Missile.Create(info.clientSubMissileId[0], iso.pos, iso.pos + offset, originator); } } iso.pos = newPos; }