void LateUpdate() { frames++; if (frames >= interval) { frames = 0; if ((currentState != birdStates.escaping)) { rbs = getRect(baconGO); rg = getRect(gameObject); //Rect br = getRect(baconSpot); pr = getRect(playerHitZone); bool pBool = Intersect(rg, pr); //print ("pBool = " + pBool); if ((Intersect(rg, rbs) || pBool) && currentState != birdStates.grabbing) { if (Intersect(rg, pr)) { currentState = birdStates.attacking; } else { //print("hit cooking spot"); currentState = birdStates.grabbing; } //print("current state " + currentState); } } bo = getRect(boatOar); rg = getRect(gameObject); if ((currentState != birdStates.swatted || currentState != birdStates.escaping) && playerIdle == false) { if (Intersect(rg, bo)) { currentState = birdStates.swatted; } } } }
void Swimming() { if (animator.GetInteger("bird_animation") != 0) { animator.SetInteger("bird_animation", 0); } int direction = -1; if (!goRight) { direction = -1; transform.rotation = new Quaternion(0f,180f,0f, 1f); } transform.Translate(new Vector3(direction * flySpeed * Time.deltaTime, 0f, 0f)); float dist = Vector3.Distance(target.position, transform.position); //print ("distance = " + dist); if ((dist < 6) && (dist > 5)) { currentState = birdStates.diving; } }
void Grabbing() { if (animator.GetInteger("bird_animation") != 3) { animator.SetInteger("bird_animation", 3); grabTime = Time.time + grabAnimationTime; grabBaconEvent(baconSpot.name); } if (Time.time > grabTime) { //print ("grab time is over"); currentState = birdStates.escaping; } }
void Attacking() { if (animator.GetInteger("bird_animation") != 3) { animator.SetInteger("bird_animation", 3); grabTime = Time.time + 0.1f; //grabBaconEvent(baconSpot.name); } if (Time.time > grabTime) { //print ("attack time is over"); BirdAttackEvent(4f); currentState = birdStates.escaping; } }
void Alert() { if (animator.GetInteger("bird_animation") != -1) { //print ("animator var first time = " + animator.GetInteger("bird_animation")); animator.SetInteger("bird_animation", -1); //print ("animator var after time = " + animator.GetInteger("bird_animation")); alertCounter = Time.time + alertTime; } //print("T = " + Time.time + "| ac = " + alertCounter); if (Time.time > alertCounter) { currentState = birdStates.flying; } }
public void GetHit(int clearingEnemy = 0) { if (hit == false) { hitTime = Time.time + hitAnimationTime; currentState = birdStates.swatted; hit = true; //print("hit recieved"); animator.SetInteger("bird_animation", 2); Toolbox.Instance.birdHitCount++; if (clearingEnemy == 0) { BirdHitEvent(boatOar.transform.position); } else { BirdHitEvent(gameObject.transform.position); } BirdPointsEvent(gameObject.transform.position, 35); //boatOarClass.fire(); } if (Time.time > hitTime) { currentState = birdStates.escaping; } //destroyMissile (); }
public void Fire() { //flying = true; float distance = Mathf.Infinity; //var distance = Mathf.Infinity; baconSpotScript = baconSpot.GetComponent<CookingController>(); //GameObject.Find("Cooking_Left"); foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player")) { if ((transform.position.x) < 0) { goRight = false; } else { goRight = true; } float diff = (go.transform.position - transform.position).sqrMagnitude; if (diff < distance) { distance = diff; target = go.transform; } } currentState = birdStates.alert; }