void OnCollisionEnter(Collision coll) { if (coll.gameObject.tag == "Tiles") { movingState = GelState.stop; State normalMovementState = new EnemyMovementState (this, transform.position, 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(); base.BehaviorStateMathine.Update(); if (base.BehaviorStateMathine.IsFinished()) { if (movingState == GelState.move) { movingState = GelState.stop; State normalMovementState = new EnemyMovementState(this, this.transform.position, speed); base.BehaviorStateMathine.ChangeState(normalMovementState); } else { movingState = GelState.move; int 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); } } } }
// Use this for initialization protected override void Start() { movingState = GelState.move; State normalMovementState = new EnemyMovementState(this, randomTakeStep(), speed); base.BehaviorStateMathine.ChangeState(normalMovementState); }
void OnCollisionEnter(Collision coll) { if (coll.gameObject.tag == "Tiles") { movingState = GelState.stop; State normalMovementState = new EnemyMovementState(this, transform.position, 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 (); base.BehaviorStateMathine.Update (); if (base.BehaviorStateMathine.IsFinished()) { if (movingState == GelState.move) { movingState = GelState.stop; State normalMovementState = new EnemyMovementState (this, this.transform.position, speed); base.BehaviorStateMathine.ChangeState (normalMovementState); } else { movingState = GelState.move; int 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); } } } }
// Use this for initialization protected override void Start () { movingState = GelState.move; State normalMovementState = new EnemyMovementState (this, randomTakeStep(), speed); base.BehaviorStateMathine.ChangeState (normalMovementState); }