Example #1
0
 void Update()
 {
     if (Game == null)
     {
         Game = Locator.Get <GridiaGame>();
         //InitTabbedGui();
         Game.Initialize(GridiaConstants.Size, GridiaConstants.Depth, GridiaConstants.SectorSize); // :(
         GameInitWaitHandle.Set();
     }
     if (Game.View.Focus == null)
     {
         return;
     }
     if (Game.StateMachine != null)
     {
         Game.StateMachine.Step(Time.deltaTime);
     }
     Game.View.Render();
     for (int i = 0; i < Game.Animations.Count; i++)
     {
         var animation = Game.Animations[i];
         if (animation.Dead)
         {
             Game.Animations.RemoveAt(i);
         }
         else
         {
             animation.Step(Time.deltaTime);
         }
     }
     ResizeCamera(); // :( only on resize
 }
Example #2
0
        public static void Connect(String ip, int port)
        {
            if (GridiaConstants.ErrorMessage != null || connecting)
            {
                return;
            }
            Debug.Log("Connecting to server ...");
            var game = new GridiaGame();

            try
            {
                _conn = new ConnectionToGridiaServerHandler(ip, port, game);
                Locator.Provide(game);
                Locator.Provide(_conn);

                new Thread(() =>
                {
                    try
                    {
                        Debug.Log("Starting connection ...");
                        connecting = true;
                        _conn.Start(() => Debug.Log("Connection settled!"), _conn);
                        Debug.Log("connection started");
                    }
                    catch (Exception ex)
                    {
                        connecting = false;
                        Debug.LogError(ex);
                        GridiaConstants.ErrorMessage       = "Connection to server has been lost.";
                        GridiaConstants.ErrorMessageAction = () =>
                        {
                            GridiaConstants.SoundPlayer.MuteSfx = GridiaConstants.SoundPlayer.MuteMusic = true;
                            SceneManager.LoadScene("ServerSelection");
                        };
                    }
                }).Start();
            }
            catch (SocketException ex)
            {
                GridiaConstants.ErrorMessage = "Could not connect to " + ip + " at port " + port;
                Debug.Log(ex);
            }
        }
Example #3
0
 public TargetSelectState()
 {
     _driver  = Locator.Get <GridiaDriver>();
     _tileMap = Locator.Get <TileMap>();
     _game    = Locator.Get <GridiaGame>();
 }
Example #4
0
 public ItemMovementState(Vector3 locationOfItemToMove)
 {
     LocationOfItemToMove = locationOfItemToMove;
     _driver = Locator.Get <GridiaDriver>();
     _game   = Locator.Get <GridiaGame>();
 }
Example #5
0
 // :(
 public IdleState()
 {
     _driver             = Locator.Get <GridiaDriver>();
     _game               = Locator.Get <GridiaGame>();
     _game.SelectorDelta = Vector3.zero;
 }
Example #6
0
 public ConnectionToGridiaServerHandler(String host, int port, GridiaGame game)
 {
     _socketHandler = new FileTransferringSocketReciever(new SocketHandlerImpl(host, port), GridiaConstants.GetFileSystem());
     _game          = game;
 }
        private Vector3 _destinationSelectorDelta = Vector3.zero; // :(

        #endregion Fields

        #region Constructors

        public ActionLocationPickState(GridiaAction action)
        {
            _driver = Locator.Get <GridiaDriver>();
            _game   = Locator.Get <GridiaGame>();
            _action = action;
        }