void CollisionFix() { Collision cobj = MoveUntilCollision(posX, 0); if (cobj != null && cobj.other is EnemyBullet) { EnemyBullet eb = (EnemyBullet)cobj.other; if (!eb.hit) { HUD.SCORE -= 25; playerHealth = playerHealth - EnemyBullet.bulletDamage; cobj.other.LateDestroy(); eb.hit = true; SetCycle(20, 2, 255); } } if (cobj != null && cobj.other is RoadBlock) { HUD.SCORE -= 50; TirePop.Play(volume: 0.3f); playerHealth = playerHealth - RoadBlock.blockDamage; cobj.other.LateDestroy(); SetCycle(20, 2, 255); } if (cobj != null && cobj.other is PowerUpGun) { GunPickUp.Play(volume: 0.3f); timeStart = Time.time; PowerUpAnimationG pag = new PowerUpAnimationG(); Game.main.LateAddChild(pag); attackSpeed = 10; cobj.other.LateDestroy(); } if (cobj != null && cobj.other is PowerUpLife) { LifePickUp.Play(volume: 0.3f); curHP = curHP + 50; playerHealth = playerHealth + 50; PowerUpAnimationL pal = new PowerUpAnimationL(); Game.main.LateAddChild(pal); cobj.other.LateDestroy(); } if (cobj != null && cobj.other is PowerUpShield) { ShieldPickUp.Play(volume: 0.3f); curHP = playerHealth; timeStart2 = Time.time; Invulnerability = true; cobj.other.LateDestroy(); PowerUpAnimationS pas = new PowerUpAnimationS(); Game.main.LateAddChild(pas); } }
void OnCollision(GameObject obj) { if (obj is EnemyBullet) { EnemyBullet eb = (EnemyBullet)obj; if (!eb.hit) { HUD.SCORE -= 25; playerHealth = playerHealth - EnemyBullet.bulletDamage; obj.LateDestroy(); eb.hit = true; SetCycle(20, 2, 255); } } if (obj is RoadBlock) { HUD.SCORE -= 50; TirePop.Play(volume: 0.3f); playerHealth = playerHealth - RoadBlock.blockDamage; obj.LateDestroy(); SetCycle(20, 2, 255); } if (obj is PowerUpGun) { GunPickUp.Play(volume: 0.3f); timeStart = Time.time; PowerUpAnimationG pag = new PowerUpAnimationG(); Game.main.LateAddChild(pag); obj.LateDestroy(); } if (obj is PowerUpShield) { ShieldPickUp.Play(volume: 0.3f); PowerUpAnimationS pas = new PowerUpAnimationS(); Game.main.LateAddChild(pas); curHP = playerHealth; timeStart2 = Time.time; Invulnerability = true; obj.LateDestroy(); } if (obj is PowerUpLife) { LifePickUp.Play(volume: 0.3f); PowerUpAnimationL pal = new PowerUpAnimationL(); Game.main.LateAddChild(pal); } }