private void Awake() { //pick reference Player = FindObjectOfType <PlayerController>(); MyWeapon = GetComponent <RangedWeapon>(); //SetupEnemyType enemyType = EnemyType.typeB; //state machine setup _stateMachine = new StateMachine(); var Sight = new SightPlayer(this); var Shoot = new ShootPlayer(this); var ZigZag = new ZigZagMovement(this); //add transition between state AddTransition(Sight, ZigZag, SpottedPlayer()); AddTransition(Shoot, ZigZag, HasShooted()); AddTransition(ZigZag, Shoot, ReachedNextPoint()); //set conidtions Func <bool> SpottedPlayer() => () => EnableShooting(); Func <bool> HasShooted() => () => ShootingTimer >= ShootingDuration; Func <bool> ReachedNextPoint() => () => agent.remainingDistance <= agent.stoppingDistance; _stateMachine.SetState(Sight); }
private void Awake() { //pick reference Player = FindObjectOfType <PlayerController>(); MyWeapon = GetComponent <RangedWeapon>(); //SetupEnemyType enemyType = EnemyType.typeC; //state machine setup _stateMachine = new StateMachine(); var Sight = new SightPlayer(this); var followAndshoot = new FollowAndShoot(this); //add transition between state AddTransition(Sight, followAndshoot, SpottedPlayer()); //set conidtions Func <bool> SpottedPlayer() => () => EnableShooting(); //Func<bool> ReachedStoppingPoint() => () => agent.remainingDistance <= agent.stoppingDistance; _stateMachine.SetState(Sight); }