예제 #1
0
 private void CopyGame()
 {
     if (LastGame != null)
     {
         LastGame.Copy(Tableau);
     }
 }
예제 #2
0
파일: Data.cs 프로젝트: myloran/Labirinth
 public static void Load()
 {
     if (File.Exists(Application.persistentDataPath + "/LastLevel.dat"))
     {
         BinaryFormatter bf = new BinaryFormatter();
         FileStream file = File.Open(Application.persistentDataPath + "/LastLevel.dat", FileMode.Open);
         lastGame = (LastGame)bf.Deserialize(file);
         file.Close();
     }
 }
예제 #3
0
    // 初始化数据
    public override void SetData(Player data, params object[] objs)
    {
        if (objs != null)
        {
            lastGame = (LastGame)objs[0];
        }
        // 显示角色
        string roleStr = "";

        if (data.pos == lastGame.sb_pos)
        {
            roleStr = "小盲";
        }
        else if (data.pos == lastGame.bb_pos)
        {
            roleStr = "大盲";
        }
        if (data.pos == lastGame.button)
        {
            roleStr = string.IsNullOrEmpty(roleStr) ? "D" : "D / " + roleStr;
        }
        if (string.IsNullOrEmpty(roleStr))
        {
            role.SetActive(false);
        }
        else
        {
            role.SetActive(true);
            roleText.text = roleStr;
        }
        // 显示牌型
        cardType.SetActive(!string.IsNullOrEmpty(data.GetCardType()));
        cardTypeText.text = data.GetCardType();

        // 下注总数
        if (data.win > 0)
        {
            totalCount.SetActive(true);
            totalCount.GetComponent <Text>().text = "+" + data.win.ToString();
        }
        else if (data.bet > 0)
        {
            totalCount.SetActive(true);
            totalCount.GetComponent <Text>().text = "-" + data.bet.ToString();
        }
        else
        {
            totalCount.SetActive(false);
        }
        InitRounds(data, data.actions);
    }
예제 #4
0
 private LastGame lastGame; //used to read and save last difficulty level
 protected Game()
 {
     flagCounter = new FlagCounter();
     AddElement(flagCounter);
     stopwatch = new Stopwatch();
     AddElement(stopwatch);
     gameButton = new GameButton();
     AddGameButtonMouseActions(gameButton);
     AddElement(gameButton);
     scoreboard     = new Scoreboard();
     lastGame       = new LastGame();
     diffLevel      = lastGame.GetDifficultyLevel();
     customGameSize = lastGame.GetCustomGameSize();
 }
예제 #5
0
    public void SetData(LastGame lastGame)
    {
        if (lastGame == null || lastGame.players == null)
        {
            return;
        }
        List <Player> list = new List <Player>(lastGame.players);

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i] == null)
            {
                list.RemoveAt(i);
                i--;
            }
        }
        SetDatas(list, lastGame);
    }
예제 #6
0
    public void SaveLastGame()
    {
        LastGame game = new LastGame();
        game.Maze = Maze;
        game.playerPosition = p.transform.position;
        game.keyLeft = 0;
        game.keyTime = new float[1];
        game.keyTime[0] = 1;
        game.keysPosition = new Vector3[1];
        game.keysPosition[0] = new Vector3(f.transform.position.x, 0, f.transform.position.z);
        game.timeLeft = 30;

        Data.lastGame = game;
    }
예제 #7
0
        public void WatchPowerLog()
        {
            var powerLog = Path.Combine(Dir, "Logs/Power.log");
            var t        = new Thread(() =>
            {
                if (!File.Exists(powerLog))
                {
                    MainActivity.Instance.Log("Could not find Power.log");
                    while (!File.Exists(powerLog))
                    {
                        Thread.Sleep(5000);
                    }
                }
                MainActivity.Instance.Log("Found Power.log");
                var gameStart = LogHelper.FindEntryPoint(GameStart, powerLog, true);
                var gameEnd   = LogHelper.FindEntryPoint(GameEnd, powerLog, false);
                var pos       = gameStart > gameEnd ? gameStart : gameEnd;
                while (true)
                {
                    using (var fs = new FileStream(powerLog, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        using (var sr = new StreamReader(fs, Encoding.ASCII))
                        {
                            if (pos < fs.Length)
                            {
                                fs.Seek(pos, SeekOrigin.Begin);
                                var newLines = sr.ReadToEnd().Split('\n');
                                foreach (var line in newLines.Where(IsRelevantLine))
                                {
                                    Log.Debug("LogWatcher", line);
                                    if (line.Contains(GameStart))
                                    {
                                        MainActivity.Instance.Log("New game!");
                                        Log.Debug("LogWatcher", "NEW GAME");
                                        CurrentGame.Clear();
                                        CurrentGame.Add(line);
                                    }
                                    else if (line.Contains(GameEnd))
                                    {
                                        CurrentGame.Add(line);
                                        MainActivity.Instance.Log($"Game complete! ({CurrentGame.Count} lines)");
                                        Log.Debug("LogWatcher", "COMPLETE GAME");
                                        LastGame.Clear();
                                        LastGame.AddRange(CurrentGame);
                                    }
                                    else
                                    {
                                        CurrentGame.Add(line);
                                    }
                                }
                                pos = fs.Length;
                            }
                            else if (pos > fs.Length)
                            {
                                WatchPowerLog();
                                return;
                            }
                        }
                    Thread.Sleep(5000);
                }
            });

            t.Start();
        }