/// <summary> /// Declaration of references will be used for the states logic goes here /// Eg. /// public ISteer steeringScript; /// public GameObject pathRoute; /// public Queue<GameObject> enemyQueue = new Queue<GameObject>(); /// /// </summary> private void Start() { /// <summary> /// Instantiation of states Instances goes here. /// Eg. /// chaseEnemy = new ChaseState() /// { /// chasingRange = this.chasingRange, /// shootingRange = this.shootingRange, /// alertRange = this.alertRange, /// movementController = this /// }; /// </summary> ////Instantiate the first state fightingState = new FightingState() { gameplayFSMManager = this }; stateTransition = new StateTransition() { gameplayFSMManager = this }; washingState = new WashingState() { gameplayFSMManager = this }; pauseState = new PauseState() { gameplayFSMManager = this }; //push the first state for the player PushState(fightingState); }
public override bool IsValid(Mom entity) { string[] lines = entity.currentState.text.Split('\n'); string lastLine = lines[lines.Length - 1]; string currentLine = ""; switch (nextState) { case 0: currentLine = "Checking Child"; if (lastLine != currentLine) { entity.currentState.text += "\n" + currentLine; } entity.child.money += entity.money; entity.money = 0; StoreState storeState = new StoreState(); if (storeState.IsValid(entity.child)) { entity.child.currentState.text += "\nReady"; return(true); } break; case 1: currentLine = "Checking Stove"; if (lastLine != currentLine) { entity.currentState.text += "\n" + currentLine; } entity.stove.food = entity.food; CookingState cookingState = new CookingState(); if (cookingState.IsValid(entity.stove)) { entity.stove.currentState.text += "\nReady"; return(true); } break; case 2: currentLine = "Checking Washer"; if (lastLine != currentLine) { entity.currentState.text += "\n" + currentLine; } WashingState washingState = new WashingState(); if (washingState.IsValid(entity.washer)) { entity.washer.currentState.text += "\nReady"; return(true); } break; default: return(true); } return(false); }