// Use this for initialization void Start () { m_Player = transform.root.GetComponent<DPlayers>(); for(int i = 0 ; i < 10 ; i++ ) { m_MagnetList[i] = null; } Debug.Log(m_MagnetList.Length); }
// Use this for initialization void Start() { m_Player = transform.root.GetComponent <DPlayers>(); for (int i = 0; i < 10; i++) { m_MagnetList[i] = null; } Debug.Log(m_MagnetList.Length); }
// Use this for initialization void Start() { hyperEffect.SetActive(hyperAble); cam = GameObject.Find("3DGameCamera").camera; Time.timeScale = 1.0f; instance = this; screenCal = new Vector3(Screen.width / 2, Screen.height / 2); pos = transform.position; gravityScale = rigidbody2D.gravityScale; }
public void ProcessGames() { int counter = PlayerCounter; while (generator.HaveNext) { var start = DateTime.UtcNow; // MyThreadPool<Player>.Foreach(Players, player => foreach (var player in Players) { var tempStat = new SortableObservableCollection <NumberStat>(); tempStat.Sync(NumbersStatistic); if (player.ColdNumbers + player.HotNumbers > 0) { var player1 = player; tempStat.Sort(x => x.TimesAppear(player1.StatRange), ListSortDirection.Descending); } GenerateNumbersBuyTickets(player, tempStat); player.CurrentMinus += player.Tickets.Count * player.Stake; } var numbers = generator.Generate(); prevNumbers = numbers.ToList(); foreach (var numberStat in NumbersStatistic) { numberStat.Appear(numbers.Contains(numberStat.Number)); } SortableObservableCollection <Player> lostPlayers = new SortableObservableCollection <Player>(); foreach (var player in Players) { var moneyWon = Calculate.CalculateTickets(numbers, player.Tickets); player.Money += moneyWon; if (moneyWon == 0) { player.NumberOfTickets += player.TicketChangeLost; if (player.TicketChangeLost < 0) { while (player.Tickets.Count > player.NumberOfTickets && player.Tickets.Count > 1) { player.Tickets.RemoveAt(player.Tickets.Count - 1); } } } if (moneyWon > 0) { player.NumberOfTickets += player.TicketChangeWon; if (player.TicketChangeWon < 0) { while (player.Tickets.Count > player.NumberOfTickets && player.Tickets.Count > 1) { player.Tickets.RemoveAt(player.Tickets.Count - 1); } } } var currentMinus = moneyWon - player.CurrentMinus; if (currentMinus < 0) { player.CurrentMinus = -currentMinus; } else { player.CurrentMinus = 0; } // if (player.CurrentMinus > startMoney) // lostPlayers.Add(player); if (player.Money <= 0) { lostPlayers.Add(player); } player.NumberOfTickets = player.Tickets.Count; player.GamesPlayed++; } foreach (var player in lostPlayers) { counter = RemoveAndCreateNewPlayer(player, counter); } GamesPlayed++; if (Players.Count < 500) { counter = CreateChildren(counter); } if (generator.isLast) { foreach (var player in Players) { player.Money = startMoney; } } while (Players.Count > 1000) { Players.RemoveAt(Players.Count - 1); } PlayerCounter = Players.Count; if (GamesPlayed % 20 == 0) { if (Dispatcher.Thread.IsAlive) { Dispatcher.Invoke(() => { DPlayers.Sync(Players); DTopPlayers.Sync(TopPlayers); }); } } var end = DateTime.UtcNow; Console.WriteLine(end - start); //haveChanges = true; } Players.Sort(x => x.Money, ListSortDirection.Descending); Dispatcher.Invoke(() => { DPlayers.Sync(Players); DTopPlayers.Sync(TopPlayers); }); }