Ejemplo n.º 1
0
    private void Update()
    {
        foreach (LaunchControllerSO launchControllerSO in LaunchControllersSO)
        {
            LaunchData currenLaunchData = launchControllerSO.LaunchsData[launchControllerSO.CurrentState];

            if (currenLaunchData.Delay < launchControllerSO.Timer)
            {
                launchControllerSO.Timer -= currenLaunchData.Delay;

                if (currenLaunchData.Ship != null)
                {
                    Spawn(currenLaunchData);
                }

                launchControllerSO.CurrentCycle = ++launchControllerSO.CurrentCycle % currenLaunchData.Cycles;

                if (launchControllerSO.CurrentCycle == 0)
                {
                    launchControllerSO.CurrentState = ++launchControllerSO.CurrentState % launchControllerSO.LaunchsData.Count;
                }
            }
            launchControllerSO.Timer += Time.deltaTime * GameController.GameSpeed;
        }
    }
Ejemplo n.º 2
0
                public void LoadFromDevice(  )
                {
                    // at startup, this should be called to allow current objects to be restored.
                    string filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), LAUNCH_DATA_FILENAME);

                    // if the file exists
                    if (System.IO.File.Exists(filePath) == true)
                    {
                        // read it
                        using (StreamReader reader = new StreamReader(filePath))
                        {
                            string json = reader.ReadLine( );

                            try
                            {
                                // guard against the LaunchData changing and the user having old data.
                                LaunchData loadedData = JsonConvert.DeserializeObject <LaunchData>(json) as LaunchData;
                                if (loadedData.ClientModelVersion == Data.ClientModelVersion)
                                {
                                    Data = loadedData;
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
Ejemplo n.º 3
0
    // The launch the button is held down, the farther away the projectile goes
    private void ChargeLaunch()
    {
        if (canLaunch)
        {
            switch (launchMode)
            {
            case LaunchMode.launchTowardsRaycast:
                LaunchTowardRaycast();
                break;

            case LaunchMode.launchForward:
                LaunchForward();
                break;

            case LaunchMode.launchAtRaycast:
                LaunchAtRaycast();
                break;
            }

            maxDisplacementY += 0.2f * Time.deltaTime;

            // Update projectile arc
            LaunchData launchData = CalculateLaunchData(transform);
            DrawPath(transform, launchData); // Draw predicted path
        }
    }
Ejemplo n.º 4
0
        async Task <(bool success, string message)> LaunchCatalyst(LaunchData launchOptions, int port)
        {
            var projectDir = Path.GetDirectoryName(launchOptions.Project);

            if (!Directory.Exists(projectDir))
            {
                projectDir = launchOptions.WorkspaceDirectory;
            }

            Environment.SetEnvironmentVariable("__XAMARIN_DEBUG_HOSTS__", "127.0.0.1");
            Environment.SetEnvironmentVariable("__XAMARIN_DEBUG_PORT__", port.ToString());

            var args = new string[]
            {
                "build",
                //"--no-restore",
                "-f",
                launchOptions.ProjectTargetFramework,
                $"\"{launchOptions.Project}\"",
                "-t:Run"                 //,
                //"-verbosity:diag"
            };

            SendConsoleEvent("Executing: dotnet " + string.Join(" ", args));

            return(await Task.Run(() => DotnetRunner.Run(
                                      d => SendConsoleEvent(d),
                                      projectDir,
                                      args)));
        }
Ejemplo n.º 5
0
        public void SetLaunchData(LaunchData launchData)
        {
            var root          = Path.GetDirectoryName(typeof(HotReloadManager).Assembly.Location);
            var reloadifyPath = Path.Combine(root, "Reloadify", "Reloadify.dll");

            if (!File.Exists(reloadifyPath))
            {
                return;
            }

            var projectDir = Path.GetDirectoryName(launchData.Project);

            if (!Directory.Exists(projectDir))
            {
                projectDir = launchData.WorkspaceDirectory;
            }

            var args = new ProcessArgumentBuilder();

            args.AppendQuoted(reloadifyPath);

            args.AppendQuoted(launchData.Project);
            args.Append($"-t={launchData.ProjectTargetFramework}");
            args.Append($"-p={launchData.Platform}");
            args.Append($"-c={launchData.Configuration}");
            args.Append($"-f=\"{launchData.WorkspaceDirectory}\"");
            var runCommand = args.ToString();

            runner = new DotnetRunner(runCommand, projectDir, CancellationToken.None, s => Console.WriteLine(s));
        }
Ejemplo n.º 6
0
        public Func <float, Vector3> GetFunc(Vector3 startPos, Vector3 targetPos)
        {
            LaunchData data = CalculateLaunchData(startPos, targetPos);

            var relative = DisplacementFync(data);

            return((f) => startPos + relative(f));
        }
Ejemplo n.º 7
0
 public Projectile(Vector3 startPosition, Vector3 endPosition, float height, float gravity)
 {
     g = gravity;
     h = height;
     this.startPosition = startPosition;
     this.endPosition   = endPosition;
     launchData         = CalculateLaunchData(startPosition, endPosition);
 }
    private void DropNextPuck()
    {
        if (currentLaunch != null && remainingPucks > 0)
        {
            --remainingPucks;
            //GameObject puck = Instantiate<GameObject>(PuckPrefab, dropPosition, Quaternion.AngleAxis(-90f, new Vector3(1, 0, 0)));
            GameObject puck = Instantiate <GameObject>(PuckPrefab, dropPosition, PuckPrefab.transform.rotation);
            //GameObject puckGroup = Instantiate<GameObject>(PuckGroupPrefab, dropPosition, Quaternion.identity);
            //GameObject puck = puckGroup.transform.GetChild(0).gameObject;
            LaunchData puckData = puck.AddComponent <LaunchData>();
            puckData.Power  = currentLaunch.Power;
            puckData.Angle  = currentLaunch.Angle;
            puckData.Player = currentLaunch.PlayerInfo;
            //++triggerCount;
            if (currentLaunch.PlayerInfo.Avatar != null)
            {
                Renderer renderer = puck.GetComponent <Renderer>();
                if (renderer != null)
                {
                    renderer.material.SetTexture("_MainTex", currentLaunch.PlayerInfo.Avatar);
                }
                else
                {
                    Debug.LogError("Can't find puck renderer component.");
                }
            }

            Text userNameDisplay = puck.GetComponentInChildren <Text>();
            //Text userNameDisplay = puckGroup.GetComponentInChildren<Text>();
            if (userNameDisplay != null)
            {
                userNameDisplay.text = currentLaunch.PlayerInfo.DisplayName;
            }
            else
            {
                Debug.LogError("Can't find puck username display.");
            }

            Rigidbody rb = puck.GetComponent <Rigidbody>();
            if (rb != null)
            {
                rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ;
            }
            else
            {
                Debug.LogError("Launch Queue Manager could not get rigidbody of the puck prefab.");
            }
        }
        else if (launchQueue.Count > 0)
        {
            currentLaunch = launchQueue[0];
            launchQueue.RemoveAt(0);
            remainingPucks = currentLaunch.PuckCount;
            DropNextPuck();
        }
    }
Ejemplo n.º 9
0
    //발사 정보를 가져온다음 상태를 변경
    public void Shot()
    {
        m_LaunchData = m_Bow.GetVectorMoveToTarget();
        originPos    = transform.position;
        time         = 0f;

        SoundManager.Instance.EffectSoundPlay(SoundManager.EffectSounds.ARROW_SHOT);
        m_ArrowState = State.SHOT;
        EventManager.Instance.NotifyObservers(EventList.ARROW_SHOT_START);
    }
Ejemplo n.º 10
0
        private Func <float, Vector3> DisplacementFync(LaunchData data)
        {
            Func <float, Vector3> result = (f) => {
                var t       = data.timeToTarget * f;
                var forward = data.initialVelocity * t;
                var up      = Vector3.up * G * t * t / 2f;
                return(forward + up);
            };

            return(result);
        }
Ejemplo n.º 11
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter != null)
     {
         LaunchData ld = JsonConvert.DeserializeObject <LaunchData>((string)e.Parameter);
         if (ld != null && ld.type == typeof(Task))
         {
             FrameContent.Navigate(typeof(AddTask), ld.data);
         }
     }
 }
Ejemplo n.º 12
0
    public void DrawPath()
    {
        LaunchData launchData = GetVectorMoveToTarget();

        for (int i = 1; i <= m_DrawLineLen; i++)
        {
            float   simulationTime = (i / (float)m_MaxLineLen) * launchData.timeToTarget;
            Vector3 displacement   = (launchData.initialVelocity * simulationTime) + (Vector2.up * Physics2D.gravity.y * simulationTime * simulationTime / 2f);
            Vector3 drawPoint      = m_ArrowPos.position + displacement;
            m_LineRenderer.SetPosition(i - 1, drawPoint);
        }
    }
Ejemplo n.º 13
0
    void DrawParabolicArc()
    {
        LaunchData launchData = CalculateLaunchData(TargetRigidbody);

        for (int i = 0; i < LineRendererCount; i++)
        {
            float   simulationTime = i / (float)LineRendererCount * launchData.timeToTarget;
            Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * Gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = LaunchPosition + displacement;
            LineRenderer.SetPosition(i, drawPoint);
        }
    }
    private void FetchExternalVariables()
    {
        demonLaunchData = demon.GetComponent <LaunchData>();
        demonBody       = demon.GetComponent <Rigidbody>();
        demonSprite     = demon.GetComponent <SpriteRenderer>();

        anim  = GetComponent <PlayerAnimationController>();
        input = GetComponent <PlayerInput>();

        launcher = GetComponentInChildren <LaunchModule>();
        line     = GetComponentInChildren <LineDrawer>();
        targeter = GetComponentInChildren <PlayerTargettingManager>();
    }
Ejemplo n.º 15
0
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Launch();
            }

            if (debugPath)
            {
                LaunchData launchData = CalculateLaunchData();
                DrawPath(projectileRb.position, launchData.initialVelocity, launchData.timeToTarget, gravity, drawPathResolution);
            }
        }
Ejemplo n.º 16
0
    private void CupCatchHandler(GameObject cup, GameObject puck)
    {
        LaunchData launchData = puck.GetComponent <LaunchData>();

        if (launchData != null)
        {
            pointMultipliers[launchData.Player.Id] = PointMultiplier;
            puckMultipliers[launchData.Player.Id]  = PuckMultiplier;
        }
        else
        {
            Debug.LogError("PrizeComponent - Cup caught puck that has no launch data attached.");
        }
    }
Ejemplo n.º 17
0
    void SpawnPickableItems(Vector3 targetLoc)
    {
        LaunchData launchData        = CalculateLaunchData(targetLoc);
        Vector3    previousDrawPoint = LaunchRigidBody.position;

        int resolution = 10;

        Vector3 randVector = MyMath.RandomVectorInRange(Vector3.one * 0.3f, Vector3.one);
        Color   itemColor  = new Color(randVector.x, randVector.y, randVector.z);

        Gizmos.color = Color.green;
        for (int i = 1; i <= resolution; i++)
        {
            if (i > 2)
            {
                float   simulationTime = i / (float)resolution * launchData.timeToTarget;
                Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f;
                Vector3 drawPoint      = LaunchRigidBody.position + displacement;


                if (LevelManager.Instance.isBonusStage())
                {
                    GameObject obj = Instantiate(bonusLevelItemPrefab, drawPoint, Quaternion.LookRotation(previousDrawPoint - drawPoint));
                    allpickableItems.Add(obj);
                }
                else
                {
                    if (i == 7)
                    {
                        GameObject obj = Instantiate(getPickableItembasedOnlevel(), drawPoint, Quaternion.LookRotation(previousDrawPoint - drawPoint));
                        allpickableItems.Add(obj);
                    }
                    else
                    {
                        GameObject obj = Instantiate(RingItemPrefab, drawPoint, Quaternion.LookRotation(previousDrawPoint - drawPoint));
                        allpickableItems.Add(obj);
                    }
                }



                previousDrawPoint = drawPoint;

                if (i > resolution - 2)
                {
                    break;
                }
            }
        }
    }
Ejemplo n.º 18
0
    // Draws the predicted path of the projectile
    private void DrawPath(Transform projectile, LaunchData launchData)
    {
        Vector3[] positions = new Vector3[resolution + 1];

        for (int i = 0; i < resolution + 1; i++)
        {
            float   simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * gravityY * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = projectile.position + displacement;
            positions[i] = drawPoint;
        }
        projectilePath.positionCount = resolution + 1;
        projectilePath.SetPositions(positions);
    }
    private void BumperHitHandler(GameObject bumper, GameObject puck)
    {
        if (remainingHits > 0)
        {
            //objectiveText.text = string.Format(objectiveString, --remainingHits, goalHits);
            //display.Add(titleString, string.Format(objectiveString, --remainingHits, goalHits), 5, 0);
            if (EventList.AddRotatingText != null)
            {
                EventList.AddRotatingText(titleString, string.Format(objectiveString, --remainingHits, goalHits));
            }
            if (remainingHits <= 0)
            {
                //objectiveText.text = string.Format(completedString, goalHits);
                //display.Add(titleString, string.Format(objectiveString, --remainingHits, goalHits), 5, 0);
                if (EventList.AddRotatingText != null)
                {
                    EventList.AddRotatingText(titleString, string.Format(completedString, goalHits));
                }
                string missionId = Constants.GetMissionId(missionName);
                if (missionId == null)
                {
                    Debug.LogError("Could not retrieve mission Id for mission name: " + missionName);
                    return;
                }

                if (EventList.MissionCompleted != null)
                {
                    EventList.MissionCompleted(missionId);
                }
            }
        }

        LaunchData launchData = puck.GetComponent <LaunchData>();

        if (launchData != null)
        {
            if (hitsPerPlayer.ContainsKey(launchData.Player.DisplayName))
            {
                int currentHitAmount = hitsPerPlayer[launchData.Player.DisplayName];
                hitsPerPlayer[launchData.Player.DisplayName] = currentHitAmount + 1;
            }
            else
            {
                hitsPerPlayer.Add(launchData.Player.DisplayName, 1);
            }
        }

        UpdateLeaderboard();
    }
Ejemplo n.º 20
0
        void DrawPath()
        {
            LaunchData launchData        = CalculateLaunchData();
            Vector3    previousDrawPoint = ball.position;
            int        resolution        = 30;

            for (int i = 1; i <= resolution; i++)
            {
                float   simulationTime = i / (float)resolution * launchData.timeToTarget;
                Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f;
                Vector3 drawPoint      = ball.position + displacement;
                Debug.DrawLine(previousDrawPoint, drawPoint, Color.green);
                previousDrawPoint = drawPoint;
            }
        }
Ejemplo n.º 21
0
    private void CupCatchHandler(GameObject cup, GameObject puck)
    {
        PrizeComponent prize      = cup.GetComponent <PrizeComponent>();
        LaunchData     launchData = puck.GetComponent <LaunchData>();

        if (prize != null && launchData != null)
        {
            string userId = launchData.Player.Id;
            ApplyPrize(prize, userId);
        }
        else
        {
            Debug.LogError("UserManager - can't process cup catch because prize component or launch data was missing.");
        }
    }
Ejemplo n.º 22
0
    public static void DrawPath(Vector3 startPos, Vector3 endPos)
    {
        LaunchData launchData        = CalculateLaunchData(startPos, endPos);
        Vector3    previousDrawPoint = startPos;

        int resolution = 30;

        for (int i = 1; i <= resolution; i++)
        {
            float   simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * -9f * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = startPos + displacement;
            Debug.DrawLine(previousDrawPoint, drawPoint, Color.green);
            previousDrawPoint = drawPoint;
        }
    }
    private IEnumerator RotateAndFire(GameObject puck, LaunchData puckData)
    {
        float angle = Vector3.Angle(startForwardVector, Launcher.transform.forward);

        while (angle < (puckData.Angle - angleTolerance) || angle > (puckData.Angle + angleTolerance))
        {
            //float rotateAngle = LauncherTurnSpeed * Time.deltaTime * Mathf.Sign(angle - puckData.Angle);
            float rotateAngle = LauncherTurnSpeed * Time.deltaTime * Mathf.Sign(angle - puckData.Angle) * Mathf.Sign(Direction);
            Launcher.transform.RotateAround(rotatePoint, Vector3.forward, rotateAngle);
            yield return(null);

            angle = Vector3.Angle(startForwardVector, Launcher.transform.forward);
        }

        Fire(puck, puckData.Power);
    }
Ejemplo n.º 24
0
    void DrawPath()
    {
        LaunchData launchData = CalculateLaunchData();

        lineRenderer = GetComponent <LineRenderer>();

        int resolution = 30;

        for (int i = 1; i <= resolution; i++)
        {
            float   simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = potion.GetComponent <Rigidbody>().position + displacement;
            lineRenderer.SetPosition(i - 1, drawPoint);
        }
    }
Ejemplo n.º 25
0
    void DrawPath()
    {
        LaunchData launchData        = CalculateLaunchData();
        Vector3    previousDrawPoint = rb.position;

        int resolution = lr.positionCount - 1;

        for (int i = 0; i <= resolution; i++)
        {
            float   simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = rb.position + displacement;
            lr.SetPosition(i, previousDrawPoint);
            previousDrawPoint = drawPoint;
        }
    }
Ejemplo n.º 26
0
    void DrawPath(Vector3 targetLoc)
    {
        LaunchData launchData        = CalculateLaunchData(targetLoc);
        Vector3    previousDrawPoint = LaunchRigidBody.position;

        int resolution = 30;

        Gizmos.color = Color.green;
        for (int i = 1; i <= resolution; i++)
        {
            float   simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = LaunchRigidBody.position + displacement;
            Gizmos.DrawLine(previousDrawPoint, drawPoint);
            previousDrawPoint = drawPoint;
        }
    }
Ejemplo n.º 27
0
    void DrawPath()
    {
        LaunchData launchData        = CalculateDestination();
        Vector3    previousDrawPoint = ball.position;

        int resolution = 30;

        for (int i = 1; i <= resolution; i++)
        {
            float   simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 distance       = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = ball.position + distance;
            //Debug.DrawLine(previousDrawPoint, drawPoint,Color.green);
            lineDrawer[i - 1].DrawLineInGameView(previousDrawPoint, drawPoint, Color.green);
            previousDrawPoint = drawPoint;
        }
    }
Ejemplo n.º 28
0
    /// <summary>
    /// 0-basket, 1-baseball
    /// </summary>
    public void DrawPath(int id, Rigidbody rb)
    {
        LaunchData launchData = CalculateLaunchData(rb, _basketHeight);

        if (id == 0)
        {
            var _dist = Vector3.Distance(_target.position, transform.position);
            _basketHeight = _dist * _heightMultiplier;
            _basketHeight = Mathf.Clamp(_basketHeight, 0, _maxBasketHeight);
            launchData    = CalculateLaunchData(rb, _basketHeight);
        }

        else if (id == 1)
        {
            var _dist = Vector3.Distance(_target.position, transform.position);
            _baseballHeight = _dist * _heightMultiplier;
            _baseballHeight = Mathf.Clamp(_baseballHeight, 0, _maxBaseballHeight);
            launchData      = CalculateLaunchData(rb, _baseballHeight);
        }


        Vector3 previousDrawPoint = rb.position;

        _path = new Vector3[_resolution];

        for (int i = 0; i < _resolution; i++)
        {
            float   simulationTime = i / (float)_resolution * launchData.timeToTarget;
            Vector3 displacement   = launchData.initialVelocity * simulationTime + Vector3.up * _gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint      = rb.position + displacement;
            _path[i] = drawPoint;
            Debug.DrawLine(previousDrawPoint, drawPoint, Color.green);
            previousDrawPoint = drawPoint;

            if (_line.positionCount != _resolution)
            {
                _line.positionCount = _resolution;
            }

            if (i < _resolution)
            {
                _line.SetPosition(i, drawPoint);
            }
        }
    }
Ejemplo n.º 29
0
    // Launches the projectile on the predicted path
    private void Launch()
    {
        if (canLaunch)
        {
            GameObject projectile = Instantiate(projectilePrefab, transform.position, transform.rotation); // Create projectile
            // TODO: reduce duplicate code by sending launchData from ChargeLaunch() to Launch()
            LaunchData launchData = CalculateLaunchData(projectile.transform);
            projectile.GetComponent <Rigidbody>().velocity = launchData.initialVelocity; // Launch projectile
            DrawPath(projectile.transform, launchData);                                  // Draw predicted path
            canLaunch = false;

            // Needed for LaunchTowardRaycast)
            isCharging = false;

            // Needed for LaunchForward()
            targetDisplacement = 0;
        }
    }
Ejemplo n.º 30
0
    //Draw arc and split it up to 30 line segments
    void DrawPath()
    {
        LaunchData launchData        = CalculateLaunchData();
        Vector3    previousDrawPoint = ball.position;

        //number of line segments
        int resolution = 30;

        for (int i = 1; i <= resolution; i++)
        {
            //gets the current time to draw the line, value between 0 and overall time
            float simulationTime = i / (float)resolution * launchData.timeToTarget;
            //s = ut + (at^2 / 2)
            Vector3 displacement = launchData.initialVelocity * simulationTime + Vector3.up * gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint    = ball.position + displacement;
            Debug.DrawLine(previousDrawPoint, drawPoint, Color.green);
            previousDrawPoint = drawPoint;
        }
    }
Ejemplo n.º 31
0
        private void Worker()
        {
            PROCESS_INFORMATION pi = new PROCESS_INFORMATION();

            try {
                Safe.SetEnabled(abortButton, true);
                Safe.SetEnabled(exitButton, false);
                ResetProgress();

                LaunchData info = new LaunchData();
                info.LaunchEventId = "phoenix_load_" + new Random().Next(0xFFFF).ToString();
                info.ClientExe = server.ClientExe;
                info.UltimaDir = server.UltimaDir;
                info.PhoenixDir = Constants.PhoenixDir;
                info.Address = server.Address;
                info.ServerEncName = server.Encryption;
                info.Username = account.Name;
                info.Password = account.Password;

                // Read encryption
                UOKey keys;
                if (Constants.UOKeys.List.TryGetValue(server.Encryption, out keys)) {
                    info.ServerEncryption = keys.GameEncryption.ToString();
                    info.ServerKey1 = keys.Key1;
                    info.ServerKey2 = keys.Key2;
                }
                else {
                    PrintEvent(Resources.Launcher_LoadingEncryption + "..");
                    throw new Exception(Resources.Launcher_CannotFindEncryption + " UOKeys.cfg");
                }

                // Check client list for selected client
                PrintEvent(Resources.Launcher_CheckingClient + "..");
                bool clientCheck = CheckClient(out info.ClientHash);
                if (clientCheck)
                    PrintResult(Resources.Launcher_Known, System.Drawing.Color.Green);
                else
                    PrintResult(Resources.Launcher_Unknown, System.Drawing.Color.Black);

                // Save config files
                PrintEvent(Resources.Launcher_Saving + " login.cfg..");
                LaunchEvents.SaveLoginCfg(server.UltimaDir, server.Address);
                PrintResult(Resources.Launcher_Done, System.Drawing.Color.Green);

                PrintEvent(Resources.Launcher_Saving + " uo.cfg..");
                LaunchEvents.SaveUoCfg(server, account);
                PrintResult(Resources.Launcher_Done, System.Drawing.Color.Green);

                // Update registry
                PrintEvent(Resources.Launcher_UpdatingRegistry + "..");
                if (LaunchEvents.UpdateRegistry(server.UltimaDir, forceRegistryUpdate))
                    PrintResult(Resources.Launcher_Done, System.Drawing.Color.Green);
                else
                    PrintResult(Resources.Launcher_Skipped, Color.Black);

                // Start suspended client
                PrintEvent(Resources.Launcher_StartingClient + "..");
                STARTUPINFO si = new STARTUPINFO();
                si.cb = Marshal.SizeOf(si);

                if (!Api.CreateProcess(null, info.ToString(), IntPtr.Zero, IntPtr.Zero, false,
                          CreationFlags.CREATE_SUSPENDED, IntPtr.Zero, info.UltimaDir, ref si, out pi)) {
                    uint err = Api.GetLastError();
                    throw new Exception(Resources.Launcher_UnableToStartClient + " " + Resources.Launcher_ErrorNumber + " = 0x" + err.ToString("X"));
                }
                PrintResult(Resources.Launcher_Done, System.Drawing.Color.Green);

                // Patch client
                PrintEvent(Resources.Launcher_PatchingClient + "..");
                LaunchEvents.PatchClient(pi.hProcess, pi.hThread);
                PrintResult(Resources.Launcher_Done, System.Drawing.Color.Green);

                // Resume client execution
                PrintEvent(Resources.Launcher_RunningClient + "..");

                EventWaitHandle hEvent = new EventWaitHandle(false, EventResetMode.AutoReset, info.LaunchEventId);
                if (((int)Api.ResumeThread(pi.hThread)) < 0) {
                    uint err = Api.GetLastError();
                    throw new Exception(Resources.Launcher_UnableToResumeClient + " " + Resources.Launcher_ErrorNumber + " = 0x" + err.ToString("X"));
                }

                if (!hEvent.WaitOne(8000, false))
                    throw new Exception(Resources.Launcher_UnableToDetectPhoenix);
                else
                    PrintResult(Resources.Launcher_Done, System.Drawing.Color.Green);

                success = true;
                PrintEvent(Resources.Launcher_Finished);
                Safe.SetValue(progressBar, progressBar.Value + 1);

                Safe.SetEnabled(abortButton, false);
                Safe.SetText(exitButton, Resources.Launcher_Done);
                Safe.SetEnabled(exitButton, true);

                Thread.Sleep(2000);
                Safe.Close(this);
            }
            catch (Exception e) {
                PrintError();

                Safe.SetEnabled(abortButton, false);
                Safe.SetText(exitButton, Resources.Launcher_Exit);
                Safe.SetEnabled(exitButton, true);

                success = false;
                if (pi.hProcess != null) Api.TerminateProcess(pi.hProcess, uint.MaxValue);

                MessageBox.Show(e.Message, Resources.Launcher_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 32
0
 public RockLaunchData( )
 {
     Data = new LaunchData( );
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Translate incoming args to the args we'll pass to the screen saver app.
        /// </summary>
        /// <param name="incomingArgs"></param>
        /// <returns>Returns TRUE if something critical failed and program should abort launch.</returns>
        private static bool TryParseScreenSaverArgs(string[] incomingArgs, ref LaunchData zoopy, ref string AbortReason)
        {
            bool fAbort = false;
            string outModeStr = "";
            bool fHasWindowHandle = false;
            string outHwndStr = "";

            // Examine incoming args and build outgoing args.
            // When Windows launches a screen saver, it sends specific
            // command line args. Those will only ever be the following
            // (EB = the behavior that Windows expects):
            //  /S                - EB: run screensaver in fullscreen
            //                      so we pass /screensaver to our app
            //  /P outHwndStr   - EB: show little Preview in control panel
            //                      so we pass /cp_minipreview -outHwndStr
            //  no args           - EB: show Settings dlg on desktop
            //                      so we pass /dt_configure
            //  /C                - EB: show Settings dlg on desktop
            //                      so we pass /dt_configure
            //  /C:outHwndStr   - EB: show Settings modal to control panel
            //                      so we pass /cp_configure -outHwndStr

            if (incomingArgs.Length < 1) // no args
            {
                ourLaunchData.LaunchMode = ScrSvrLaunchMode.Configure;
                outModeStr = M_DT_CONFIGURE;
            }
            else if (incomingArgs.Length < 2) // 1 arg
            {
                // can only be:
                //  /S or
                //  /C or
                //  /C:hWnd  (note: single arg, no space in it)

                // these two are exclusive, only one will ever be true
                if (incomingArgs[0].ToLowerInvariant().Trim() == @"/s")
                {
                    outModeStr = M_SCREENSAVER;
                    ourLaunchData.LaunchMode = ScrSvrLaunchMode.Default;
                }
                if (incomingArgs[0].ToLowerInvariant().Trim() == @"/c")
                {
                    ourLaunchData.LaunchMode = ScrSvrLaunchMode.Configure;
                    outModeStr = M_DT_CONFIGURE;
                }

                if (incomingArgs[0].ToLowerInvariant().Trim().StartsWith(@"/c:"))
                {
                    ourLaunchData.LaunchMode = ScrSvrLaunchMode.CP_Configure;
                    outModeStr = M_CP_CONFIGURE;
                    // get the chars after /c: for the outHwndStr
                    outHwndStr = incomingArgs[0].Substring(3);
                    fHasWindowHandle = true;
                }
            }
            else if (incomingArgs.Length < 3) // 2 args
            {
                // can only be /P outHwndStr (note space)
                ourLaunchData.LaunchMode = ScrSvrLaunchMode.CP_Preview;
                outModeStr = M_CP_MINIPREVIEW;
                fHasWindowHandle = true;
                outHwndStr = incomingArgs[1];
            }
            else
            {
                AbortReason = "CommandLine had more than 2 arguments, could not parse.";
                fAbort = true;
            }

            // add outModeStr info to outgoingArgs
            ourLaunchData.OutGoingArgs = FROMSTUB + " " + outModeStr;

            // process window handle
            if (fHasWindowHandle)
            {
                // Validate hWnd, as modal dialogs in this launcher will use it
                bool IsValid = false;
                IntPtr hWnd = IntPtr.Zero;

                IsValid = TryGetValidatedWindowHandle(outHwndStr, ref hWnd);
                if (!IsValid)
                {
                    AbortReason = "Bad hWnd passed to screen saver launcher.";
                    fAbort = true;
                }

                // add outHwndStr as str to OutGoingArgs
                ourLaunchData.OutGoingArgs += " -" + outHwndStr;
                ourLaunchData.PassedHwnd = hWnd;
            }
            else  // incoming args did not contain hWnd
            {
                ourLaunchData.PassedHwnd = IntPtr.Zero;
            }

            return fAbort;
        }
Ejemplo n.º 34
0
        internal static void Initialize()
        {
            if (initialized)
                throw new InvalidProgramException();
            initialized = true;

            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            Core.LoginComplete += new EventHandler(Core_LoginComplete);
            Core.Disconnected += new EventHandler(Core_Disconnected);

            launchData = LaunchData.FromCmdLine(System.Environment.CommandLine);

            clientThreadId = Thread.CurrentThread.ManagedThreadId;

            SetInitEvent();
            InitLogging();

            // TODO: Set security

            try {
                culture = CultureInfo.GetCultureInfo(launchData.Culture);
            }
            catch (Exception e) {
                culture = CultureInfo.GetCultureInfo("en-US");
                ExceptionDialog.Show(e, "Error creating requested culture.");
            }

            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = true;

            if (!clientKeys.Load()) {
                ShowMessageBoxAsync("Unknown Client. Please use the same account and password you specified in launcher.", "Information");
            }
            spellList = new SpellList();

            Config.InternalSettings.Path = Path.Combine(launchData.PhoenixDir, SettingsFile);

            Config.Init();
            Config.Profile.ProfileChanged += new EventHandler(Profile_ProfileChanged);

            guiThread = new PhoenixGuiThread();

            // Run DataFiles.Load in different thread.
            Thread loadDataFilesThread = new Thread(new ParameterizedThreadStart(DataFiles.Load));
            loadDataFilesThread.Start(launchData.UltimaDir);

            Phoenix.Logging.JournalHandler.Init();
            Notepad.Init();
            Phoenix.Runtime.ReportViewer.Init();
            Journal.Init();
            WorldPacketHandler.Init();
            Aliases.Init();
            LoginInfo.Init();
            UIManager.Init();
            SpeechColorOverride.Init();
            Phoenix.Runtime.ClientMessageHandler.Init();
            Phoenix.Runtime.RuntimeCore.Hotkeys.Init();
            LatencyMeasurement.Init();

            // Create scripts and plugins dir if doesn't exists
            DirectoryInfo scriptsDir = new DirectoryInfo(Phoenix.Runtime.RuntimeCore.ScriptsDirectory);
            if (!scriptsDir.Exists) scriptsDir.Create();

            DirectoryInfo pluginsDir = new DirectoryInfo(Phoenix.Runtime.RuntimeCore.PluginsDirectory);
            if (!pluginsDir.Exists) pluginsDir.Create();

            Core.RegisterServerMessageCallback(0xA9, new MessageCallback(OnCharacterList), CallbackPriority.Highest);
            Core.RegisterServerMessageCallback(0x1B, new MessageCallback(OnLoginConfirmedPacket), CallbackPriority.Normal);
            Core.RegisterServerMessageCallback(0x55, new MessageCallback(OnLoginCompletePacket), CallbackPriority.Highest);

            loadDataFilesThread.Join();

            PlayerSkills.Init();

            Config.Profile.FpsLimit.Changed += new EventHandler(FrameLimit_Changed);

            Config.InternalSettings.Load();
            Config.Profile.LoadDefault();

            Phoenix.Runtime.RuntimeCore.RegisterPhoenix();
            Phoenix.Runtime.RuntimeCore.ReloadPlugins();
            Phoenix.Runtime.RuntimeCore.CompileScripts(true);

            Trace.WriteLine("Phoenix initialized.", DateTime.Now.ToString());
        }