Пример #1
0
        private async Task OnTick()
        {
            var hud = HeadupDisplay.GetModule();

            if (!hud.IsDisabled)
            {
                var ped    = API.PlayerPedId();
                var anchor = hud.GetMinimapAnchor();

                ScreenInterface.DrawText(
                    $"Tonläge: {(API.NetworkIsPlayerTalking(API.PlayerId()) ? "~b~" : "")}{Translate()}", 0.25f,
                    !API.IsPedSittingInAnyVehicle(ped)
                        ? new Vector2(anchor.X + 0.0005f,
                                      (float)(anchor.BottomY - anchor.UnitY * 18f / 2 / 2) - anchor.UnitY * 18f * 2 - 0.0005f)
                        : new Vector2(anchor.X + anchor.Width + 0.001f, (float)(anchor.BottomY - anchor.Height / 2)),
                    Color.FromArgb(200, 200, 200, 200));

                if (Game.IsControlPressed(0, Control.Sprint) && Game.IsControlJustPressed(0, Control.VehicleHeadlight))
                {
                    IterateRange();
                }
            }

            await Task.FromResult(0);
        }
Пример #2
0
        private async Task OnTick()
        {
            var player = Cache.Player;
            var entity = Cache.Entity;

            if (entity.IsDead)
            {
                WasDead = true;

                if (Timestamp < 1)
                {
                    player.DisableHud();

                    Timestamp = Date.Timestamp;
                }

                var timeLeft = new TimeSpan(Date.TimestampToTicks(Timestamp + 1000 * 60 * 20 - Date.Timestamp));

                ScreenInterface.DrawText(
                    timeLeft.Ticks > 1
                        ? $"Du är medvetslös. ({timeLeft.Minutes}:{timeLeft.Seconds})"
                        : "Du är medvetslös. (Tryck E för att återuppstå vid sjukhuset)",
                    0.3f, new Vector2(0.5f, 0.75f), Color.FromArgb(175, 175, 175), true);

                if (Game.IsControlJustPressed(0, Control.DropWeapon))
                {
                    API.ClearPedTasksImmediately(entity.Id);
                }

                if (timeLeft.Ticks < 1 && Game.IsControlJustPressed(0, Control.Context) &&
                    InterfaceManager.GetModule().MenuContext == null)
                {
                    API.DoScreenFadeOut(0);

                    player.Character.Revive(new Position(319.6946f, -573.5911f, 43.31747f, 231.9435f));

                    ItemHelper.RemoveAll(InventoryManager.GetModule().GetContainer("equipment_inventory"), self => true);
                    ItemHelper.RemoveAll(InventoryManager.GetModule().GetContainer("pockets_inventory"), self => true);

                    await BaseScript.Delay(3000);

                    API.DoScreenFadeIn(3000);
                }

                await Task.FromResult(0);
            }
            else
            {
                if (WasDead)
                {
                    Timestamp = 0;

                    player.EnableHud();
                }

                await BaseScript.Delay(1000);
            }
        }
Пример #3
0
    public void TakingLives()
    {
        maxHP--;
        _hpCounts.FindLast(h => h.activeSelf == true).SetActive(false);

        if (maxHP <= 0)
        {
            ScreenInterface.GetInstance().Execute(ScreenType.RestartMenu);
        }
    }
Пример #4
0
 private void Awake()
 {
     _controllers = new Controllers();
     Initialization();
     ScreenInterface.GetInstance().Execute(ScreenType.GameMenu);
     _mainCanvas               = GameObject.FindGameObjectWithTag("MainCanvas").GetComponent <Canvas>();
     _gameMenu                 = _mainCanvas.GetComponentInChildren <GameMenuBehaviour>();
     _helpButton               = _gameMenu.GameMenuHelpButton;
     _tutorialHand             = _mainCanvas.GetComponentInChildren <TutorialHandBehaviour>();
     CardDealerController      = (CardDealerController)_controllers._initializations[0];
     DifficultyController      = (DifficultyController)_controllers._initializations[1];
     CameraAnimationController = GetComponentInChildren <CameraAnimationController>();
 }
Пример #5
0
        public void Initialize(ControlEditorView control, GraphicsDevice graphicsdevice, IServiceProvider services)
        {
            this.Control        = control;
            this.GraphicsDevice = graphicsdevice;
            this.Services       = services;
            this.StateMachine   = new FiniteStateMachine();

            this.ActionManagers = new Dictionary <string, ActionManager>();

            this.ScreenInterface = new EditorInterface(control);

            //DataLoader.Initialize();
            FontRenderer.Instance.Initialize(GraphicsDevice);
        }
Пример #6
0
        public void changeToScreen(Screens s)
        {
            if (actualScreen != null)
                actualScreen.UnloadContent();

            switch (s)
            {
                case Screens.FilmList:
                    actualScreen = new FilmList(this);
                    break;
                default:
                    actualScreen = new MainMenu(this);
                    break;
            }

            if (actualScreen != null)
                actualScreen.Initialize();
        }
Пример #7
0
        private async Task OnTick()
        {
            var player = Cache.Player;

            if (player?.Entity != null && API.IsPedSittingInAnyVehicle(player.Entity.Id))
            {
                var entity = Cache.Entity;
                var anchor = GetMinimapAnchor();

                ScreenInterface.DrawText(
                    $"KM/H: {Math.Ceiling(API.GetEntitySpeed(API.GetVehiclePedIsIn(entity.Id, false)) * 3.6)}", 0.25f,
                    new Vector2(anchor.X + anchor.Width + 0.001f,
                                (float)(anchor.BottomY - anchor.Height / 2) - 0.025f),
                    Color.FromArgb(200, 200, 200, 200));
            }

            await Task.FromResult(0);
        }
Пример #8
0
        public void changeToScreen(Screens s)
        {
            if (actualScreen != null)
            {
                actualScreen.UnloadContent();
            }

            switch (s)
            {
            case Screens.FilmList:
                actualScreen = new FilmList(this);
                break;

            default:
                actualScreen = new MainMenu(this);
                break;
            }

            if (actualScreen != null)
            {
                actualScreen.Initialize();
            }
        }
Пример #9
0
        public bool Initalize(int screenWidth, int screenHeight, DirectoryInfo dataSet, bool showTutorial, Form parentForm, out string reason)
        {
            _parentForm = parentForm;

            Random = new Random();

            MousePos = new Point();

            ScreenWidth = screenWidth;
            ScreenHeight = screenHeight;
            GameDataSet = dataSet;

            Galaxy = new Galaxy();
            EmpireManager = new EmpireManager(this);

            ShipShader = GorgonLibrary.Graphics.FXShader.FromFile("ColorShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3);
            StarShader = GorgonLibrary.Graphics.FXShader.FromFile("StarShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3);

            if (!SpriteManager.Initialize(GameDataSet, out reason))
            {
                return false;
            }
            if (!FontManager.Initialize(GameDataSet, out reason))
            {
                return false;
            }
            RaceManager = new RaceManager();
            if (!RaceManager.Initialize(GameDataSet, Random, out reason))
            {
                return false;
            }
            AIManager = new AIManager();
            if (!AIManager.Initialize(GameDataSet, out reason))
            {
                return false;
            }
            MasterTechnologyManager = new MasterTechnologyManager();
            if (!MasterTechnologyManager.Initialize(this, out reason))
            {
                return false;
            }
            _mainGameMenu = new MainGameMenu();
            if (!_mainGameMenu.Initialize(this, out reason))
            {
                return false;
            }

            _screenInterface = _mainGameMenu;
            _currentScreen = Screen.MainMenu;

            _situationReport = new SituationReport(this);

            Cursor = SpriteManager.GetSprite("Cursor", Random);
            if (Cursor == null)
            {
                reason = "Cursor is not defined in sprites.xml";
                return false;
            }

            reason = string.Empty;
            return true;
        }
Пример #10
0
 public void ChangeToScreen(Screen whichScreen)
 {
     switch (whichScreen)
     {
         case Screen.MainMenu:
             if (_mainGameMenu == null)
             {
                 _mainGameMenu = new MainGameMenu();
                 string reason;
                 if (!_mainGameMenu.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Main Menu. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _screenInterface = _mainGameMenu;
             break;
         case Screen.NewGame:
             if (_newGame == null)
             {
                 _newGame = new NewGame();
                 string reason;
                 if (!_newGame.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading New Game Menu. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _screenInterface = _newGame;
             break;
         case Screen.Galaxy:
             if (_galaxyScreen == null)
             {
                 _galaxyScreen = new GalaxyScreen();
                 string reason;
                 if (!_galaxyScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Galaxy Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _galaxyScreen.CenterScreen();
             _screenInterface = _galaxyScreen;
             break;
         case Screen.Diplomacy:
             if (_diplomacyScreen == null)
             {
                 _diplomacyScreen = new DiplomacyScreen();
                 string reason;
                 if (!_diplomacyScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Diplomacy Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _diplomacyScreen.SetupScreen();
             _screenInterface = _diplomacyScreen;
             break;
         case Screen.FleetList:
             if (_fleetListScreen == null)
             {
                 _fleetListScreen = new FleetListScreen();
                 string reason;
                 if (!_fleetListScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Fleet List Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _fleetListScreen.LoadScreen();
             _screenInterface = _fleetListScreen;
             break;
         case Screen.ProcessTurn:
             EmpireManager.CurrentEmpire.ClearTurnData();
             if (_processingTurnScreen == null)
             {
                 _processingTurnScreen = new ProcessingTurnScreen();
                 string reason;
                 if (!_processingTurnScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Processing Turn Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             if (!EmpireManager.ProcessNextEmpire())
             {
                 _situationReport.Refresh();
                 ChangeToScreen(Screen.Galaxy);
                 break;
             }
             _screenInterface = _processingTurnScreen;
             break;
         case Screen.Battle:
             /*if (_spaceCombat == null)
             {
                 _spaceCombat = new SpaceCombat();
                 _spaceCombat.Initialize(this);
             }
             _spaceCombat.SetupScreen();
             _screenInterface = _spaceCombat;*/
             break;
     }
     _currentScreen = whichScreen;
 }
    // Use this for initialization
    void Awake()
    {
        // Se inicializa el estado del objeto.
        _iEnergy = iMaxEnergy;
        _action = Action.normal;
        _objKiller = _objKamikaze = null;

        // Se crea la barra de energía y se inicializan los parámetros relacionados.
        barEnergy = UIStateSprite.create( "Energy.png", 0, 0);
        barEnergy.zIndex = 1;
        bShowEnergy = false;
        bNewShowEnergy = true;
        fTimeShowEnergy = 0;
        barEnergy.hidden = true;

        thisAudioSource = audio;
        thisGameObject = gameObject;
        thisTransform = transform;
        thisRenderer = renderer;
        motionBot = GetComponent<MotionBot>();
        fMagnitude = thisRenderer.bounds.extents.magnitude; // Valor de la extensión del mesh de este enemigo.

        // Componente Stage del objeto que representa el nivel.
        stage = GameObject.Find( "Floor").GetComponent<Stage>();
        screenInterface = GameObject.Find( "Floor").GetComponent<ScreenInterface>();
    }
Пример #12
0
 public PokeButton(ScreenInterface screen, int x, int y, int w, int h) : base(screen, x, y, w, h)
 {
     screen.Controls.Add(this);
 }
Пример #13
0
		public PokeButton(ScreenInterface screen, int x, int y, int w, int h) : base(screen, x, y, w, h) {
			screen.Controls.Add(this);
		}
Пример #14
0
        public void ChangeToScreen(Screen whichScreen)
        {
            switch (whichScreen)
            {
            case Screen.MainMenu:
                if (_mainGameMenu == null)
                {
                    _mainGameMenu = new MainGameMenu();
                    string reason;
                    if (!_mainGameMenu.Initialize(this, out reason))
                    {
                        MessageBox.Show("Exception in loading Main Menu. Reason: " + reason);
                        _parentForm.Close();
                    }
                }
                _screenInterface = _mainGameMenu;
                break;

            case Screen.NewGame:
                if (_newGame == null)
                {
                    _newGame = new NewGame();
                    string reason;
                    if (!_newGame.Initialize(this, out reason))
                    {
                        MessageBox.Show("Exception in loading New Game Menu. Reason: " + reason);
                        _parentForm.Close();
                    }
                }
                _screenInterface = _newGame;
                break;

            case Screen.Galaxy:
                if (_galaxyScreen == null)
                {
                    _galaxyScreen = new GalaxyScreen();
                    string reason;
                    if (!_galaxyScreen.Initialize(this, out reason))
                    {
                        MessageBox.Show("Exception in loading Galaxy Screen. Reason: " + reason);
                        _parentForm.Close();
                    }
                }
                _galaxyScreen.CenterScreen();
                _screenInterface = _galaxyScreen;
                break;

            case Screen.Diplomacy:
                if (_diplomacyScreen == null)
                {
                    _diplomacyScreen = new DiplomacyScreen();
                    string reason;
                    if (!_diplomacyScreen.Initialize(this, out reason))
                    {
                        MessageBox.Show("Exception in loading Diplomacy Screen. Reason: " + reason);
                        _parentForm.Close();
                    }
                }
                _diplomacyScreen.SetupScreen();
                _screenInterface = _diplomacyScreen;
                break;

            case Screen.ProcessTurn:
                EmpireManager.CurrentEmpire.ClearTurnData();
                if (_processingTurnScreen == null)
                {
                    _processingTurnScreen = new ProcessingTurnScreen();
                    string reason;
                    if (!_processingTurnScreen.Initialize(this, out reason))
                    {
                        MessageBox.Show("Exception in loading Processing Turn Screen. Reason: " + reason);
                        _parentForm.Close();
                    }
                }
                if (!EmpireManager.ProcessNextEmpire())
                {
                    _situationReport.Refresh();
                    ChangeToScreen(Screen.Galaxy);
                    break;
                }
                _screenInterface = _processingTurnScreen;
                break;

            case Screen.Battle:
                /*if (_spaceCombat == null)
                 * {
                 *      _spaceCombat = new SpaceCombat();
                 *      _spaceCombat.Initialize(this);
                 * }
                 * _spaceCombat.SetupScreen();
                 * _screenInterface = _spaceCombat;*/
                break;
            }
            _currentScreen = whichScreen;
        }
Пример #15
0
 public void ChangeToScreen(Screen whichScreen)
 {
     if (_currentScreen == Screen.InGame && whichScreen != Screen.InGame)
     {
         //call OnGameOver
         OnGameOver();
     }
     _currentScreen = whichScreen;
     switch (whichScreen)
     {
         case Screen.MainMenu:
         {
             //Main Menu is always initialized before this point
             PlayerManager.Players.Clear();
             LevelNumber = 100;
             SetupLevel();
             _screenInterface = _mainMenu;
             // Clean up _host if we have left MultiplayerPreGameServer
             if (_host != null)
             {
                 if (!_host.IsShutDown)
                 {
                     _host.ShutDown();
                 }
                 _host.ObjectReceived -= HandleObject;
                 _host = null;
                 _clientAddressesAndMonikers.Clear();
             }
             // Clean up _client if we have left MultiplayerPreGameServer
             if (_client != null)
             {
                 if (!_client.IsShutDown)
                 {
                     _client.ShutDown();
                 }
                 _client.ObjectReceived -= HandleObject;
                 _client = null;
             }
             break;
         }
         case Screen.MultiplayerPreGameClient:
         {
             if (_multiplayerGameSetup == null)
             {
                 string reason;
                 _multiplayerGameSetup = new MultiplayerGameSetup();
                 if (!_multiplayerGameSetup.Initialize(this, out reason))
                 {
                     MessageBox.Show("Error in loading Multiplayer PreGame Screen.  Reason: " + reason);
                     ExitGame();
                 }
             }
             _screenInterface = _multiplayerGameSetup;
             break;
         }
         case Screen.MultiplayerPreGameServer:
         {
             if (_multiplayerGameSetup == null)
             {
                 string reason;
                 _multiplayerGameSetup = new MultiplayerGameSetup();
                 if (!_multiplayerGameSetup.Initialize(this, out reason))
                 {
                     MessageBox.Show("Error in loading Multiplayer PreGame Screen.  Reason: " + reason);
                     ExitGame();
                 }
             }
             if (_client != null)
             {
                 _client.ShutDown();
                 _client = null;
             }
             _host = new Host { CurrentlyAcceptingPlayers = true };
             _host.ObjectReceived += HandleObject;
             _screenInterface = _multiplayerGameSetup;
             PlayerList.Players = new [] { _mainMenu.PlayerName };
             NewPlayerListUpdate = true;
             break;
         }
         case Screen.InGame:
         {
             if (_inGame == null)
             {
                 string reason;
                 _inGame = new InGame();
                 if (!_inGame.Initialize(this, out reason))
                 {
                     MessageBox.Show("Error in loading In-Game Screen.  Reason: " + reason);
                     ExitGame();
                 }
             }
             ObjectManager.Clear();
             _screenInterface = _inGame;
             if (_host != null || _client != null)
             {
                 if (_host != null)
                 {
                     OnPushAsteroids(null, null);
                     _1000msPushDataTimer.Elapsed += OnPushAsteroids;
                     _1000msPushDataTimer.Start();
                 }
             }
             break;
         }
         case Screen.Upgrade:
         {
             if (_upgradeAndWaitScreen == null)
             {
                 string reason;
                 _upgradeAndWaitScreen = new UpgradeAndWaitScreen();
                 if (!_upgradeAndWaitScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Error in loading Upgrade Screen.  Reason: " + reason);
                     ExitGame();
                 }
             }
             lock (_lockDrawObject)
             {
                 _upgradeAndWaitScreen.RefreshLabels();
             }
             _screenInterface = _upgradeAndWaitScreen;
             if (IsHost)
             {
                 if (ShoppingPlayers == null)
                 {
                     ShoppingPlayers = new Dictionary<IPAddress, List<Object>>();
                 }
                 foreach (var item in _clientAddressesAndMonikers)
                 {
                     if (item.Value[ID] != null && PlayerManager.Players[ID].Bank >= MIN_COST_FOR_SHIP)
                     {
                         ShoppingPlayers.Add(item.Key, item.Value);
                     }
                 }
                 if (ShoppingPlayers.Count > 0)
                 {
                     _upgradeAndWaitScreen.DisableTheReadyButton();
                 }
                 else
                 {
                     _upgradeAndWaitScreen.EnableTheReadyButton();
                 }
                 _host.SendObjectTCP(new NetworkMessage { Content = "Change to " + Screen.Upgrade.ToString() + " Screen." });
             }
             else
             {
                 _upgradeAndWaitScreen.EnableTheReadyButton();
             }
             break;
         }
     }
 }
Пример #16
0
        public bool Initialize(int screenWidth, int screenHeight, Xasteroids parentForm, out string reason)
        {
            _parentForm = parentForm;
            Random = new Random();
            MousePos = new Point();
            ScreenSize = new Point(screenWidth, screenHeight);
            PlayerList = new PlayerList();

            ShipShader = GorgonLibrary.Graphics.FXShader.FromFile("ColorShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3);

            if (!SpriteManager.Initialize(out reason))
            {
                return false;
            }
            if (!FontManager.Initialize(out reason))
            {
                return false;
            }

            _backgroundStars = new BackgroundStars();
            if (!_backgroundStars.Initialize(this, out reason))
            {
                return false;
            }

            Cursor = SpriteManager.GetSprite("Cursor", Random);
            if (Cursor == null)
            {
                reason = "Cursor is not defined in sprites.xml";
                return false;
            }

            PlayerManager = new PlayerManager(this);
            AsteroidManager = new AsteroidManager(this);
            ObjectManager = new ObjectManager(this);
            ShipSelectionWindow = new ShipSelectionWindow();
            if (!ShipSelectionWindow.Initialize(this, out reason))
            {
                return false;
            }
            ShipSelectionWindow.ShipSelected += OnShipSelected;

            _mainMenu = new MainMenu();
            if (!_mainMenu.Initialize(this, out reason))
            {
                return false;
            }

            _screenInterface = _mainMenu;
            _currentScreen = Screen.MainMenu;

            ChatText = new StringBuilder();
            NewChatMessage = false;

            return true;
        }
Пример #17
0
        public bool Initalize(int screenWidth, int screenHeight, DirectoryInfo dataSet, bool showTutorial, Form parentForm, out string reason)
        {
            _parentForm = parentForm;

            Random = new Random();

            MousePos = new Point();

            ScreenWidth  = screenWidth;
            ScreenHeight = screenHeight;
            GameDataSet  = dataSet;

            Galaxy        = new Galaxy();
            EmpireManager = new EmpireManager(this);

            ShipShader = GorgonLibrary.Graphics.FXShader.FromFile("ColorShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3);
            StarShader = GorgonLibrary.Graphics.FXShader.FromFile("StarShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3);

            if (!SpriteManager.Initialize(GameDataSet, out reason))
            {
                return(false);
            }
            if (!FontManager.Initialize(GameDataSet, out reason))
            {
                return(false);
            }
            RaceManager = new RaceManager();
            if (!RaceManager.Initialize(GameDataSet, Random, out reason))
            {
                return(false);
            }
            AIManager = new AIManager();
            if (!AIManager.Initialize(GameDataSet, out reason))
            {
                return(false);
            }
            MasterTechnologyManager = new MasterTechnologyManager();
            if (!MasterTechnologyManager.Initialize(this, out reason))
            {
                return(false);
            }
            _mainGameMenu = new MainGameMenu();
            if (!_mainGameMenu.Initialize(this, out reason))
            {
                return(false);
            }

            _screenInterface = _mainGameMenu;
            _currentScreen   = Screen.MainMenu;

            _situationReport = new SituationReport(this);

            Cursor = SpriteManager.GetSprite("Cursor", Random);
            if (Cursor == null)
            {
                reason = "Cursor is not defined in sprites.xml";
                return(false);
            }

            reason = string.Empty;
            return(true);
        }