Esempio n. 1
0
 private bool HanldeBitsyInput(BitsyInput.InputId id)
 {
     if (_input != null)
     {
         return(_input.PollInput(id));
     }
     else
     {
         return(BitsyUnityUtils.GetInputWASD(id));
     }
 }
Esempio n. 2
0
        public void RestartGame()
        {
            if (this.GameData == null || this.Renderer == null || _surface == null)
            {
                this.enabled = false;
                return;
            }

            //parse game
            var         parser = new BitsyGameParser();
            Environment environment;

            using (var reader = new System.IO.StringReader(this.GameData.text))
            {
                environment = parser.Parse(reader, this.HanldeBitsyInput, BitsyUnityUtils.LoadTextureFont(this.FontTexture));
            }

            if (this.UseExtensionFunctions)
            {
                environment.ScriptInterpreter.ScriptExtension = BitsyExtensionFunctions.CreateTable();
            }
            environment.OnMessage += this.OnBitsyMessageCallback;


            //prepare renderer
            if (this.Margin != _surface.Margin)
            {
                Object.Destroy(_surface.Texture);
                _surface = TextureRenderSurface.Create(this.Margin);
            }
            this.Renderer.material.mainTexture = _surface.Texture;

            //get input
            _input = this.GetComponent <IBitsyInput>();

            //begin game
            _game.Begin(environment, _surface, this.ShowTitleText);
        }