void Start() { GameplayData.Setup(); world1InfoDisplay.Setup(); world2InfoDisplay.Setup(); }
public static GameplayData Load(string name) { Debug.Log("LOADING"); if (File.Exists(GetFilePath(name))) { try { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(GetFilePath(name), FileMode.Open); GameplayData loadedGame = (GameplayData)bf.Deserialize(file); file.Close(); return(loadedGame); } catch (SystemException e) { Debug.LogError(e); return(null); } } else { Debug.LogError("File doens't exit"); return(null); } }
internal void UpdatePlayerRemainingMovement(ActorData actor, bool send = true) { ActorTurnSM turnSm = actor.gameObject.GetComponent <ActorTurnSM>(); ActorController actorController = actor.gameObject.GetComponent <ActorController>(); ActorMovement actorMovement = actor.GetActorMovement(); float movementCost = GetActorMovementCost(actor, out float lastStepCost); bool cannotExceedMaxMovement = GameplayData.Get()?.m_movementMaximumType == GameplayData.MovementMaximumType.CannotExceedMax; List <ActorTargeting.AbilityRequestData> abilityRequest = actor.TeamSensitiveData_authority.GetAbilityRequestData(); bool abilitySet = !abilityRequest.IsNullOrEmpty() && abilityRequest[0].m_actionType != AbilityData.ActionType.INVALID_ACTION; actor.RemainingHorizontalMovement = actorMovement.CalculateMaxHorizontalMovement() - movementCost; actor.RemainingMovementWithQueuedAbility = abilitySet ? actor.RemainingHorizontalMovement : actorMovement.CalculateMaxHorizontalMovement(true) - movementCost; actor.QueuedMovementAllowsAbility = abilitySet || (cannotExceedMaxMovement ? actor.RemainingMovementWithQueuedAbility >= 0 : actor.RemainingMovementWithQueuedAbility + lastStepCost > 0); Log.Info($"UpdatePlayerMovement: Basic: {actor.m_postAbilityHorizontalMovement}/{actor.m_maxHorizontalMovement}, +", $"Remaining: {actor.RemainingMovementWithQueuedAbility}/{actor.RemainingHorizontalMovement}, " + $"Movement cost: {movementCost}, Ability set: {abilitySet}, Ability allowed: {actor.QueuedMovementAllowsAbility}, " + $"Movement max type: {GameplayData.Get()?.m_movementMaximumType}"); actorMovement.UpdateSquaresCanMoveTo(); if (send) { actorController.CallRpcUpdateRemainingMovement(actor.RemainingHorizontalMovement, actor.RemainingMovementWithQueuedAbility); } }
public SharedData(PhysicsObjectsFactory objectsFactory, GameplayData gameplayData, PhysicsData physicsData, RenderData renderData, KeyState keys) { ObjectsFactory = objectsFactory; GameplayData = gameplayData; PhysicsData = physicsData; RenderData = renderData; Keys = keys; }
public static GameplayData Create() { GameplayData asset = ScriptableObject.CreateInstance <GameplayData> (); AssetDatabase.CreateAsset(asset, "Assets/GameDataFiles/GameplayData.asset"); AssetDatabase.SaveAssets(); return(asset); }
public void DeleteMap() { if (selectedSavedGame != null) { GameplayData.Delete(selectedSavedGame.saveName); ClearGrid(); FetchGrid(); selectedSavedGame = null; } }
public void Setup() { WorldData worldData = GameplayData.GetWorldData(worldID); int bonusCount = BonusCollectableList.GetWorldCollectedCount(worldID); moonCountDisplay.text = bonusCount.ToString() + "/" + worldData.moonMax.ToString(); collectableCountDisplay.text = "x" + worldData.collectCount; }
private void UpdateData() { PlayerHealth.SaveHealth(); PlaytimeData.finishedStages++; CollectableDisplay.instance.SaveScore(); BonusCollectableManager.SaveCollectedStates(); WorldData worldData = GameplayData.GetWorldData(); worldData.collectCount = CollectableDisplay.instance.Score; }
public void OnLoadButtonClicked() { if (selectedSavedGame != null) { Debug.Log("Load " + selectedSavedGame.saveName); NextShiftLoaderData data = new NextShiftLoaderData(GameplayData.Load(selectedSavedGame.saveName)); SceneSwitcher.Singleton.PrepareToLoadLevel(data); } }
// public class ObserverMessage : MessageBase // { // public Replay.Message Message; // // public override void Serialize(NetworkWriter writer) // { // GeneratedNetworkCode._WriteMessage_Replay(writer, this.Message); // } // // public override void Deserialize(NetworkReader reader) // { // this.Message = GeneratedNetworkCode._ReadMessage_Replay(reader); // } // } public void LaunchGame(bool spawnObjects = true) { MapLoader = new AssetLoader(); MapLoader.LoadAssetBundle("Bundles/scenes/maps.bundle"); MapLoader.LoadAsset( $"archive:/buildplayer-robotfactory_opu_gamemode/buildplayer-{GameConfig.Map.ToLower()}"); MapLoader.ConstructCaches(); AssetsLoader = new AssetLoader(); AssetsLoader.LoadAsset("resources.assets"); AssetsLoader.ConstructCaches(); MiscLoader = new AssetLoader(); MiscLoader.LoadAssetBundle("Bundles/scenes/frontend.bundle"); MiscLoader.LoadAsset("archive:/buildplayer-options_ui/buildplayer-clientenvironmentsingletons"); MiscLoader.ConstructCaches(); if (!spawnObjects) { return; } SpawnObject(MiscLoader, "ApplicationSingletonsNetId", out _); SpawnObject(MiscLoader, "GameSceneSingletons", out var gameSceneSingletons); TheatricsManager = gameSceneSingletons.GetComponent <TheatricsManager>(); AbilityModManager = gameSceneSingletons.GetComponent <AbilityModManager>(); SpawnObject(MiscLoader, "SharedEffectBarrierManager", out SharedEffectBarrierManager); SpawnObject(MiscLoader, "SharedActionBuffer", out SharedActionBuffer); SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.Done; SpawnScene(MapLoader, 1, out var commonGameLogic); InterfaceManager = commonGameLogic.GetComponent <InterfaceManager>(); GameFlow = commonGameLogic.GetComponent <GameFlow>(); // MatchLogger = commonGameLogic.GetComponent<MatchLogger>(); ServerCombatManager = commonGameLogic.GetComponent <ServerCombatManager>(); ServerEffectManager = commonGameLogic.GetComponent <ServerEffectManager>(); TeamStatusDisplay = commonGameLogic.GetComponent <TeamStatusDisplay>(); ServerActionBuffer = commonGameLogic.GetComponent <ServerActionBuffer>(); TeamSelectData = commonGameLogic.GetComponent <TeamSelectData>(); BarrierManager = commonGameLogic.GetComponent <BarrierManager>(); SpawnObject <Board, Board>(MapLoader, out Board); SpawnScene(MapLoader, 2, out BrushCoordinator); SpawnScene(MapLoader, 3, out var sceneGameLogic); GameFlowData = sceneGameLogic.GetComponent <GameFlowData>(); GameplayData = sceneGameLogic.GetComponent <GameplayData>(); SpoilsManager = sceneGameLogic.GetComponent <SpoilsManager>(); ObjectivePoints = sceneGameLogic.GetComponent <ObjectivePoints>(); SpawnPointManager = sceneGameLogic.GetComponent <SpawnPointManager>(); MatchObjectiveKill = sceneGameLogic.GetComponent <MatchObjectiveKill>(); DumpNetObjects(); }
public void LoadGameState() { GameplayData gameplayData = SaveLoadSystem_JamieG.LoadGameplay(); // Load enemies GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); foreach (var enemy in enemies) { if (!gameplayData.m_enemyIds.Contains(enemy.name)) { enemy.SetActive(false); } } }
private void FetchGrid() { savedGames = GameplayData.GetMapsInDirectory(); Debug.Log("maps count in directory -> " + savedGames.Length); for (int i = 0; i < savedGames.Length; i++) { Button button = Instantiate(buttonPrefab, grid).GetComponent <Button>(); SavedGameSelector gameSelector = button.gameObject.AddComponent <SavedGameSelector>(); gameSelector.saveName = savedGames[i]; gameSelector.loadGameMenu = this; } }
private void Start() { if (SceneSwitcher.Singleton.sceneLoaderData != null && SceneSwitcher.Singleton.sceneLoaderData.GetType() == typeof(NextShiftLoaderData)) { NextShiftLoaderData data = SceneSwitcher.Singleton.sceneLoaderData as NextShiftLoaderData; title.text += data.gameplayData.progressData.shiftsPassed; minedShale.text = data.gameplayData.progressData.totalShaleMined.ToString(); targetShaleAmount.text = data.gameplayData.scenarioData.goal.targetShaleAmount.ToString(); shiftsRemaining.text = (data.gameplayData.scenarioData.goal.numberOfShifts - data.gameplayData.progressData.shiftsPassed).ToString() + " out of " + data.gameplayData.scenarioData.goal.numberOfShifts; scenarioDone = data.gameplayData.progressData.shiftsPassed == data.gameplayData.scenarioData.goal.numberOfShifts; _data = data.gameplayData; } }
public void EndShift() { LevelScenarioData scenarioData = ScenarioProgressController.Singleton.scenarioData; LevelProgressData progressData = ScenarioProgressController.Singleton.progressData; progressData.shiftsPassed++; MapData mapData = new MapData(scenarioData.name, BlockGridController.Singleton.grid); GameplayData gameplayData = new GameplayData( "Saved Game - " + scenarioData.name + " - Shift #" + (progressData.shiftsPassed + 1) + " - " + DateTime.Now.ToString("MM-dd-yyyy--HH-mm-ss"), mapData, scenarioData, progressData ); SceneSwitcher.Singleton.ToResultsScene(new NextShiftLoaderData(gameplayData)); }
public GameStartup() { const float dt = 1 / 60f; ClientSize = new Size(900, 720); DoubleBuffered = true; keys = new KeyState(); world = new EcsWorld(); worldEvents = new EcsWorld(); worldConstraints = new EcsWorld(); gameplayData = new GameplayData(new Vector2(0, -9.80665f)); physicsData = new PhysicsData(dt, 10, 4, 2); renderData = new RenderData(ClientSize.Width, ClientSize.Height, 60f); var sharedData = new SharedData(new PhysicsObjectsFactory(world, worldConstraints), gameplayData, physicsData, renderData, keys); gameplaySystems = new EcsSystems(world, sharedData); gameplaySystems .AddWorld(worldEvents, PhysicsWorldNames.Events) .AddWorld(worldConstraints, PhysicsWorldNames.Constraints) .Add(new InitEnvironment()) // .Add(new CreateSegments()) .Add(new Grabber()) .Inject() .Init(); physicsSystems = new EcsSystems(world, physicsData); physicsSystems .AddWorld(worldEvents, PhysicsWorldNames.Events) .AddWorld(worldConstraints, PhysicsWorldNames.Constraints) // force generators .Add(new ApplyStaticGravity()) // custom one .Add(new UpdateSprings()) // apply forces .Add(new IntegratePoses()) // update bounding volumes .Add(new UpdateCirclesBV()) .Add(new UpdateMeshesBV()) // broad phase .Add(new BroadPhase()) // narrow phase .Add(new ContactTesterCircleCircle()) .Add(new ContactTesterCircleMesh()) .Add(new ContactTesterCircleSegment()) .Add(new ContactTesterMeshSegment()) .Add(new ContactTesterCircleAABox()) // solver phase .Add(new DynamicDefaultContactSolver <Dynamic, Dynamic>()) .Add(new StaticDefaultContactSolver <Dynamic, Static>()) // physics systems internally use PhysicsData, // but you can inject your own data for custom force generators .Inject(gameplayData) .Init(); renderSystems = new EcsSystems(world, sharedData); renderSystems .AddWorld(worldEvents, PhysicsWorldNames.Events) .AddWorld(worldConstraints, PhysicsWorldNames.Constraints) .Add(new DrawVelocities()) .Add(new DrawSegments()) .Add(new DrawMeshes()) .Add(new DrawAABoxes()) .Add(new DrawSprings()) // .Add(new DrawBoundingBoxes()) .Add(new RenderMeshesMassCenter()) .Inject(renderData) .Init(); var timer = new Timer(); timer.Interval = 16; timer.Tick += GameLoop; timer.Start(); }
/// <summary> /// Init this game and loads all the assets needed to receive players /// </summary> public void LaunchGame() { SetGameStatus(GameStatus.Launching); MapLoader = new AssetLoader(); MapLoader.LoadAssetBundle("Bundles/scenes/maps.bundle"); MapLoader.LoadAsset($"archive:/buildplayer-robotfactory_opu_gamemode/buildplayer-{GameConfig.Map.ToLower()}"); MapLoader.ConstructCaches(); AssetsLoader = new AssetLoader(); AssetsLoader.LoadAsset("resources.assets"); AssetsLoader.ConstructCaches(); MiscLoader = new AssetLoader(); MiscLoader.LoadAssetBundle("Bundles/scenes/frontend.bundle"); MiscLoader.LoadAsset("archive:/buildplayer-options_ui/buildplayer-clientenvironmentsingletons"); MiscLoader.ConstructCaches(); SpawnObject(MiscLoader, "ApplicationSingletonsNetId", out _); SpawnObject(MiscLoader, "GameSceneSingletons", out var gameSceneSingletons); TheatricsManager = gameSceneSingletons.GetComponent <TheatricsManager>(); AbilityModManager = gameSceneSingletons.GetComponent <AbilityModManager>(); SpawnObject(MiscLoader, "SharedEffectBarrierManager", out SharedEffectBarrierManager); SpawnObject(MiscLoader, "SharedActionBuffer", out SharedActionBuffer); SharedActionBuffer.Networkm_actionPhase = ActionBufferPhase.Done; SpawnScene(MapLoader, 1, out var commonGameLogic); InterfaceManager = commonGameLogic.GetComponent <InterfaceManager>(); GameFlow = commonGameLogic.GetComponent <GameFlow>(); MatchLogger = commonGameLogic.GetComponent <MatchLogger>(); ServerCombatManager = commonGameLogic.GetComponent <ServerCombatManager>(); ServerEffectManager = commonGameLogic.GetComponent <ServerEffectManager>(); TeamStatusDisplay = commonGameLogic.GetComponent <TeamStatusDisplay>(); ServerActionBuffer = commonGameLogic.GetComponent <ServerActionBuffer>(); TeamSelectData = commonGameLogic.GetComponent <TeamSelectData>(); BarrierManager = commonGameLogic.GetComponent <BarrierManager>(); SpawnObject <Board, Board>(MapLoader, out Board); SpawnScene(MapLoader, 2, out BrushCoordinator); SpawnScene(MapLoader, 3, out var sceneGameLogic); GameFlowData = sceneGameLogic.GetComponent <GameFlowData>(); GameplayData = sceneGameLogic.GetComponent <GameplayData>(); SpoilsManager = sceneGameLogic.GetComponent <SpoilsManager>(); ObjectivePoints = sceneGameLogic.GetComponent <ObjectivePoints>(); SpawnPointManager = sceneGameLogic.GetComponent <SpawnPointManager>(); MatchObjectiveKill = sceneGameLogic.GetComponent <MatchObjectiveKill>(); PrintAllNetworkGameObjects(); foreach (LobbyPlayerInfo playerInfo in TeamInfo.TeamPlayerInfo) { // We use the ReadyState here to indicate wheter a player or bot finished loading the match if (playerInfo.IsNPCBot) { playerInfo.ReadyState = ReadyState.Ready; // Bots are marked as ready as they don't have to load anything } else { playerInfo.ReadyState = ReadyState.Unknown; // Unknown means it is loading } } SetGameStatus(GameStatus.Launched); }
// Saves the current state of the game into the Gameplay.save file public static void SaveGameplay(int currentLevel, GameObject[] enemies, GameObject[] doors) { GameplayData gameplayData = new GameplayData(currentLevel, enemies, doors); SaveToFile(GameplayFile, gameplayData); }
public NextShiftLoaderData(GameplayData gameplayData) { this.gameplayData = gameplayData; }
private BoardSquarePathInfo BackOff(ActorData actor, BoardSquarePathInfo pathEnd, HashSet <GridPos> occupiedSquares) { if (actor == null) { Log.Error($"Backoff failed because actor is null!"); return(null); } Log.Info($"Calculating backoff for {actor.DisplayName}"); BoardSquare dest = pathEnd.prev?.square ?? pathEnd.square; if (occupiedSquares.Contains(dest.GetGridPosition())) { bool diagMovementAllowed = GameplayData.Get().m_diagonalMovement != GameplayData.DiagonalMovement.Disabled; List <BoardSquare> neighbours = new List <BoardSquare>(8); Queue <BoardSquare> candidates = new Queue <BoardSquare>(); candidates.Enqueue(pathEnd.square); while (candidates.Count > 0) { BoardSquare s = candidates.Dequeue(); if (!occupiedSquares.Contains(s.GetGridPosition())) { dest = s; break; } neighbours.Clear(); if (!diagMovementAllowed) { Board.Get().GetStraightAdjacentSquares(s.x, s.y, ref neighbours); } else { Board.Get().GetAllAdjacentSquares(s.x, s.y, ref neighbours); } neighbours.Sort(delegate(BoardSquare a, BoardSquare b) { return(dest.HorizontalDistanceInWorldTo(a).CompareTo(dest.HorizontalDistanceInWorldTo(b))); }); foreach (var n in neighbours) { if (n.IsBoardHeight()) { candidates.Enqueue(n); } } } } if (occupiedSquares.Contains(dest.GetGridPosition())) { Log.Error($"Backoff failed to find a free square for {actor.DisplayName}!"); } occupiedSquares.Add(dest.GetGridPosition()); BoardSquarePathInfo result = actor.GetActorMovement().BuildPathTo_IgnoreBarriers(pathEnd.square, dest); result.heuristicCost += pathEnd.heuristicCost; // not actually correct but shouldn't matter result.moveCost += pathEnd.moveCost; result.m_moverBumpedFromClash = true; return(result); }