Ejemplo n.º 1
0
 /// <summary>
 /// An event listener for MouseInputManager.Singleton.onMouseDragEnd
 /// </summary>
 /// <param name="obj"> The object from which the player starts to drag </param>
 private void HandleMouseDragEnd(MouseInteractable obj)
 {
     switch (currentPlayerState)
     {
     case PlayerState.MovementPlanning:
         if (path.Count > 0 && (obj == this || obj.GetComponent <Tile>() == path.Start))
         {
             CurrentPlayerState = PlayerState.MovementConfirmation;
         }
         break;
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// An event listener for MouseInputManager.Singleton.onMouseEnter
    /// </summary>
    /// <param name="obj"> The object at which the mouse is pointing at </param>
    private void HandleMouseTargetChange(MouseInteractable obj)
    {
        if (MouseInputManager.Singleton.IsMouseDragging)
        {
            switch (currentPlayerState)
            {
            case PlayerState.MovementPlanning:
                if (obj == this)
                {
                    if (path.Count == 1)
                    {
                        RemoveWayPoint();
                    }
                }
                else if (obj.GetComponent <Tile>())
                {
                    Tile tile = obj.GetComponent <Tile>();

                    if (path.Count > 0)
                    {
                        if (tile == path.Last.Previous.Value)
                        {
                            RemoveWayPoint();
                        }
                        else if (path.Count < Player.Ap && tile.IsHighlighted(Tile.HighlightColor.Blue) && GridManager.Instance.IsAdjacent(tile, path.Last.Value))
                        {
                            AddWayPoint(tile);
                        }
                    }
                    else if (path.Count < Player.Ap && tile.IsHighlighted(Tile.HighlightColor.Blue) && GridManager.Instance.IsAdjacent(tile, path.Start))
                    {
                        AddWayPoint(tile);
                    }
                }
                break;
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// An event listener for MouseInputManager.Singleton.onMouseClick
    /// </summary>
    /// <param name="obj"> The clicked object </param>
    private void HandleMouseClick(MouseInteractable obj)
    {
        // handle click sound
        //AudioSource audioSource = gameObject.GetComponent<AudioSource>();

        switch (currentPlayerState)
        {
        case PlayerState.Idle:
            if (obj == this || (obj.GetComponent <Tile>() == GridManager.Instance.GetTile(Player.transform.position)))
            {
                CurrentPlayerState = PlayerState.MovementPlanning;
                SoundManager.Instance.TapTile();
                //audioSource.PlayOneShot(TapTile);
            }
            else if (obj.GetComponent <Enemy>())
            {
                GridManager.Instance.ToggleDetectionArea(obj.GetComponent <EnemyController>().UID);
                //audioSource.PlayOneShot(TapTile);
                SoundManager.Instance.TapTile();
            }
            else if (obj.GetComponent <UICard>())
            {
                //audioSource.PlayOneShot(TapCard);
                SoundManager.Instance.TapTile();
                CurrentPlayerState = PlayerState.CardBrowsing;
            }
            break;

        case PlayerState.MovementPlanning:
            SoundManager.Instance.TapTile();
            //audioSource.PlayOneShot(TapTile);
            if (obj == this)
            {
                CurrentPlayerState = PlayerState.Idle;
            }
            else if (obj.GetComponent <Enemy>())
            {
                GridManager.Instance.ToggleDetectionArea(obj.GetComponent <EnemyController>().UID);
            }
            else if (obj.GetComponent <Tile>())
            {
                Tile tile = obj.GetComponent <Tile>();

                if (tile == path.Start)
                {
                    CurrentPlayerState = PlayerState.Idle;
                }
                else
                {
                    Tile playerTile = GridManager.Instance.GetTile(Player.transform.position);

                    if (tile.IsHighlighted(Tile.HighlightColor.Blue))
                    {
                        Path = Navigation.FindPath(GridManager.Instance, playerTile, tile, Player.IsAccessibleTo);
                        CurrentPlayerState = PlayerState.MovementConfirmation;
                    }
                }
            }
            break;

        case PlayerState.CardBrowsing:
            if (obj.GetComponent <UICard>())
            {
                CardToUse = obj.GetComponent <UICard>().Card;
                //audioSource.PlayOneShot(TapCard);
                SoundManager.Instance.TapCard();
                CurrentPlayerState = PlayerState.CardUsagePlanning;
            }
            break;

        case PlayerState.CardUsagePlanning:
            if (obj == this)
            {
                targetTile = GridManager.Instance.GetTile(transform.position);

                if (targetTile.IsHighlighted(Tile.HighlightColor.Green))
                {
                    CurrentPlayerState = PlayerState.CardUsageConfirmation;
                }
                else
                {
                    targetTile = null;
                }
            }
            else if (obj.GetComponent <Enemy>())
            {
                targetTile = GridManager.Instance.GetTile(obj.transform.position);

                if (targetTile.IsHighlighted(Tile.HighlightColor.Green))
                {
                    CurrentPlayerState = PlayerState.CardUsageConfirmation;
                }
                else
                {
                    GridManager.Instance.ToggleDetectionArea(obj.GetComponent <EnemyController>().UID);
                    targetTile = null;
                }
            }
            else if (obj.GetComponent <Tile>())
            {
                targetTile = obj.GetComponent <Tile>();

                if (targetTile.IsHighlighted(Tile.HighlightColor.Green))
                {
                    CurrentPlayerState = PlayerState.CardUsageConfirmation;
                }
                else
                {
                    targetTile = null;
                }
            }
            break;
        }
    }