示例#1
0
 public RenderStack(VERGEMap vmap, String rstring, Char delim)
 {
     var tokens = rstring.Trim().ToUpper().Split(delim);
     list = (
         from token in tokens
         select MapToken(vmap, token.Trim())
     ).ToArray();
 }
示例#2
0
 private static RenderLayer MapToken(VERGEMap vergeMap, string token)
 {
     switch (token) {
         case "R": // rendering script layer (defaults to hook_render and fixed parallax)
             return new ScriptRenderLayer();
         case "E": // entity layer
             return new EntityLayer();
         default: // tile layer
             int layer_number;
             if (Int32.TryParse(token, out layer_number) && (layer_number > 0))
                 return vergeMap.tiles[layer_number - 1];
             else
                 throw new MalformedRenderstringException("Invalid token '" + token + "' in renderstring");
     }
 }
示例#3
0
        public RenderStack(VERGEMap vmap, String rstring, Char delim)
        {
            int cur_pos, next_pos, len, layer_number;
            String str = rstring.Trim().ToUpper();
            String cur_token;
            RenderLayer cur_layer;
            Queue<RenderLayer> layer_queue = new Queue<RenderLayer>(); // Temporary loading queue
            map = vmap;

            cur_pos = 0;
            len = str.Length;
            while (cur_pos < len) {
                next_pos = str.IndexOf(delim, cur_pos);
                if (next_pos == -1) next_pos = len;
                cur_token = str.Substring(cur_pos, next_pos - cur_pos).Trim();
                //Console.WriteLine(cur_token);
                switch (cur_token) {
                    case "R": // rendering script layer (defaults to hook_render and fixed parallax)
                        cur_layer = new ScriptRenderLayer();
                        layer_queue.Enqueue(cur_layer);
                        break;
                    case "E": // entity layer
                        cur_layer = new EntityLayer();
                        layer_queue.Enqueue(cur_layer);
                        break;
                    default: // tile layer
                        try {
                            layer_number = Int32.Parse(cur_token);
                            if (layer_number <= 0) throw new Exception();
                        }
                        catch (Exception) { throw new MalformedRenderstringException(rstring); } // not a positive integer
                        cur_layer = map.tiles[layer_number - 1];
                        layer_queue.Enqueue(cur_layer);
                        break;
                }
                cur_pos = next_pos + 1;
            }

            // Collections are slow, so we'll shift the layers into a fixed array now that we've got them all.
            list = new RenderLayer[layer_queue.Count];
            for (int count = 0; count < list.Length; count++) {
                list[count] = layer_queue.Dequeue();
            }
        }
示例#4
0
 public Script_paradise_isle2( VERGEMap map )
     : base(map)
 {
     Console.WriteLine( "Paradise Isle scripts loaded." );
 }
示例#5
0
        public VERGEGame()
            : base()
        {
            System.Diagnostics.StackTrace stack = new System.Diagnostics.StackTrace();
            stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();

            // the assembly/namespace to search for script classes defaults to the one
            // from which this constructor was called.
            Type sourcetype = stack.GetFrame(1).GetMethod().DeclaringType;
            main_assembly = sourcetype.Assembly;
            main_namespace = sourcetype.Namespace;
            game_input_handler = () => { return true; }; // unless overriden, always pass control to the map handler

            VERGEGame.game = this;
            Default_Handlers.game = this;
            followers = new FollowerChain(null);

            // Set up timing
            this.IsFixedTimeStep = false;

            tick_length = 10; // In milliseconds. VERGE standard is 100 ticks per second
            _last_tick_time = 0;
            _tick = 0;

            // Set up graphics
            graphics = new GraphicsDeviceManager(this);

            // Uncomment this line to remove fps throttling:
            graphics.SynchronizeWithVerticalRetrace = false;

            camera = null;
            hook_render = null;
            system_font = null;
            MapContent = new ContentManager(Services, "Content");
            Content.RootDirectory = "Content";

            // Set up input
            input = new InputManager();
            initialize_buttons();

            // Initialize other variables
            global = new ScriptBank();
            map = null;
            player = null;
            player_controllable_stack = new Stack<bool>();
            player_controllable = PLAYER_CONTROLLABLE_DEFAULT;
            player_tile_obstruction = true;
            default_entity_handler = Default_Handlers.omnibus_vergestyle_handler;
            entities_paused = false;
            entities_paused_stack = new Stack<bool>();
            action_queue = new Queue<Action>();
        }
示例#6
0
 public RenderStack(VERGEMap vmap, String rstring)
     : this(vmap, rstring, ',')
 {
 }
示例#7
0
 public Script_town01(VERGEMap map)
     : base(map)
 {
 }