public override void OnBombDestroyed(NewBomb destroyedBomb) { base.OnBombDestroyed(destroyedBomb); int numPellets = numPelletsPerTrail + UnityEngine.Random.Range(-variance, variance); occupancyGrid.LayNewTrail(numPellets); }
public override void OnBombDestroyed(NewBomb destroyedBomb) { base.OnBombDestroyed(destroyedBomb); //do we have no bombs left? if(bombsInPlay.Count == 0) { //create all the bombs at once for(int i = 0; i < numberOfBombsToCreate; ++i) { occupancyGrid.LayNewTrail(pelletsPerTrail); } } }
private void UpSpec() { prejump = -1; if (vy < 0) { vy /= 2.1f; vy = MomChange(vy, 0.22f); } vx /= 1.7f; speclag = 18; GameObject NewBomb; energy -= 3.3f; NewBomb = Instantiate(NSpecBombOrg, new Vector3(transform.position.x, transform.position.y - 0.95f, transform.position.z), transform.rotation); NewBomb.GetComponent <NSpecBomb>().SetImm(playernumber); }
/// <summary> /// This code should deal with destroying a set of bombs and then /// calculating the score and dealing with all the enemies /// </summary> /// <param name="bomb"></param> public void OnBombTriggered(NewBomb bomb) { //get a list of bombs to explode List<NewBomb> bombsToExplode = FindConnectedBombs(bomb); //find all the unique enemies in range of the bombs List<GameObject> enemies = new List<GameObject>(FindEnemies(bombsToExplode)); DestroyBombLinks(bombsToExplode); //destroy bombs and enemies in a way that looks cool DestroyEnemies(enemies); //remove the bombs from the list of bombs in play DestroyBombs(bombsToExplode, bomb); if (bombsDestroyed >= strategyChangeFrequency) { SetRandomStrategy(); //reset the counter bombsDestroyed = 0; } }
private void AttackControl() { GeneralAttackControl(); //side spec if (attackType == -2) { if (framein == 1) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_throw; } if (framein == 5 || BowChargeTime >= 5) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_throw2; } if (framein == 17) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } Jump(); if (jumpCon > 0 && jumpframes > 0) { vy += gravity / 2f; jumpframes--; } else { jumpframes = 0; } if (framein == 10) { float Power = 0; if (BowChargeTime > 6) { Power = 0.55f + ((1 - Mathf.Pow(0.9f, BowChargeTime - 6)) * .58f); } else { Power = 0.55f; } BowChargeTime = -1; SlimeCool = 190; GameObject NewBomb; NewBomb = Instantiate(BombOrg, transform.position, transform.rotation); NewBomb.GetComponent <BowBombScript>().ChangeVol(Power * Mathf.Cos(BowAngle / 180 * Mathf.PI), Power * Mathf.Sin(BowAngle / 180 * Mathf.PI), playernumber, true); } if (specialCon > 0 && BowChargeTime <= 30 && BowChargeTime >= 0 && bowBuff) { BowChargeTime++; attackstun++; } else { bowBuff = false; } } //neutral slime if (attackType == -3) { Debug.Log("framein: " + framein); if (framein == 1) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_throw; } if (framein == 5) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } Jump(); if (jumpCon > 0 && jumpframes > 0) { vy += gravity / 2f; jumpframes--; } else { jumpframes = 0; } if (specialCon == 0) { bowBuff = false; } //because Duel TNT is basketball if (rightCon == 2) { faceright = true; } if (leftCon == 2) { faceright = false; } if (faceright) { transform.rotation = Quaternion.Euler(0, 180, 0); } else { transform.rotation = Quaternion.Euler(0, 0, 0); } if (framein == 5) { if (faceright) { faceright = true; BowAngle = 50; } else { faceright = false; BowAngle = 130; } float Power = 0; if (BowChargeTime > 6) { Power = 0.21f + ((1 - Mathf.Pow(0.96f, BowChargeTime - 6)) * 1.11f); } else { Power = 0.21f; } SlimeCool = 60; GameObject NewBomb; NewBomb = Instantiate(BombOrg, transform.position, transform.rotation); NewBomb.GetComponent <BowBombScript>().ChangeVol(Power * Mathf.Cos(BowAngle / 180 * Mathf.PI), Power * Mathf.Sin(BowAngle / 180 * Mathf.PI), playernumber, false); NewBomb.GetComponent <SpriteRenderer>().sprite = SlimeBoom; /*if (doubleBowShot) * { * if (BowChargeTime > 3) BowChargeTime += 4; * else BowChargeTime = 6; * * if (BowChargeTime > 3) Power = 0.24f + ((1 - Mathf.Pow(0.96f, BowChargeTime - 3)) * 1.11f); * else Power = 0.24f; * * GameObject NewBomb2; * NewBomb2 = Instantiate(BombOrg, transform.position, transform.rotation); * NewBomb2.GetComponent<BowBombScript>().ChangeVol(Power * 1.05f * Mathf.Cos(BowAngle / 180 * Mathf.PI), Power * 1.05f * Mathf.Sin(BowAngle / 180 * Mathf.PI), playernumber, false); * NewBomb2.GetComponent<SpriteRenderer>().sprite = SlimeBoom; * }*/ BowChargeTime = -1; } if (specialCon > 0 && BowChargeTime <= 58 && BowChargeTime >= 0 && bowBuff) { BowChargeTime++; attackstun++; } } if (attackType == -4) { if (framein == 3) { MyMegaBomb = Instantiate(MegaBombOrg, new Vector3(transform.position.x, transform.position.y - 0.4f, transform.position.z), transform.rotation); CanMegaBomb = false; SlimeCool = 100; } } if (attackType == -1) { //vy = MomChange(vy, -0.12f); //vx /= 1.2f; if (framein > 3) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_selfd_end; } } if (grounded && attackType >= 5) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_prejump; attackType = -99; if (attackstun > landingLag) { genstun = landingLag; } else { genstun = attackstun; } genstun += 4; attackstun = 0; } /*if (!grounded && (attackType == 0 || attackType == 2 || attackType == 3)) * { * gameObject.GetComponent<SpriteRenderer>().sprite = sprite_stand; * attackType = -99; * attackstun = 4; * }*/ if (attackType == 0) { if (framein == 2) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack2; } if (framein == 4) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack3; } if (framein == 6) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack4; } if (framein == 8) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack5; } if (framein == 10) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack6; } if (framein == 12) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack7; } if (framein == 14) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack1; } if (framein == 16) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack2; } if (framein == 18) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack3; } if (framein == 20) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack4; } if (framein == 22) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack5; } if (framein == 24) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack6; } if (framein == 26) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack7; } if (framein == 28) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack1; } if (framein == 31) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack2; } if (framein == 34) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack3; } if (framein == 36) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack4; } if (framein == 41) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack3; } if (framein == 44) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack2; } if (framein == 46) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stack1; } if (framein == 26) { Booms[BoomCount + 1].Create(x, y - 1.5f, 5.0f, 0.45f, 3.2f, 1, 0, 0, 1, 1); } } if (attackType == 1) { if (framein == 3) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_jab; } if (framein == 7) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_jab_start; } if (framein == 10) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } } if (attackType == 2) { //Dash ~ 1.5 units in and goes ~ 2.2 units for the hitbox //if (framein == 1) Debug.Log("x = " + x); //if (framein == 10) Debug.Log("x = " + x); //if (framein == 18) Debug.Log("x = " + x); if (framein == 10) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_dash; if (faceright) { vx = MomChange(vx, 0.43f); } else { vx = MomChange(vx, -0.43f); } if (faceright) { Booms[BoomCount + 1].Create(x - 3.5f, y - 0.6f, 4.4f, 0.37f, 2, 1, 0, playernumber, 1, 1); } else { Booms[BoomCount + 1].Create(x + 3.5f, y - 0.6f, 4.4f, 0.37f, 2, 1, 0, playernumber, 1, 1); } } if (framein == 18) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_dash_start; } } if (attackType == 3) { if (framein == 6) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_upper; } if (framein == 9) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_upper_start; } if (framein == 14) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } } if (attackType == 4) { if (framein >= 10 && framein <= 11) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_power2; } if (framein >= 18 && framein <= 21) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_power5; } if (framein == 12) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_power1; } if (framein == 14) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_power3; } if (framein == 16) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_power4; } if (framein == 22) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_power4; } if (framein == 24) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_power6; } if (framein == 16) { GameObject NewBomb; NewBomb = Instantiate(PowBombOrg, transform.position, transform.rotation); if (faceright) { NewBomb.GetComponent <PowShot>().ChangeVol(0.5f, 0.5f, playernumber); } else { NewBomb.GetComponent <PowShot>().ChangeVol(-0.5f, 0.5f, playernumber); } } } //nair if (attackType == 5) { if (framein == 16) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_nair_start; } if (framein == 21) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } if (framein == 8) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_nair; } } //fair if (attackType == 6) { //if (framein == 11) vy /= 1.4f; //if (framein == 21) vy /= 1.4f; //if (framein >= 11 && framein <= 21) vy /= 1.1f; if (framein == 5) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_fair_start; } if (framein == 11) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_fair; } if (framein == 17) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_fair_start; } if (framein == 20) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_fair_start2; } if (framein == 23) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } //if (framein == 19) gameObject.GetComponent<SpriteRenderer>().sprite = sprite_fair_start; //if (framein == 21) gameObject.GetComponent<SpriteRenderer>().sprite = sprite_fair; //if (framein == 24) gameObject.GetComponent<SpriteRenderer>().sprite = sprite_fair_start; // if (framein == 28) gameObject.GetComponent<SpriteRenderer>().sprite = sprite_fair_start2; if (framein == 30) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } } //dair if (attackType == 7) { if (framein == 16) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_dair_start; } if (framein == 28) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } if (framein == 7) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_dair; } if (framein == 10) { Booms[BoomCount + 1].Create(x, y - 1.1f, 4.3f, 0.35f, 2.7f, 1, 0, 0, 1, 1); } } //uair if (attackType == 8) { if (framein == 2) { Booms[BoomCount + 1].Create(x, y - 1.8f, 4.6f, 0.58f, 2.3f, 1, 0, playernumber, 1, 1.1f); } if (framein == 18) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_uair_start; } if (framein == 30) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_stand; } if (framein == 4) { gameObject.GetComponent <SpriteRenderer>().sprite = sprite_uair; } } }
public virtual void OnBombDestroyed(NewBomb destroyedBomb) { bombsInPlay.Remove(destroyedBomb); }
public virtual void AddBomb(NewBomb bomb) { bombsInPlay.Add(bomb); }
public void OnPelletCollected(NewBomb owner) { //need to know which bomb it was connected to? float blastRadius = owner.GetBlastRadius(); //check to see if any bombs are in range of the bomb that just got a pellet collected foreach (NewBomb bomb in currentLayoutStrategy.bombsInPlay) { //check to see if bombs are in range float distanceBetweenBombs = Vector3.Distance(bomb.transform.position, owner.transform.position); if (distanceBetweenBombs < blastRadius/2 && bomb.readyToBlow && bomb != owner) { //it's in range so lets mark it as such bomb.MarkExplodable(); //create line link CreateLink(owner, bomb); } } //if a bomb has just been activated then we need to check to see //if it falls under radius of any other bombs //check to see if any bombs are in range of the bomb that just got a pellet collected foreach (NewBomb bomb in currentLayoutStrategy.bombsInPlay) { float blastRad = bomb.GetBlastRadius(); //check to see if bombs are in range float distanceBetweenBombs = Vector3.Distance(bomb.transform.position, owner.transform.position); if (distanceBetweenBombs < blastRad / 2 && bomb != owner) { //it's in range so lets mark it as such owner.MarkExplodable(); //create line link CreateLink(bomb, owner); } } }
public void AddBomb(NewBomb bomb) { currentLayoutStrategy.AddBomb(bomb); //should we check here to see if the bomb could be in range and be primed? }
List<NewBomb> FindConnectedBombs(NewBomb bomb) { List<NewBomb> bombsFound = new List<NewBomb>(); bomb.FindBombs(bombsFound); return bombsFound; }
void DestroyBombs(List<NewBomb> bombs, NewBomb startBomb) { //remove bombs from the manager foreach (NewBomb bomb in bombs) { currentLayoutStrategy.OnBombDestroyed(bomb); } //add to the bomb destruction counter bombsDestroyed += bombs.Count; totalBombsDestroyed += bombs.Count; //send all this information somwhere so that the score can be calculated StartCoroutine(startBomb.ExplodeBombs(bombs)); }
void CreateLink(NewBomb origin, NewBomb destination) { origin.AddBombLink(destination, linkLine); }
public override void OnBombDestroyed(NewBomb destroyedBomb) { base.OnBombDestroyed(destroyedBomb); //this strategy is time based so we don't actually want to do anything when a bomb gets destroyed }