Beispiel #1
0
    protected override void FireWeapon()
    {
        base.FireWeapon();
        m_launcherState = LauncherState.LockingOn;
        // Create rocket
        GameObject newRocket = Instantiate(m_projectilePrefab);

        newRocket.transform.position = m_launchPositions[m_currentLaunchPosition].position;
        newRocket.transform.rotation = m_launchPositions[m_currentLaunchPosition].rotation;
        foreach (BaseProjectile projectileScript in newRocket.GetComponents <BaseProjectile>())
        {
            projectileScript.M_ProjectileFired(this.gameObject);
        }

        // Todo: move to specific projectile
        Collider[] ownUnitColliders = m_ownUnit.GetComponentsInChildren <Collider>();
        foreach (Collider collider in ownUnitColliders)
        {
            Physics.IgnoreCollision(newRocket.GetComponent <Collider>(), collider);
        }

        // Change to next launcher position
        m_currentLaunchPosition++;
        if (m_currentLaunchPosition >= m_launchPositions.Length)
        {
            m_currentLaunchPosition = 0;
        }
    }
        private void CheckStartUpdate()
        {
            // falls ein spiel gespielt wird, oder ein update läuft,
            // wird kein neues update gestartet
            if (State != LauncherState.IDLE)
            {
                return;
            }

            // sind keine updates eingereiht => nichts updaten
            if (pendingUpdates.Count == 0)
            {
                return;
            }

            currentUpdate = pendingUpdates.Dequeue();

            // events setzen
            updateWorker.DoWork             += currentUpdate.OnCheckForUpdates;
            updateWorker.ProgressChanged    += currentUpdate.OnProgressChanged;
            updateWorker.RunWorkerCompleted += currentUpdate.OnUpdateCompleted;
            updateWorker.RunWorkerCompleted += updateWorker_RunWorkerCompleted;

            // update starten
            updateWorker.RunWorkerAsync(updateWorker);
            State = LauncherState.GAME_UPDATING;
        }
Beispiel #3
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.X))
        {
            Debug.Log(State.ToString());
        }

        switch (State)
        {
        case LauncherState.Idle:

            if (spawn.Agents.Count - 1 == spawn.agentIndex)
            {
                State = LauncherState.End;
                break;
            }

            FixAgent();

            if (Input.GetKeyDown(KeyCode.Space))
            {
                record.Record();
            }
            break;

        case LauncherState.End:
            gm.CurrentState = GameState.Finished;

            break;

        case LauncherState.Launch:

            break;
        }
    }
Beispiel #4
0
        protected void OnDataLoadingStateChanged(LauncherState state)
        {
            var handler = DataLoadingStateChanged;

            if (handler != null)
            {
                //перенаправляем выполнение кода подписчиков в тот поток, в котором был создан экземпляр этого класса
                _syncContext.Post((unused) => { handler(this, new LauncherStateEventArgs(state)); }, null);
            }
        }
Beispiel #5
0
 public void SetState(LauncherState state)
 {
     if (state == LauncherState.Error)
     {
         if (progressBar.Style == ProgressBarStyle.Marquee)
         {
             progressBar.Style = ProgressBarStyle.Blocks;
             progressBar.Value = 0;
         }
     }
 }
        public MainWindow()
        {
            // udpate worker initalisieren
            updateWorker = new BackgroundWorker();
            updateWorker.WorkerReportsProgress      = true;
            updateWorker.WorkerSupportsCancellation = true;

            // nichts passiert gerade
            State = LauncherState.IDLE;

            pendingUpdates = new Queue <GameTab>();

            InitializeComponent();

            // einstellungen laden
            gameManager = new GameManager();

            // prüfen ob die datei existiert
            if (File.Exists(configFilePath))
            {
                // wenn ja => dann laden wir sie
                gameManager.Load(configFilePath);
            }
            else
            {
                // wenn nicht => erstellen wir standard games
                Game game1 = new Game();
                game1.Name = "Erstes Spiel";
                gameManager.games.Add(game1);

                // config speichern
                gameManager.Save(configFilePath);
            }

            // alle spiele durchgehen
            foreach (Game game in gameManager.games)
            {
                // tabitem erstellen
                TabItem item = new TabItem();
                // dem tabitem den namen des spieles als namen geben
                // item.Name = game.Name;
                // den anzeigenamen des tabs auf den spielenamen setzten
                item.Header = game.Name;
                // ein neues gametab erstellen und dem tabitem hinzufügen
                item.Content = new GameTab(game, this);
                // das tabitem dem tabcontrol hinzufügen
                GameTabControl.Items.Add(item);
            }
        }
        void updateWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // worker resetten
            updateWorker.DoWork             -= currentUpdate.OnCheckForUpdates;
            updateWorker.RunWorkerCompleted -= currentUpdate.OnUpdateCompleted;
            updateWorker.RunWorkerCompleted -= updateWorker_RunWorkerCompleted;
            updateWorker.ProgressChanged    -= currentUpdate.OnProgressChanged;

            // launcher state resetten
            currentUpdate = null;
            State         = LauncherState.IDLE;

            // prüfen ob das nächste Update starten soll
            CheckStartUpdate();
        }
Beispiel #8
0
 public void SetState(LauncherState state)
 {
     ThreadSafeInvoke(() =>
     {
         if (state == LauncherState.Error)
         {
             if (progressBar.Style == ProgressBarStyle.Marquee)
             {
                 progressBar.Style = ProgressBarStyle.Blocks;
                 progressBar.Value = 0;
             }
             label1.ForeColor = Color.Red;
             label1.Text      = "Launcher has encountered an error";
         }
     });
 }
Beispiel #9
0
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();
        if (m_launcherState == LauncherState.LockingOn)
        {
            m_lockonTime -= Time.deltaTime;
            if (m_lockonTime <= 0)
            {
                m_launcherState = LauncherState.LockedOn;
            }
        }

        if (m_launcherState == LauncherState.LockedOn && m_canFire) // Has to be both locked on and off cooldown
        {
            FireWeapon();
        }
    }
Beispiel #10
0
 public void ChangeLauncherState(LauncherState newState)
 {
     if (newState == LauncherState.AWAITING_LOGIN)
     {
         pnlCheckVersion.Visible   = false;
         pnlFullDownload.Visible   = false;
         pnlUpdateProgress.Visible = false;
         pnlLogin.Visible          = true;
         btnCancelUpdate.Visible   = false;
         btnFullDownload.Visible   = false;
         btnStartGame.Visible      = true;
         txtUsername.Select();
     }
     else if (newState == LauncherState.CHECKING_VERSION)
     {
         pnlFullDownload.Visible   = false;
         pnlUpdateProgress.Visible = false;
         pnlLogin.Visible          = false;
         pnlCheckVersion.Visible   = true;
         btnFullDownload.Visible   = false;
         btnStartGame.Visible      = false;
         btnCancelUpdate.Visible   = true;
     }
     else if (newState == LauncherState.FULL_DOWNLOAD_REQUIRED)
     {
         pnlUpdateProgress.Visible = false;
         pnlLogin.Visible          = false;
         pnlCheckVersion.Visible   = false;
         pnlFullDownload.Visible   = true;
         btnStartGame.Visible      = false;
         btnCancelUpdate.Visible   = false;
         btnFullDownload.Visible   = true;
     }
     else if (newState == LauncherState.UPDATING)
     {
         pnlLogin.Visible          = false;
         pnlCheckVersion.Visible   = false;
         pnlFullDownload.Visible   = false;
         pnlUpdateProgress.Visible = true;
         btnFullDownload.Visible   = false;
         btnStartGame.Visible      = false;
         btnCancelUpdate.Visible   = true;
     }
     launcherState = newState;
 }
Beispiel #11
0
        public Launcher(VersionInfo versionInfo, AuthResult authResult, Config config = null, bool disableXincgc = false)
        {
            _authResult       = authResult;
            VersionInfo       = versionInfo;
            State             = LauncherState.Initializing;
            _config           = config ?? Config.Load();
            _versionDirectory = Path.Combine(BmclCore.BaseDirectory, ".minecraft\\versions", VersionInfo.Id);
            _libraryDirectory = Path.Combine(BmclCore.MinecraftDirectory, "libraries");
            _nativesDirectory = Path.Combine(_versionDirectory, $"{VersionInfo.Id}-natives-{TimeHelper.TimeStamp()}");

            if (!disableXincgc)
            {
                _arguments.AddRange(new[] { "-Xincgc" });
            }
            if (!string.IsNullOrEmpty(_config.ExtraJvmArg))
            {
                _arguments.AddRange(ChildProcess.SplitCommandLine(_config.ExtraJvmArg));
            }
        }
Beispiel #12
0
        protected override void OnReset(bool enterGame)
        {
            var boids = Entity.GetByClass<TheBoringOne>();

            if(boids == null || boids.Count() < 1)
            {
                Debug.LogWarning("No boids found in the level");
                return;
            }

            remainingBoids = boids.ToList();

            Input.MouseEvents += ProcessMouseEvents;

            state = LauncherState.Ready;

            Instance = this;

            CurrentBoid.Position = Position;

            CurrentBoid.Physics.Resting = true;
        }
Beispiel #13
0
        private void UpdateLauncherState(LauncherState newState)
        {
            m_launcherState = newState;

            switch (m_launcherState)
            {
                case LauncherState.LS_SIGNIN:
                    passTF.Show();
                    userTF.Show();
                    passLBL.Show();
                    infoLBL.Show();
                    infoLBL.Text = "E-Mail";
                    registerLink.Show();
                    forgotPassLink.Show();
                    actionBtn.Enabled = true;
                    actionBtn.Text = LocRM.GetString("actionBtnSignIn");
                    pauseBtn.Hide();
                    playBtn.Hide();
                    totalProgressBar.Hide();
                    middleLBL.Hide();
                    break;
                case LauncherState.LS_ONLINE:
                    actionBtn.Enabled = true;
                    infoLBL.Text = LocRM.GetString("updateComplete"); ;
                    pauseBtn.Hide();
                    playBtn.Hide();
                    actionBtn.Text = LocRM.GetString("actionBtnOnline");
                    downloadBtn.Hide();
                    middleLBL.Show();
                    middleLBL.Text = String.Format(LocRM.GetString("updated") + " - V{0}", m_localVersionNumber);
                    break;
                case LauncherState.LS_OFFLINE:
                    passTF.Hide();
                    userTF.Hide();
                    passLBL.Hide();
                    totalProgressBar.Hide();
                    infoLBL.Hide();
                    downloadBtn.Hide();
                    middleLBL.Show();
                    registerLink.Hide();
                    forgotPassLink.Hide();
                    playBtn.Hide();
                    pauseBtn.Hide();
                    actionBtn.Text = LocRM.GetString("actionBtnOffline");
                    actionBtn.Enabled = true;
                    break;
                case LauncherState.LS_UPDATING:
                    pauseBtn.Show();
                    actionBtn.Enabled = false;
                    middleLBL.Hide();
                    downloadBtn.Hide();
                    totalProgressBar.Show();
                    infoLBL.Show();
                    infoLBL.Text = LocRM.GetString("initializingUpdate");
                    break;
            }
        }
Beispiel #14
0
 public LauncherStateEventArgs(LauncherState state)
 {
     State = state;
 }
 public void OnGameStopped()
 {
     // war ein update am laufen? weitermachen ansonsten idle
     State = currentUpdate != null ? LauncherState.GAME_UPDATING : LauncherState.IDLE;
 }
Beispiel #16
0
 public void ForceRepair()
 {
     m_launcherState = LauncherState.LS_REPAIRING;
     UpdateGame();
 }
Beispiel #17
0
        /// <summary>
        /// Invoked from the last fired boid (or the OnReset method) when it has stopped moving around.
        /// </summary>
        public void PostFire()
        {
            var playerCamera = Actor.Client as PlayerCamera;
            playerCamera.TargetEntity = CurrentBoid;

            CurrentBoid.Position = Position;
            CurrentBoid.Physics.Resting = true;

            state = LauncherState.Ready;
        }
Beispiel #18
0
 public override void M_AllowFire()
 {
     base.M_AllowFire();
     m_launcherState = LauncherState.LockingOn;
 }
Beispiel #19
0
        private void Fire(Vec3 mousePosWorld)
        {
            state = LauncherState.Firing;

            var targetDir = Vec3.ClampXYZ(Position - mousePosWorld, -MaxPullDistance, MaxPullDistance);
            targetDir.X = 0;

            CurrentBoid.Physics.Resting = false;
            CurrentBoid.Launch(targetDir * LauncherStrength);
            remainingBoids.Remove(CurrentBoid);
        }
Beispiel #20
0
        /// <summary>
        /// This function is used to process any mouse events, such as a change in cursor position, or clicks.
        /// </summary>
        /// <param name="x">The x position of the mouse on the screen.</param>
        /// <param name="y">The y position of the mouse on the screen.</param>
        /// <param name="mouseEvent">The event that occurred. Provides information on whether it was just a move, or whether something was clicked, etc.</param>
        /// <param name="wheelDelta"></param>
        private void ProcessMouseEvents(MouseEventArgs e)
        {
            switch(e.MouseEvent)
            {
                // If the event was the user left-clicking, then set the launcher into the Held state, which means we're getting ready to fire
                case MouseEvent.LeftButtonDown:
                    {
                        Vec3 relativePos = CurrentBoid.Position - Renderer.ScreenToWorld(e.X, e.Y);
                        // Check if the player clicked on the active boid.
                        if(CurrentBoid.LocalBoundingBox.Contains(ref relativePos) && remainingBoids.Any())
                        {
                            CurrentBoid.Position = Position;
                            CurrentBoid.Physics.Resting = true;
                            state = LauncherState.Held;
                        }
                    }
                    break;

                // When the left mouse button is released, that's treated as the fire signal
                // (provided the state is Held, of course, just as a sanity check)
                case MouseEvent.LeftButtonUp:
                    {
                        if(state == LauncherState.Held)
                        {
                            var playerCamera = Actor.Client as PlayerCamera;
                            playerCamera.TargetEntity = CurrentBoid;

                            Fire(Renderer.ScreenToWorld(e.X, e.Y));
                        }
                    }
                    break;

                case MouseEvent.Move:
                    {
                        var screenWorldPos = Renderer.ScreenToWorld(e.X, e.Y);
                        Debug.DrawSphere(screenWorldPos, .3f, Color.Red, .1f);

                        if(state == LauncherState.Held && (Math.Pow(screenWorldPos.Y - Position.Y, 2) + Math.Pow(screenWorldPos.Z - Position.Z, 2) - Math.Pow(MaxPullDistance, 2)) <= 0)
                        {
                            CurrentBoid.Position = Position - new Vec3(0, Position.Y - screenWorldPos.Y, Position.Z - screenWorldPos.Z);
                        }
                    }
                    break;
            }
        }
 public void OnGameStarted()
 {
     State = LauncherState.GAME_PLAYING;
 }
Beispiel #22
0
        public void changeButtonState(LauncherState newState, main MainForm)
        {
            state = newState;
            switch (state)
            {
            case LauncherState.Idle:
            {
                MainForm._Play.Text               = "Play";
                MainForm._Play.Enabled            = true;
                MainForm._TotalFile.Visible       = false;
                MainForm._estimatedTime.Visible   = false;
                MainForm._ProgressBar.Value       = 100;
                MainForm._TotalFile.Text          = "";
                MainForm._estimatedTime.Text      = "";
                MainForm._downloading.Visible     = false;
                MainForm._downloadingInfo.Visible = false;
                MainForm._Play.BackgroundImage    = Properties.Resources.button;
                break;
            }

            case LauncherState.Downloading:
            {
                MainForm._Play.Text               = "Downloading";
                MainForm._Play.Enabled            = false;
                MainForm._TotalFile.Visible       = true;
                MainForm._estimatedTime.Visible   = true;
                MainForm._TotalFile.Text          = "";
                MainForm._downloading.Visible     = true;
                MainForm._downloadingInfo.Visible = true;
                MainForm._Play.BackgroundImage    = Properties.Resources.buttonUpdate;
                break;
            }

            case LauncherState.PendingUpdate:
            {
                MainForm._Play.Text               = "Update";
                MainForm._Play.Enabled            = true;
                MainForm._ProgressBar.Value       = 0;
                MainForm._TotalFile.Visible       = true;
                MainForm._estimatedTime.Visible   = false;
                MainForm._downloading.Visible     = false;
                MainForm._downloadingInfo.Visible = false;
                MainForm._Play.BackgroundImage    = Properties.Resources.buttonUpdate;
                MainForm._Play.Update();
                break;
            }

            case LauncherState.Repair:
            {
                MainForm._Play.Text               = "Verifing";
                MainForm._Play.Enabled            = false;
                MainForm._TotalFile.Visible       = true;
                MainForm._estimatedTime.Visible   = false;
                MainForm._TotalFile.Text          = "";
                MainForm._downloading.Visible     = false;
                MainForm._downloadingInfo.Visible = false;
                MainForm._Play.BackgroundImage    = Properties.Resources.buttonUpdate;
                break;
            }

            case LauncherState.Uninstall:
            {
                MainForm._Play.Text               = "Uninstall";
                MainForm._Play.Enabled            = false;
                MainForm._TotalFile.Visible       = false;
                MainForm._estimatedTime.Visible   = false;
                MainForm._downloading.Visible     = false;
                MainForm._downloadingInfo.Visible = false;
                MainForm._Play.BackgroundImage    = Properties.Resources.buttonUpdate;
                break;
            }
            }
        }
Beispiel #23
0
    private IEnumerator ReturnToIdle()
    {
        yield return(new WaitForSeconds(2));

        State = LauncherState.Idle;
    }
Beispiel #24
0
 private void Backend_AccuracyProcessed(object sender, EventArgs e)
 {
     FindObjectOfType <Agent>().OnJump();
     CurrentAgent.AddComponent <Jump>();
     State = LauncherState.Launch;
 }
Beispiel #25
0
 private void FixAgent()
 {
     CurrentAgent = FindObjectOfType <Agent>().gameObject;
     CurrentAgent.transform.position = launcher_posn.transform.position;
     State = LauncherState.Idle;
 }