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

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

            if (IsKeyPressed(key))
            {
                CallSubroutineAtLabel(label);
            }
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #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)");
            }
        }
Beispiel #8
0
 public void GoToLabel(CommandParams param)
 {
     ProgramPtr = TryGetLabelLineNumber(param.GetString());
 }
Beispiel #9
0
 public void CallLabel(CommandParams param)
 {
     CallStack.Push(ProgramPtr);
     ProgramPtr = TryGetLabelLineNumber(param.GetString());
 }
Beispiel #10
0
 public void LoadVariableToStack(CommandParams param)
 {
     ExprStack.Push(Vars.GetAsString(param.GetString()));
 }
Beispiel #11
0
 public void StoreStackToVariable(CommandParams param)
 {
     Vars.Set(param.GetString(), ExprStack.PopString());
 }
Beispiel #12
0
 public void PrintToDebugger(CommandParams param)
 {
     Debugger.Println(param.GetString());
 }