public void MakeDamage(float damage) { if (DamageMeter.instance.isActive) { DamageMeter.instance.damage += damage; } if (ShipsController.instance.doubleDamageActive) { damage = damage * 2f; } if (health <= damage) { if (isActive) { isActive = false; destroyWithPointsAction.Invoke(); RemoveFromExpObjList(); } } else { health -= damage; StartCoroutine(DamageAnimation()); string audioEffectPoolPath = "Prefabs/AudioEffects/hitEffect"; GameObject audioEffectObj = ObjectsPool.PullObject(audioEffectPoolPath); AudioEffect audioEffect = audioEffectObj.GetComponent <AudioEffect> (); audioEffect.poolPath = audioEffectPoolPath; audioEffect.StartEffect(); } }
void RelocatePosition() { string path = "Prefabs/Effects/warp"; GameObject expObj = ObjectsPool.PullObject(path); Effect exp = expObj.GetComponent <Effect>(); exp.poolPath = path; exp.transform.position = this.transform.position; exp.main.Play(); exp.DestoyOverTime(exp.main.main.duration); int random = Random.Range(0, 3); if (random == 0) { ship.explodeObject.explodeTransform.position = SpawnerController.instance.topElusiveSpawner.GetRandomPositionInWorld(); } else if (random == 1) { ship.explodeObject.explodeTransform.position = SpawnerController.instance.topLeftElusiveSpawner.GetRandomPositionInWorld(); } else if (random == 2) { ship.explodeObject.explodeTransform.position = SpawnerController.instance.topRightElusiveSpawner.GetRandomPositionInWorld(); } GeneratePath(); ship.movementController.PathByPointsRebind(); }
void SpawnMines() { int bulletsCount = 8; float bulletLerpPathPart = 1f / (float)bulletsCount; float bulletsLerpPosition = 0; float minX = Camera.main.ScreenToWorldPoint(SpawnerController.instance.bottomSpawner.leftTop.position).x; float maxX = Camera.main.ScreenToWorldPoint(SpawnerController.instance.bottomSpawner.rightTop.position).x; float positionY = Camera.main.ScreenToWorldPoint(SpawnerController.instance.bottomSpawner.rightTop.position).y; for (int i = 0; i < bulletsCount; i++) { mineTimer.SetTimer(ship.explodeObject.damageHealthParam.spawnTime2); string path = "Prefabs/Airships/bullets/race_" + ship.explodeObject.raceType.ToString() + "/mine"; GameObject bulletObj = ObjectsPool.PullObject(path); Transform spawnerTransform = ship.GetRandomSpawner(); ExplodeObject bulletExpObj = bulletObj.GetComponent <ExplodeObject> (); bulletExpObj.explodeTransform.position = spawnerTransform.position; bulletExpObj.poolPath = path; ShipsController.instance.explodeObjects.Add(bulletExpObj); bulletExpObj.DefaultAwake(); bulletExpObj.directionPosition = Vector3.Lerp(new Vector3(minX, positionY, 0), new Vector3(maxX, positionY, 0), bulletsLerpPosition); bulletExpObj.directionVector = bulletExpObj.directionPosition - bulletExpObj.explodeTransform.position; bulletExpObj.directionVector.Normalize(); bulletExpObj.SetAngle(); bulletsLerpPosition += bulletLerpPathPart; } }
public ExplodeObject SpawnShip(int race, int type, int expObjType) { string expObjTypeString = ""; if (expObjType == Cannon.leftBullet) { expObjTypeString = "leftShips"; } else if (expObjType == Cannon.rightBullet) { expObjTypeString = "rightShips"; } else if (expObjType == Cannon.allBullet) { expObjTypeString = "allShips"; } string poolPath = "Prefabs/Airships/" + expObjTypeString + "/race_" + race.ToString() + "/ship_" + type.ToString(); GameObject newObj = ObjectsPool.PullObject(poolPath); ExplodeObject expObj = newObj.GetComponent <ExplodeObject> (); expObj.ExplodeObjectAwake(); expObj.poolPath = poolPath; explodeObjects.Add(expObj); return(expObj); }
public void SetRightCannon(int id) { if (rightCannon != null) { ObjectsPool.PushObject(rightCannon.poolPath, rightCannon.gameObject); } string poolPath = "Prefabs/Cannons/type_" + id.ToString() + "/right"; GameObject cannon = ObjectsPool.PullObject(poolPath); rightCannon = cannon.GetComponent <Cannon> (); rightCannon.poolPath = poolPath; cannon.transform.position = rightCannonTransform.position; string cannonKey = Cannon.rightBullet.ToString() + "_" + id.ToString(); LevelController.instance.currentRightButtonKey = cannonKey; if (LevelController.instance.cannonButtonsStatus.ContainsKey(cannonKey)) { LevelController.instance.cannonButtonsStatus [cannonKey] = true; } else { LevelController.instance.cannonButtonsStatus.Add(cannonKey, true); } }
public void SetSoundEffect() { if (type != 7 && type != 8 && type != 9) { string audioEffectPoolPath = ""; if ( type == 1 || type == 2 || type == 3 || type == 6) { int expIndex = Random.Range(0, 5); audioEffectPoolPath = "Prefabs/AudioEffects/Explodes/exp" + expIndex.ToString(); } else if (type == 4 || type == 5) { int expIndex = Random.Range(0, 4); audioEffectPoolPath = "Prefabs/AudioEffects/Explodes/texp" + expIndex.ToString(); } GameObject audioEffectObj = ObjectsPool.PullObject(audioEffectPoolPath); AudioEffect audioEffect = audioEffectObj.GetComponent <AudioEffect> (); audioEffect.poolPath = audioEffectPoolPath; audioEffect.StartEffect(); } }
public void BulletTriangleSpawn() { if (bulletTimer.TimeIsOver()) { string bulletPath = ""; if (cannonType == leftBullet) { bulletPath = PoolPath.cannonBulletTriangleLeft; } else if (cannonType == rightBullet) { bulletPath = PoolPath.cannonBulletTriangleRight; } GameObject newObj = ObjectsPool.PullObject(bulletPath); Vector3 bulletDirection = cannonBulletSpawner.position - cannonCore.position; bulletDirection.Normalize(); newObj.transform.position = cannonBulletSpawner.position; Bullet bullet = newObj.GetComponent <Bullet> (); bullet.poolPath = bulletPath; bullet.directionVector = bulletDirection; bullet.BulletAwake(); bullet.bulletType = cannonType; bulletTimer.SetTimer(damageHealthParam.spawnTime); /*string audioEffectPoolPath = "Prefabs/AudioEffects/Cannons/type_3"; * GameObject audioEffectObj = ObjectsPool.PullObject (audioEffectPoolPath); * AudioEffect audioEffect = audioEffectObj.GetComponent<AudioEffect> (); * audioEffect.poolPath = audioEffectPoolPath; * audioEffect.StartEffect ();*/ } }
public void ShipActive() { if (ship.explodeObject.isActive) { /*if (bulletTimer.TimeIsOver ()) { * SpawnBullets (); * }*/ ship.movementController.TranslateByPointsPath(); if (mineTimer.TimeIsOver()) { SpawnMines(); } if (torpedoTimer.TimeIsOver()) { torpedoTimer.SetTimer(ship.explodeObject.damageHealthParam.spawnTime3); string path = "Prefabs/Airships/bullets/race_" + ship.explodeObject.raceType.ToString() + "/torpedo"; GameObject bulletObj = ObjectsPool.PullObject(path); Transform spawnerTransform = ship.GetRandomSpawner(); ExplodeObject bulletExpObj = bulletObj.GetComponent <ExplodeObject> (); bulletExpObj.explodeTransform.position = spawnerTransform.position; bulletExpObj.poolPath = path; ShipsController.instance.explodeObjects.Add(bulletExpObj); bulletExpObj.DefaultAwake(); } } }
public void MineSpawnBullet() { if (bulletTimer.TimeIsOver()) { string bulletPath = ""; if (cannonType == leftBullet) { if (isShatter) { bulletPath = PoolPath.cannonBulletMineShatterLeft; } else { bulletPath = PoolPath.cannonBulletMineLeft; } } else if (cannonType == rightBullet) { if (isShatter) { bulletPath = PoolPath.cannonBulletMineShatterRight; } else { bulletPath = PoolPath.cannonBulletMineRight; } } GameObject newObj = ObjectsPool.PullObject(bulletPath); Vector3 bulletDirection = cannonBulletSpawner.position - cannonCore.position; bulletDirection.Normalize(); newObj.transform.position = cannonBulletSpawner.position; Bullet bullet = newObj.GetComponent <Bullet> (); bullet.poolPath = bulletPath; bullet.directionVector = bulletDirection; bullet.BulletAwake(); bullet.bulletType = cannonType; /*string effectPath = "Prefabs/Effects/mineSpawnEffect"; * GameObject effectObj = ObjectsPool.PullObject(effectPath); * effectObj.transform.position = cannonBulletSpawner.position; * Effect effect = effectObj.GetComponent<Effect> (); * effect.poolPath = effectPath; * effect.main.Play (); * effect.DestoyOverTime (effect.main.main.duration);*/ spawnEffect.Play(); bullet.speed = damageHealthParam.bulletSpeed; bulletTimer.SetTimer(damageHealthParam.spawnTime); /*string audioEffectPoolPath = "Prefabs/AudioEffects/Cannons/type_2"; * GameObject audioEffectObj = ObjectsPool.PullObject (audioEffectPoolPath); * AudioEffect audioEffect = audioEffectObj.GetComponent<AudioEffect> (); * audioEffect.poolPath = audioEffectPoolPath; * audioEffect.StartEffect ();*/ } }
public void DefaultTrippleSpawnBullet() { if (bulletTimer.TimeIsOver()) { string bulletPath = ""; if (cannonType == leftBullet) { bulletPath = PoolPath.cannonBulletDefaultLeft; } else if (cannonType == rightBullet) { bulletPath = PoolPath.cannonBulletDefaultRight; } GameObject newBullet = ObjectsPool.PullObject(bulletPath); Vector3 bulletDirection = cannonBulletSpawner.position - cannonCore.position; bulletDirection.Normalize(); newBullet.transform.position = cannonBulletSpawner.position; Bullet bullet = newBullet.GetComponent <Bullet> (); bullet.poolPath = bulletPath; bullet.directionVector = bulletDirection; bullet.BulletAwake(); bullet.bulletType = cannonType; GameObject newBulletLeft = ObjectsPool.PullObject(bulletPath); Vector3 bulletDirectionLeft = cannonBulletLeftSpawner.position - cannonBulletCoreLeft.position; bulletDirectionLeft.Normalize(); newBulletLeft.transform.position = cannonBulletLeftSpawner.position; Bullet bulletLeft = newBulletLeft.GetComponent <Bullet> (); bulletLeft.poolPath = bulletPath; bulletLeft.directionVector = bulletDirectionLeft; bulletLeft.BulletAwake(); bulletLeft.bulletType = cannonType; GameObject newBulletRight = ObjectsPool.PullObject(bulletPath); Vector3 bulletDirectionRight = cannonBulletRightSpawner.position - cannonBulletCoreRight.position; bulletDirectionRight.Normalize(); newBulletRight.transform.position = cannonBulletRightSpawner.position; Bullet bulletRight = newBulletRight.GetComponent <Bullet> (); bulletRight.poolPath = bulletPath; bulletRight.directionVector = bulletDirectionRight; bulletRight.BulletAwake(); bulletRight.bulletType = cannonType; foreach (ParticleSystem effect in spawnEffects) { effect.Play(); } bulletTimer.SetTimer(damageHealthParam.spawnTime); /*string audioEffectPoolPath = "Prefabs/AudioEffects/Cannons/type_1"; * GameObject audioEffectObj = ObjectsPool.PullObject (audioEffectPoolPath); * AudioEffect audioEffect = audioEffectObj.GetComponent<AudioEffect> (); * audioEffect.poolPath = audioEffectPoolPath; * audioEffect.StartEffect ();*/ } }
public void BulletMineTrigger(ExplodeObject expObj) { if (Cannon.CheckSuitability(expObj.objectType, bullet.bulletType)) { if (!explodeTimerActive) { explodeTimer.SetTimer(explodeTime); explodeTimerActive = true; StartCoroutine(explodeTimer.ActionAfterTimer(() => { foreach (ExplodeObject obj in bullet.triggeredExplodeObject) { if (obj.gameObject.activeInHierarchy) { if (Cannon.CheckSuitability(obj.objectType, bullet.bulletType)) { obj.MakeDamage(bullet.damageHealthParams.damage); } } } string effectPath = ""; if (isShutterMine) { effectPath = "Prefabs/Effects/bullet2ExplodeShatter"; } else { effectPath = "Prefabs/Effects/bullet2Explode"; } Vector3 bulletPosition = bullet.transform.position; GameObject effectObj = ObjectsPool.PullObject(effectPath); effectObj.transform.position = bulletPosition; Effect effect = effectObj.GetComponent <Effect> (); effect.poolPath = effectPath; effect.main.Play(); effect.DestoyOverTime(effect.main.main.duration); if (isShutterMine) { string shatterPath = "Prefabs/Bullets/bullet2ShatterPart"; for (int i = 0; i < shattersCount; i++) { GameObject shatter = ObjectsPool.PullObject(shatterPath); //Debug.Log(bullet.transform.position); shatter.transform.position = bulletPosition; Bullet sbullet = shatter.GetComponent <Bullet> (); sbullet.poolPath = shatterPath; sbullet.BulletAwake(); sbullet.bulletType = bullet.bulletType; } } ObjectsPool.PushObject(bullet.poolPath, this.gameObject); })); } } }
void DestroyAction() { string path = "Prefabs/Effects/explode"; GameObject expObj = ObjectsPool.PullObject(path); Effect exp = expObj.GetComponent <Effect>(); exp.poolPath = path; exp.transform.position = this.transform.position; exp.DestoyOverTime(exp.main.main.duration); }
public void SpawnCannonBox(int cannonType) { string path = "Prefabs/Boxes/cannonBox_" + cannonType.ToString(); GameObject boxObj = ObjectsPool.PullObject(path); Box box = boxObj.GetComponent <Box> (); box.expObject.poolPath = path; box.expObject.ExplodeObjectAwake(); explodeObjects.Add(box.expObject); }
public void SpawnAbilityBox(int boxID) { string path = "Prefabs/Boxes/abilityBox_" + boxID.ToString(); GameObject boxObj = ObjectsPool.PullObject(path); Box box = boxObj.GetComponent <Box> (); box.expObject.poolPath = path; box.expObject.ExplodeObjectAwake(); explodeObjects.Add(box.expObject); }
void DestroyEffect() { GameObject expEffectObj = ObjectsPool.PullObject("Prefabs/Effects/explode"); expEffectObj.transform.position = expObject.explodeTransform.position; Effect expEffect = expEffectObj.GetComponent <Effect> (); expEffect.main.Play(); expEffect.poolPath = "Prefabs/Effects/explode"; expEffect.DestoyOverTime(expEffect.main.main.duration); }
public void BossExplodeSound() { int bossType = type - 6; string audioEffectPoolPath = "Prefabs/AudioEffects/Explodes/race_" + explodeObject.raceType.ToString() + "_boss_" + bossType.ToString(); GameObject audioEffectObj = ObjectsPool.PullObject(audioEffectPoolPath); AudioEffect audioEffect = audioEffectObj.GetComponent <AudioEffect> (); audioEffect.poolPath = audioEffectPoolPath; audioEffect.StartEffect(); }
public void SpawnBoss(int race, int type) { string poolPath = "Prefabs/Airships/bosses/race_" + race.ToString() + "_boss_" + type.ToString(); GameObject newObj = ObjectsPool.PullObject(poolPath); ExplodeObject expObj = newObj.GetComponent <ExplodeObject> (); expObj.ExplodeObjectAwake(); expObj.poolPath = poolPath; explodeObjects.Add(expObj); }
public void ShipActiveAction() { if (ship.movementController.objectGetRound && !chargeMode) { SetChargeMode(); } if (!chargeMode && ship.explodeObject.isActive && !ship.explodeObject.isFreeze) { if (bulletTimer.TimeIsOver()) { bulletTimer.SetTimer(ship.explodeObject.damageHealthParam.spawnTime); string path = "Prefabs/Airships/bullets/race_" + ship.explodeObject.raceType.ToString() + "/defaultArmor"; GameObject bulletObj = ObjectsPool.PullObject(path); Transform spawnerTransform = ship.GetRandomSpawner(); ExplodeObject bulletExpObj = bulletObj.GetComponent <ExplodeObject> (); bulletExpObj.explodeTransform.position = spawnerTransform.position; bulletExpObj.poolPath = path; ShipsController.instance.explodeObjects.Add(bulletExpObj); bulletExpObj.DefaultAwake(); } if (mineTimer.TimeIsOver()) { mineTimer.SetTimer(ship.explodeObject.damageHealthParam.spawnTime2); string path = "Prefabs/Airships/bullets/race_" + ship.explodeObject.raceType.ToString() + "/mine"; GameObject mineObj = ObjectsPool.PullObject(path); Transform spawnerTransform = ship.GetRandomSpawner(); ExplodeObject mineExpObj = mineObj.GetComponent <ExplodeObject> (); mineExpObj.explodeTransform.position = spawnerTransform.position; mineExpObj.poolPath = path; ShipsController.instance.explodeObjects.Add(mineExpObj); mineExpObj.DefaultAwake(); } } if (chargeMode) { ship.movementController.TranslateByLerpPath(ship.explodeObject.damageHealthParam.chargePathTime); } else { ship.movementController.TranslateByPointsPath(); } }
public void DestroyPart() { string path = "Prefabs/Effects/bullet2ExplodeShatter"; GameObject expObj = ObjectsPool.PullObject(path); Effect exp = expObj.GetComponent <Effect>(); exp.poolPath = path; exp.transform.position = this.transform.position; exp.DestoyOverTime(exp.main.main.duration); this.gameObject.SetActive(false); polinomial.TryDestroy(); }
public void Tier2ShipActive() { movementController.TranslateByStandartPath(); if (spawnBulletTimer.TimeIsOver() && explodeObject.isActive && !explodeObject.isFreeze) { spawnBulletTimer.SetTimer(explodeObject.damageHealthParam.spawnTime); string path = "Prefabs/Airships/bullets/race_" + explodeObject.raceType.ToString() + "/default"; GameObject bulletObj = ObjectsPool.PullObject(path); Transform spawnerTransform = GetRandomSpawner(); ExplodeObject bulletExpObj = bulletObj.GetComponent <ExplodeObject> (); bulletExpObj.explodeTransform.position = spawnerTransform.position; bulletExpObj.poolPath = path; ShipsController.instance.explodeObjects.Add(bulletExpObj); bulletExpObj.DefaultAwake(); } }
void Update() { if (parallaxSpawnTimer.TimeIsOver()) { int parallaxID = Random.Range(0, (int)(typeof(BackgroundController).GetField("planet_" + planetID.ToString() + "_maximum_parallax").GetValue(null)) + 1); string path = "Prefabs/Backgrounds/planet_" + planetID + "/Parallax/parallax_" + parallaxID.ToString(); //Debug.Log (path); for (int i = 0; i < Random.Range(1, 3); i++) { GameObject newParallaxObject = ObjectsPool.PullObject(path); ParallaxObject parallaxObject = newParallaxObject.GetComponent <ParallaxObject> (); parallaxObject.poolPath = path; float positionZ = parallaxObject.objectTransform.position.z; if (currentSystem.upToDown) { parallaxObject.objectTransform.position = SpawnerController.instance.parallaxSpawnerTop.GetRandomPositionInWorld(); } else { parallaxObject.objectTransform.localScale = new Vector3(parallaxObject.objectTransform.localScale.x, parallaxObject.objectTransform.localScale.y * -1, parallaxObject.objectTransform.localScale.z); parallaxObject.objectTransform.position = SpawnerController.instance.parallaxSpawnerBottom.GetRandomPositionInWorld(); } parallaxObject.objectTransform.position = new Vector3( parallaxObject.objectTransform.position.x, parallaxObject.objectTransform.position.y, positionZ ); parallaxObject.speed = currentSystem.speed * 1.5f; if (currentSystem.upToDown) { parallaxObject.speed = parallaxObject.speed * -1f; } parallaxSpawnTimer.SetTimer(Random.Range(minimumTime, maximumTimer)); parallaxObject.frameRate = 0; } } }
public void ShipActiveAction() { //if (readyToTranslate) { if (ship.movementController.objectOnPathEnd) { currentPhase += 1; if (currentPhase == 1) { Phase1(); if (ship.explodeObject.isActive) { string path = "Prefabs/Airships/bullets/race_" + ship.explodeObject.raceType.ToString() + "/torpedo"; GameObject torpedoObj = ObjectsPool.PullObject(path); ExplodeObject torpedo = torpedoObj.GetComponent <ExplodeObject> (); torpedo.explodeTransform.position = ship.GetRandomSpawner().position; torpedo.poolPath = path; torpedo.ExplodeObjectAwake(); ShipsController.instance.explodeObjects.Add(torpedo); } } else if (currentPhase == 2) { Phase2(); } else if (currentPhase == 3) { Phase0(); currentPhase = 0; } } else { ship.movementController.TranslateByStandartPath(); } //} }