public MainFrm() { InitializeComponent(); Directory.SetCurrentDirectory(Application.StartupPath); sqlMgr = new SQLiteMgr(Environment.CurrentDirectory, "twz", typeof(TWZDData)); strokeMgr = new StrokeMgr("", pictureBox1); watch = new Stopwatch(); rand = new Random(); winTimer = new System.Timers.Timer((double)(Variable.AlertIntervalMin * 60 * 1000)); taskTimer = new System.Timers.Timer(50.0); winTimer.Elapsed += new ElapsedEventHandler(OnAlert); taskTimer.Elapsed += new ElapsedEventHandler(DoAllTask); winTimer.Enabled = true; frmState = MainFrm.WinState.Halt; appIcon = (Environment.OSVersion.Version.Major <= 5) ? Resources.彩色 : Resources.黑白; Opacity = 0.0; notifyIcon1.Icon = appIcon; GetConfig(); CVDllImport.CVInit(); //鼠标穿透 //int WS_EX_APPWINDOW = 0x00040000; long STYLE = CVDllImport.GetWindowLong(Handle, -20); long WS_EX_TOOLWINDOW = 0x00000080; long WS_EX_TRANSPARENT = 0x00000020; CVDllImport.SetWindowLong(Handle, -20, STYLE | 0x80000 | (WS_EX_TRANSPARENT) | WS_EX_TOOLWINDOW); }
/// <summary> /// Nastavuje stav okna a nastavuje hodnotu State /// </summary> /// <param name="newState">Hodnota stavu k nastaveni</param> public void SetState( WinState newState ) { switch( newState ) { case WinState.Offline: HostBtn.Content = "Host a server"; ConnectBtn.Content = "Connect to host"; SetStateAll( true ); SetState( true, "OFFLINE", Colors.Red ); break; case WinState.Connected: ConnectBtn.Content = "Disconnect"; SetStateAll( true ); HostBtn.IsEnabled = false; SetState( false, "CONNECTED", Colors.LawnGreen ); break; case WinState.Hosting: HostBtn.Content = "Stop server"; SetStateAll( true ); ConnectBtn.IsEnabled = false; SetState( false, "HOSTING", Colors.DarkCyan ); break; case WinState.InMiddle: SetStateAll( false ); break; } State = newState; }
public MineField(int rows, int columns, int mineCount) { if (rows < 1) { throw new ArgumentOutOfRangeException("rows"); } if (columns < 1) { throw new ArgumentOutOfRangeException("columns"); } if (mineCount < 1 || mineCount >= rows * columns) { throw new ArgumentOutOfRangeException("mineCount"); } _rows = rows; _columns = columns; _mineCount = mineCount; _clearedCount = 0; _squareCount = _rows * _columns; _state = WinState.Unknown; bool[] live = new bool[_squareCount]; Random rnd = new Random(); int ith; for (int i = 0; i < _mineCount; i++) { ith = rnd.Next(_squareCount - i); for (int j = 0; j < _squareCount; j++) { if (live[j] == false) { if (ith == 0) { live[j] = true; break; } ith--; } } } _squares = new List<Square>(); int index; Square square; for (int y = 0; y < _rows; y++) { for (int x = 0; x < _columns; x++) { index = y * _columns + x; square = new Square(this, y, x, live[index]); square.PropertyChanged += new PropertyChangedEventHandler(square_PropertyChanged); _squares.Add(square); } } }
public void Awake() { CheckSpecial = new CheckSpecialState(this); CreateNew = new CreateNewState(this); RemoveState = new RemoveCombinationState(this); GameOverState = new GameOverState(this); WinState = new WinState(this); FieldState = new Field(this); //PauseState = new PauseState(this); }
private void Lost() { State = WinState.Lost; foreach (var s in from sq in _squares where sq.IsMine && sq.State != SquareState.Flagged select sq) { s.State = SquareState.Exposed; } }
public void Can_detect_draw(IBoardGrid boardGrid, WinState expectedWinState) { var actualWinState = boardGrid.GetWinState(); Assert.False(boardGrid.HasWinner()); Assert.Null(actualWinState.Winner); Assert.Equal(expectedWinState.Method, actualWinState.Method); Assert.Equal(expectedWinState.HasWinner, actualWinState.HasWinner); Assert.Equal(expectedWinState.Winner, actualWinState.Winner); }
private void ChangeElement(int id) { myChoice = id - 1; for (int i = 0; i < 5; i++) { vRegion.SetRegionEffect(i + 1, RegionEffect.Free); } vRegion.SetRegionEffect(id, RegionEffect.Rectangled); state = WinState.None; Invalidate(new Rectangle(xoff, yoff, 324, 244)); }
public void Can_detect_winner(string useCase, IBoardGrid boardGrid, WinState expectedWinState) { var actualWinState = boardGrid.GetWinState(); Assert.True(boardGrid.HasWinner()); Assert.NotNull(actualWinState.Winner); Assert.Equal(expectedWinState.Method, actualWinState.Method); Assert.Equal(expectedWinState.HasWinner, actualWinState.HasWinner); Assert.Equal(expectedWinState.Winner, actualWinState.Winner); }
public uint Style; //If set to custom borderstyle, the style will be set here. public ProgramSettings(string file, string NiceName) { Filepath = file; FileName = NiceName; //Some defaults Borderstyle = BorderStyle.SIZABLE; WindowState = WinState.NORMAL; Style = 382664704; Enabled = false; }
public static void Intitialize(TrackBar VolumeBar, Form Main, Button Pinned, Button Fullscr) { VolumeBar.Value = defVolume_P; if (defFullscreen_P == true) { WinState.FullScreen(Main, Fullscr); } if (defPined_P == true) { WinState.TogglePin(Main, Pinned); } }
public ProgramSettings(string file, string NiceName) { Filepath = file; FileName = NiceName; //Some defaults Borderstyle = BorderStyle.SIZABLE; WindowState = WinState.NORMAL; Style = 382664704; Enabled = false; }
private void Won() { #if DEBUG Debug.Assert(State == WinState.Unknown); foreach (var square in from s in _squares where !s.IsMine select s) { Debug.Assert(square.State == SquareState.Exposed); } #endif State = WinState.Won; }
void Awake() { // Singleton logic: if (Instance == null) { Instance = this; } else { this.enabled = false; return; } }
public void EndOfGameReaction(WinState winState) { string spectatorReaction; switch (winState) { case WinState.Loss: spectatorReaction = "sad"; audioSource.clip = reactionClips[2]; audioSource.Play(); break; case WinState.Win: spectatorReaction = "cheer"; audioSource.clip = reactionClips[0]; audioSource.Play(); break; case WinState.Neutral: spectatorReaction = "look"; audioSource.clip = reactionClips[1]; audioSource.Play(); break; default: spectatorReaction = "look"; audioSource.clip = reactionClips[1]; audioSource.Play(); break; } ///check for each spectator if they have the appropriate animation and if yes, start their coroutine loop foreach (Spectator spectator in spectators) { foreach (AnimatorControllerParameter param in spectator.anim.parameters) { if (param.name == spectatorReaction) { StartCoroutine(spectator.Reaction(spectatorReaction)); } } if (spectatorReaction != "cheer") { spectator.anim.SetBool("sadFace", true); } else if (spectatorReaction == "cheer") { spectator.anim.SetBool("sadFace", false); } } }
void OnGUI() { EditorGUILayout.HelpBox("请确保当前场景已经保存,否则没保存的资源将无法被搜索到!", MessageType.Warning); switch (m_CurWinState) { case WinState.InitState: OnInitState(); break; case WinState.StartState: OnStartState(); if (GUILayout.Button("合并重复贴图", GUILayout.Height(40))) { if (m_MaterialPathList.Count > 0) { for (int i = 0; i < m_SelectedStrPath.Count; ++i) { if (m_SelectedStrPath[i].Contains(".png")) { Object obj = AssetDatabase.LoadAssetAtPath(m_SelectedStrPath[i], typeof(Object)) as Object; Selection.activeObject = obj; string message = "所有的材质都将引用这个纹理:" + m_SelectedStrPath[i] + " ,将删除其他纹理"; if (EditorUtility.DisplayDialog("删除重复资源", message, "确定", "取消")) { DeleteRes(m_SelectedStrPath[i]); Debug.Log("EditorUtility.DisplayDialog"); break; } else { break; } } } } } m_CurWinState = WinState.StartState; break; case WinState.FinishState: { } break; } if (GUILayout.Button("刷新", GUILayout.Height(40))) { m_CurWinState = WinState.InitState; } }
// 窗口初始化操作 private void OnInitState() { EditorGUILayout.HelpBox("查找/替换 目录名,文件名,只搜索以下目录:Assets/Art/Characters", MessageType.Info); // 绘制替换文本输入框 GUILayout.BeginHorizontal(); Replace1 = EditorGUILayout.TextField("要替换的文本:", Replace1); if (GUILayout.Button("开始搜索", GUILayout.Width(100))) { curWinState = WinState.StartState; ShowNotification(new GUIContent("注意:区分大小写,否则无法完成替换操作!")); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); }
public override void Update() { if (this.menu is SleepAndDeathScreen) { orig_Update(); } else { //Created Delegate to call base.Update Type[] constructorSignature = new Type[0]; RuntimeMethodHandle handle = typeof(Menu.PositionedMenuObject).GetMethod("Update").MethodHandle; RuntimeHelpers.PrepareMethod(handle); IntPtr ptr = handle.GetFunctionPointer(); Action funct = (Action)Activator.CreateInstance(typeof(Action), this, ptr); funct(); //PositionedMenuObject.Update this.lastBlackFade = this.blackFade; if (this.blackFade > 0f) { this.blackFade = Mathf.Min(1f, this.blackFade + 0.025f); } if (this.addPassageButtonWhenTokenBecomesVisible) { bool flag = true; for (int i = 0; i < this.tokens.Count; i++) { if (this.tokens[i].endgameMeter.fullfilledNow && this.tokens[i].endgameMeter.showAsFullfilled < 0.9f) { flag = false; } } if (flag) { (this.menu as MultiplayerSleepAndDeathScreen).AddPassageButton(true); this.addPassageButtonWhenTokenBecomesVisible = false; } } if (this.pingAchivements && this.AllAnimationsDone) { this.pingAchivements = false; for (int j = 0; j < (this.menu as MultiplayerSleepAndDeathScreen).winState.endgameTrackers.Count; j++) { if (!(this.menu as MultiplayerSleepAndDeathScreen).winState.endgameTrackers[j].GoalAlreadyFullfilled && (this.menu as MultiplayerSleepAndDeathScreen).winState.endgameTrackers[j].GoalFullfilled) { this.menu.manager.CueAchievement(WinState.PassageAchievementID((this.menu as MultiplayerSleepAndDeathScreen).winState.endgameTrackers[j].ID), 6f); } } } } }
public async Task TellGameResult(WinState state, ICity city) { if (!cityToChat.ContainsKey(city)) { return; } var chatId = cityToChat[city]; switch (state) { case WinState.MafiaWins: await bot.SendTextMessageAsync(chatId, "Мафия победила"); break; case WinState.InProcess: await bot.SendTextMessageAsync(chatId, "Ничья"); break; case WinState.PeacefulWins: await bot.SendTextMessageAsync(chatId, "Мирные победили"); break; case WinState.PsychoWins: await bot.SendTextMessageAsync(chatId, "Все сошли с ума"); break; default: await bot.SendTextMessageAsync(chatId, "Technical problems"); break; } var mapMessage = new StringBuilder(); foreach (var person in city.Population) { mapMessage.Append($"{person.Name} was {(person.NightRole == null ? "Peaceful" : person.NightRole.Name)}\n"); } mapMessage.Append("\nType /play if you want restart\nLike this game? Share this bot!"); await bot.SendTextMessageAsync(chatId, mapMessage.ToString()); await bot.SendTextMessageAsync(chatId, "🍑"); }
public MineField(int rows = DefaultHeight, int columns = DefaultWidth, int mineCount = DefaultMineCount) { Contract.Requires(rows > 0); Contract.Requires(columns > 0); Contract.Requires(mineCount > 0 && mineCount <= rows * columns); _rows = rows; _columns = columns; _mineCount = mineCount; _clearedCount = 0; _squareCount = _rows * _columns; _state = WinState.Unknown; bool[] live = new bool[_squareCount]; Random rnd = Util.Rnd; int ith; for (int i = 0; i < _mineCount; i++) { ith = rnd.Next(_squareCount - i); for (int j = 0; j < _squareCount; j++) { if (live[j] == false) { if (ith == 0) { live[j] = true; break; } ith--; } } } var squares = new List<Square>(); for (int y = 0; y < _rows; y++) { for (int x = 0; x < _columns; x++) { var index = y * _columns + x; var square = new Square(this, y, x, live[index]); square.PropertyChanged += square_PropertyChanged; squares.Add(square); } } _squares = squares.ToReadOnlyCollection(); }
private void OnInitState() { // 1: 获取选中的对象 if (m_selectedObj == null) { m_selectedObj = Selection.activeObject; selectedStrPath = AssetDatabase.GetAssetPath(m_selectedObj); } if (m_selectedObj == null) { this.Close(); } // 2: 显示选中的对象的所有依赖项 // 2.1 显示纹理依赖 if (m_selectedObj.GetType() == typeof(Texture2D)) { FindTextureDepend(); } else if (m_selectedObj.GetType() == typeof(Material)) { FindMaterialDepend(); } else if (m_selectedObj.GetType() == typeof(GameObject)) { FindGameObjectDepend(); } else { if (EditorUtility.DisplayDialog("错误", "查看不了(" + m_selectedObj.GetType() + ")这种资源的依赖,如果需要请联系程序部!", "关闭")) { this.Close(); } else { this.Close(); } } // 更新win的Title标题 win.title = "使用了 " + m_selectedObj.name + " 的所有资源"; curWinState = WinState.StartState; #region 确定是否保存了场景 // 确定是否保存了场景 if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) { ShowNotification(new GUIContent("请确保当前场景已经保存,否则没保存的资源将无法被搜索到!")); } #endregion }
void OnInputState() { EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("请输入搜索路径", GUILayout.Width(120)); searchPath = EditorGUILayout.TextArea(searchPath); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("删除上次生成的文件", GUILayout.Height(30))) { curWinState = WinState.InitState; } EditorGUILayout.EndVertical(); }
public string GetWinnerString(WinState winner) { if (winner == WinState.P0) { return("1"); } else if (winner == WinState.P1) { return("2"); } else { return("Tie"); } }
public WinState checkWinstateDiagonalRightDown()//checks every combination of 4 cells horizontally in a diagonal going down-right, and calls checkWinStateOfCells on them. { for (int i = 0; i < pos.GetLength(0) - numNeededInRow + 1; i++) { for (int j = 0; j < pos.GetLength(1) - numNeededInRow + 1; j++) { WinState winstate = checkWinStateOfCells(pos[i + 3, j], pos[i + 2, j + 1], pos[i + 1, j + 2], pos[i, j + 3]); if (winstate != WinState.noWinner) { return(winstate); } } } return(WinState.noWinner); }
private WinState checkWinstateHorizontal()//checks every combination of 4 cells horizontally in a row, and calls checkWinStateOfCells on them. { for (int i = 0; i < pos.GetLength(0) - numNeededInRow + 1; i++) { for (int j = 0; j < pos.GetLength(1); j++) { WinState winstate = checkWinStateOfCells(pos[i, j], pos[i + 1, j], pos[i + 2, j], pos[i + 3, j]); if (winstate != WinState.noWinner) { return(winstate); } } } return(WinState.noWinner); }
private WinState checkWinstateVertical() //checks every combination of 4 cells vertically in a row, and calls checkWinStateOfCells on them. { for (int i = 0; i < pos.GetLength(0); i++) { for (int j = 0; j < pos.GetLength(1) - numNeededInRow + 1; j++) { WinState winstate = checkWinStateOfCells(pos[i, j], pos[i, j + 1], pos[i, j + 2], pos[i, j + 3]); if (winstate != WinState.noWinner) { return(winstate); } } } return(WinState.noWinner); // if no winner has been found in the entire loop, then there is no winner. }
private static bool DetermineWinner(int horizontalValue, int verticalValue, ref WinState winState) { if (horizontalValue == 3 || verticalValue == 3) { winState = WinState.CrossWin; return(true); } if (horizontalValue == -3 || verticalValue == -3) { winState = WinState.NoughtWin; return(true); } return(false); }
private void OnInitState() { m_MaterialPathList.Clear(); FindTextureDepend(); m_Win.title = "查找所有有多个 Texture 的 Matrial"; m_CurWinState = WinState.StartState; #region 确定是否保存了场景 // 确定是否保存了场景 if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) { ShowNotification(new GUIContent("请确保当前场景已经保存,否则没保存的资源将无法被搜索到!")); } #endregion }
public void EndRoundPhase() { WinState ws = IsWin(dealer.Hand, players[0].Hand); dealer.Hand.Cards.ForEach(x => x.IsHidden = false); outputProvider.SetCursorPosition(0, boardTop); PrintEndTableState(); outputProvider.WriteLine(); outputProvider.SetCursorPosition(0, boardTop + promptLine + 3); CheckWinstate(ws); dealer.ClearHand(); players.ForEach(x => x.ClearHand()); outputProvider.Freeze(); }
private void CheckWinstate(WinState ws) { switch (ws) { case WinState.win: PlayerWon(); break; case WinState.lose: PlayerLost(); break; case WinState.draw: PlayerDraw(); break; } }
private void SetFalseForRestartGame() { gageAmout = 0f; //how many slider value is oneTime = 0f; //one second for update seconds splashTime = 3f; WaitTime = 3.5f; prevSelectedCharacter = -1; //prev selected character number; selectedCharacter = 1; //선택 된 릭터 번호 oppSelectedCharacter = 1; //seleted opp character number sortingOrderNumber = 3; time = 180; //game time isSpacePressed = false; //space pressed or not isPlaying = false; winState = WinState.None; Game.Instance.roomManager.IsConnected = false; Game.Instance.roomManager.IsAlignment = false; }
public void OnPlayerLost(Player player) { var players = player.World.Players.Where(p => !p.NonCombatant); var enemies = players.Where(p => !p.IsAlliedWith(player)); if (Info.Cooperative) { WinStateCooperative = WinState.Lost; var allies = players.Where(p => p.IsAlliedWith(player)); if (allies.Any(p => p.PlayerActor.Trait <MissionObjectives>().WinStateCooperative == WinState.Lost)) { foreach (var p in allies) { p.WinState = WinState.Lost; p.World.OnPlayerWinStateChanged(p); } if (Info.EarlyGameOver) { foreach (var p in enemies) { p.WinState = WinState.Won; p.World.OnPlayerWinStateChanged(p); } } } } else { player.WinState = WinState.Lost; player.World.OnPlayerWinStateChanged(player); if (Info.EarlyGameOver) { foreach (var p in enemies) { p.WinState = WinState.Won; p.World.OnPlayerWinStateChanged(p); } } } CheckIfGameIsOver(player); }
// Start is called before the first frame update private void Start() { m_gameStateMachine = new GameStateMachine(); var splash = new SplashState(this, UIController.Instance.SplashPanel); var mainMenu = new MainMenuState(this, UIController.Instance.MainMenuPanel, UIController.Instance.MainMenuPlayButton); var tutorial = new TutorialState(this, UIController.Instance.TutorialPanel, UIController.Instance.TutorialDoneButton); var gameplay = new GamePlayState(this, UIController.Instance.GamePlayPanel); var win = new WinState(this, UIController.Instance.LevelCompletePanel, UIController.Instance.WinContinueButton); var fail = new FailState(this, UIController.Instance.LevelFailPanel, UIController.Instance.FailContinueButton); //Adding Transitions At(splash, mainMenu, CanShowMainMenu()); At(mainMenu, tutorial, CanPlayTutorial()); At(mainMenu, gameplay, CanPlayGame()); At(tutorial, gameplay, () => tutorial.HasTutorialFinished); At(gameplay, win, GameToWin()); At(gameplay, fail, GameToFail()); At(win, mainMenu, WinToMainMenu()); void At(IState from, IState to, Func <bool> condition) => m_gameStateMachine.AddTransition(from, to, condition); //Adding Conditions for Transitions Func <bool> CanShowMainMenu() => () => splash.HasSplashEnded; Func <bool> CanPlayGame() => () => mainMenu.HasPressedPlay && PlayerPrefs.GetInt(GameConstants.TutorialCompleted, 0) == 1; Func <bool> CanPlayTutorial() => () => mainMenu.HasPressedPlay && PlayerPrefs.GetInt(GameConstants.TutorialCompleted, 0) == 0; Func <bool> GameToWin() => () => gameplay.HasWon; Func <bool> GameToFail() => () => gameplay.HasLost; Func <bool> WinToMainMenu() => () => win.HasPressedContinue; //SetDefaultState m_gameStateMachine.SetState(splash); }
protected override void LoadContent() { Library.Player tempPlayer = new Library.Player { Type = Library.Player.ClassType.Wizard }; networkManager = new NetworkManager(tempPlayer); playerManager = new PlayerManager(networkManager); spriteBatch = new SpriteBatch(GraphicsDevice); AssetManager.LoadTextures(Content); mainMenu = new MainMenuState(Window); characterSelection = new CharacterSelectionState(Window, networkManager); lobby = new LobbyState(Window, networkManager, ref player, playerManager); gameOver = new WinState(Window); }
void OnGUI() { EditorGUILayout.HelpBox("请确保当前场景已经保存,否则没保存的资源将无法被搜索到!", MessageType.Warning); switch (curWinState) { case WinState.InitState: OnInitState(); break; case WinState.StartState: OnStartState(); break; } if (GUILayout.Button("刷新", GUILayout.Height(40))) { curWinState = WinState.InitState; } }
public void MakeMove(MoveDirection direction) { if (!IsMoveValid(direction)) { return; } switch (direction) { case MoveDirection.Up: boardState.robotPos.y--; break; case MoveDirection.Down: boardState.robotPos.y++; break; case MoveDirection.Left: boardState.robotPos.x--; break; case MoveDirection.Right: boardState.robotPos.x++; break; default: break; } switch (boardState.board[boardState.robotPos.x][boardState.robotPos.y]) { case TileType.Exit: winState = WinState.Win; break; case TileType.Mine: winState = WinState.Lose; break; default: break; } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); screen = new Point(1080, 920); ApplyResolutionSettings(); // TODO: use this.Content to load your game content here playingState = new PlayingState(); gameOverState = new GameOverState(); startState = new StartState(); winState = new WinState(); GameStateManager.AddGameState("playingstate", playingState); GameStateManager.AddGameState("gameOverState", gameOverState); GameStateManager.AddGameState("stateState", startState); gameStateManager.AddGameState("winState", winState); GameStateManager.SwitchTo("stateState"); }
public void ResetMap() { ClearAllCellState(); ScoreBlue = ScoreRed = 3; gems.ClearChildren(); Gems = new Gem[nRows, nCols]; AddGem(4, 0, Gem.Team.Blue); AddGem(16, 4, Gem.Team.Blue); AddGem(4, 8, Gem.Team.Blue); AddGem(0, 4, Gem.Team.Red); AddGem(12, 0, Gem.Team.Red); AddGem(12, 8, Gem.Team.Red); State = MapState.RedTurn; winState = WinState.None; }
public void GoWinRed() { winState = WinState.Red; }
public void GoWinBlue() { winState = WinState.Blue; }
private void Won() { #if DEBUG Debug.Assert(_state == WinState.Unknown); foreach (Square square in _squares) { if (!square.IsMine) { Debug.Assert(square.State == SquareState.Exposed); } } #endif this._state = WinState.Won; PropertyChanged(this, new PropertyChangedEventArgs(StatePropertyName)); }
private void Lost() { this._state = WinState.Lost; PropertyChanged(this, new PropertyChangedEventArgs(StatePropertyName)); foreach (Square s in _squares) { if (s.IsMine && s.State != SquareState.Flagged) { s.State = SquareState.Exposed; } } }
public void OnPlayerLost(Player player) { var players = player.World.Players.Where(p => !p.NonCombatant); var enemies = players.Where(p => !p.IsAlliedWith(player)); if (Info.Cooperative) { WinStateCooperative = WinState.Lost; var allies = players.Where(p => p.IsAlliedWith(player)); if (allies.Any(p => p.PlayerActor.Trait<MissionObjectives>().WinStateCooperative == WinState.Lost)) { foreach (var p in allies) { p.WinState = WinState.Lost; p.World.OnPlayerWinStateChanged(p); } if (Info.EarlyGameOver) foreach (var p in enemies) p.PlayerActor.Trait<MissionObjectives>().ForceDefeat(p); } } else { player.WinState = WinState.Lost; player.World.OnPlayerWinStateChanged(player); if (Info.EarlyGameOver) foreach (var p in enemies) { p.WinState = WinState.Won; p.World.OnPlayerWinStateChanged(p); } } CheckIfGameIsOver(player); }
void RaisePlayerWinEvent(PlayerWinState a_state) { CancelInvoke(); // Ignore attempts to raise player events, when a state has been already determined if (_winState != WinState.None) { Debug.LogWarning("Attempted to raise PlayerWin Event, but player win state has already been determined, ignoring..."); return; } // Notify listeners of event foreach (GameObject eventListener in _eventListeners) { ExecuteEvents.Execute<ISceneManagerEvents>(eventListener, null, (x, y) => x.OnPlayerWon(a_state)); } // Set win state to current event _winState = WinState.Win; }
/* void Awake() { if (!AffdexUnityUtils.ValidPlatform()) return; #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX detector = GetComponent<Detector>(); devices = WebCamTexture.devices; if(devices.Length > 0) { SelectCamera(isFrontFacing); if(device.name != "Null") { webcamTexture = new WebCamTexture(device.name, targetWidth, targetHeight, (int)sampleRate); webcamTexture.Play(); } } #endif } */ IEnumerator Start() { yield return Application.RequestUserAuthorization(UserAuthorization.WebCam); if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { Debug.Log("Has been Authorized"); winState = GameObject.Find("WinArea").GetComponent<WinState>(); winState.hasStarted = true; } else { Debug.Log("Has not been Authorized"); yield return null; } detector = GetComponent<Detector>(); devices = WebCamTexture.devices; if (devices.Length > 0) { SelectCamera(isFrontFacing); if (device.name != "Null") { webcamTexture = new WebCamTexture(device.name, targetWidth, targetHeight, (int)sampleRate); webcamTexture.Play(); } } }
void DoAllTask(object source, System.Timers.ElapsedEventArgs e) { switch (this.frmState) { case WinState.AlertIn: Invoke(new MethodInvoker(delegate() { panel1.Visible = false; panel1.BackColor = this.BackColor; //this.TransparencyKey = Color.White; frmOpacity = Variable.AlertOpacity * (watch.ElapsedMilliseconds / (Variable.FadeIntervalSec * 500.0)); if (frmOpacity >= Variable.AlertOpacity) { frmState = WinState.AlertOut; frmOpacity = Variable.AlertOpacity; watch.Reset(); watch.Start(); } })); break; case WinState.AlertOut: Invoke(new MethodInvoker(delegate() { frmOpacity = Variable.AlertOpacity - Variable.AlertOpacity * (watch.ElapsedMilliseconds / (Variable.FadeIntervalSec * 500.0)); if (frmOpacity <= 0) { frmState = WinState.PhraseIn; frmOpacity = 0; //this.TransparencyKey = this.BackColor; watch.Reset(); watch.Start(); } })); break; case WinState.PhraseIn: Invoke(new MethodInvoker(delegate() { label词语.Text = label词语.Text.Replace(currentChar, "_"); panel1.Visible = true; if (this.BackColor.B == 255) panel1.BackColor = Color.FromArgb(this.BackColor.ToArgb() - 1); else panel1.BackColor = Color.FromArgb(this.BackColor.ToArgb() + 1); //panel1.Height = label释义.Height + 96; frmOpacity = Variable.PhraseOpacity * (watch.ElapsedMilliseconds / (Variable.FadeIntervalSec * 1000.0)); if (frmOpacity >= Variable.PhraseOpacity) { frmState = WinState.Working; frmOpacity = Variable.PhraseOpacity; watch.Reset(); watch.Start(); if (camUsable) { taskTimer.Interval = 15; ThreadPool.QueueUserWorkItem(delegate { CVDllImport.CVStart(Variable.WebCamID.ToString()); }); } } })); break; case WinState.Working: Invoke(new MethodInvoker(delegate() { if (strokeMgr.Done || (watch.ElapsedMilliseconds > Variable.ShowIntervalMin * 60 * 1000)) { CVDllImport.CVQuit(); frmState = WinState.PhraseOut; taskTimer.Interval = 50; watch.Reset(); watch.Start(); } else { strokeMgr.OnDraw(); } })); break; case WinState.PhraseOut: Invoke(new MethodInvoker(delegate() { label词语.Text = label词语.Text.Replace("_", currentChar); frmOpacity = Variable.PhraseOpacity - Variable.PhraseOpacity * (watch.ElapsedMilliseconds / (Variable.FadeIntervalSec * 1000.0)); if (frmOpacity <= 0) { if (quitFlag) { Application.Exit(); } else { 退出ToolStripMenuItem.Enabled = true; 设置ToolStripMenuItem.Enabled = true; 预览ToolStripMenuItem.Text = "寫個字"; frmState = WinState.Halt; frmOpacity = 0; watch.Reset(); watch.Stop(); } } })); break; case WinState.Halt: Invoke(new MethodInvoker(delegate() { watch.Reset(); watch.Stop(); taskTimer.Enabled = false; })); break; default: break; } Invoke(new MethodInvoker(delegate() { Opacity = frmOpacity; })); }
private void PreAlert() { this.CheckCam(); MainFrm.frameCallBack = new FrameCallBack(this.OnData); MainFrm.quitCallBack = new QuitCallBack(this.OnQuit); CVDllImport.CVSetFrameEvent(MainFrm.frameCallBack); CVDllImport.CVSetQuitEvent(MainFrm.quitCallBack); testID = rand.Next(phraseCount << 4, phraseCount << 5) % phraseCount; //testID = 10; DataTable dtPhrase = sqlMgr.SelectFromTable("Phrase", "rowid", testID.ToString()); label词语.Text = (string)dtPhrase.Rows[0]["词语"]; label注音.Text = (string)dtPhrase.Rows[0]["注音"]; string temp = (string)dtPhrase.Rows[0]["释义"]; if (temp.Length > 50) { label释义.Text = temp.Substring(0, 50) + "..."; } else { label释义.Text = temp; } int pos = int.Parse((string)dtPhrase.Rows[0]["单字位置"]) - 1; currentChar = new string(label词语.Text[pos], 1); DataTable dtStroke = sqlMgr.SelectFromTable("StrokeOrder", "汉字", currentChar); strokeMgr = new StrokeMgr((string)dtStroke.Rows[0]["笔顺数据"], this.pictureBox1); pictureBox1.Image = null; pictureBox2.Image = null; this.Opacity = 0; if (!camUsable) { this.frmState = WinState.PhraseIn; } else { this.frmState = WinState.AlertIn; } 退出ToolStripMenuItem.Enabled = false; 设置ToolStripMenuItem.Enabled = false; 预览ToolStripMenuItem.Text = "不寫了"; taskTimer.Enabled = true; watch.Reset(); watch.Start(); }