// Use this for initialization protected override void Start() { state = GoriyaState.move; State normalMovementState = new EnemyMovementState(this, randomTakeStep(), speed); base.BehaviorStateMathine.ChangeState(normalMovementState); }
public override void hittenByBoomerange (GameObject collider) { if (state != GoriyaState.stop) { state_mem = state; } state = GoriyaState.stop; stun_start_time = Time.time; }
public override void hittenByBoomerange(GameObject collider) { if (state != GoriyaState.stop) { state_mem = state; } state = GoriyaState.stop; stun_start_time = Time.time; }
void OnCollisionEnter(Collision coll) { if (coll.gameObject.tag == "Tiles") { state = GoriyaState.move; State normalMovementState = new EnemyMovementState(this, randomTakeStep(), speed); base.BehaviorStateMathine.ChangeState(normalMovementState); } }
// Update is called once per frame protected override void Update() { // float time_delta_fraction = Time.deltaTime / (1.0f / Application.targetFrameRate); base.Update(); if (state != GoriyaState.stop) { base.BehaviorStateMathine.Update(); animationCounter++; animationCounter %= 30; GetComponent <SpriteRenderer> ().sprite = Sprites [2 * currentMovingTowardDetectorInd + animationCounter / 15]; if (base.BehaviorStateMathine.IsFinished()) { int randNum = Random.Range(0, 100); if (state == GoriyaState.move && randNum < attackProb * 100) { state = GoriyaState.attack; Vector3 velocity = (currentMovingTowardDetector.transform.position - transform.position).normalized * 5; velocity.z = 0; State attackState = new GoriyaAttackState(this, boomerang, velocity); base.BehaviorStateMathine.ChangeState(attackState); } else { state = GoriyaState.move; randNum = Random.Range(0, 100); if (!currentMovingTowardDetector.GetComponent <Detector> ().CollideWithTile() && randNum >= changeDirectionProb * 100) { State normalMovementState = new EnemyMovementState(this, currentMovingTowardDetector.transform.position, speed); base.BehaviorStateMathine.ChangeState(normalMovementState); } else { State normalMovementState = new EnemyMovementState(this, randomTakeStep(), speed); base.BehaviorStateMathine.ChangeState(normalMovementState); } } } } else { if (Time.time - stun_start_time > 5) { state = state_mem; } } }
// Update is called once per frame protected override void Update () { // float time_delta_fraction = Time.deltaTime / (1.0f / Application.targetFrameRate); base.Update (); if (state != GoriyaState.stop) { base.BehaviorStateMathine.Update (); animationCounter++; animationCounter %= 30; GetComponent<SpriteRenderer> ().sprite = Sprites [2 * currentMovingTowardDetectorInd + animationCounter / 15]; if (base.BehaviorStateMathine.IsFinished ()) { int randNum = Random.Range (0, 100); if (state == GoriyaState.move && randNum < attackProb * 100) { state = GoriyaState.attack; Vector3 velocity = (currentMovingTowardDetector.transform.position - transform.position).normalized * 5; velocity.z = 0; State attackState = new GoriyaAttackState (this, boomerang, velocity); base.BehaviorStateMathine.ChangeState (attackState); } else { state = GoriyaState.move; randNum = Random.Range (0, 100); if (!currentMovingTowardDetector.GetComponent<Detector> ().CollideWithTile () && randNum >= changeDirectionProb * 100) { State normalMovementState = new EnemyMovementState (this, currentMovingTowardDetector.transform.position, speed); base.BehaviorStateMathine.ChangeState (normalMovementState); } else { State normalMovementState = new EnemyMovementState (this, randomTakeStep (), speed); base.BehaviorStateMathine.ChangeState (normalMovementState); } } } } else { if (Time.time - stun_start_time > 5) { state = state_mem; } } }
void OnCollisionEnter(Collision coll) { if (coll.gameObject.tag == "Tiles") { state = GoriyaState.move; State normalMovementState = new EnemyMovementState (this, randomTakeStep(), speed); base.BehaviorStateMathine.ChangeState (normalMovementState); } }
// Use this for initialization protected override void Start () { state = GoriyaState.move; State normalMovementState = new EnemyMovementState (this, randomTakeStep(), speed); base.BehaviorStateMathine.ChangeState (normalMovementState); }