private float ApplyGravity() { if (movementDirection != Direction.Down) { return(0f); } else { if (lemmingStateController.isFloater()) { return(gravitySpeedGain / 2); } return(gravitySpeedGain); } }
public void SetupStateMachine() { stateMachine = new FiniteStateMachine <LemmingAI>(this); idleState.AddTrigger((int)Trigger.StartGame, walkingState); walkingState.AddTransition((int)Trigger.ArrivedAtExit, () => true, exitingLevelState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkForceExplode(), explodingState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => !movementController.CheckFloor(), fallingState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, CheckIsBlocker, blockingState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => movementController.CheckWallForward() && stateController.checkSkill(Skill.Basher), bashingState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => movementController.CheckWallForward() && stateController.isClimber(), climbingState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkSkill(Skill.Digger), diggingState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkSkill(Skill.Exploder), explodingState); walkingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkSkill(Skill.Builder), buildingState); fallingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => this.transform.position.y <= movementController.borderFallKillThreshold, deathState); fallingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => movementController.CheckFloor() && movementController.checkFallDeath(), deathState); fallingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => movementController.CheckFloor(), landingState); fallingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.isFloater(), floatingState); floatingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => this.transform.position.y <= movementController.borderFallKillThreshold, deathState); floatingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => movementController.CheckFloor(), landingState); floatingState.AddCondition(() => stateController.checkForceExplode(), explodingState); landingState.AddTransition((int)Trigger.FinishedTask, () => true, walkingState); climbingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => movementController.CheckFloor(), walkingState); climbingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkForceExplode(), fallingState); diggingState.AddTransition((int)Trigger.FinishedTask, () => true, walkingState); diggingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkForceExplode(), explodingState); bashingState.AddTransition((int)Trigger.FinishedTask, () => true, walkingState); bashingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkForceExplode(), explodingState); buildingState.AddTransition((int)Trigger.FinishedTask, () => true, walkingState); buildingState.AddTransition((int)Trigger.ArrivedAtWaypoint, () => stateController.checkForceExplode(), explodingState); blockingState.AddCondition(() => !movementController.CheckFloor(), fallingState); blockingState.AddCondition(() => stateController.checkForceExplode(), explodingState); stateMachine.SetState(idleState); }