//--------------------------------------------------------------- void OnCollisionEnter2D(Collision2D collision) { //If all the prisoners are down, stop bounding collision of this ball by destroying it if (Prisoner.GetAllPrisonerDead()) { RemoveFromPlay(); } if (collision.gameObject.GetComponent <BlockOfStage>()) { Instantiate(hitParticlePref, transform.position, Quaternion.identity); } if (collision.gameObject.CompareTag("Prisoner")) { justHit = true; SpeedTweaking(); limitHit--; ResetTimeHitWallInARow(); Instantiate(hitParticlePref, transform.position, Quaternion.identity); } if (collision.gameObject.CompareTag("Enemy")) { justHit = true; SpeedTweaking(); limitHit--; ResetTimeHitWallInARow(); Instantiate(hitParticlePref, transform.position, Quaternion.identity); } //if (collision.gameObject.CompareTag("Tweaking Wall") ){ //SpeedTweaking (); //limitTimeToHitWall = 6; //} if (collision.gameObject.CompareTag("Wall")) { limitTimeToHitWall--; if (limitTimeToHitWall <= 0) { //TODO print("do change direction of stage ball"); SpeedTweaking(); ResetTimeHitWallInARow(); } } }
//--------------------------------------------------------------- void Update() { if (EnemyWaveController.GetWaveHasStarted() && !Prisoner.GetAllPrisonerDead()) { spawningTime -= Time.deltaTime; if (spawningTime <= 0) { SpawnBattleBall(); spawningTime = maxSpawningTime; readyStartCountWaitTime = true; } if (readyStartCountWaitTime) { waitTimeForLaunched -= Time.deltaTime; if (waitTimeForLaunched <= 0 && ball) { ball.GetComponent <ProjectileBall> ().PushBall(); waitTimeForLaunched = maxWaitTimeForLaunched; readyStartCountWaitTime = false; } } } }
// Update is called once per frame void Update() { //If the aiming shot is launched from straight shot if (GetComponent <EnemyShot>() && bCanGenerateOtherShot) { randomTimeShotExplode -= Time.deltaTime; if (randomTimeShotExplode <= 0) { Fire(); //TODO add explosion effect GameObject explodeEffect = GetComponent <EnemyShot>().explodeParticlePref; Instantiate(explodeEffect, transform.position, Quaternion.identity); Destroy(gameObject); } return; } //If the aiming shot is launched from enemy if (EnemyWaveController.GetWaveHasStarted()) { shotCoolDownTime -= Time.deltaTime; if (shotCoolDownTime <= 0f && !Prisoner.GetAllPrisonerDead()) { PLAYABLE_SKILL skillToPlayThisTurn; if (bulletCount > 0) { skillToPlayThisTurn = PLAYABLE_SKILL.FIRE; } else { skillToPlayThisTurn = GetPlaySkills(); } switch (skillToPlayThisTurn) { case PLAYABLE_SKILL.FIRE: if (numberOfShotsPerLaunch <= 1) { Fire(); actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak); shotCoolDownTime = maxCoolDownTime + actualRandomCoolDown; } else if (numberOfShotsPerLaunch > 1) { if (bulletCount >= numberOfShotsPerLaunch) { actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak); shotCoolDownTime = maxCoolDownTime + actualRandomCoolDown; bulletCount = 0; break; //TODO check this } intervalPerBullets -= Time.deltaTime; if (intervalPerBullets <= 0) { Fire(); bulletCount++; intervalPerBullets = maxBulletInterval; } } break; case PLAYABLE_SKILL.HEAL: GetComponent <EnemyHealingSkill>().Heal(shotPower); actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak); shotCoolDownTime = maxCoolDownTime + actualRandomCoolDown; break; case PLAYABLE_SKILL.BOMBBARD: GetComponent <EnemyBombardSkill>().Bombbard(); actualRandomCoolDown = Random.Range(0f, randomCoolDownTweak); shotCoolDownTime = maxCoolDownTime + actualRandomCoolDown + 5; break; default: break; } } } }