Ejemplo n.º 1
0
    public void JumpTo(WorldMapArea area)
    {
        Debug.Assert(jumpRoutine == null, "jump routine must not already be in progress");

        jumpTarget = area;
        jumpRoutine = StartCoroutine(JumpRoutine());
    }
        private static bool Matches(WorldMapArea area, string[] s)
        {
            var areaname = s[0].Replace(" ", "").Replace("'", "");

            return(areaname.StartsWith(area.AreaName, StringComparison.InvariantCultureIgnoreCase) ||
                   area.AreaName.StartsWith(areaname, StringComparison.InvariantCultureIgnoreCase));
        }
Ejemplo n.º 3
0
    private IEnumerator JumpRoutine()
    {
        Debug.Assert(Moorable.State == DockingState.InSpace);
        Debug.Assert(SpaceTraderConfig.WorldMap && SpaceTraderConfig.WorldMap.JumpEffectCurve != null);

        yield return null;

        //make sure this still exists..
        if (!jumpTarget)
        {
            yield break;
        }

        ResetControls();

        //TODO: don't just instantly go to correct rot
        var jumpDir = jumpTarget.transform.position.normalized;

        bool aimingAtTarget;
        do
        {
            aimingAtTarget = RotateToDirection(jumpDir);
            yield return null;
        } while (!aimingAtTarget);
        
        //cheat - snap the last bit, if any
        transform.rotation = Quaternion.LookRotation(jumpDir, transform.up);

        //disable physics
        RigidBody.isKinematic = true;
        RigidBody.angularVelocity = Vector3.zero;
        RigidBody.velocity = Vector3.zero;
        Collider.enabled = false;

        var jumpOrigin = transform.position;
        var jumpEnd = transform.position + (jumpDir * JUMP_DIST);
        var jumpCurve = SpaceTraderConfig.WorldMap.JumpEffectCurve;

        float jumpProgress = 0;
        float increment = 1 / JUMP_TIME;
        while (jumpProgress < 1)
        {
            float effectPos = jumpCurve.Evaluate(jumpProgress);

            transform.position = Vector3.LerpUnclamped(jumpOrigin, jumpEnd, effectPos);
            jumpProgress += Time.deltaTime * increment;

            yield return null;
        }

        /* this is likely to destroy or reset us, so do this last,
         but before JumpTarget is unset so receivers can figure out
         where we jumped to */
        SendMessage("OnCompletedJump");

        jumpTarget = null;
        jumpRoutine = null;
    }
Ejemplo n.º 4
0
        public bool TryGet(int uiMapId, out WorldMapArea area)
        {
            if (areas.TryGetValue(uiMapId, out var map))
            {
                area = map;
                return(true);
            }

            area = default;
            return(false);
        }
Ejemplo n.º 5
0
 public static WorldMapMarker Create(WorldMapMarker prefab, WorldMapArea forArea)
 {
     var marker = (WorldMapMarker) Instantiate(prefab);
     marker.transform.SetParent(forArea.transform, false);
     marker.transform.localPosition = Vector3.zero;
     marker.transform.localRotation = Quaternion.identity;
     marker.forArea = forArea;
     marker.gameObject.layer = LayerMask.NameToLayer("World Map");
     
     return marker;
 }
Ejemplo n.º 6
0
 public static void LoadMapsEditorFiles()
 {
     try
     {
         DbcStores.InitFiles();
         WorldMapArea.LoadData();
         WorldMapOverlay.LoadData();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 7
0
 public static void LoadPoIsEditorFiles()
 {
     try
     {
         DbcStores.InitFiles();
         AreaPoi.LoadData();
         AreaTable.LoadData();
         DungeonMap.LoadData();
         Map.LoadData();
         WorldMapArea.LoadData();
         WorldMapOverlay.LoadData();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private static void PopulateUIMap(WorldMapArea area, IEnumerable <string[]> uimapLines)
        {
            var kalidor = uimapLines.Where(s => s[0] == "Kalimdor").Select(s => s[1]).FirstOrDefault();

            var matches = uimapLines.Where(s => Matches(area, s))
                          .ToList();

            if (matches.Count > 1)
            {
            }

            if (matches.Count == 0)
            {
            }

            matches.ForEach(a =>
            {
                area.UIMapId   = int.Parse(a[1]);
                area.Continent = a[2] == kalidor ? "Kalimdor" : "Azeroth";
            });
        }
Ejemplo n.º 9
0
        protected override void InitializeComponents()
        {
            var canvas            = new Canvas();
            var canvasBackTexture = Engine.Instance.Renderer.CreateTexture(MRes.UIWindow2_img_WorldMap_Border_0);

            canvas.Background = new ImageBrush()
            {
                ImageSource = new BitmapImage()
                {
                    Texture = canvasBackTexture
                }, Stretch = Stretch.None
            };
            canvas.SetBinding(Canvas.WidthProperty, new Binding(UIWorldMap.WidthProperty)
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            canvas.SetBinding(Canvas.HeightProperty, new Binding(UIWorldMap.HeightProperty)
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            canvas.Parent = this;
            this.Content  = canvas;

            Border title = new Border();

            title.Height = 17;
            title.SetBinding(Canvas.WidthProperty, new Binding(Canvas.WidthProperty)
            {
                Source = canvas
            });
            canvas.Children.Add(title);
            this.SetDragTarget(title);

            ComboBox cmbMaps = new ComboBox();

            cmbMaps.Width  = 150;
            cmbMaps.Height = 20;
            Canvas.SetLeft(cmbMaps, 10);
            Canvas.SetTop(cmbMaps, 23);
            cmbMaps.SetBinding(ComboBox.SelectedItemProperty, new Binding(UIWorldMap.CurrentWorldMapProperty)
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            canvas.Children.Add(cmbMaps);
            this.CmbMaps = cmbMaps;

            WorldMapArea mapArea = new WorldMapArea();

            mapArea.Width  = 640;
            mapArea.Height = 480;
            Canvas.SetLeft(mapArea, 7);
            Canvas.SetTop(mapArea, 44);
            canvas.Children.Add(mapArea);
            this.SetBinding(CurrentWorldMapProperty, new Binding(Control.DataContextProperty)
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.SetBinding(CurrentMapIDProperty, new Binding("CurrentMapID")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.MapArea = mapArea;

            Button btnBack = new Button();

            btnBack.Width   = 50;
            btnBack.Height  = 20;
            btnBack.Content = "返回";
            btnBack.Click  += BtnBack_Click;
            Canvas.SetLeft(btnBack, 180);
            Canvas.SetTop(btnBack, 23);
            canvas.Children.Add(btnBack);

            this.Width  = canvasBackTexture.Width;
            this.Height = canvasBackTexture.Height;
            base.InitializeComponents();
        }
Ejemplo n.º 10
0
        protected override void InitializeComponents()
        {
            var canvas            = new Canvas();
            var canvasBackTexture = Engine.Instance.AssetManager.LoadTexture(null, nameof(MRes.UIWindow2_img_WorldMap_Border_0));

            canvas.Background = new ImageBrush()
            {
                ImageSource = new BitmapImage()
                {
                    Texture = canvasBackTexture
                }, Stretch = Stretch.None
            };
            canvas.SetBinding(Canvas.WidthProperty, new Binding(UIWorldMap.WidthProperty)
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            canvas.SetBinding(Canvas.HeightProperty, new Binding(UIWorldMap.HeightProperty)
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            canvas.Parent = this;
            this.Content  = canvas;

            Border title = new Border();

            title.Height = 17;
            title.SetBinding(Canvas.WidthProperty, new Binding(Canvas.WidthProperty)
            {
                Source = canvas
            });
            canvas.Children.Add(title);
            this.SetDragTarget(title);

            ComboBox cmbMaps = new ComboBox();

            cmbMaps.Width  = 150;
            cmbMaps.Height = 20;
            Canvas.SetLeft(cmbMaps, 10);
            Canvas.SetTop(cmbMaps, 23);
            cmbMaps.SetBinding(ComboBox.SelectedItemProperty, new Binding(UIWorldMap.CurrentWorldMapProperty)
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            canvas.Children.Add(cmbMaps);
            this.CmbMaps = cmbMaps;

            ComboBox cmbQuestList = new ComboBox();

            cmbQuestList.Width  = 100;
            cmbQuestList.Height = 20;
            Canvas.SetLeft(cmbQuestList, 250);
            Canvas.SetTop(cmbQuestList, 23);
            cmbQuestList.SetBinding(ComboBox.SelectedIndexProperty, new Binding(UIWorldMap.SelectedQuestLimitIndexProperty)
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            canvas.Children.Add(cmbQuestList);
            this.CmbQuestList = cmbQuestList;

            WorldMapArea mapArea = new WorldMapArea();

            mapArea.Width  = 640;
            mapArea.Height = 480;
            mapArea.InputBindings.Add(new InputBinding(new RelayCommand(MapArea_RightClick), new MouseGesture(MouseAction.RightClick)));
            Canvas.SetLeft(mapArea, 7);
            Canvas.SetTop(mapArea, 44);
            canvas.Children.Add(mapArea);
            this.SetBinding(CurrentWorldMapProperty, new Binding(Control.DataContextProperty)
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.SetBinding(CurrentMapIDProperty, new Binding("CurrentMapID")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.SetBinding(SelectedQuestLimitIndexProperty, new Binding("SelectedQuestIndex")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.MapArea = mapArea;

            Button btnBack = new Button();

            btnBack.Width   = 50;
            btnBack.Height  = 20;
            btnBack.Content = "返回";
            btnBack.Click  += BtnBack_Click;
            Canvas.SetLeft(btnBack, 180);
            Canvas.SetTop(btnBack, 23);
            canvas.Children.Add(btnBack);

            ImageButton btnClose = new ImageButton();

            btnClose.Name   = "Close";
            btnClose.Click += BtnClose_Click;
            btnClose.SetResourceReference(UIElement.StyleProperty, MapRenderResourceKey.MapRenderButtonStyle);
            Canvas.SetRight(btnClose, 7);
            Canvas.SetTop(btnClose, 5);
            canvas.Children.Add(btnClose);

            this.Width  = canvasBackTexture.Width;
            this.Height = canvasBackTexture.Height;
            base.InitializeComponents();
        }
Ejemplo n.º 11
0
    private IEnumerator LoadAreaRoutine(WorldMapArea area)
    {
        Debug.Assert(!MissionManager.Instance.Mission, "can't switch world scenes while in a mission");

        if (IsWorldSceneActive)
        {
            var currentArea = GetCurrentArea();

            SceneManager.SetActiveScene(SpaceTraderConfig.GlobalScene);
            yield return null;

            yield return SceneManager.UnloadSceneAsync(currentArea.name);
        }

        if (area)
        {
            yield return SceneManager.LoadSceneAsync(area.name, LoadSceneMode.Additive);
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(area.name));
            yield return null;
        }
    }
Ejemplo n.º 12
0
 public Coroutine LoadArea(WorldMapArea area)
 {
     return StartCoroutine(LoadAreaRoutine(area));
 }
Ejemplo n.º 13
0
    private IEnumerator LevelTransitionRoutine(WorldMapArea area)
    {
        yield return GUIController.Current.ShowLoadingOverlay();

        yield return SpaceTraderConfig.WorldMap.LoadArea(area);

        transform.position = Vector3.zero;
        transform.rotation = Quaternion.identity;

        GUIController.Current.DismissLoadingOverlay();
        yield return GUIController.Current.SwitchTo(ScreenID.None);
    }