void Awake() { terrainManager = GameObject.Find("Map").GetComponent<TerrainManager>(); // Create A* path manager and GO pathManager = utils.PrefabManager.Create("AStartPathManager").GetComponent<AStarPathManager>(); pathManager.transform.parent = transform; soldiersPaths = new Dictionary<SoldierController, SoldierPathManager>(); // Instantiate cursor if not found GameObject cursor_go; if ((cursor_go = GameObject.Find("Cursor")) == null) { var prefab_class = Resources.Load("Prefabs/Cursor", typeof(GameObject)); cursor_go = (GameObject)Instantiate(prefab_class); cursor_go.name = prefab_class.name; // Save it cursor = cursor_go.GetComponent<GameCursor>(); } // Instantiate hover if ((hover = GameObject.Find("Hover")) == null) { var prefab_class = Resources.Load("Prefabs/Hover", typeof(GameObject)); hover = (GameObject)Instantiate(prefab_class); hover.name = prefab_class.name; } // Create path visulizer child GO and get main component var path_visualizer_go = utils.PrefabManager.Create("PathVisualizer"); path_visualizer_go.transform.parent = transform; pathVisualizer = path_visualizer_go.GetComponent<PathVisualizer>(); charDefManager = new ja2.CharacterDefinitionManager("Data"); clothManager = new ja2.ClothManager("Data"); charEntityManager = new ja2.CharacterEntityManager(charDefManager, clothManager); }
// Use this for initialization void Start () { gc = this; Icon = GetComponent<dfSprite>(); Label = GetComponentInChildren<dfLabel>(); }
public UIManager() { GameCursor = new GameCursor(this); _sbUI = Service.Get <SpriteBatchUI>(); InputManager.MouseDragging += (sender, e) => { if (_isDraggingControl) { DoDragControl(Mouse.Position); } }; InputManager.LeftMouseButtonDown += (sender, e) => { //if (!IsModalControlOpen /*&& ObjectsBlockingInputExists*/) // return; if (MouseOverControl != null) { MakeTopMostGump(MouseOverControl); MouseOverControl.InvokeMouseDown(Mouse.Position, MouseButton.Left); if (MouseOverControl.AcceptKeyboardInput) { _keyboardFocusControl = MouseOverControl; } _mouseDownControls[(int)MouseButton.Left] = MouseOverControl; } else { if (IsModalControlOpen) { _gumps.ForEach(s => { if (s.ControlInfo.IsModal && s.ControlInfo.ModalClickOutsideAreaClosesThisControl) { s.Dispose(); } }); } } }; InputManager.LeftMouseButtonUp += (sender, e) => { //if (!IsModalControlOpen && ObjectsBlockingInputExists) // return; //if (MouseOverControl == null) // return; const int btn = (int)MouseButton.Left; EndDragControl(Mouse.Position); if (MouseOverControl != null) { if (_mouseDownControls[btn] != null && MouseOverControl == _mouseDownControls[btn]) { MouseOverControl.InvokeMouseClick(Mouse.Position, MouseButton.Left); } MouseOverControl.InvokeMouseUp(Mouse.Position, MouseButton.Left); if (_mouseDownControls[btn] != null && MouseOverControl != _mouseDownControls[btn]) { _mouseDownControls[btn].InvokeMouseUp(Mouse.Position, MouseButton.Left); } } else { _mouseDownControls[btn]?.InvokeMouseUp(Mouse.Position, MouseButton.Left); } CloseIfClickOutGumps(); _mouseDownControls[btn] = null; }; InputManager.LeftMouseDoubleClick += (sender, e) => { //if (!IsModalControlOpen /*&& ObjectsBlockingInputExists*/) // e.Result = false; if (MouseOverControl != null && IsMouseOverUI) { e.Result |= MouseOverControl.InvokeMouseDoubleClick(Mouse.Position, MouseButton.Left); } }; InputManager.RightMouseButtonDown += (sender, e) => { //if (!IsModalControlOpen && ObjectsBlockingInputExists) // return; if (MouseOverControl != null) { MakeTopMostGump(MouseOverControl); MouseOverControl.InvokeMouseDown(Mouse.Position, MouseButton.Right); if (MouseOverControl.AcceptKeyboardInput) { _keyboardFocusControl = MouseOverControl; } _mouseDownControls[(int)MouseButton.Right] = MouseOverControl; } else { if (IsModalControlOpen) { _gumps.ForEach(s => { if (s.ControlInfo.IsModal && s.ControlInfo.ModalClickOutsideAreaClosesThisControl) { s.Dispose(); } }); } } CloseIfClickOutGumps(); }; InputManager.RightMouseButtonUp += (sender, e) => { //if (!IsModalControlOpen /*&& ObjectsBlockingInputExists*/) // return; //if (MouseOverControl == null) // return; const int btn = (int)MouseButton.Right; EndDragControl(Mouse.Position); if (MouseOverControl != null) { if (_mouseDownControls[btn] != null && MouseOverControl == _mouseDownControls[btn]) { MouseOverControl.InvokeMouseClick(Mouse.Position, MouseButton.Right); } MouseOverControl.InvokeMouseUp(Mouse.Position, MouseButton.Right); if (_mouseDownControls[btn] != null && MouseOverControl != _mouseDownControls[btn]) { _mouseDownControls[btn].InvokeMouseUp(Mouse.Position, MouseButton.Right); } } else { _mouseDownControls[btn]?.InvokeMouseUp(Mouse.Position, MouseButton.Right); } CloseIfClickOutGumps(); _mouseDownControls[btn] = null; }; InputManager.MouseWheel += (sender, isup) => { if (!IsModalControlOpen /*&& ObjectsBlockingInputExists*/) { return; } if (MouseOverControl != null && MouseOverControl.AcceptMouseInput) { MouseOverControl.InvokeMouseWheel(isup ? MouseEvent.WheelScrollUp : MouseEvent.WheelScrollDown); } }; InputManager.KeyDown += (sender, e) => { _keyboardFocusControl?.InvokeKeyDown(e.keysym.sym, e.keysym.mod); }; InputManager.KeyUp += (sender, e) => { _keyboardFocusControl?.InvokeKeyUp(e.keysym.sym, e.keysym.mod); }; InputManager.TextInput += (sender, e) => { _keyboardFocusControl?.InvokeTextInput(e); }; }
public override void Update(double totalMS, double frameMS) { base.Update(totalMS, frameMS); if (!World.InGame) { Dispose(); } GameScene scene = Client.Game.GetScene <GameScene>(); if (IsDisposed || ProfileManager.Current == null || scene == null) { return; } Direction dir = (Direction)GameCursor.GetMouseDirection(World.Player.X, World.Player.Y, _mx, _my, 0); ushort gumpID = (ushort)(0x1194 + ((int)dir + 1) % 8); if (_direction != dir || _arrow == null) { _direction = dir; if (_arrow == null) { Add(_arrow = new GumpPic(0, 0, gumpID, 0)); } else { _arrow.Graphic = gumpID; } Width = _arrow.Width; Height = _arrow.Height; } int gox = World.Player.X - _mx; int goy = World.Player.Y - _my; int x = (ProfileManager.Current.GameWindowSize.X >> 1) - (gox - goy) * 22; int y = (ProfileManager.Current.GameWindowSize.Y >> 1) - (gox + goy) * 22; x -= (int)World.Player.Offset.X; y -= (int)(World.Player.Offset.Y - World.Player.Offset.Z); y += World.Player.Z << 2; switch (dir) { case Direction.North: x -= _arrow.Width; break; case Direction.South: y -= _arrow.Height; break; case Direction.East: x -= _arrow.Width; y -= _arrow.Height; break; case Direction.West: break; case Direction.Right: x -= _arrow.Width; y -= _arrow.Height / 2; break; case Direction.Left: x += _arrow.Width / 2; y -= _arrow.Height / 2; break; case Direction.Up: x -= _arrow.Width / 2; y += _arrow.Height / 2; break; case Direction.Down: x -= _arrow.Width / 2; y -= _arrow.Height; break; } Point p = new Point(x, y); p = Client.Game.Scene.Camera.WorldToScreen(p); p.X += ProfileManager.Current.GameWindowPosition.X; p.Y += ProfileManager.Current.GameWindowPosition.Y; x = p.X; y = p.Y; if (x < ProfileManager.Current.GameWindowPosition.X) { x = ProfileManager.Current.GameWindowPosition.X; } else if (x > ProfileManager.Current.GameWindowPosition.X + ProfileManager.Current.GameWindowSize.X - _arrow.Width) { x = ProfileManager.Current.GameWindowPosition.X + ProfileManager.Current.GameWindowSize.X - _arrow.Width; } if (y < ProfileManager.Current.GameWindowPosition.Y) { y = ProfileManager.Current.GameWindowPosition.Y; } else if (y > ProfileManager.Current.GameWindowPosition.Y + ProfileManager.Current.GameWindowSize.Y - _arrow.Height) { y = ProfileManager.Current.GameWindowPosition.Y + ProfileManager.Current.GameWindowSize.Y - _arrow.Height; } X = x; Y = y; if (_timer < Time.Ticks) { _timer = Time.Ticks + 1000; _needHue = !_needHue; } _arrow.Hue = (ushort)(_needHue ? 0 : 0x21); }
public static void InitializeGameCursor() { GameCursor = new GameCursor(); }
// ------------------------------------------------------------------------------- private void Awake() { Instance = this; }
public override void Update(double totalMS, double frameMS) { base.Update(totalMS, frameMS); if (!World.InGame) { Dispose(); } var scene = Client.Game.GetScene <GameScene>(); if (IsDisposed || ProfileManager.Current == null || scene == null) { return; } Direction dir = (Direction)GameCursor.GetMouseDirection(World.Player.X, World.Player.Y, _mx, _my, 0); ushort gumpID = (ushort)(0x1194 + ((int)dir + 1) % 8); if (_direction != dir || _arrow == null) { _direction = dir; if (_arrow == null) { Add(_arrow = new GumpPic(0, 0, gumpID, 0)); } else { _arrow.Graphic = gumpID; } Width = _arrow.Width; Height = _arrow.Height; } var scale = scene.Scale; int gox = _mx - World.Player.X; int goy = _my - World.Player.Y; int x = (ProfileManager.Current.GameWindowPosition.X + (ProfileManager.Current.GameWindowSize.X >> 1)) + 6 + ((gox - goy) * (int)(22 / scale)) - (int)((_arrow.Width / 2f) / scale); int y = (ProfileManager.Current.GameWindowPosition.Y + (ProfileManager.Current.GameWindowSize.Y >> 1)) + 6 + ((gox + goy) * (int)(22 / scale)) + (int)((_arrow.Height) / scale); x -= (int)(World.Player.Offset.X / scale); y -= (int)(((World.Player.Offset.Y - World.Player.Offset.Z) + (World.Player.Z >> 2)) / scale); if (x < ProfileManager.Current.GameWindowPosition.X) { x = ProfileManager.Current.GameWindowPosition.X; } else if (x > ProfileManager.Current.GameWindowPosition.X + ProfileManager.Current.GameWindowSize.X - _arrow.Width) { x = ProfileManager.Current.GameWindowPosition.X + ProfileManager.Current.GameWindowSize.X - _arrow.Width; } if (y < ProfileManager.Current.GameWindowPosition.Y) { y = ProfileManager.Current.GameWindowPosition.Y; } else if (y > ProfileManager.Current.GameWindowPosition.Y + ProfileManager.Current.GameWindowSize.Y - _arrow.Height) { y = ProfileManager.Current.GameWindowPosition.Y + ProfileManager.Current.GameWindowSize.Y - _arrow.Height; } X = x; Y = y; if (_timer < Time.Ticks) { _timer = Time.Ticks + 1000; _needHue = !_needHue; } _arrow.Hue = (ushort)(_needHue ? 0 : 0x21); }
void Update() { //Cambiar estos IF por un switch (intentarlo vaya) if (currentPlayerHand.Count > 0 && isCardSelector) { text.text = currentPlayerHand [pointedCardIndex].getCardName(); uiImage.gameObject.SetActive(true); pointedCardIndex = cardSelector.pointAtCard(cursor, currentPlayerHand, pointedCardIndex); selectedCardIndex = cardSelector.selectCard(CurrentPlayer, cursor, currentPlayerHand, pointedCardIndex, board); if (selectedCardIndex != -1) { isCardSelector = false; isBoardSelector = true; boardCursor = Instantiate(cursor) as GameCursor; currentSlot = findFirstEmptyGrid(board); boardCursor.setCursorInSlot(currentSlot); boardCursor.showCursor(true); changeCursorAlfa(cursor, 0.5f); uiImage.gameObject.SetActive(false); } } else if (currentPlayerHand.Count > 0 && isBoardSelector) { if (Input.GetKeyDown(KeyCode.UpArrow)) { if (currentSlot.X - 1 >= 0) { board.putCursorInPosition(boardCursor, currentSlot.X - 1, currentSlot.Y); currentSlot = board.getGridSpace(currentSlot.X - 1, currentSlot.Y); boardCursor.playMoveSound(); } } if (Input.GetKeyDown(KeyCode.DownArrow)) { if (currentSlot.X + 1 < board.getBoardLength()) { board.putCursorInPosition(boardCursor, currentSlot.X + 1, currentSlot.Y); currentSlot = board.getGridSpace(currentSlot.X + 1, currentSlot.Y); boardCursor.playMoveSound(); } } if (Input.GetKeyDown(KeyCode.RightArrow)) { if (currentSlot.Y + 1 < board.getBoardLength()) { board.putCursorInPosition(boardCursor, currentSlot.X, currentSlot.Y + 1); currentSlot = board.getGridSpace(currentSlot.X, currentSlot.Y + 1); boardCursor.playMoveSound(); } } if (Input.GetKeyDown(KeyCode.LeftArrow)) { if (currentSlot.Y - 1 >= 0) { board.putCursorInPosition(boardCursor, currentSlot.X, currentSlot.Y - 1); currentSlot = board.getGridSpace(currentSlot.X, currentSlot.Y - 1); boardCursor.playMoveSound(); } } if (Input.GetKeyDown(KeyCode.Return)) { if (!board.getGridSpace(currentSlot.X, currentSlot.Y).containsCard()) { currentPlayerHand [selectedCardIndex].transform.localPosition = new Vector3(0, 0); board.putCardInPosition(currentPlayerHand [selectedCardIndex], currentSlot.X, currentSlot.Y); currentPlayerHand.RemoveAt(selectedCardIndex); cursor.playOkSound(); Destroy(boardCursor.gameObject); changeCursorAlfa(cursor, 1f); if (currentPlayerHand.Count > 0) { resetCursorPosition(CurrentPlayer, cursor, currentPlayerHand); } failed = false; isBoardSelector = false; if (currentPlayerHand.Count > 0) { isCardSelector = true; } pointedCardIndex = 0; selectedCardIndex = -1; } else { cursor.playFailSound(); failed = true; } } } else if (!isCardSelector && !isBoardSelector) { cursor.showCursor(false); uiImage.gameObject.SetActive(false); } }
public virtual void StartCommand(ActivitiesUnit _unit, GameCursor _cursor, SceneTileMapManager _tileMapManager) { }