Esempio n. 1
0
 public void Deactivate()
 {
     ParentGame.RemoveActiveScreen(this.Name);
     IsActivated    = false;
     PreviousScreen = null;
     OnDeactivate();
 }
Esempio n. 2
0
        public override void Initialize(GnomicGame game)
        {
            Hud = ParentGame.GetScreen <HudScreen>();

            int floorHeight = 60;

            Physics = new Gnomic.Physics.PhysicsSystem(this);
            Physics.CreateBorder(ParentGame.ScreenWidth * PLAY_AREA_WIDTH_IN_SCREENS,
                                 ParentGame.ScreenHeight, // * PLAY_AREA_HEIGHT_IN_SCREENS,
                                 new Vector2(0.0f, -floorHeight),
                                 /*friction*/ 0.005f);

            // Create a 2D camera
            base.Camera2D = camera = new Camera2D(ParentGame.GraphicsDevice.Viewport);

            CreateBackground();

            Vector2 vehiclePos = new Vector2(ParentGame.ScreenWidth / 5, ParentGame.ScreenHeight - floorHeight);
            Vector2 vehicleSizePhysicsCoords   = new Vector2(2.7f, 4.5f);
            Vector2 vehicleOffsetPhysicsCoords = new Vector2(0.0f, -vehicleSizePhysicsCoords.Y / 2.0f);

            Vector2 princessPos = vehiclePos - ConvertUnits.ToDisplayUnits(new Vector2(0.0f, vehicleSizePhysicsCoords.Y));

            lilMissBadAss = Princess.CreatePrincess(princessPos, new Vector2(0.6f, 1.2f), new Vector2(0.0f, -0.6f));
            base.AddEntity(lilMissBadAss); // sets ParentScreen

            Vehicle = PrincessVehicle.CreateDefaultEntity(vehiclePos, vehicleSizePhysicsCoords, vehicleOffsetPhysicsCoords);
            base.AddEntity(Vehicle);


            units = new UnitManager(this);

            //float startX = 0.7f;

            //for (int i = 0; i < 20; ++i)
            //{
            //    AddUnit(UnitType.Grunt, new Vector2(startX+(i*0.05f), 0.7f));
            //}

            //startX = 0.4f;

            //for (int i = 0; i < 5; ++i)
            //{
            //    AddUnit(UnitType.Knight, new Vector2(startX + (i * 0.05f), 0.7f));
            //}

            projectiles = new ProjectileManager(this);

            this.Audio = this.ParentGame.Audio;

            base.Initialize(game);

            standingJoint = new RevoluteJoint(lilMissBadAss.Physics.Bodies[0], Vehicle.Physics.Bodies[0], Vector2.Zero, new Vector2(0.0f, -vehicleSizePhysicsCoords.Y));
            Physics.World.AddJoint(standingJoint);
        }
Esempio n. 3
0
        public void Activate()
        {
            HandleInput  = true;
            deactivating = false;

            ParentGame.AddActiveScreen(this.Name);

            if (!this.IsInitialized)
            {
                Initialize(ParentGame);
            }

            IsActivated = true;
            OnActivate();
        }
Esempio n. 4
0
        public LevelEditor(ParentGame game)
        {
            parentGame = game;
            effect = parentGame.objEffect;

            EventTypes = new string[]{
                "PUT_PLAYER",
                "PUT_ENEMY",
                "SET_CONDITION",
                "TRIGGER_FLAG",
                "PLAY_ANIMATION",
                "PLAY_SOUND",
                "SET_OBJECTIVE",
                "END_LEVEL",
                "END_GAME"
            };
        }
Esempio n. 5
0
        public void Activate(int insertPosFromEnd)
        {
            HandleInput  = true;
            deactivating = false;

            ParentGame.InsertScreen(this.Name, insertPosFromEnd);

            if (!this.IsInitialized)
            {
                Initialize(ParentGame);
            }

            IsActivated = true;
            OnActivate();

            ClickEnabled     = false;
            CurrentClickable = null;
#if WINDOWS_PHONE
            TouchTwinStick.ClearTaps();
#endif
        }
Esempio n. 6
0
        public override void Initialize(GnomicGame game)
        {
            levelScreen = ParentGame.GetScreen <LevelScreen>();

            Vector2 imageSize = new Vector2(64.0f / 720.0f);
            Vector2 topRight  = new Vector2(ParentGame.ScreenWidth, -ParentGame.ScreenHeight) * (0.5f / ParentGame.ScreenHeight) - new Vector2(imageSize.X, -imageSize.Y);

            IconMoveRight = base.AddSprite("IconMove", imageSize, topRight, new Vector2(0.5f), true);
            IconMoveLeft  = base.AddSprite("IconMove", imageSize, topRight - new Vector2(imageSize.X, 0.0f), new Vector2(0.5f), true);
            IconMoveLeft.Settings.SpriteEffects = SpriteEffects.FlipHorizontally;

            ClipEntitySettings settings;

            settings                 = new ClipEntitySettings();
            settings.ClipFile        = "heart";
            settings.Scale           = Vector2.One;
            settings.DefaultAnimName = "heartBG";
            settings.Position        = new Vector2(90, 90);
            HeartBG = (ClipEntity)settings.CreateEntity();
            base.AddEntity(HeartBG);

            settings                 = new ClipEntitySettings();
            settings.ClipFile        = "heart";
            settings.Scale           = Vector2.One * 0.5f;
            settings.DefaultAnimName = "beatA";
            settings.Position        = new Vector2(90, 90);
            Heart = (ClipEntity)settings.CreateEntity();
            base.AddEntity(Heart);

            font = Content.Load <SpriteFont>("UIFont");

            base.Initialize(game);

            IconMoveRight.Visible = false;
            IconMoveLeft.Visible  = false;
        }
Esempio n. 7
0
        public Form1(ParentGame game)
        {
            parentGame = game;

            InitializeComponent();
        }
Esempio n. 8
0
 void Start()
 {
     FullGame   = GameObject.Find("Game").GetComponent <FullGame>();
     ParentGame = GameObject.Find(gameObject.name.Substring(0, 1)).GetComponent <ParentGame>();
     CellNo     = gameObject.name[2] - '1';
 }
Esempio n. 9
0
        public G1(Game parent) : base(parent, 1024 * 2, 768 * 2, Color.White)
        {
            SpatialMode = SpatialMode.SafeArea;

            OnUpdate += UpdateAction;
            OnDraw   += DrawAction;
            OnUnLoad += OnUnload;

            Keyboard.KeyPressed += (sender, args) =>
            {
                if (args.Key == Key.Space)
                {
                    ParentGame.Window.VSync = !ParentGame.Window.VSync;
                }

                if (args.Key == Key.X)
                {
                    Player.Position = new Vector2(80, 80);
                }

                if (args.Key == Key.Escape)
                {
                    ParentGame.Exit();
                }
            };

            var wall = new Sprite(ContentLoader.Texture2DFromFile("Test_Wall.png"), new Vector2(0, 0));

            fnt = ContentLoader.FontFromFile("Segoe UI_24.fnt");

            for (var i = 0; i < 50; i++)
            {
                AddInstance(new Wall(this, new Vector2(i * 16, 12), wall));
                AddInstance(new Wall(this, new Vector2(i * 16, 52), wall));
            }

            AddInstance(new MovingWall(this, new Vector2(200, 100), wall));

            Player = new Player(this, new Vector2(80, 80));
            AddInstance(Player);

            var btn = new Button(new Vector2(20, 100), "Hello", fnt, Color.Red);

            btn.ControlClicked += delegate { Console.WriteLine("CLICKED"); };

            Zoom = new Label(new Vector2(10, 10), "Zoom: 0", fnt, Color.Red);

            Rotation = new Label(new Vector2(10, 10 + fnt.LineHeight), "Rotation: 0 deg", fnt, Color.Red);

            INSIDE = new Label(new Vector2(10, 150), "Player is in: ", fnt, Color.Red);

            UserInterface.AddControl(btn);
            UserInterface.AddControl(Zoom);
            UserInterface.AddControl(Rotation);
            UserInterface.AddControl(INSIDE);
            var cursor = new Sprite(ContentLoader.Texture2DFromFile("Cursor.png"), new Vector2(0, 0))
            {
                Width  = 64,
                Height = 64
            };

            cur = new Cursor(cursor);
            UserInterface.AddControl(cur);

            TestTexture = cursor.Texture;

            Camera.Zoom = 0.7f;

            SafeZoneEnabled = true;
            SafeZone        = new Rectangle(0, 0, 256, 256);

            //DrawMode = DrawMode.DrawCheck;

            //Disable the animation collision exception
            Settings.AttemptToPerPixelCheckAnimation = false;



            /*if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\Fonts"))
             *  Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\Fonts");
             *
             * var standardSizes = new[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36 };
             *
             * foreach (var size in standardSizes)
             * {
             *  foreach (var fontFamily in System.Drawing.FontFamily.Families)
             *  {
             *      if (fontFamily.Name == "") continue;
             *      Console.WriteLine(fontFamily.Name + " : " + size);
             *      using (var stream =
             *          new FileStream(
             *              Directory.GetCurrentDirectory() + "\\Fonts\\" + fontFamily.Name + "_" + size + ".fnt",
             *              FileMode.Create))
             *      {
             *          var font = FontBuilder.CreateFontFromName(fontFamily.Name, size);
             *          font.WriteOut(stream);
             *      }
             *  }
             * }
             *
             * MessageBox.Show("Build fonts", "Complete");*/



            var testSound = ContentLoader.LoadWaveFromFile("TestWave.wav");

            testSound.Volume  = 0.25f;
            testSound.Pitch   = 2;
            testSound.Looping = true;
            testSound.Play();
        }
Esempio n. 10
0
        public Form2(ParentGame game)
        {
            InitializeComponent();

            parentGame = game;
        }