예제 #1
0
        public void IfKeyPressedGoto(CommandParams param)
        {
            string key   = param.GetString();
            string label = param.GetString();

            if (IsKeyPressed(key))
            {
                GoToLabel(label);
            }
        }
예제 #2
0
        public void IfKeyPressedCall(CommandParams param)
        {
            string key   = param.GetString();
            string label = param.GetString();

            if (IsKeyPressed(key))
            {
                CallSubroutineAtLabel(label);
            }
        }
예제 #3
0
        public void PutObject(CommandParams param)
        {
            AssertTargetPosition();

            GameObject o = new GameObject(new Tile());

            o.Id = param.GetString();
            o.Animation.Clear();
            Map.PutObject(o, TargetObject);
        }
예제 #4
0
        public void FindObjectById(CommandParams param)
        {
            PositionedObject po = Map.FindObjectById(param.GetString());

            if (po == null)
            {
                throw new PTMException("Object not found with id: " + param);
            }

            TargetObject = po.Position;
        }
예제 #5
0
        public void SetVariable(CommandParams param)
        {
            string name  = param.GetStringDirect().Trim();
            string value = param.GetString().Trim();

            if (!name.StartsWith("$"))
            {
                throw new PTMException("Invalid variable name");
            }

            Vars.Set(name, value);
        }
예제 #6
0
        public void LoadMap(CommandParams param)
        {
            try
            {
                Map = MapFile.LoadFromRawBytes(param.GetString());
                Window.Graphics.Tileset = Map.Tileset;
                Window.Graphics.Palette = Map.Palette;

                if (MapRenderer != null)
                {
                    MapRenderer.Map = Map;
                }
            }
            catch (DirectoryNotFoundException dnfex)
            {
                throw new PTMException("Map file not found: " + dnfex.Message);
            }
            catch (FileNotFoundException fnfex)
            {
                throw new PTMException("Map file not found: " + fnfex.FileName);
            }
        }
예제 #7
0
        public void InitWindow(CommandParams param)
        {
            if (param.Count != 5)
            {
                throw new PTMException("Invalid parameter count");
            }

            try
            {
                string title  = param.GetString();
                int    width  = param.GetNumber();
                int    height = param.GetNumber();
                int    cols   = param.GetNumber();
                int    rows   = param.GetNumber();

                Window      = new GameWindow(this, "", cols, rows);
                Window.Size = new Size(width, height);
                Window.Text = title;
            }
            catch (Exception ex)
            {
                throw new PTMException("Invalid parameter(s)");
            }
        }
예제 #8
0
 public void GoToLabel(CommandParams param)
 {
     ProgramPtr = TryGetLabelLineNumber(param.GetString());
 }
예제 #9
0
 public void CallLabel(CommandParams param)
 {
     CallStack.Push(ProgramPtr);
     ProgramPtr = TryGetLabelLineNumber(param.GetString());
 }
예제 #10
0
 public void LoadVariableToStack(CommandParams param)
 {
     ExprStack.Push(Vars.GetAsString(param.GetString()));
 }
예제 #11
0
 public void StoreStackToVariable(CommandParams param)
 {
     Vars.Set(param.GetString(), ExprStack.PopString());
 }
예제 #12
0
 public void PrintToDebugger(CommandParams param)
 {
     Debugger.Println(param.GetString());
 }