Ejemplo n.º 1
0
 public static void Move(int offset, ref World world)
 {
     foreach (GameObject go in world.AllElements)
     {
         go.Top += offset;
     }
 }
Ejemplo n.º 2
0
        public override void Init(World world, GameEventHandler aiEventHandler)
        {
            base.Init(world, aiEventHandler);

            Dictionary<GameEventArg, object> args = new Dictionary<GameEventArg, object>();
            args[GameEventArg.points] = 1;

            World.MGO.getEvent(GameEvent.gotPoints, args);
        }
Ejemplo n.º 3
0
        private void openLevel(string filename)
        {
            this.Text = "littleRunner Level Editor - " + filename;
            hScroll.Value = hScroll.Minimum;
            vScroll.Value = vScroll.Minimum;

            world = new World(tmpHandler.TmpFilename, drawHandler, new GameSession(), PlayMode.Editor);
            tmpHandler.SaveHandler = world.Serialize;
            setDelegateHandlers();

            showlevelSettings_Click(new object(), new EventArgs());
            drawHandler.Update();
        }
Ejemplo n.º 4
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tmpHandler.New())
            {
                this.Text = "littleRunner Level Editor";
                world = new World();
                tmpHandler.SaveHandler = world.Serialize;
                setDelegateHandlers();

                showlevelSettings_Click(sender, e);
                hScroll.Value = hScroll.Minimum;
                vScroll.Value = vScroll.Minimum;
                drawHandler.Update();
            }
        }
Ejemplo n.º 5
0
        public Editor()
        {
            InitializeComponent();
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
            ControlStyles.OptimizedDoubleBuffer, true);

            // extern inits
            drawHandler = GetDraw.DrawHandler(level, this.Update);
            AnimateImage.Refresh = false;
            EditorUI.drawHandler = drawHandler;
            EditorUI.level = level;
            EditorUI.properties = properties;
            TmpFileHandler.BackupFilename = Environment.CurrentDirectory + "\\backup.lrl";

            World defaultWorld = new World();
            tmpHandler = new TmpFileHandler(openFile, saveFile, defaultWorld.Serialize, 5);
            defaultWorld = null;

            defaultContextMenuItems = objectContext.Items.Count;
            curRectangle = Rectangle.Empty;

            focus = null;
            moving = false;
            mouseX = 0;
            mouseY = 0;
            pressedKeys = new List<Keys>();

            #region Images loading
            floorToolStripMenuItem.Image = Image.FromFile(Files.floor_middle);
            floorToolStripButton.Image = Image.FromFile(Files.floor_middle);

            designElementToolStripMenuItem.Image = Image.FromFile(Files.tree);
            treeToolStripMenuItem.Image = Image.FromFile(Files.tree);
            treeToolStripButton.Image = Image.FromFile(Files.tree);

            brickToolStripMenuItem.Image = Image.FromFile(Files.brick_blue);
            brickToolStripButton.Image = Image.FromFile(Files.brick_blue);

            boxToolStripMenuItem.Image = Image.FromFile(Files.box1);
            boxToolStripButton.Image = Image.FromFile(Files.box1); ;

            pipeToolStripMenuItem.Image = Image.FromFile(Files.pipe_green_up);
            pipeToolStripButton.Image = Image.FromFile(Files.pipe_green_up); ;

            pointStarToolStripMenuItem.Image = Image.FromFile(Files.star);
            starToolStripButton.Image = Image.FromFile(Files.star); ;

            platformToolStripMenuItem.Image = Image.FromFile(Files.brick_blue);
            bricksToolStripMenuItem.Image = Image.FromFile(Files.brick_blue);
            bricksToolStripButton.Image = Image.FromFile(Files.brick_blue); ;

            enemyToolStripMenuItem.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.turtle_green));
            turtleToolStripMenuItem.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.turtle_green));
            turtleToolStripButton.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.turtle_green));

            spikaToolStripMenuItem.Image = Image.FromFile(Files.spika_green);
            spikaToolStripButton.Image = Image.FromFile(Files.spika_green); ;

            gumbaToolStripMenuItem.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.gumba_brown));
            gumbaToolStripButton.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.gumba_brown));

            levelEndToolStripMenuItem.Image = Image.FromFile(Files.levelend_house);
            houseToolStripMenuItem.Image = Image.FromFile(Files.levelend_house);
            houseToolStripButton.Image = Image.FromFile(Files.levelend_house); ;

            gameLevelbeginToolStripMenuItem.Image = Image.FromFile(Files.icon_png);
            gameWindowToolStripMenuItem.Image = Image.FromFile(Files.icon_png);

            startGameCurrentToolStripMenuItem.Image = Image.FromFile(Files.icon_png);
            startGameCurrentToolStripButton.Image = Image.FromFile(Files.icon_png);
            #endregion
        }
Ejemplo n.º 6
0
        public void Init(World world, GameControlObjects gameControlObj)
        {
            this.gameControlObj = gameControlObj;
            this.World = world;

            Cheat.Init(this);
        }
Ejemplo n.º 7
0
        private void StartGame(string filename, PlayMode playMode)
        {
            // check if file exists
            if (!File.Exists(filename))
            {
                MessageBox.Show("Can't load " + filename + "!", "Error - File not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }

            this.BackColor = Color.DarkSeaGreen;
            LoadingForm f = new LoadingForm();
            f.Show();
            if (!(Location.X == 0 && Location.Y == 0))
                f.Location = new System.Drawing.Point(Location.X + (Width - f.Width) / 2, Location.Y + (Height - f.Height) / 2);

            f.Message("Set title");
            // set form title
            string title = "";

            if (filename.StartsWith(Path.GetTempPath()))
            {
                Text = "littleRunner";
            }
            else
            {
                int lastBackslash = filename.LastIndexOf("/");
                if (lastBackslash == -1)
                    title = filename.Substring(0);
                else
                    title = filename.Substring(lastBackslash + 1);

                int lastDot = title.LastIndexOf(".");
                if (lastDot != -1)
                {
                    title = title.Substring(0, lastDot);
                }

                Text = "littleRunner - " + title;
            }

            // main game AI - world neets AiEventHandler
            f.Message("Creating Game AI");
            ai = new GameAI(GameAIInteract);

            if (session == null) // first run or complete new run (after game over)
            {
                session = new GameSession();
            }

            // The world
            f.Message("Creating World");
            world = new World(filename, drawHandler, ai.getEvent, session, playMode);

            // Main game object
            f.Message("Creating MGO");
            Tux tux = new Tux(
                mgoChangeTop  == 0 ? Globals.Scroll.Top : Globals.Scroll.Top + mgoChangeTop,
                mgoChangeLeft == 0 ? Globals.Scroll.X   : Globals.Scroll.X   + mgoChangeLeft
            );
            tux.Init(world, ai.getEvent); // can init

            // set viewport if need
            if (mgoChangeTop != 0 || mgoChangeLeft != 0)
            {
                world.Viewport.Y -= mgoChangeTop;
                world.Viewport.X -= mgoChangeLeft;
            }

            // got MGO!
            f.Message("Initializing World");
            world.Init(tux);

            // change window size
            ignoreSizeChange = true;
            Width = world.Settings.GameWindowWidth + 5;
            Height = world.Settings.GameWindowHeight + 29;
            ignoreSizeChange = false;

            // GameControls
            f.Message("Creating GameControlObjects");
            if (gameControlObjs == null) // first run or complete new run (after game over)
            {
                GameControl_Score gameControlObjScore = new GameControl_Score(15, 20, "Verdana", 12);
                GameControl_Points gameControlObjPoints = new GameControl_Points(15, Width / 2 - 120 / 2, "Verdana", 12);
                GameControl_Lives gameControlObjLives = new GameControl_Lives(15, Width - 140, 4, "Verdana", 12);
                GameControl_FPS gameControlObjFPS = new GameControl_FPS(40, Width - 140, "Verdana", 12);
                GameControl_Debug gameControlObjDebug = new GameControl_Debug(65, Width - 25, "Verdana", 12);
                GameControl_Sound gameControlObjSound = new GameControl_Sound();

                gameControlObjs = new GameControlObjects(gameControlObjScore, gameControlObjPoints, gameControlObjLives, gameControlObjFPS, gameControlObjDebug, gameControlObjSound);
            }

            // init AI with the world - now we have the GameControlObjects
            f.Message("Initializing Game AI");
            ai.Init(world, gameControlObjs);

            // init Script Engine
            f.Message("Initializing ScriptEngine");
            ai.InitScript();

            if (!lastModeIsNull)
                ai.World.MGO.Mode = lastMode;

            f.Message("Initializing Sound");
            gameControlObjs.Sound.Start();

            Cursor.Hide();
            f.Close();
            this.BackColor = Color.White;
            ai.Pause(true);
        }
Ejemplo n.º 8
0
 public virtual void Init(World world, GameEventHandler aiEventHandler)
 {
     this.world = world;
     this.aiEventHandler = aiEventHandler;
 }