private void Awake() { instance = this; cursorRect = transform.GetComponent <RectTransform>(); cursorImage = transform.GetComponent <Image>(); state = CursorStates.DEFAULT; defaultPivot = new Vector2(0.12f, 0.88f); castPivot = new Vector2(0.5f, 0.5f); mainCamera = Camera.main; }
/// <summary> /// Sets cursor's state to one of a given /// enumeration of states /// </summary> /// <param name="newState">new state of cursor</param> void SetCursorState(CursorStates newState) { // change state if button isn't currently depressed if (!depressed) { // play sound effect on initial mouse over of enemy if (newState == CursorStates.Hostile && currState != CursorStates.Hostile) { AudioManager.Play(AudioClipNames.player_mouseOverHostile, true); } currState = newState; Cursor.SetCursor(cursorTextures[(int)currCursor][(int)currState], hotspots[(int)currCursor][(int)currState], CursorMode.ForceSoftware); } }
public void SetCursorState(string which) { if (which == "CAST") { state = CursorStates.CAST; cursorImage.sprite = castCursor; cursorRect.pivot = castPivot; } else if (which == "DEFAULT") { state = CursorStates.DEFAULT; cursorImage.sprite = defaultCursor; cursorRect.pivot = defaultPivot; } }
private void Awake() { instance = this; currentState = CursorStates.DEFAULT; mainCamera = Camera.main; Transform child = transform.Find("CursorManager"); realCursor = child.GetComponent <Image>(); rectTransform = transform.GetComponent <RectTransform>(); cursorRect = child.GetComponent <RectTransform>(); combatPointsIndicator = transform.Find("CPNumber"); combatPointsIndicatorTMP = combatPointsIndicator.GetComponent <TMP_Text>(); combatPointsIndicatorRect = combatPointsIndicator.GetComponent <RectTransform>(); baseAnchor = combatPointsIndicatorRect.anchoredPosition; defaultPivot = new Vector2(0.05f, 0.95f); attackPivot = new Vector2(0.9f, 0.5f); movePivot = new Vector2(0.05f, 0.95f); castPivot = new Vector2(0.25f, 0.75f); cannotPivot = new Vector2(0.05f, 0.95f); pickupPivot = new Vector2(0.5f, 0.75f); shootPivot = Vector2.zero; }
public void SetCurstor(CursorStates mode) { if (mode == cursorState) { return; } switch (mode) { case CursorStates.normal: Cursor.SetCursor(Curs_Normal, new Vector2(25, 25), CursorMode.ForceSoftware); break; case CursorStates.interactable: Cursor.SetCursor(Curs_Inter, new Vector2(25, 25), CursorMode.ForceSoftware); break; case CursorStates.deactivated: Cursor.SetCursor(Curs_Deact, new Vector2(25, 25), CursorMode.ForceSoftware); break; } cursorState = mode; }
public void SetCursor(string whichCursor, string dir) { if (whichCursor == "DEFAULT") { realCursor.sprite = defaultCursor; cursorRect.pivot = defaultPivot; cursorRect.eulerAngles = Vector3.zero; currentState = CursorStates.DEFAULT; combatPointsIndicatorRect.anchoredPosition = baseAnchor; } else if (whichCursor == "ATTACK") { realCursor.sprite = attackCursor; cursorRect.pivot = attackPivot; currentState = CursorStates.ATTACK; if (realCursor.sprite != defaultCursor) { switch (dir) { case "bottom": cursorRect.eulerAngles = new Vector3(0, 0, 90f); combatPointsIndicatorRect.anchoredPosition = new Vector2(baseAnchor.x + 15f, baseAnchor.y); break; case "left": cursorRect.eulerAngles = Vector3.zero; combatPointsIndicatorRect.anchoredPosition = new Vector2(baseAnchor.x - 30f, baseAnchor.y + 15f); break; case "top": cursorRect.eulerAngles = new Vector3(0, 0, -90f); combatPointsIndicatorRect.anchoredPosition = new Vector2(baseAnchor.x - 15f, baseAnchor.y + 50f); break; case "right": cursorRect.eulerAngles = new Vector3(0, 0, 180f); combatPointsIndicatorRect.anchoredPosition = new Vector2(baseAnchor.x + 33f, baseAnchor.y + 14f); break; } } } else if (whichCursor == "MOVE") { realCursor.sprite = moveCursor; cursorRect.pivot = movePivot; cursorRect.eulerAngles = Vector3.zero; currentState = CursorStates.MOVE; combatPointsIndicatorRect.anchoredPosition = baseAnchor; } else if (whichCursor == "CAST") { realCursor.sprite = castCursor; cursorRect.pivot = castPivot; cursorRect.eulerAngles = Vector3.zero; currentState = CursorStates.CAST; combatPointsIndicatorRect.anchoredPosition = baseAnchor; } else if (whichCursor == "CANNOT") { realCursor.sprite = cannotCursor; cursorRect.pivot = cannotPivot; cursorRect.eulerAngles = Vector3.zero; currentState = CursorStates.CANNOT; combatPointsIndicatorRect.anchoredPosition = baseAnchor; } else if (whichCursor == "PICKUP") { realCursor.sprite = pickupCursor; cursorRect.pivot = pickupPivot; cursorRect.eulerAngles = Vector3.zero; currentState = CursorStates.PICKUP; combatPointsIndicatorRect.anchoredPosition = baseAnchor; } else if (whichCursor == "SHOOT") { realCursor.sprite = shootCursor; cursorRect.pivot = shootPivot; cursorRect.eulerAngles = Vector3.zero; currentState = CursorStates.SHOOT; combatPointsIndicatorRect.anchoredPosition = baseAnchor; } }
/// <summary> /// The main panel's action event handler. /// </summary> private void panelAction_Click(object sender, EventArgs e) { MouseEventArgs m = (e as MouseEventArgs); bool shiftPressed = Control.ModifierKeys.HasFlag(Keys.Shift); // placing a tower if (this._CursorState == CursorStates.PlaceTower) { TDTowerButton b = GetSelectedTowerButton(); if (b == null) { return; } TDTower newTower = b.Tower; // if on path - no newTower.Location = new TDLocation(m.X, m.Y); if (TDSession.thisSession.CurrentLevel.CanPlaceTower(newTower)) { // actually place the tower placeTower((e as MouseEventArgs).Location); // and after we place the tower, unselect the tower if we did not have shift down (or right clicked) if (m.Button == System.Windows.Forms.MouseButtons.Left && !shiftPressed) { this.CursorState = CursorStates.Normal; GetSelectedTowerButton().Checked = false; } } } // selecting something else { if (TDSession.thisSession == null) { return; } // attempt to highlight tower selected this.CurrentlySelectedEntity = GetTowerAtPoint((e as MouseEventArgs).Location); if (CurrentlySelectedEntity != null) { UnhighlightAll(); CurrentlySelectedEntity.IsHighlighted = true; LoadDetailsOfTower(CurrentlySelectedEntity as TDEntity); if (CurrentlySelectedEntity is TDTower) { btnDelete.Enabled = true; ResetPurchaseButtons(); ResetAIButtons(); } else { btnDelete.Enabled = false; btn_Repair.Enabled = false; btnUpgrade.Enabled = false; } } else // nothing was clicked on { UnhighlightAll(); ClearDetails(); ResetPurchaseButtons(); ResetAIButtons(); } } }
private void btnDeleteTowerType_Click(object sender, EventArgs e) { this.CursorState = CursorStates.DeleteTower; }
public void Update(KeyboardState keyboard, MouseState mouse, Camera camera ) { State = CursorStates.Default; previousKeyboard = currentKeyboard; currentKeyboard = keyboard; previousMouse = currentMouse; currentMouse = mouse; AtTileX = (currentMouse.X - (int)camera.X) / 24; AtTileY = (currentMouse.Y - (int)camera.Y) / 24; if (MouseLock == true && MouseLockCounter > 0) MouseLockCounter--; else if (MouseLock == true) MouseLock = false; }
public void ChangeCursor(CursorStates state) { State = state; }