static void DrawGameObjectName(LevelMapPathElement pathElement, GizmoType gizmoType) { GUIStyle style = new GUIStyle(); style.normal.textColor = Color.blue; Handles.Label(pathElement.transform.position + (Vector3.down * 0.1f) + (Vector3.left * 0.1f), pathElement.gameObject.name, style); }
/// <summary> /// Sets the destination. /// </summary> /// <param name="newDestination">New destination.</param> public virtual void SetDestination(LevelMapPathElement newDestination) { // if we haven't reached our destination yet, we do nothing and exit if (transform.position != _destination.transform.position - _offset) { return; } // otherwise we set our new destination _destination = newDestination; _shouldMove = true; }
/// <summary> /// Handles input and decides if we can move or not /// </summary> /// <param name="movement">Movement.</param> public virtual void InputMovement() { // we get both direction axis if (InputManager.Instance != null) { _horizontalMove = InputManager.Instance.PrimaryMovement.x; _verticalMove = InputManager.Instance.PrimaryMovement.y; } if (!CollidingWithAPathElement) { return; } if (InputManager.Instance.JumpButton.State.CurrentState == MMInput.ButtonStates.ButtonDown) { ButtonPressed(); } _movement = ""; // if one or both axis values is above a small value if ((Mathf.Abs(_horizontalMove) > _threshold) || (Mathf.Abs(_verticalMove) > _threshold)) { if (_horizontalMove > _threshold) { _movement = "Right"; } if (_horizontalMove < -_threshold) { _movement = "Left"; } if (_verticalMove > _threshold) { _movement = "Up"; } if (_verticalMove < -_threshold) { _movement = "Down"; } } // if we haven't registered any input, we do nothing and exit if (_movement == "") { return; } // if the path element we're on right now is automated, we do nothing and exit if (_currentPathElement.AutomaticMovement) { return; } if ((_movement == "Up") && (_currentPathElement.CanGoUp())) { _destination = _currentPathElement.Up; _shouldMove = true; } if ((_movement == "Right") && (_currentPathElement.CanGoRight())) { _destination = _currentPathElement.Right; _shouldMove = true; } if ((_movement == "Down") && (_currentPathElement.CanGoDown())) { _destination = _currentPathElement.Down; _shouldMove = true; } if ((_movement == "Left") && (_currentPathElement.CanGoLeft())) { _destination = _currentPathElement.Left; _shouldMove = true; } }
/// <summary> /// Sets the current path element. /// </summary> /// <param name="pathElement">Path element.</param> public virtual void SetCurrentPathElement(LevelMapPathElement pathElement) { _currentPathElement = pathElement; }