Beispiel #1
0
        private void Update()
        {
            //if (GameStatus.Paused) return;
            if (CaravanServer != null && World != null)
            {
                try
                {
                    if (!WaitingServerResponse && (lastPingDateTimeUtc.AddSeconds(1) < DateTime.UtcNow || CommandsToSend.Any()))
                    {
                        WaitingServerResponse = true;

                        var request = new ProcessWorldRequestClientSideEntity
                        {
                            WorldGuid      = World?.Guid,
                            Player         = Player,
                            ClientCommands = CommandsToSend.ToArray()
                        };

                        StartCoroutine(CaravanServer.ProcessWorld(request, ProcessServerResponse));
                        lastPingDateTimeUtc = DateTime.UtcNow;
                    }

                    ProcessMovePlayer();
                }
                catch (Exception e)
                {
                    CaravanServer = null;
                    Debug.LogError($"Error while WorldController.Update(): {e}");
                }
            }
        }
Beispiel #2
0
        //private void UpdateVisibleCities()
        //{
        //    foreach (var city in Cities.Where(c => !c.Visible))
        //        if (Mathf.Abs(city.X - PlayerController.transform.position.x) < 1 + city.Size / 2 && Mathf.Abs(city.Y - PlayerController.transform.position.y) < 1 + city.Size / 2)
        //        {
        //            city.SetVisible();
        //            WriteLog($"You find city {city.Name}");
        //        }
        //}

        //private void InitializePlayer()
        //{
        //    Player = new Player();
        //    var firstCity = Cities[0];
        //    PlayerController = Instantiate(PlayerControllerBase, new Vector3(firstCity.X, firstCity.Y, 0), Quaternion.identity);
        //    PlayerController.CityEntered = firstCity;

        //    WriteSystemLog($"Created Player in {firstCity.Name} with X={firstCity.X} and Y={firstCity.Y}");

        //    PlayerController.InitializePlayer();


        //    //Player.Bramins = new List<Bramin> {new Bramin(), new Bramin(), new Bramin()};
        //}

        public void WorldClick()
        {
            var moveTo = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            CommandsToSend.Add(new MovePlayerClientCommandClientSideEntity
            {
                ToX = moveTo.x,
                ToY = moveTo.y
            });
        }
Beispiel #3
0
 private void SendCommand(Command command)
 {
     CommandsToSend.Add(command);
 }