Пример #1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game game = new Game())
     {
         game.Run();
     }
 }
Пример #2
0
        public InstantBullet(Game game, float x, float y, float sourceX, float sourceY, int damage)
            : base(game, 0, "instantbullet")
        {
            X = x;
            Y = y;

            _sourceX = sourceX;
            _sourceY = sourceY;
            _damage = damage;

            // Slumpa animationshastigheten en aning. Mellan 4-6 ca.
            //_animSpeed = 1 + (int)(Util.Random () * 3);
            _maxLifeTime = 25;
            _lifeTime = 0;

            float p1 = 0.4f + (float)Util.Random () * 0.5f - 0.25f;
            // punkt 1: 0.15-
            float p2 = 0.9f + (float)Util.Random () * 0.3f - 0.2f;

            _streakStart = Math.Min (p1, p2);
            _streakEnd = Math.Max (p1, p2);
            _streakMid = _streakStart + (_streakEnd - _streakStart) * 0.7f;

            var c = Collider.LineFirst(sourceX, sourceY, x, y, HandleHit, this);
            c.FilterType = typeof(Vehicle);
            _game.AddCollider(c);
        }
Пример #3
0
 public Generic(Game game, float x, float y, SpriteTemplate spriteTemplate)
     : base(game,0,"generic")
 {
     X = x;
     Y = y;
     //	_random = (float)Util.Random();
     SpriteTemplate = spriteTemplate;
 }
Пример #4
0
 public GameObject(Game game, int updatePriority, string typeId)
 {
     UpdatePriority = updatePriority;
     _game = game;
     X = 0;
     Y = 0;
     TypeId = typeId;
 }
Пример #5
0
        public MainMenuState(Game owner)
        {
            game = owner;

            buttons.Add(new GuiButton("Join Game", -1f, 0.3f, delegate () { game.States.Push(new GameState(game)); }));
            buttons.Add(new GuiButton("Host Game", -1f, 0f, delegate () { game.States.Push(new GameState(game)); }));
            buttons.Add(new GuiButton("Settings", -1f, -0.3f, delegate () { game.States.Push(new MainSettingsState(game)); }));
            buttons.Add(new GuiButton("Exit Game", -1f, -0.6f,
                delegate () { Environment.Exit(1); }));
        }
Пример #6
0
        public void Update(Game game)
        {
            Background bg = game.Application.Renderer.Backgrounds[0];
            Input input = game.Application.Input;

            // Lägg på acceleration om spelaren trycker i någon riktning, men bara upp till maximal hastighet.
            if (input.isDown (Key.CameraLeft))	_xVelocity = Math.Max (_xVelocity - acceleration, -maxVelocity);
            if (input.isDown (Key.CameraRight))	_xVelocity = Math.Min (_xVelocity + acceleration, maxVelocity);
            if (input.isDown (Key.CameraUp))	_yVelocity = Math.Max (_yVelocity - acceleration, -maxVelocity);
            if (input.isDown (Key.CameraDown))	_yVelocity = Math.Min (_yVelocity + acceleration, maxVelocity);

            // Om X-hastigheten är negativ (åt vänster), lägg på friktion åt höger. Annars tvärt om.
            if (_xVelocity < 0)	_xVelocity = Math.Min (_xVelocity + friction, 0);
            if (_xVelocity > 0)	_xVelocity = Math.Max (_xVelocity - friction, 0);

            // Om Y-hastigheten är negativ (uppåt), lägg på friktion neråt. Annars tvärt om.
            if (_yVelocity < 0)	_yVelocity = Math.Min (_yVelocity + friction, 0);
            if (_yVelocity > 0)	_yVelocity = Math.Max (_yVelocity - friction, 0);

            // Uppdatera positionen med hjälp av hastigheterna.
            _x = _x + _xVelocity;
            _y = _y + _yVelocity;

            // Kollidera mot vänsterkanten och nolla X-hastigheten.
            if (_x < 0)
            {
                _x = 0;
                _xVelocity = 0;
            }
            // Kollidera mot högerkanten och nolla X-hastigheten.
            if (_x > bg.MaxHScroll)
            {
                _x = bg.MaxHScroll;
                _xVelocity = 0;
            }
            // Kollidera mot överkanten och nolla Y-hastigheten.
            if (_y < 0)
            {
                _y = 0;
                _yVelocity = 0;
            }
            // Kollidera mot nederkanten och nolla Y-hastigheten.
            if (_y > bg.MaxVScroll)
            {
                _y = bg.MaxVScroll;
                _yVelocity = 0;
            }

            // Nu har vi en färdig position, så scrolla bakgrundslagret.
            bg.HScroll = _x;
            bg.VScroll = _y;
            game.Application.Renderer.Backgrounds[1].HScroll = _x;
            game.Application.Renderer.Backgrounds[1].VScroll = _y;
        }
Пример #7
0
        public Machinegun(Game game, int x, int y)
            : base(game,x,y,"machinegun")
        {
            _fireTimer.Elapsed += HandleFireTimerElapsed;
            _targetingTimer.Elapsed += HandleFireTimerElapsed;

            CurrentUpgradeChanged += delegate
            {
                _fireTimer.ResetValue = CurrentUpgrade.ReloadTime;
            };
        }
Пример #8
0
        public MainWindow()
        {
            InitializeComponent();

            game = new Game(this);
            Game.me = new Player(0, "Bam");
            game.AddPlayer(Game.me);

            myStats.DataContext = Game.me;

            listBoxOut.Items.Refresh();
            hitInput.SelectAll();
            KeyDown += inputKeyDown;
        }
Пример #9
0
        static void Main(string[] args)
        {
            var hostname = Settings.Default.Hostname;
            var port = Settings.Default.Port;
            var username = Settings.Default.Username;
            var password = Settings.Default.Password;
            var logLevel = Settings.Default.Loglevel;
            var p = new Game<CommandLineUI>(hostname, port, username, password, logLevel);

            Console.OutputEncoding = Encoding.UTF8;
            Console.InputEncoding = Encoding.UTF8;

            p.Start();
        }
Пример #10
0
        public Bullet(Game game, float x, float y, float targetX, float targetY, int damage)
            : base(game,0,"bullet")
        {
            X = x;
            Y = y;
            _damage = damage;

            float d = Util.Distance(x,y,targetX,targetY);
            _sourceX = x;
            _sourceY = y;
            _targetX = targetX;
            _targetY = targetY;
            _k = 0.0f;
            _v = 12.0f / d;

            _sprite = new Sprite(_bulletTmp, 0, 2);
        }
Пример #11
0
        public MainSettingsState(Game owner)
        {
            game = owner;

            //Temp solution
            UserSettings userSettings = new UserSettings();
            try
            {
                userSettings.UpdateFromFile("Userprefs.txt");
            }
            catch(Exception)
            {
                userSettings.GenerateNewUserpref("Userprefs.txt");
            }

            //Create and fill gui lists here

            // The titles for each layer
            Font font = new Font(FontFamily.GenericSansSerif, 20);
            texSettingsTitle = GraphicsTools.GenerateTextureFromText("-SETTINGS-", font);
            texGeneralTitle  = GraphicsTools.GenerateTextureFromText("-GENERAL-",  font);
            texAudioTitle    = GraphicsTools.GenerateTextureFromText("-AUDIO-",    font);
            texVideoTitle    = GraphicsTools.GenerateTextureFromText("-VIDEO-",    font);
            texControlsTitle = GraphicsTools.GenerateTextureFromText("-CONTROLS-", font);

                    /* Add the GUI elements to each layer and delegate functionality */
            //The top layer of the options menu:
            topLayerButtons.Add(new GuiButton("General",  layoutX[0], layoutY[0], delegate () { currentLayer = (int)settingStates.generalLayer; }));
            topLayerButtons.Add(new GuiButton("Audio",    layoutX[0], layoutY[1], delegate () { currentLayer = (int)settingStates.audioLayer; }));
            topLayerButtons.Add(new GuiButton("Video",    layoutX[0], layoutY[2], delegate () { currentLayer = (int)settingStates.videoLayer; }));
            topLayerButtons.Add(new GuiButton("Controls", layoutX[0], layoutY[3], delegate () { currentLayer = (int)settingStates.controlsLayer; }));
            topLayerButtons.Add(new GuiButton("Return",   layoutX[1], layoutY[3], delegate () { game.States.Pop(); }));

            generalLayerGUI.Add(new GuiButton("Return", layoutX[1], layoutY[3], delegate () { currentLayer = (int)settingStates.topLayer; }));

            audioLayerGUI.Add(new GUICheckBox(layoutX[1], layoutY[0], userSettings.MUSIC));
            audioLayerGUI.Add(new GUICheckBox(layoutX[1], layoutY[1], userSettings.SOUND));
            audioLayerGUI.Add(new GUISlider(  layoutX[1], layoutY[2], userSettings.VOLUME));
            audioLayerGUI.Add(new GuiButton("Return", layoutX[1], layoutY[3], delegate () { currentLayer = (int)settingStates.topLayer; }));

            videoLayerGUI.Add(new GuiButton("Return", layoutX[1], layoutY[3], delegate () { currentLayer = (int)settingStates.topLayer; }));

            controlsLayerGUI.Add(new GuiButton("Return", layoutX[1], layoutY[3], delegate () { currentLayer = (int)settingStates.topLayer; }));
        }
Пример #12
0
        public Explosion(Game game, float x, float y, ExplosionType type)
            : base(game, 0, "explosion")
        {
            X = x;
            Y = y;
            _animSpeed = 4f;
            _type = type;

            switch (_type) {

            case ExplosionType.Smoky:
                _template = new SpriteTemplate () { TilemapName = "units", Rectangle = new Rectangle(0, 832, 96, 96) };
                _frameCount = 16;
                _animSpeed = 4f;
                _lifeTime = -6;
                break;
            }

            _sprite = new Sprite(_template, 0, Priority.Explosion);
            _sprite[0].Angle = (ushort)Util.RandomInt(0,4095);
            _sprite[0].Scale = Util.Random(0.6f, 1.0f);
        }
Пример #13
0
        public ShopState(Game owner)
        {

        }
Пример #14
0
 public GameState(Game owner)
 {
     game = owner;
     Client.ConnectToServer(HelperFunctions.GetIP4Address());
 }
Пример #15
0
        static void Main(string[] args)
        {
            var p = new Game<CommandLineUI>("username", "password");

            p.Start();
        }
Пример #16
0
        public OptionsState(Game owner)
        {

        }
Пример #17
0
 public void OnGameStarted(Player player, Game newGame)
 {
     _clientProcessor.OnGameStarted(player, newGame);
 }
Пример #18
0
        public GameMenuState(Game owner)
        {

        }
Пример #19
0
 private static void GameWindowTask()
 {
     game = new Game();
     game.Run(60);
 }