/// <summary> /// 保存 /// </summary> /// <param name="request"></param> /// <returns></returns> public bool SaveDangerZone(SaveDangerZone request) { using (var db = DbFactory.Open()) { var info = new DangerZone(); info.adcd = request.adcd; info.DangerZoneName = request.name; var log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; var logList = new List <operateLog>(); if (request.id != 0) { var model = GetDangerZoneById(request.id); if (model == null) { throw new Exception("该类型不存在"); } info.Id = request.id; log.operateMsg = "编辑id为:" + request.id + "原类型为:" + info.DangerZoneName + ",现类型为:" + request.name + "的危险点类型数据"; logList.Add(log); info.operateLog = JsonTools.ObjectToJson(logList); return(db.Update(info) == 1); } else { log.operateMsg = "新增类型为:" + request.name + "的危险点类型数据"; logList.Add(log); info.operateLog = JsonTools.ObjectToJson(logList); return(db.Insert(info) == 1); } } }
public Camera3D(DangerZone pParent) { m_pParent = pParent; m_fAspectRation = m_pParent.GraphicsDevice.Viewport.AspectRatio; m_pView = Matrix.CreateLookAt(m_pPosition, m_pLookAt, new Vector3(0, 1, 0)); m_pProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(m_fFieldOfView), m_fAspectRation, 0.1f, 10000.0f); }
public TitleScreen(DangerZone pParent) : base(pParent) { #if WINDOWS WebCoreConfig pConfig = new WebCoreConfig(); pConfig.EnableJavascript = true; //WebCore.Initialize(pConfig, true); this.Parent.IsMouseVisible = true; m_pWebView = WebCore.CreateWebView(800, 600); { m_pWebView.LoadURL("http://www.google.com"); //Content\\Editor\\index.html while (m_pWebView.IsLoadingPage) WebCore.Update(); m_pWebView.Render().SaveToPNG("result.png", true); /* * Här kan vi då kanske ladda in filen? */ } //WebCore.Shutdown(); #endif }
public MainMenuScreen(DangerZone pParent) : base(pParent) { m_pParent = pParent; }
void Start() { danger = dangerZone.GetComponent <DangerZone>(); leftLimit = danger.transform.position.x - danger.sizeX / 2 + 0.5f; rightLimit = danger.transform.position.x + danger.sizeX / 2 - 0.5f; }
public Screen(DangerZone pParent) { m_pParent = pParent; }
public GameplayScreen(DangerZone pParent) : base(pParent) { }
public LoadingScreen(DangerZone pParent) : base(pParent) { }
public GameOverScreen(DangerZone pParent) : base(pParent) { m_pParent = pParent; }
// The center of the AI - get an action override public List <WorldAction> GetAction(World world) { // The immediate action comes from level 1 WorldAction bestAction = WorldAction.NoAction; // Update level 1 heuristic parameters World.Player player = playerNum == 1 ? world.Player1 : world.Player2; // Calculate new level 1 action if timer is up if (decisionTimer <= 0) { ActionWithFiller decision = level1Searcher.ComputeBestAction(world, fillerAction, strategy.NextPathIndex); bestAction = decision.Action; fillerAction = decision.FillerAction; decisionTimer = Level1StepSize; // Otherwise do the filler action } else { bestAction = fillerAction; // Check distance to path bool doneWithPath = false; if (strategy.SearchPath != null) { doneWithPath = strategy.NextPathIndex >= strategy.SearchPath.States.Count - 1; } // Calculate the path if this frame has been designated to it if (calculatePathNextFrame) { // Run A* Path path = level2Searcher.ComputeBestPath(blockWorld); // Must be set before using the level 1 heuristic with a path strategy.SearchPath = path; strategy.NextPathIndex = 0; calculatePathNextFrame = false; // If no path is able to be calculated, then check again sooner than normal if (path == null) { strategyTimer = NoPathFoundRefreshTimer; } } else { // Compute a new strategy if the old one is no longer valid SimplifiedWorld currentState = new SimplifiedWorld(world, playerNum); if (isFirstTime || !previousState.IsEquivalent(currentState) || doneWithPath || dangerZoneShifted(world) || playerLeftPath(world, strategy.SearchPath) || strategyTimer <= 0 || world.IsTerminal()) { if (isFirstTime) { previousState = currentState; } isFirstTime = false; // Get reward and update QValues if learning if (IsLearning) { float reward = SimplifiedWorld.Reward(previousState, strategy.Type, currentState); QLearner.UpdateQValue(previousState, strategy.Type, currentState, reward); // Don't learn once world is terminal if (world.IsTerminal()) { IsLearning = false; } } // Get a new strategy StrategyType newStrategy = QLearner.GetStrategy(currentState); #if STRATEGY_PRINT Debug.Log("Player " + playerNum.ToString() + " selects strategy: " + newStrategy.ToString()); #endif strategy = Strategy.StrategyWithType(playerNum, newStrategy); level1Searcher = new DiscreteAdversarialSearch(playerNum, strategy.Level1Heuristic, getFillerAction, getNewPathIndex, Level1StepSize, 4); level2Searcher = new AStar(Level2MaxNodesInPrioQueue, Level2MaxExpansions, strategy.Level2CostFunction, strategy.Level2GoalFunction, strategy.Level2HeuristicFunction); // Create block world and danger zone blockWorld = new BlockWorld(playerNum, world); // Recalc danger zone dangerZone = new DangerZone(opponentNum, world, blockWorld); // Must be set before using the level 2 reward, cost, and goal functions strategy.Level2DangerZone = dangerZone; // Calculate the path in the next frame calculatePathNextFrame = true; // Speeds up framerate after player has died if (world.IsTerminal()) { calculatePathNextFrame = false; } // Reset previous state previousState = currentState; strategyTimer = MaxStrategyTime; } } // Debug rendering of danger zone #if DANGER_RENDER dangerZone.Render(ResourceScript); dangerZone.RenderPlayerBeliefs(ResourceScript); #endif } // Advance path position strategy.NextPathIndex = getNewPathIndex(player, strategy.NextPathIndex); decisionTimer--; strategyTimer--; #if PATH_RENDER if (strategy.SearchPath != null) { strategy.SearchPath.Render(ResourceScript, strategy.NextPathIndex); } #endif // Return a single-valued list with the best action return(new List <WorldAction>() { bestAction }); }
public HighScoreScreen(DangerZone pParent) : base(pParent) { }
void Generate() { int currentTotalLength = 0; int zoneLength = 0; for (int i = 0; i < totalZoneAmount; i++) { if (i % 2 == 0) { zoneLength = UnityEngine.Random.Range(minSafeZoneLength, maxSafeZoneLength + 1); float initialZ; if (i == 0) { initialZ = firstZoneZ; zoneLength++; currentTotalLength--; } else { initialZ = initialZoneZ + currentTotalLength; if (i == totalZoneAmount - 1) { zoneLength += lastZoneExtraLength; } } zones.Add(Instantiate(safeZonePrefab, transform)); SafeZone newZone = zones[zones.Count - 1].GetComponent <SafeZone>(); if (newZone) { newZone.Initialize(initialZoneX, initialZ, levelWidth, zoneLength); } } else { zoneLength = UnityEngine.Random.Range(minBaseDangerZoneLength, maxBaseDangerZoneLength + 1) + currentLevel; DangerZoneSO newZoneSO = dangerZoneSOs[UnityEngine.Random.Range(0, dangerZoneSOs.Count)]; zones.Add(Instantiate(newZoneSO.prefab, transform)); DangerZone newZone = zones[zones.Count - 1].GetComponent <DangerZone>(); if (newZone) { newZone.Initialize(initialZoneX, initialZoneZ + currentTotalLength, levelWidth, zoneLength); newZone.SetType(newZoneSO.type); newZone.SetObstacleValues(newZoneSO.minObstacleGenerationTime, newZoneSO.maxObstacleGenerationTime, newZoneSO.minObstacleSpeed, newZoneSO.maxObstacleSpeed); newZone.SetListElements(newZoneSO.tilePrefabs, newZoneSO.obstaclePrefabs); if (newZoneSO.type == DangerZoneTypes.Water) { newZone.SetWaterZoneTriggerPrefab(waterZoneTriggerPrefab); } } } currentTotalLength += zoneLength; } GameObject levelEndTrigger = Instantiate(levelEndTriggerPrefab, transform); Vector3 size = levelEndTrigger.GetComponent <BoxCollider>().size; size.x = levelWidth; levelEndTrigger.GetComponent <BoxCollider>().size = size; Vector3 position = levelEndTrigger.transform.position; position.z = currentTotalLength - zoneLength - 1f - tileOffset; levelEndTrigger.transform.position = position; }
public OptionsScreen(DangerZone pParent) : base(pParent) { m_pParent = pParent; }