private GameState GoForestCrossroads(GameState state, ForestSSC.Direction direction) { var path = new List <int>(state.HubaForest.CurrentForestWay); path.Add((int)direction); GameState s = state; if (path.Count == state.HubaForest.RightForestWay.Count && path.SequenceEqual(state.HubaForest.RightForestWay)) { s = state.Set(state.HubaForest.SetIsOnSite(true)); } return(s.Set(s.HubaForest.SetCurrentForestWay(path))); }
public override void OnStateChanged(GameState newState, GameState oldState) { if (!(newState.HubaForest.IsOnSite && (oldState == null || !oldState.HubaForest.IsOnSite)) && // Player just came on site - spirit no longer needed ((newState.HubaForest.IsInForest && (oldState == null || !oldState.HubaForest.IsInForest)) || // Player just came to forest (oldState != null && oldState.HubaForest.CurrentForestWay.Count < newState.HubaForest.CurrentForestWay.Count))) // Player went further to the forest { // Prepare spirit if need be IsSpiritReleased = false; if (newState.HubaForest.IsHubaBlessed) { ForestSSC.Direction dir = GetCurrentDir(newState); if (dir != ForestSSC.Direction.None) { // Prepare data for Fungus method var currAnimArr = SpiritAnims[dir]; CurrentSpiritAnim = currAnimArr[Rnd.Next(0, currAnimArr.Length)]; IsSpiritReleased = true; } } Spirit.SetActive(IsSpiritReleased); } }