public override void Start(bool AtFirst) { //if (LState.IsStartegyRun == true) //{ // Print("Стратегия уже запущена!", true); // return; //} if (AtFirst) { LState.Reset(); } if (CStrategyPrices.StartUpdateCandles()) { LState.IsStartegyRun = true; ChangeState?.Invoke(true, true, LParam.StrategyName); } else { LState.IsStartegyRun = false; ChangeState?.Invoke(true, false, LParam.StrategyName); } SaveData(); }
public void StartWave() { EagleEyes.Instance.SetActiveFFButtons(true); float time_left = 5f * (next_wave_time - Mathf.Floor(TIME)) / 30f; if (Wave_interval > 0 && time_left > 0) { float dreams_awarded = Mathf.RoundToInt(Mathf.Max(5f, time_left)); Debug.Log("Awarding " + dreams_awarded + " points for starting wave early\n"); if (!LevelBalancer.Instance.am_enabled) { addDreams(dreams_awarded, Vector3.one, true);//wave button position wtf Tracker.Log(PlayerEvent.StartWaveEarly, true, customAttributes: new Dictionary <string, string>() { { "attribute_2", dreams_awarded.ToString() }, { "attribute_1", Moon.Instance.current_wave.ToString() } }, customMetrics: new Dictionary <string, double>() { { "metric_2", next_wave_time - TIME }, { "metric_1", Wave_interval } }); } } make_wave = true; next_monster_time = TIME; level_state = LState.WaveStarted; EagleEyes.Instance.WaveButton(false); }
private void VariabledState(Token token) { if (token.TokenType != TokenType.Name || token.TokenString != "in") { throw new InvalidSyntaxException($"Expected \"in\" keyword. Got {token.TokenString}", token.Line, token.Position); } _state = LState.InGot; }
private void InGotState(Token token) { if (token.TokenType == TokenType.Control && token.TokenString == "..") { if (!_sass.Exit()) { throw new InvalidSyntaxException("Invalid start of range definition", token.Line, token.Position); } _state = LState.RangeGot; return; } _sass.Add(token); }
private void RangeGotState(Token token) { if (token.TokenType == TokenType.Name && token.TokenString == "do") { if (!_eass.Exit()) { throw new InvalidSyntaxException("Invalid end of range definition", token.Line, token.Position); } _state = LState.Body; return; } _eass.Add(token); }
private void AddKey(Token token) { _current = token.TokenString switch { "end" => null, "var" => new Definition(this, token.Line, token.Position), "for" => new Loop(this, token.Line, token.Position), "read" => new Reader(this, token.Line, token.Position), "print" => new Printer(this, token.Line, token.Position), "assert" => new Assertion(this, token.Line, token.Position), _ => throw new InvalidSyntaxException($"Invalid keyword for start of expression {token.TokenString}", token.Line, token.Position) }; if (token.TokenString == "end") { _state = LState.End; } }
IEnumerator FinishLevel() { level_active = false; yield return(StartCoroutine(CoroutineUtil.WaitForRealSeconds(2f))); //Tracker.Log("Level Finished" + Central.Instance.current_lvl + " " + Peripheral.Instance.difficulty.ToString() + " health " + Peripheral.Instance.GetHealth()); Debug.Log("YOU WIN LEVEL\n"); EagleEyes.Instance.SetActiveFFButtons(false); // float remaining_wishes = my_inventory.GetWishScore(); ScoreKeeper.Instance.CalcScore(dreams, health); Central.Instance.changeState(GameState.Won); level_state = LState.Won; yield return(null); }
public bool Load(Level level) { Init(); difficulty = Central.Instance.getCurrentDifficultyLevel(); // Debug.Log("Loaded level " + level + " with difficulty " + difficulty + "\n"); monsters_transform = Monsters_Bucket.Instance.gameObject.transform; arrows_transform = GameObject.Find("Arrows").gameObject.transform; Moon.Instance.monsters_transform = monsters_transform; // Debug.Log("using FancyLoader to load " + level + "\n"); if (level.fancy) { FancyLoader.Instance.LoadLevel(level.name); } else { file = new Queue <string>(((TextAsset)Resources.Load("Levels/" + level.name)).text.Split('\n')); Debug.Log("Loading file " + level.name + "\n"); Loader.Instance.setFile(file); Loader.Instance.oldLoadLevel(); } //SetDiagonal(Vector3.Distance(WaypointMultiPathfinder.Instance.paths[0].finish.transform.position, WaypointMultiPathfinder.Instance.paths[0].start.transform.position) * 2); //the above does nto work for paths that loop back SetDiagonal(60f); overseer = EventOverseer.Instance; level_state = LState.WaveButton; Moon.Instance.WaveInProgress = false; level_active = true; //Debug.Log ("Peripheral FINISHED LOADING at " + Duration.realtimeSinceStartup); if (GameStatCollector.Instance != null) { GameStatCollector.Instance.Init(); } // on_level_start_trigger.OnSignal(); return(true); }
private void EmptyState(Token token) { if (token.TokenType != TokenType.Name) { throw new InvalidSyntaxException($"Expected loop variable id. Got {token.TokenString}", token.Line, token.Position); } if (Keywords.Contains(token.TokenString)) { throw new InvalidSyntaxException($"Loop variable can not be a reserved keyword. Got {token.TokenString}", token.Line, token.Position); } _loopvar = GetDefinition(token.TokenString); if (_loopvar == null) { throw new InvalidSyntaxException($"Use of undefined variable as loop variable. {token.TokenString}", token.Line, token.Position); } if (!(_loopvar.GetValue() is MplInteger)) { throw new InvalidSyntaxException($"Loop variable {token.TokenString} is not an integer", token.Line, token.Position); } _state = LState.Variabled; }
void Init() { Debug.Log("Peripheral INITIALIZING\n"); //done_making_wave = false; targets = new MyArray <HitMe>(); monster_count = 0; level_state = LState.WaveButton; //wave_button_visible = false; my_inventory.InitWishes(); cities = new List <int>(); have_cities = false; building_a_city = false; default_wave_interval = 0.1f; // waves are spaced at least X seconds apart next_wave_time = 0.5f; // first wave time previous_timeScale = TimeScale.Normal; current_timeScale = TimeScale.Normal; setTimeScale(current_timeScale); toy_parents = new List <Toy>(); firearms = new List <Firearm>(); // haveToys = new List<string>(); haveMonsters = new Dictionary <string, bool>(); toy_selected = null; rune_selected = RuneType.Null; // monsters = 0; Wave_interval = 0; next_monster_time = 0; level_active = false; island_selected = null; make_wave = false; dreams = 0; toys = 0; all_toys = 0; TIME = 0f; my_inventory.InitWishes(); hero_points = new Dictionary <RuneType, int> { { RuneType.Sensible, 1 }, { RuneType.Airy, 1 }, { RuneType.Vexing, 1 } }; zoo = Zoo.Instance; }
public override void Add(Token token) { //TODO: Ensure definitions are possible in loops switch (_state) { case LState.Empty: EmptyState(token); break; case LState.Variabled: VariabledState(token); break; case LState.InGot: InGotState(token); break; case LState.RangeGot: RangeGotState(token); break; case LState.Body: BodyState(token); break; case LState.End: if (token.TokenType != TokenType.Name || token.TokenString != "for") { throw new InvalidSyntaxException($"No {token.TokenString} to end", token.Line, token.Position); } _state = LState.For; break; case LState.For: throw new InvalidSyntaxException($"Expected line termination. Got {token.TokenString}", token.Line, token.Position); } }
private void OnGUI() { GUILayout.BeginHorizontal(); GUILayout.Label("Seed"); initialState.Value = GUILayout.TextField(initialState.Value, GUILayout.MinWidth(50.0f)); GUILayout.EndHorizontal(); GUILayout.Space(10.0f); GUILayout.Label("Rules"); for (int i = 0; i < initialState.Rules.Count; ++i) { GUILayout.BeginHorizontal(); string newStr = GUILayout.TextField(initialState.Rules[i].Trigger.ToString(), GUILayout.MinWidth(50.0f)); if (newStr.Length == 1) { initialState.Rules[i] = new LSystem.Rule(newStr[0], initialState.Rules[i].ReplaceWith); } newStr = GUILayout.TextField(initialState.Rules[i].ReplaceWith, GUILayout.MinWidth(120.0f)); initialState.Rules[i] = new LSystem.Rule(initialState.Rules[i].Trigger, newStr); if (GUILayout.Button("Delete")) { initialState.Rules.RemoveAt(i); i -= 1; } GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Add")) { initialState.Rules.Add(new LSystem.Rule('F', "F")); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10.0f); if (GUILayout.Button("Edit Commands")) { var wnd = GetWindow <DFSystem.Editor.CommandEditor>(); wnd.Commands = commands; wnd.Show(); } GUILayout.Space(15.0f); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save")) { var filePath = EditorUtility.SaveFilePanel("Choose where to save", Path.Combine(Application.dataPath, "../"), "MySystem", "lsystem"); if (filePath != "") { var errMsg = LSystem.Serializer.ToFile(initialState, filePath); if (errMsg != "") { Debug.LogError("Error saving to " + filePath + ": " + errMsg); } } } if (GUILayout.Button("Load")) { var filePath = EditorUtility.OpenFilePanel("Choose the file to load", Path.Combine(Application.dataPath, "../"), "lsystem"); if (filePath != "") { var errMsg = LSystem.Serializer.FromFile(filePath, out initialState); if (errMsg != "") { Debug.LogError("Error loading from " + filePath + ": " + errMsg); } } } if (GUILayout.Button("Clear") && EditorUtility.DisplayDialog("Confirm", "Are you sure you want to clear everything?", "Yes")) { var defaultRule = new List <Rule>() { new Rule('F', "F+F+F") }; initialState = new LSystem.LState("F", defaultRule, new LSystem.PrioritySystem_Random()); } GUILayout.EndHorizontal(); GUILayout.Space(15.0f); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Make Shader")) { var filePath = EditorUtility.SaveFilePanelInProject("Save Shader", "MyShader", "shader", "Choose the shader name"); if (filePath != "") { var errMsg = MakeShader(filePath); if (errMsg == "") { EditorUtility.RevealInFinder(filePath); } else { Debug.LogError("Error generating " + filePath + ": " + errMsg); } } } nIterations = EditorGUILayout.IntField("Iterations", nIterations); } }
public StringEntry(int number, LState state, string text) { m_State = state; m_Number = number; m_Text = text; }
public void LoadBasicMidLevelShit(SaveState saver) { // Debug.Log("Peripheral loaded snapshot, wave " + saver.current_wave + "\n"); StopAllCoroutines(); level_state = LState.WaveButton; ChangeTime(TimeScale.Normal); Wave_interval = 0f; TIME = 0f; have_cities = false; toy_parents = new List <Toy>(); Moon.Instance.WaveInProgress = false; foreach (unitStatsSaver a in saver.actor_stats) { Central.Instance.setUnitStats(a, a.toy_id.toy_type == ToyType.Hero); } Monitor.Instance.ResetIslands(); xp_factor.Reset(); damage_factor.Reset(); dream_factor.Reset(); difficulty = saver.difficulty; if (saver.type == SaveStateType.MidLevel) { FancyLoader.Instance.LoadWavesOnly(Central.Instance.level_list.levels[Central.Instance.current_lvl].name); Moon.Instance.SetWave(saver.current_wave, 0); Sun.Instance.Init(0); Moon.Instance.WaveInProgress = false; foreach (unitStatsSaver a in saver.actor_stats) { Central.Instance.setUnitStats(a, true); } TIME = next_wave_time; Debug.Log("Peripheral Loading snapshot\n"); // Sun.Instance.SetTimePassively(saver.time_of_day); PlaceCastle(); RuneSaver castle_toysaver = saver.getCastle(); if (castle_toysaver != null) { castle.loadSnapshot(castle_toysaver); //this guy needs to be loaded first } else { Debug.LogError("Could not find castle toysaver!"); } //castle.rune.DoSpecialThing(EffectType.Architect); //load gnomesss if (saver.health > 0) { SetHealth(saver.health, false); } dreams = saver.dreams; setToys(0); monster_count = 0; for (int i = 0; i < saver.islands.Count; i++) { var island_saver = saver.islands[i]; Island_Button island = null; Monitor.Instance.islands.TryGetValue(island_saver.name, out island); if (island == null) { Debug.Log("Could not find island " + island_saver.name + "\n"); continue; } if (island_saver.island_type != IslandType.Null) { island.ChangeType(island_saver.island_type, false); } if (island_saver.toy_saver != null) { if (island_saver.toy_saver.rune_saver.runetype == RuneType.Castle) { continue; } if (island_saver.toy_saver.toy_name.Equals(Get.NullToyName())) { continue; } Toy toy = null; GameObject toy_object = makeToy(island_saver.toy_saver.toy_name, island, false, ref toy, false); if (toy_object == null) { Debug.Log("FAILED TO LOAD TOY! NO FIREARM\n"); return; } toy.loadSnapshot(island_saver.toy_saver); if (toy.firearm != null) { toy.firearm.CheckForUpgrades(); } if (island_saver.toy_saver.rune_saver.runetype != RuneType.Modulator && (island_saver.toy_saver.type == ToyType.Normal)) { incrementToys(); } } if (!(island_saver.block_timer > 0)) { continue; } island.MakeDeadIsland(island_saver.block_timer); } //skillmaster is initialized indirectly, when the toys are initialized, through Rune Central.Instance.level_list.special_skill_button_driver.Init(); EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Normal, false); } else { Debug.LogError("Loading midlevel shit on a non midlevel savegame!\n"); Debug.Log("Peripheral loaded start level snapshot, current wave is " + 0 + "\n"); Moon.Instance.SetWave(0, 0); Sun.Instance.Init(0); PlaceCastle(); }// end loading snapshot specific stuff EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Normal, false); level_active = true; ChangeTime(TimeScale.Normal); // not sure what this is for, what are we saving for castle??? //if (saver.castle != null){ castle.loadSnapshot(saver.castle); } }
void Update() { if (Time.timeScale == 0) { return; } if (!level_active) { return; } TIME += Time.deltaTime; if (current_timeScale == TimeScale.Pause) { return; } if (level_state == LState.WaveEnded)// || (level_state == LState.OnLastWavelet)) { if (Moon.Instance.GetCurrentWave() < Moon.Instance.GetWaveCount()) { if (Wave_interval > 0) { // Debug.Log("Next wave time " + next_wave_time + " wave_interval " + wave_interval + "\n"); next_wave_time = Mathf.Floor(TIME + Wave_interval); EagleEyes.Instance.WaveButton(true); EagleEyes.Instance.UpdateWaveTimer(next_wave_time - Mathf.Floor(TIME)); level_state = LState.WaitingToStartNextWave; } else if (monsters_transform.childCount <= 0) { EagleEyes.Instance.WaveButton(true); //don't do anything until the wave is actually over, see above EagleEyes.Instance.SetActiveFFButtons(false); level_state = LState.WaitingToStartNextWave; } } else if (level_active && monsters_transform.childCount <= 0 && (overseer == null || (overseer != null && overseer.ingame_finished == true))) { StartCoroutine(FinishLevel()); } // Debug.Log("Childcount " + monsters_transform.childCount + "\n"); } if (level_state == LState.WaveButton && Mathf.Floor(TIME) > next_wave_time) {//this is only for start of level I think EagleEyes.Instance.WaveButton(true); EagleEyes.Instance.SetActiveFFButtons(false); level_state = LState.WaitingToStartNextWave; } if (level_state == LState.WaitingToStartNextWave) { // Debug.Log("wave_interval " + Wave_interval + " TIME " + TIME + " next_wave_time " + next_wave_time + "\n"); if (Wave_interval > 0 && Mathf.Floor(TIME) > next_wave_time && !LevelBalancer.Instance.am_enabled) { StartWave(); // Debug.Log("Automatically Starting wave\n"); } else { EagleEyes.Instance.UpdateWaveTimer(next_wave_time - Mathf.Floor(TIME)); } } if (make_wave) { if (onWaveStart != null) { onWaveStart(Moon.Instance.GetCurrentWave()); } make_wave = false; // on_wave_start_trigger.OnSignal(); } if (health < 1) { Debug.Log("YOU LOST\n"); Noisemaker.Instance.Play("lost_game"); Central.Instance.changeState(GameState.Lost); level_state = LState.Lost; level_active = false; ChangeTime(TimeScale.Pause); } }
public StringEntry(GenericReader reader) { m_State = (LState)reader.ReadEncodedInt(); m_Number = reader.ReadInt(); m_Text = reader.ReadString(); }
public StringEntry( int number, LState state, string text ) { m_State = state; m_Number = number; m_Text = text; }
public StringEntry( GenericReader reader ) { m_State = (LState)reader.ReadEncodedInt(); m_Number = reader.ReadInt(); m_Text = reader.ReadString(); }