void SetAIMode(Mode aiModeToSet) { timer = 0; timerLength = 0; velocity.x = 0; velocity.y = 0; switch (aiModeToSet) { case Mode.idle: aiMode = Mode.idle; anim.Play("Asha Idle"); timerLength = Random.Range(1.0f, 6.0f); //Set how long the Asha will be idling before starting to wander break; case Mode.wandering: aiMode = Mode.wandering; anim.Play("Asha Inch Forward"); timerLength = 0.15f; //Set how long the Asha will pause between each inch loop inchLoops = Random.Range(4, 6); inchLoopsCounter = 0; if (Random.Range(0, 10) >= 5) { GetComponent <SpriteRenderer>().flipX = !GetComponent <SpriteRenderer>().flipX; } break; case Mode.alert: aiMode = Mode.alert; anim.Play("Asha Idle"); timerLength = 2.0f; //Set how long the Asha will remain alert until attacking/losing interest and wandering velocity.y = 1.5f; //Pop them up, like they got startled a lil bit GetComponent <SpriteRenderer>().flipX = (enemyController.player.transform.position.x > transform.position.x) ? true : false; GameObject exclamationPointObject = GenericObject.CreateObject(new Vector3(transform.position.x, transform.position.y + 0.4f, 0), exclamationPointSprite, 0.5f); break; case Mode.attackInching: aiMode = Mode.attackInching; anim.Play("Asha Inch Forward"); timerLength = 0.1f; //Set how long the Asha will pause Between each inch loop chaseTimer = 0; GetComponent <SpriteRenderer>().flipX = (enemyController.player.transform.position.x > transform.position.x) ? true : false; break; case Mode.attackLeaping: aiMode = Mode.attackLeaping; anim.Play("Asha Attacking"); velocity.x = (enemyController.player.transform.position.x > transform.position.x) ? 3.0f : -3.0f; //Throw the Asha towards the player horizontally velocity.y = 2.0f; //Lift the Asha slightly off the ground GetComponent <SpriteRenderer>().flipX = (enemyController.player.transform.position.x > transform.position.x) ? true : false; break; } }