void IThrewBomb() { //i just threw the bomb. wait until it either hits someone or hits the ground before deciding what to do. if (myLSB != null) { if (myLSB.GetComponent <StickyBomb>().ownerID == myPlayer.playerID) { //its ur bomb //check to see if it landed on the ground or stuck someone if (myLSB.GetComponent <StickyBomb>().hitGround) { //it hit the ground myState = AIState.BombOnGround; //PopText.Create("MY BOMB ON GROUND", Color.white, 120,this.transform.position); } else if (myLSB.GetComponent <StickyBomb>().stuckID > 0) { myState = AIState.SomeoneElseStuck; stuckPlayer = PlayerController.GetByPlayerID(myLSB.GetComponent <StickyBomb>().stuckID); //PopText.Create("SOMEONE ELSE STUCK", Color.white, 120,this.transform.position); } } else { //its not ur bomb. see if ur bomb even ecists LocalStickyBomb[] allbombs = GameObject.FindObjectsOfType <LocalStickyBomb> (); bool myBombExists = false; foreach (var b in allbombs) { if (b.GetComponent <StickyBomb>().ownerID == myPlayer.playerID) { //we are good myBombExists = true; myLSB = b; } } if (!myBombExists) { //what happened to my bomb?? } } } else { myLSB = GameObject.FindObjectOfType <LocalStickyBomb> (); if (myLSB == null) { //what happened to my bomb?? } } }
void AvoidBombMidAir() { //someone just threw the bomb. wait until it either hits someone or hits the ground before deciding what to do. if (theirLSB != null) { if (theirLSB.GetComponent <StickyBomb>().ownerID == hasBombPlayer.playerID) { //its their bomb //check to see if it landed on the ground or stuck someone if (theirLSB.GetComponent <StickyBomb>().hitGround) { //it hit the ground myState = AIState.BombOnGround; //PopText.Create("MY BOMB ON GROUND", Color.white, 120,this.transform.position); } else if (theirLSB.GetComponent <StickyBomb>().stuckID > 0) { if (theirLSB.GetComponent <StickyBomb>().stuckID != myPlayer.playerID) { myState = AIState.SomeoneElseStuck; stuckPlayer = PlayerController.GetByPlayerID(theirLSB.GetComponent <StickyBomb>().stuckID); //PopText.Create("SOMEONE ELSE STUCK", Color.white, 120,this.transform.position); } } else if (Vector3.Distance(theirLSB.transform.position, this.transform.position) < 2.5f) //if its getting close to us { //try and jump away if (myPlayer.IsGrounded() && !justJumped) { myPlayer.COMMAND_Jump(); justJumped = true; } } } else { //its not their bomb. see if their bomb even ecists LocalStickyBomb[] allbombs = GameObject.FindObjectsOfType <LocalStickyBomb> (); bool theirBombExists = false; foreach (var b in allbombs) { if (b.GetComponent <StickyBomb>().ownerID == hasBombPlayer.playerID) { //we are good theirBombExists = true; theirLSB = b; } } if (!theirBombExists) { //what happened to my bomb?? } } } else { theirLSB = GameObject.FindObjectOfType <LocalStickyBomb> (); if (theirLSB == null) { //what happened to my bomb?? } } }
public bool ShouldISprint() { float juice = myPlayer.SprintRatio(); int stickyTime = 10; bool grounded = false; if (GameObject.FindObjectOfType <LocalStickyBomb>() != null) { LocalStickyBomb sb = GameObject.FindObjectOfType <LocalStickyBomb>(); stickyTime = sb.GetTimerInSeconds(false); grounded = sb.GetComponent <StickyBomb>().hitGround; } if (stickyTime <= 2) { return(true); } else if (stickyTime <= 4) { if (myState == AIState.IAmStuck || myState == AIState.SomeoneElseStuck) { return(true); } else { if (juice > .5f) { return(true); } else { return(false); } } } else if (stickyTime <= 7) { if (myState == AIState.IAmStuck || myState == AIState.SomeoneElseStuck) { if (juice > .8f) { return(true); } return(false); } return(false); } if (grounded) { if (juice > .5f) { return(true); } else { return(false); } } if (stickyTime == 10) { if (myState == AIState.IHaveBomb || myState == AIState.SomeoneElseHasBomb || myState == AIState.SomeoneElseThrewBomb) { if (juice > .7f) { return(true); } } } return(false); }