/// <summary>
 /// Sets the Current selected piece only if it belongs to the current players turn. Also Displays any
 /// info about  the current piece. CuurentPiece will be used to determine if charater can roll.
 ///
 /// </summary>
 /// <param name="piece">Piece to display info about when selected</param>
 /// <returns>Character piece if can roll, else null</returns>
 private void DetermineSelecetion(CharacterPiece piece)
 {
     //Debug.Log("Selected Piece " + piece + " Turn Phase: " + _turn.TurnPhase);
     if (_turnStarted)
     {
         // Hnadle differently not sure how yet......
         if (_turn.TurnPhase == Phase.Attack)
         {
             // piece is attackable
             if (_Attack.SelectPieceToAttack(piece))
             {
                 if (_Attack.PieceToAttack != null)
                 {
                     _Attack.PieceToAttack.DisplaySelected(false);
                 }
                 piece.DisplaySelected(true); // highlight selecteced piece
             }
         }
     }
     if (piece)
     {
         SetCurrentPiece(piece); // select piece
     }
     else
     {
         _currentPiece = null;
     }
 }
 /// <summary>
 /// Sets the Current selected piece only if it belongs to the current players turn. Also Displays any
 /// info about  the current piece. CuurentPiece will be used to determine if charater can roll.
 ///
 /// </summary>
 /// <param name="piece">Piece to display info about when selected</param>
 /// <returns>Character piece if can roll, else null</returns>
 private void SetCurrentPiece(CharacterPiece piece)
 {
     if (_currentPiece != null && _currentPiece != Turn.Piece)
     {
         _currentPiece.DisplaySelected(false);
     }
     _DontRollButton.gameObject.SetActive(false);
     _DontRollButton.enabled = false;
     _RollButton.gameObject.SetActive(false);
     _RollButton.enabled = false;
     // Means the piece belongs to the current sides turn
     if (CurrentSide == piece.Stat.Side)
     {
         // Piece belongs to Current Player
         if (CurrentPlayer != null && CurrentPlayer.Pieces != null && CurrentPlayer.Pieces.Contains(piece))
         {
             if (piece.canMove && !_turnStarted) // piece can still roll.
             {
                 _RollButton.gameObject.SetActive(true);
                 _RollButton.enabled = true;
                 _DontRollButton.gameObject.SetActive(true);
                 _DontRollButton.enabled = true;
                 piece.DisplaySelected(true);
                 _currentPiece = piece;
             }
         }
     }
     _currentPiece = piece;
 }
    private bool DidCurrentPieceTurnChange()
    {
        // Character began turn
        if (GameManager.instance.TurnStarted)
        {
            if (TurnStarted != true) // turn just started
            {
                CurrentPieceTurn       = GameManager.instance.Turn.Piece;
                TurnStarted            = true;
                CurrentPieceTurnHealth = (CurrentPieceTurn != null) ? CurrentPieceTurn.Stat.CurrentHealth : 0;
                CurrentPieceTurnAttack = (CurrentPieceTurn != null) ? CurrentPieceTurn.Stat.CurrentAttack : 0;

                // Hide Panels b/c Turn started on selected piece
                NamePanel.SetActive(false);
                AttackPanel.SetActive(false);
                HealthPanel.SetActive(false);
                return(true);
            }
            else if (CurrentPieceTurnHealth != CurrentPieceTurn.Stat.CurrentHealth || CurrentPieceTurnAttack != CurrentPieceTurn.Stat.CurrentAttack)
            {
                // attack or health has changed of current piece;
                return(true);
            }
        }
        else if (TurnStarted == true) // hide current piece turn bc turn over
        {
            TurnStarted      = false;
            CurrentPieceTurn = null;
            NamePanelTurn.SetActive(false);
            AttackPanelTurn.SetActive(false);
            HealthPanelTurn.SetActive(false);
        }

        return(false);
    }
Ejemplo n.º 4
0
 private void MoveToStart(GameObject tile)
 {
     Piece = GameManager.instance.CurrentPiece;
     Piece.transform.position = tile.transform.position;
     Piece.SetCurrentTile(tile);
     tile.GetComponent <Tile>().HighlightTile(false);
 }
    /// <summary>
    /// Displays the current selced pieces health bar
    /// </summary>
    private void DisplayHealth(CharacterPiece piece, GameObject healthPanel)
    {
        int health            = CurrentPiece.Stat.CurrentHealth;
        int currentChildCount = healthPanel.transform.childCount; // get the current amount of health being displayed

        // need to add or remove hearts
        if (currentChildCount != health)
        {
            GameObject image;

            // add hearts
            if (health > currentChildCount)
            {
                for (int i = currentChildCount; i < health; i++) // add the difference of hearts
                {
                    image = Instantiate(ImagePrefab, healthPanel.transform);
                    image.GetComponent <Image>().sprite = HealthSprite;
                }
            }
            else // remove hearts
            {
                for (int i = 0; i < currentChildCount - health; i++) // remove the difference of hearts
                {
                    Destroy(healthPanel.transform.GetChild(i).gameObject);
                }
            }
        }
    }
    /// <summary>
    /// Displays the current selected pieces attack bar.
    /// </summary>
    private void DisplayAttack(CharacterPiece piece, GameObject attackPanel)
    {
        int attack            = piece.Stat.CurrentAttack;         // attack points
        int currentChildCount = attackPanel.transform.childCount; // get the current amount of health being displayed

        // need to add or remove swords
        if (currentChildCount != attack)
        {
            GameObject image;

            // add swords
            if (attack > currentChildCount)
            {
                for (int i = currentChildCount; i < attack; i++) // add the difference of swords
                {
                    image = Instantiate(ImagePrefab, attackPanel.transform);
                    image.GetComponent <Image>().sprite = AttackSprite;
                }
            }
            else // remove swords
            {
                for (int i = 0; i < currentChildCount - attack; i++) // remove the difference of swords
                {
                    Destroy(attackPanel.transform.GetChild(i).gameObject);
                }
            }
        }
    }
 // Determine if anything is applied
 public virtual void OnDraw(CharacterPiece piece)
 {
     SetOwner(piece);
     if (DrawEffectFunctions != null)
     {
         DrawEffectFunctions.Invoke();
     }
 }
 /// <summary>
 /// Rest the varaibles to be ready for the next draw card.
 /// </summary>
 private void ResetVars()
 {
     answer    = -1;
     _Piece    = null;
     _CardType = TileTypes.Empty;
     DrawPanel.SetActive(false);
     _doneDraw = false;
 }
Ejemplo n.º 9
0
 public override void OnDraw(CharacterPiece piece)
 {
     base.OnDraw(piece);
     for (int i = 0; i < InstanceEffects.Count; i++)
     {
         InstanceEffects[i].OnDraw(piece);
     }
 }
    protected event Action DiscardEffectFunction;  // What happens when a card is discarded. Can be used to turn off active effects

    // Called when card is created
    public virtual void Initialize(Card c)
    {
        card           = c;
        CharacterOwner = null;
        didActivate    = false;
        isStagged      = false;
        numUsesLeft    = baseNumUses;
        SetDescription();
    }
 public void SetupAttack(CharacterPiece pieceAttacking)
 {
     BtnAttackUI.SetActive(true);
     _doneAttack         = false;
     TotalDamgeText.text = "Total Damge: 0";
     _PieceAttacking     = pieceAttacking;
     Debug.Log("Attacking ");
     DeteremineAttackablePieces();
 }
 /// <summary>
 /// Called when the card is drawn from the deck.
 /// </summary>
 /// <param name="c">Character that drew the card. (Owner)</param>
 public void OnDraw(CharacterPiece piece)
 {
     CharacterOwner = piece;
     if (CardEffect)
     {
         CardEffect.OnDraw(piece);
         Debug.Log("OnDraw owner = " + piece.Stat.Name);
     }
 }
 /// <summary>
 /// Called when card is being discarded. My not happen when card is used. Usally will be stagged
 /// for discard and called at end of phase. Card is also flagged as not activated for if card can be used again.
 /// </summary>
 public void OnDiscard()
 {
     //handle discard
     if (CardEffect)
     {
         CardEffect.OnDiscard();
     }
     DiscardHandler.Invoke(this);
     CharacterOwner = null;
 }
Ejemplo n.º 14
0
    private void PieceDied(CharacterPiece piece)
    {
        CharacterPiece p = null;

        p = piece;
        Debug.Log("Play found Piece Died " + piece);
        DeadPieces.Add(piece);
        TotalPieceCount--;
        Pieces.Remove(p);
    }
 /// <summary>
 /// Used if anything happens when the card is discarded.
 /// </summary>
 public virtual void OnDiscard()
 {
     didActivate    = false;
     isStagged      = false;
     numUsesLeft    = baseNumUses;
     CharacterOwner = null;
     if (DiscardEffectFunction != null)
     {
         DiscardEffectFunction.Invoke();
     }
 }
 IEnumerator EndTurnPhase()
 {
     GameManager.instance.CurrentPiece = null;
     _HelpText.text = "Select Piece to Move";
     _turnPhase     = Phase.EndTurn;
     GameManager.instance.TurnStarted = false;
     _piece.EndTurn();
     GameManager.instance.CurrentPlayer.TotalPiecesLeftToMove--;
     _piece = null;
     return(null);
 }
    private void Awake()
    {
        Init();
        if (GameManager.instance.CurrentPiece != null)
        {
            CurrentPiece = GameManager.instance.CurrentPiece;
        }

        // Hide Panels bc no character is selected
        AttackPanel.SetActive(false);
        HealthPanel.SetActive(false);
    }
 private void Update()
 {
     /* ****************TODO Change later
      * // piece selected changed
      * if (gm.CurrentPiece != _Piece)
      * {
      *  _Piece = gm.CurrentPiece;
      *  UpdateDisplay();
      * }*/
     _Piece = gm.CurrentPiece;
     UpdateDisplay();
 }
    private void Init()
    {
        TurnStarted      = false;
        CurrentPieceTurn = null;

        // hide current seleceted
        NamePanel.SetActive(false);
        AttackPanel.SetActive(false);
        HealthPanel.SetActive(false);

        //hide current turn
        NamePanelTurn.SetActive(false);
        AttackPanelTurn.SetActive(false);
        HealthPanelTurn.SetActive(false);
    }
 /// <summary>
 /// Use this to draw a card from a deck and give it to the passed piece.
 /// </summary>
 /// <param name="piece"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 private IEnumerator DrawLoop(CharacterPiece piece, CardType type)
 {
     _Piece    = piece;
     _CardType = (TileTypes)type;
     if (CanPieceDraw())
     {
         Debug.Log(_Piece + " can Draw.");
         //user said yes
         answer = 1;
         if (answer == 1)
         {
             yield return(DetermineDeck());
         }
     }
 }
 public bool SelectPieceToAttack(CharacterPiece piece)
 {
     if (AttackablePieces.Contains(piece)) // piece is attackable
     {
         PieceToAttack = piece;
         return(true);
     }
     else // piece not attackable
     {
         if (PieceToAttack) // remove piece to attack becasue user selected different piece that could not be selected
         {
             PieceToAttack = null;
         }
         return(false);
     }
 }
    IEnumerator TurnLoop(int move)
    {
        _piece = GameManager.instance.CurrentPiece;
        Debug.Log("Begin Movement");
        yield return(MovementPhase(move));

        yield return(DrawPhase());

        Debug.Log("Begin Attacking");
        yield return(AttackPhase());

        Debug.Log("Done Attacking");
        Debug.Log("Begin EndTurn");
        yield return(EndTurnPhase());

        Debug.Log("Done Turn");
        _turnPhase = Phase.Roll;
    }
    private IEnumerator StartGame()
    {
        yield return(new WaitForSeconds(1)); // wait till everything is done loading

        if (_DoStartNewGame)                 // new game
        {
            yield return(SetupPiecesForNewGame());
        }
        else // loaded game
        {
            yield return(SetupPiecesForContinuedGame());
        }
        Debug.Log("Done Setingup the Game");
        c               = null;
        _currentPiece   = null;
        _gameStarted    = true;
        CanSelectePiece = true;

        // move camera to current sides pieces
        if (CurrentSide == SideType.Good)
        {
            _Camera.GetComponent <CameraMovement>().target = _GoodHomeTile.transform;
        }
        else
        {
            _Camera.GetComponent <CameraMovement>().target = _GoodHomeTile.transform;
        }

        _HelpText.text = "Select Piece to Move";

        while (_WinningSide == SideType.None) // loop till a side has no pieces left
        {
            _currentPiece = null;
            if (CurrentSide == SideType.Good) // good turn
            {
                yield return(GoodPlayersTurn());
            }
            else // evils turn
            {
                yield return(EvilPlayersTurn());
            }
        }
        Debug.Log("Done Game" + _WinningSide);
    }
 /// <summary>
 /// This handles the end of the attack phase turn by reseting variables.
 /// </summary>
 private void EndAttack()
 {
     Debug.Log("Ending Attack");
     GameManager.instance.CanSelectePiece = true;
     GameManager.instance.CurrentPiece    = _PieceAttacking;
     BtnAttackUI.SetActive(false);  // turn off attack button
     AttackDiceUI.SetActive(false); // turn off dice
     AttackablePieces.Clear();
     if (PieceToAttack != null)
     {
         PieceToAttack.DisplaySelected(false); // unselected the attack piece
     }
     _PieceAttacking = null;
     PieceToAttack   = null;
     _DoneAttackRoll = false;
     _AttackDiceList.Clear();
     _AttackAmount     = 0;
     _AppliedAttack    = false;
     _attackDiceModify = 0;
     _doneAttack       = true;
 }
Ejemplo n.º 25
0
    [SerializeField] private CharacterPiece Piece; // Piece to move

    /// <summary>
    /// Nav Mesh is used to find a path to the selcted tile by using the agent var from
    /// the character piece.
    /// </summary>
    /// <param name="tile">Destination tile selected</param>
    public void MovePiece(GameObject tile)
    {
        if (GameManager.instance.TurnStarted) // only do if turn has started
        {
            // if button is not blocked by player
            if (EventSystem.current.IsPointerOverGameObject())
            {
                Piece = GameManager.instance.Turn.Piece;
                GameManager.instance.Turn.Moving();
                //TODO: Animate**********
                GameManager.instance.CurrentPiece = Piece;
                Piece.Agent.SetDestination(tile.transform.position);
                Piece.SetCurrentTile(tile);
                Piece.StartCoroutine(WaitForAgent());
            }
        }
        else
        {
            // use this for the start of the game to move the each piece to starting location
            MoveToStart(tile);
        }
    }
    private IEnumerator DrawLoop(CharacterPiece piece)
    {
        ResetVars();
        _Piece    = piece;
        _CardType = _Piece.CurrentTile.Type.Type;
        if (CanPieceDraw())
        {
            Debug.Log(_Piece + " can Draw.");
            DrawPanel.SetActive(true);
            string cardTypeName = Enum.GetName(typeof(TileTypes), _CardType);
            DrawTitle.text = "Would you like to Draw a " + cardTypeName + " Card?";
            yield return(WaitForAnswer());

            DrawPanel.SetActive(false);
            //user said yes
            if (answer == 1)
            {
                yield return(DetermineDeck());
            }
        }
        _doneDraw = true;
    }
 private bool DidCurrentPieceChange()
 {
     if (GameManager.instance.CurrentPiece != CurrentPiece) // current piece seleced changed
     {
         CurrentPiece       = GameManager.instance.CurrentPiece;
         CurrentPieceHealth = (CurrentPiece != null) ? CurrentPiece.Stat.CurrentHealth : 0;
         CurrentPieceAttack = (CurrentPiece != null) ? CurrentPiece.Stat.CurrentAttack : 0;
         return(true);
     }
     else if (CurrentPiece != null)                                 // current piece did not change and is not null
     {
         if (CurrentPiece.Stat.CurrentHealth != CurrentPieceHealth) // health of current piece changed
         {
             return(true);
         }
         else if (CurrentPiece.Stat.CurrentAttack != CurrentPieceAttack) // attack of current piece changed
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 28
0
        void DefinitionType()
        {
            int pos = this.ColorParallelepiped.IndexOf(".");

               if (pos == -1)
               {
               this.Type = TypePiece.Left;
               return;
               }

               if (pos % 2 == 1)
               {
               if (this.ColorParallelepiped[pos - 1] != '.')
               {
                   this.Type = TypePiece.Left;
               }
               }
               else
               {

               if (this.ColorParallelepiped[pos + 1] != '.')
               {
                   this.Type = TypePiece.Right;
               }
               }

               if (pos <= 1)
               {
               this.Character = CharacterPiece.Width;
               }

               if (pos >= 2 && pos <= 3)
               {
               this.Character = CharacterPiece.Depth;
               }

               if (pos >= 4)
               {
               this.Character = CharacterPiece.Height;
               }
        }
 public void SetOwner(CharacterPiece piece)
 {
     CharacterOwner = piece;
 }
Ejemplo n.º 30
0
 // Use this for initialization
 public Character(CharacterSheet _sheet, CharacterPiece _piece)
 {
     sheet = _sheet;
     piece = _piece;
     piece.transform.localPosition = new Vector3(1000f, 1000f, 1000f);
 }
 private void MoveAnywhere()
 {
     _piece = GameManager.instance.CurrentPiece;
     _piece.DisplayAvaliableMovement(100); // display all spaces on board for user to select
 }
Ejemplo n.º 32
0
 void Awake()
 {
     movableComponent   = GetComponent <MovablePiece>();
     characterComponent = GetComponent <CharacterPiece>();
     clearableComponent = GetComponent <ClearablePiece>();
 }