void InitFightPanel() { Skinning.ResetSkin(selectedSkin); if (fightManager == null) { Debug.LogError(debuguableInterface.debugLabel + "FightManager component shouldn't be null. If we can't get scene references we can't do anything."); } EnemyBundle bundle = gameData.enemyContent.Find(item => { return(item.enemy == actualEnemy); }); CombatDialogue selectedCombat = bundle.combatDialogue; actualTutorial.Init(() => { fightManager.Init( useCheats, bundle.punchlines, bundle.shogunDialogue, audioProjectManager, () => { panelManager.JumpTo(GamePhase.CONSEQUENCES, () => consequencesManager = FindObjectOfType <ConsequencesManager>()); audioProjectManager.FadeMusicOut(1); } ); }); }
void LoadActionFunctions() { actionFunctions.Clear(); actionFunctions.Add( "INCREASE_ENERGY_CONSUMPTION_FOR_BUILDING", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception) { Throw("Impossible cast in " + args + "\n"); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); int amount = System.Convert.ToInt32(GetArgument(args, "amount")); ConsequencesManager.GenerateConsumptionModifier(block, amount, duration); } ); actionFunctions.Add( "INCREASE_MOOD_FOR_POPULATION", (args, context) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); int amount = System.Convert.ToInt32(GetArgument(args, "amount")); int eventId = ((ObjectInteger)context["_EVENT_ID"]).ToInt(); ConsequencesManager.GenerateMoodModifier(pop, amount, duration, eventId); } ); actionFunctions.Add( "INCREASE_FOOD_CONSUMPTION_FOR_POPULATION", (args, context) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); float amount = System.Convert.ToSingle(GetArgument(args, "amount")); ConsequencesManager.GenerateFoodConsumptionModifier(pop, amount, duration); } ); actionFunctions.Add( "DECREASE_FOOD_CONSUMPTION_FOR_POPULATION", (args, context) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); float amount = System.Convert.ToSingle(GetArgument(args, "amount")); ConsequencesManager.GenerateFoodConsumptionModifier(pop, -amount, duration); } ); actionFunctions.Add( "INCREASE_HOUSE_NOTATION", (args, context) => { House house = null; try { house = (House)context[GetArgument(args, "house")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } float amount = System.Convert.ToSingle(GetArgument(args, "amount")); int duration = System.Convert.ToInt32(GetArgument(args, "duration")); ConsequencesManager.ChangeHouseNotation(house, amount, duration); } ); actionFunctions.Add( "DECREASE_MOOD_FOR_POPULATION", (args, context) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); int amount = System.Convert.ToInt32(GetArgument(args, "amount")); int eventId = ((ObjectInteger)context["_EVENT_ID"]).ToInt(); ConsequencesManager.GenerateMoodModifier(pop, -amount, duration, eventId); } ); actionFunctions.Add( "ADD_FLAG_MODIFIER_ON_BUILDING_FOR_DURATION", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); string flagModifier = GetArgument(args, "flagModifier"); ConsequencesManager.ModifyFlag(block, flagModifier, duration); } ); actionFunctions.Add( "ADD_FLAG_ON_BUILDING_FOR_DURATION", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); string flag = GetArgument(args, "flag"); ConsequencesManager.GenerateTempFlag(block, flag, duration); } ); actionFunctions.Add( "ADD_FLAG_ON_BUILDING", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } string flag = GetArgument(args, "flag"); ConsequencesManager.GenerateFlag(block, flag); } ); actionFunctions.Add( "ADD_STATE_ON_BUILDING", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } State state = (State)System.Enum.Parse(typeof(State), GetArgument(args, "state")); ConsequencesManager.AddState(block, state); } ); actionFunctions.Add( "ADD_SETTLERS_TO_NEXT_WAVE", (args, context) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } int amount = System.Convert.ToInt32(GetArgument(args, "amount")); ConsequencesManager.AddSettlerBonusForNextWave(pop, amount); } ); actionFunctions.Add( "DESTROY_BUILDING", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } ConsequencesManager.DestroyBlock(block); } ); actionFunctions.Add( "CHANGE_BUILDING_SCHEME", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } BlockScheme scheme = null; try { scheme = (BlockScheme)context[GetArgument(args, "scheme")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } int id = System.Convert.ToInt32(GetArgument(args, "id")); BlockScheme into = GameManager.instance.library.GetBlockByID(id); ConsequencesManager.ConvertBlock(block, into); } ); actionFunctions.Add( "LAY_MULTIPLE_SCHEME_ON_POSITION", (args, context) => { BlockScheme scheme = null; try { scheme = (BlockScheme)context[GetArgument(args, "scheme")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } int amount = System.Convert.ToInt32(GetArgument(args, "amount")); Vector3Int position = ((ObjectPosition)context[GetArgument(args, "position")]).ToVector3Int(); ConsequencesManager.SpawnBlocksAtLocation(amount, scheme.ID, new Vector2Int(position.x, position.z)); } ); actionFunctions.Add( "LAY_SCHEME_ON_POSITION", (args, context) => { args = AddArgument(args, "amount:1"); actionFunctions["LAY_MULTIPLE_SCHEME_ON_POSITION"](args, context); } ); actionFunctions.Add( "REMOVE_FLAG_FROM_BUILDING", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } string flag = GetArgument(args, "flag"); ConsequencesManager.DestroyFlag(block, System.Type.GetType(flag)); } ); actionFunctions.Add( "REMOVE_FLAG_FROM_BUILDING_FOR_DURATION", (args, context) => { Block block = null; try { block = (Block)context[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } int duration = System.Convert.ToInt32(GetArgument(args, "duration")); string flag = GetArgument(args, "flag"); ConsequencesManager.DestroyFlagTemporarily(block, System.Type.GetType(flag), duration); } ); actionFunctions.Add( "GAME_OVER", (args, context) => { GameManager.instance.ExitToMenu(); } ); actionFunctions.Add( "TRIGGER_EVENT", (args, context) => { int eventId = System.Convert.ToInt32(GetArgument(args, "id")); GameManager.instance.eventManager.TriggerEvent(eventId); } ); actionFunctions.Add( "DECLARE_EVENT", (args, context) => { int eventId = System.Convert.ToInt32(GetArgument(args, "id")); context["_EVENT_ID"] = new ObjectInteger(eventId); } ); actionFunctions.Add( "DECLARE_ACHIEVEMENT", (args, context) => { int eventId = System.Convert.ToInt32(GetArgument(args, "id")); context["_ACHIEVEMENT_ID"] = new ObjectInteger(eventId); } ); actionFunctions.Add( "ECHO", (args, context) => { Debug.Log("[SCRIPT ECHO] " + args); } ); actionFunctions.Add( "UNLOCK_ACHIEVEMENT", (args, context) => { int achievementId = System.Convert.ToInt32(GetArgument(args, "id")); GameManager.instance.achievementManager.achiever.UnlockAchievement(achievementId); } ); }
void LoadDataFunctions() { dataFunctions.Clear(); dataFunctions.Add( "RANDOM_BUILDING", (args, ctx) => { int id = System.Convert.ToInt32(GetArgument(args, "id")); Block block = ConsequencesManager.GetRandomBuildingOfId(id); if (block == null) { Throw("Could not find any building of ID " + id.ToString()); } return(block); } ); dataFunctions.Add( "BUILDING_COUNT", (args, ctx) => { int id = System.Convert.ToInt32(GetArgument(args, "scheme_id")); int count = GameManager.instance.systemManager.AllBlocks.FindAll(o => o.scheme.ID == id).Count; return(new ObjectInteger(count)); } ); dataFunctions.Add( "MOOD", (args, ctx) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } return(new ObjectInteger(Mathf.RoundToInt(GameManager.instance.populationManager.GetAverageMood(pop)))); } ); dataFunctions.Add( "CITIZEN_COUNT", (args, ctx) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } return(new ObjectInteger(GameManager.instance.populationManager.populations[pop].citizens.Count)); } ); dataFunctions.Add( "RANDOM_HOUSE", (args, ctx) => { Population pop = GameManager.instance.populationManager.GetPopulationByCodename(GetArgument(args, "population")); if (pop == null) { List <string> pops = new List <string>(); foreach (Population existingPop in GameManager.instance.populationManager.populationTypeList) { pops.Add(existingPop.codeName); } Throw("Invalid population name :\n " + args + "\nPick one from the following : " + string.Join(", ", pops.ToArray())); } House house = ConsequencesManager.GetRandomHouseOf(pop); if (house == null) { Throw("Could not find house belonging to pop " + pop.codeName); } return(house); } ); dataFunctions.Add( "RANDOM_POSITION", (args, ctx) => { Vector2Int coords2D = GameManager.instance.gridManagement.GetRandomCoordinates(); Vector3Int coords = new Vector3Int(coords2D.x, GameManager.instance.gridManagement.minHeight, coords2D.y); return(new ObjectPosition() { x = coords.x, y = coords.y, z = coords.z }); } ); dataFunctions.Add( "SCHEME", (args, ctx) => { int id = System.Convert.ToInt32(GetArgument(args, "id")); BlockScheme scheme = GameManager.instance.library.GetBlockByID(id); if (scheme == null) { Throw("Invalid scheme id :" + id.ToString()); } return(scheme); } ); dataFunctions.Add( "BUILDING_FROM_HOUSE", (args, ctx) => { House house = null; try { house = (House)ctx[GetArgument(args, "house")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } return(house.block); } ); dataFunctions.Add( "POSITION_FROM_BUILDING", (args, ctx) => { Block block = null; try { block = (Block)ctx[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } return(new ObjectPosition() { x = block.gridCoordinates.x, y = block.gridCoordinates.y, z = block.gridCoordinates.z }); } ); dataFunctions.Add( "SCHEME_FROM_BUILDING", (args, ctx) => { Block block = null; try { block = (Block)ctx[GetArgument(args, "building")]; } catch (System.Exception e) { Throw("Impossible cast in " + args + "\n" + e.ToString()); } return(block.scheme); } ); }