Ejemplo n.º 1
0
 /* * * * * * * * *
  * ON STONE MOVE
  */
 public void PieceMoved(PlayerStone stone)
 {
     if (!p.dr.CanRoll)
     {
         this.p.UrHandler.NewTurn();
     }
 }
Ejemplo n.º 2
0
    //float aggressivenessBonus = 0.25f;// Gets added for bops, and removed for staying on safe spaces


    override protected PlayerStone PickStoneToMove(PlayerStone[] legalStones)
    {
        Debug.Log("AIPlayer_UtilityAI");


        if (legalStones == null || legalStones.Length == 0)
        {
            Debug.LogError("Why are we being asked to pick from no stones");
            return(null);
        }

        CalcTileDanger(legalStones[0].PlayerId);

        //For each stone we rank how good it would be to pick it, where 1 is good -1 is bad
        PlayerStone bestStone = null;
        float       goodness  = -Mathf.Infinity;

        foreach (PlayerStone ps in legalStones)
        {
            float g = GetStoneGoodness(ps, ps.CurrentTile, ps.GetTileAhead());
            if (bestStone == null || g > goodness)
            {
                bestStone = ps;
                goodness  = g;
            }
        }

        Debug.Log("Chosen Stone Goodness: " + goodness);
        return(bestStone);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (isAnimating == false)
        {
            // Nothing for us to do.
            return;
        }

        if (Vector3.Distance(
                new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z),
                targetPosition) < smoothDistance)
        {
            // We've reached the target position -- do we still have moves in the queue?

            if (
                (moveQueue == null || moveQueueIndex == (moveQueue.Length))
                &&
                ((this.transform.position.y - smoothDistance) > targetPosition.y)
                )
            {
                // We are totally out of moves (and too high up), the only thing left to do is drop down.
                this.transform.position = Vector3.SmoothDamp(
                    this.transform.position,
                    new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z),
                    ref velocity,
                    smoothTimeVertical);

                // Check for bops
                if (stoneToBop != null)
                {
                    stoneToBop.ReturnToStorage();
                    stoneToBop = null;
                }
            }
            else
            {
                // Right position, right height -- let's advance the queue
                AdvanceMoveQueue();
            }
        }
        else if (this.transform.position.y < (smoothHeight - smoothDistance))
        {
            // We want to rise up before we move sideways.
            this.transform.position = Vector3.SmoothDamp(
                this.transform.position,
                new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z),
                ref velocity,
                smoothTimeVertical);
        }
        else
        {
            // Normal movement (sideways)
            this.transform.position = Vector3.SmoothDamp(
                this.transform.position,
                new Vector3(targetPosition.x, smoothHeight, targetPosition.z),
                ref velocity,
                smoothTime);
        }
    }
Ejemplo n.º 4
0
    void Update()
    {
        if (isAnimating == false)
        {
            return;
        }

        if (Vector3.Distance(
                new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z),
                targetPosition) < smoothDistance)
        {
            // We've reached the target position -- do we still have moves in the queue?
            if ((moveQueue == null || moveQueueIndex == moveQueue.Length)
                &&
                (this.transform.position.y - smoothDistance) > targetPosition.y
                )
            {
                // We are above target position
                // Out of moves, drop down the stone
                this.transform.position = Vector3.SmoothDamp(
                    this.transform.position,
                    new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z),
                    ref velocity,
                    smoothTimeVertical);

                // Check for bops
                if (stoneToBop != null)
                {
                    stoneToBop.ReturnToStorage();
                    stoneToBop = null;
                }
            }
            else
            {
                // Right position, right height, advance cube
                AdvanceMoveQueue();
            }
        }

        // Rise stone up before moving sideways
        else if (this.transform.position.y < (smoothHeight - smoothDistance))
        {
            this.transform.position = Vector3.SmoothDamp(
                this.transform.position,
                new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z),
                ref velocity,
                smoothTimeVertical);
        }
        else
        {
            this.transform.position = Vector3.SmoothDamp(
                this.transform.position,
                new Vector3(targetPosition.x, smoothHeight, targetPosition.z),
                ref velocity,
                smoothTime);
        }
    }
Ejemplo n.º 5
0
    private void Update()
    {
        if (m_IsAnimating == false)
        {
            return;
        }

        if (Vector3.Distance(
                new Vector3(this.transform.position.x, m_TargetPosition.y, this.transform.position.z),
                m_TargetPosition) < m_SmoothDistance)
        {
            // Reached the target position
            if (
                (moveQueue == null || moveQueueIndex == (moveQueue.Length))
                &&
                ((this.transform.position.y - m_SmoothDistance) > m_TargetPosition.y)
                )
            {
                // Out of moves, need to do is drop down.
                this.transform.position = Vector3.SmoothDamp(
                    this.transform.position,
                    new Vector3(this.transform.position.x, m_TargetPosition.y, this.transform.position.z),
                    ref m_Velocity,
                    m_SmoothTimeVertical);

                // Check to see if we need to remove an opponents stone
                if (m_StoneToBop != null)
                {
                    m_StoneToBop.ReturnToStorage();
                    m_StoneToBop = null;
                }
            }
            else
            {
                AdvanceMoveQueue();
            }
        }
        else if (this.transform.position.y < (m_SmoothHeight - m_SmoothDistance))
        {
            // Rise up before moving sideways.
            this.transform.position = Vector3.SmoothDamp(
                this.transform.position,
                new Vector3(this.transform.position.x, m_SmoothHeight, this.transform.position.z),
                ref m_Velocity,
                m_SmoothTimeVertical);
        }
        else
        {
            // Sideways movement
            this.transform.position = Vector3.SmoothDamp(
                this.transform.position,
                new Vector3(m_TargetPosition.x, m_SmoothHeight, m_TargetPosition.z),
                ref m_Velocity,
                m_SmoothTime);
        }
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (isAnimating == false)
        {
            //nothing for us todo.
            return;
        }
        if (Vector3.Distance(new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), targetPosition) < smoothDiatance)
        {
            //we've reached the target position -- do we still have moves in the queue?

            if ((moveQueue == null || moveQueueIndex == (moveQueue.Length))
                &&
                ((this.transform.position.y - smoothDiatance) > targetPosition.y)
                )
            {
                // drop down
                this.transform.position = Vector3.SmoothDamp(this.transform.position,
                                                             new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z),
                                                             ref velocity,
                                                             smoothTimeVertical);

                //check for bops
                if (stoneToBop != null)
                {
                    stoneToBop.ReturnToStorage();
                    stoneToBop = null;
                }
            }


            else
            {
                //right position,right height.
                AdvanceMoveQueue();
            }
        }

        else if (this.transform.position.y < (smoothHeight - smoothDiatance))
        {
            // rise up before  move sideways.
            this.transform.position = Vector3.SmoothDamp(this.transform.position,
                                                         new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z),
                                                         ref velocity,
                                                         smoothTimeVertical);
        }
        else
        {
            //normal movement
            this.transform.position = Vector3.SmoothDamp(this.transform.position,
                                                         new Vector3(targetPosition.x, smoothHeight, targetPosition.z),
                                                         ref velocity,
                                                         smoothTime);
        }
    }
Ejemplo n.º 7
0
 /* * * * * * * * *
  * ON STONE CLICK
  */
 public void PieceClicked(PlayerStone stone)
 {
     if (stone.CanMoveTo())
     {
         foreach (PlayerStone s in p.Pieces)
         {
             s.CanMove = false;
         }
         stone.StartMove();
     }
 }
Ejemplo n.º 8
0
    void OnStoneKilled(int position)
    {
        PlayerStone stoneToMove = FindObjectsOfType <PlayerStone>()
                                  .FirstOrDefault(stone => stone.Position == position && stone.Player == _game.OtherPlayer);

        if (stoneToMove != null)
        {
            stoneToMove.MoveHome();
        }
        else
        {
            Debug.LogError("No stone to kill at " + position);
        }
    }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (isAnimating == false)
        {
            return;
        }
        if (Vector3.Distance(new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), targetPosition) < smoothDistance)
        {
            //we have reached the target. do we still have moves in the queue?
            if ((moveQueue == null || moveQueueIndex == (moveQueue.Length)) &&
                (this.transform.position.y - smoothDistance) > targetPosition.y)
            {
                //we are above our target


                //we are totally out of moves, only thing to do is drop down.
                this.transform.position = Vector3.SmoothDamp(this.transform.position,
                                                             new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), ref velocity, smoothTimeVertical);
                //check for bops
                if (stoneToBop != null)
                {
                    stoneToBop.ReturnToStorage();
                    stoneToBop = null;
                }
            }


            else
            {
                //right pos, heigh -- advance queue
                AdvanceMoveQueue();
            }
        }



        // we want to rise up before we move sideways
        else if (this.transform.position.y < (smoothHeight - smoothDistance))
        {
            this.transform.position = Vector3.SmoothDamp(this.transform.position,
                                                         new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z), ref velocity, smoothTimeVertical);
        }
        else
        {
            this.transform.position = Vector3.SmoothDamp(this.transform.position,
                                                         new Vector3(targetPosition.x, smoothHeight, targetPosition.z), ref velocity, smoothTime);
        }
    }
Ejemplo n.º 10
0
    virtual protected float GetStoneGoodness(PlayerStone stone, Tile currentTile, Tile futureTile)
    {
        float goodness = 0;//Random.Range(-0.1f, 0.1f);

        if (currentTile == null)
        {
            // We aren't on the board yet, and it's always nice to add more to the board to open up more options.
            goodness += 0.20f;
        }

        if (currentTile != null && (currentTile.IsRollAgain == true && currentTile.IsSideline == false))
        {
            // We are sitting on a roll-again space in the middle.  Let's resist moving just because
            // it blocks the space from our opponent
            goodness -= 0.10f;
        }

        if (futureTile.IsRollAgain == true)
        {
            goodness += 0.50f;
        }

        if (futureTile.PlayerStone != null && futureTile.PlayerStone.PlayerId != stone.PlayerId)
        {
            // There's an enemy stone to bop!
            goodness += 0.50f;
        }

        if (futureTile.IsScoringSpace == true)
        {
            goodness += 0.50f;
        }

        float currentDanger = 0;

        if (currentTile != null)
        {
            currentDanger = tileDanger[currentTile];
        }

        goodness += currentDanger - tileDanger[futureTile];

        // TODO:  Add goodness for tiles that are behind enemies, and therefore likely to contribute to future boppage
        // TODO:  Add goodness for moving a stone forward when we might be blocking friendlies

        return(goodness);
    }
Ejemplo n.º 11
0
    virtual protected void DoClick()
    {
        //pick stone and click it

        PlayerStone[] legalStones = GetLegalMoves();
        if (legalStones == null || legalStones.Length == 0)
        {
            //we have no legal moves how did we get here?
            //we might still be in a delayed corutine somewhere?
            return;
        }
        //basic AI simply picks a legal move at random

        PlayerStone pickedStone = PickStoneToMove(legalStones);

        pickedStone.MoveMe();
    }
Ejemplo n.º 12
0
    virtual protected float GetStoneGoodness(PlayerStone stone, Tile currentTile, Tile futureTile)
    {
        float goodness = Random.Range(-0.1f, 0.1f);

        if (currentTile == null)
        {
            //we arent on the board yet and its alaways nice to add more to the board
            goodness += 0.2f;
        }

        if (currentTile != null && (currentTile.IsRollAgain == true && currentTile.IsSideLine == false))
        {
            //we are sitting on a roll again space in the middle. it is better to resist moving
            goodness -= 0.10f;
        }
        if (futureTile.IsRollAgain == true)
        {
            goodness += 0.50f;
        }

        if (futureTile.PlayerStone != null && futureTile.PlayerStone.PlayerId != stone.PlayerId)
        {
            //there's an enemy stone to bop
            goodness += 0.50f;
        }


        if (futureTile.IsScoringSpace == true)
        {
            goodness += 0.50f;
        }

        float currentDanger = 0;

        if (currentTile != null)
        {
            currentDanger = tileDanger[currentTile];
        }
        goodness += currentDanger - tileDanger[futureTile];

        //Add goodness for tiles in our private sidelines
        //TODO: add goodness ofremoving stone forward when we block friendly.

        return(goodness);
    }
Ejemplo n.º 13
0
    virtual protected void DoClick()
    {
        //pick a stone to move, then "click" it.


        PlayerStone[] legalStones = GetLegalMoves();

        if (legalStones == null || legalStones.Length == 0)
        {
            //we have no legal moves. how did we get here?
            //we might still be in a delayed coroutine somewhere. let's no freak out.
            return;
        }
        //basicAi simply picks a legal move at  random.
        PlayerStone pickStone = legalStones[Random.Range(0, legalStones.Length)];

        pickStone.MoveMe();
    }
Ejemplo n.º 14
0
    virtual protected void DoClick()
    {
        //pick a stone to move.



        PlayerStone[] legalStones = GetLegalMoves();

        if (legalStones == null || legalStones.Length == 0)
        {
            //we have no legal moves.
            return;
        }
        // picks a legal move at  random.
        PlayerStone pickStone = PickStoneToMove(legalStones);

        pickStone.MoveMe();
    }
Ejemplo n.º 15
0
    void OnStoneMoved(int startPosition, int endPosition)
    {
        if (LastClickedStone == null)
        {
            LastClickedStone = FindObjectsOfType <PlayerStone>()
                               .FirstOrDefault(stone => stone.Position == startPosition && stone.Player == _game.CurrPlayer);
        }

        if (LastClickedStone != null)
        {
            LastClickedStone.MoveTo(endPosition);
        }
        else
        {
            Debug.LogError("No stone to move from " + startPosition + " to " + endPosition);
        }
        LastClickedStone = null;
    }
Ejemplo n.º 16
0
    virtual protected void DoClick()
    {
        // Pick a stone to move, then "click" it.


        PlayerStone[] legalStones = GetLegalMoves();

        if (legalStones == null || legalStones.Length == 0)
        {
            // We have no legal moves.  How did we get here?
            // We might still be in a delayed coroutine somewhere. Let's not freak out.
            return;
        }

        // BasicAI simply picks a legal move at random

        PlayerStone pickedStone = PickStoneToMove(legalStones);

        pickedStone.MoveMe();
    }
    virtual protected float GetStonefitness(PlayerStone stone, Tile currentTile, Tile futureTile)
    {
        float fitness = Random.Range(-0.1f, 0.1f);

        if (currentTile == null)
        {
            // We aren't on the board yet
            fitness += 0.20f;
        }



        if (futureTile.PlayerStone != null && futureTile.PlayerStone.PlayerId != stone.PlayerId)
        {
            // There's an enemy
            fitness += 0.50f;
        }

        if (futureTile.IsScoringSpace == true)
        {
            fitness += 0.50f;
        }

        float currentDanger = 0;

        if (currentTile != null)
        {
            currentDanger = tileDanger[currentTile];
        }

        fitness += currentDanger - tileDanger[futureTile];



        return(fitness);
    }
Ejemplo n.º 18
0
    public void MoveMe()
    {
        // Is this the correct player?
        if (theStateManager.CurrentPlayerId != PlayerId)
        {
            return;
        }

        // Have we rolled the dice?
        if (theStateManager.IsDoneRolling == false)
        {
            // We can't move yet.
            return;
        }
        if (theStateManager.IsDoneClicking == true)
        {
            // We've already done a move!
            return;
        }

        int spacesToMove = theStateManager.DiceTotal;

        if (spacesToMove == 0)
        {
            return;
        }

        // Where should we end up?
        moveQueue = GetTilesAhead(spacesToMove);
        Tile finalTile = moveQueue[moveQueue.Length - 1];


        if (finalTile != null)
        {
            if (CanLegallyMoveTo(finalTile) == false)
            {
                // Not allowed!
                finalTile = CurrentTile;
                moveQueue = null;
                return;
            }

            // If there is an enemy tile in our legal space, the we kick it out.
            if (finalTile.PlayerStone != null)
            {
                //finalTile.PlayerStone.ReturnToStorage();
                stoneToFight = finalTile.PlayerStone;
                stoneToFight.CurrentTile.PlayerStone = null;
                stoneToFight.CurrentTile             = null;

                //NEED TO ADD FIGHT SCENE
            }
        }

        this.transform.SetParent(null);

        // Remove ourselves from our old tile
        if (CurrentTile != null)
        {
            CurrentTile.PlayerStone = null;
        }

        // Even before the animation is done, set our current tile to the new tile
        CurrentTile = finalTile;
        if (finalTile.IsScoringSpace == false)    // "Scoring" tiles are always "empty"
        {
            finalTile.PlayerStone = this;
        }

        moveQueueIndex = 0;

        theStateManager.IsDoneClicking = true;
        this.isAnimating = true;
        theStateManager.AnimationsPlaying++;
    }
Ejemplo n.º 19
0
    void OnMouseUp()
    {
        // TODO: Is the mouse over a UI element? Ignore this click.

        // Is this the correct player?
        if (theStateManager.CurrentPlayerID != PlayerId)
        {
            return;
        }

        // Have we rolled the dice?
        if (theStateManager.IsDoneRolling == false)
        {
            // We can't move yet.
            return;
        }
        if (theStateManager.IsDoneClicking == true)
        {
            // We've already done a move!
            return;
        }
        int spacesToMove = theStateManager.DiceTotal;

        if (spacesToMove == 0)
        {
            return;
        }

        //Where should we end up?
        moveQueue = GetTilesAhead(spacesToMove);
        Tile finalTile = moveQueue[moveQueue.Length - 1];

        // TODO: Check to see if the destination is legal!

        if (finalTile == null)
        {
            // Hey, wer're scoring this stone!
            //scoreMe = true;
        }
        else
        {
            if (CanLegallyMoveTo(finalTile) == false)
            {
                // Not allowed!
                finalTile = currentTile;
                moveQueue = null;
                return;
            }
            //if there is an enemy tile in our legal space, then we kick it out.
            if (finalTile.PlayerStone != null)
            {
                //finalTile.PlayerStone.ReturnToStorage();
                stoneToBop = finalTile.PlayerStone;
                stoneToBop.currentTile.PlayerStone = null;
                stoneToBop.currentTile             = null;
            }
        }

        this.transform.SetParent(null);

        // Remove ourselves from our old tile
        if (currentTile != null)
        {
            currentTile.PlayerStone = null;
        }

        // Put ourselves in our new tile.
        finalTile.PlayerStone = this;

        moveQueueIndex = 0;
        currentTile    = finalTile;
        theStateManager.IsDoneClicking = true;
        this.isAnimating = true;
    }
Ejemplo n.º 20
0
    public void MoveMe()
    {
        // Is this the correct player?
        if (theStateManager.CurrentPlayerId != PlayerId)
        {
            return;
        }

        // Have we rolled the dice?
        if (theStateManager.IsDoneRolling == false)
        {
            // We can't move yet.
            return;
        }
        if (theStateManager.IsDoneClicking == true)
        {
            // We've already done a move!
            return;
        }

        int spacesToMove = theStateManager.DiceTotal;

        if (spacesToMove == 0)
        {
            return;
        }

        // Where should we end up?
        moveQueue = GetTilesAhead(spacesToMove);
        Tile finalTile = moveQueue[moveQueue.Length - 1];

        // TODO: Check to see if the destination is legal!

        if (finalTile == null)
        {
            // Hey, we're scoring this stone!
            scoreMe = true;
        }
        else
        {
            if (CanLegallyMoveTo(finalTile) == false)
            {
                // Not allowed!
                finalTile = CurrentTile;
                moveQueue = null;
                return;
            }

            // If there is an enemy tile in our legal space, the we kick it out.
            if (finalTile.PlayerStone != null)
            {
                //finalTile.PlayerStone.ReturnToStorage();
                stoneToBop = finalTile.PlayerStone;
                stoneToBop.CurrentTile.PlayerStone = null;
                stoneToBop.CurrentTile             = null;
            }
        }

        this.transform.SetParent(null); // Become Batman

        // Remove ourselves from our old tile
        if (CurrentTile != null)
        {
            CurrentTile.PlayerStone = null;
        }

        // Even before the animation is done, set our current tile to the new tile
        storedCurrentTile = CurrentTile;
        CurrentTile       = finalTile;
        try{
            if (finalTile.IsScoringSpace == false)                // "Scoring" tiles are always "empty"
            {
                finalTile.PlayerStone = this;
                //Debug.Log("Scored!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            }
            if (finalTile.IsScoringSpace == true)                // "Scoring" tiles are always "empty"
            {
                //finalTile.PlayerStone = this;
                Debug.Log("Scored!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                Debug.Log("PlayerId" + PlayerId);
                if (PlayerId == 0)
                {
                    theStateManager.WhiteScore += 1;
                    Debug.Log("WhiteScore: " + theStateManager.WhiteScore);
                    if (theStateManager.WhiteScore == 6)
                    {
                        Debug.Log("White won");
                        theStateManager.winText.text = "WHITE HAS WON";
                        theStateManager.GameOverPanel.SetActive(true);
                    }
                }
                if (PlayerId == 1)
                {
                    theStateManager.RedScore += 1;
                    Debug.Log("RedScore: " + theStateManager.RedScore);
                    if (theStateManager.RedScore == 6)
                    {
                        Debug.Log("Red won");
                        theStateManager.winText.text = "RED HAS WON";
                        theStateManager.GameOverPanel.SetActive(true);
                    }
                }
            }
        }
        catch (Exception e) {
            Debug.Log(e, this);

            CurrentTile = storedCurrentTile;
            return;
        }


        moveQueueIndex = 0;

        theStateManager.IsDoneClicking = true;
        this.isAnimating = true;
        theStateManager.AnimationsPlaying++;
    }
Ejemplo n.º 21
0
    public void MoveMe()
    {
        //is this the correct plauer?
        if (theStateManager.CurrentPlayerId != PlayerId)
        {
            return;
        }

        if (theStateManager.IsDoneRolling == false)
        {
            //we can't move yet
            return;
        }
        if (theStateManager.IsDoneClicking == true)
        {
            //we've already done move
            return;
        }
        int spacesToMove = theStateManager.DiceTotal;

        if (spacesToMove == 0)
        {
            return;
        }

        //where should we end up?

        //if(spacesToMove ==0)
        //{
        //    return;
        //}

        moveQueue = GetTilesAhead(spacesToMove);

        Tile finalTile = moveQueue[moveQueue.Length - 1];

        if (finalTile == null)
        {
            //Hey, we're scoring this stone
            scoreMe = true;
        }
        if (finalTile != null)
        {
            if (CanLegallyMoveTo(finalTile) == false)
            {
                //not allowed
                finalTile = CurrentTile;
                moveQueue = null;
                return;
            }
            //If there is an enemy tile in our legal space, then we kick it out.
            if (finalTile.PlayerStone != null)
            {
                //finalTile.PlayerStone.ReturnToStorage();
                stoneToBop = finalTile.PlayerStone;
                stoneToBop.CurrentTile.PlayerStone = null;
                stoneToBop.CurrentTile             = null;
            }
        }

        this.transform.SetParent(null);//we have no parent

        if (CurrentTile != null)
        {
            CurrentTile.PlayerStone = null;
        }
        CurrentTile = finalTile;

        if (finalTile.IsScoringSpace == false)// Scoring tiles are always empty
        {
            finalTile.PlayerStone = this;
        }

        //Even before the animation is done, set our current tile to  the new tile


        moveQueueIndex = 0;

        theStateManager.IsDoneClicking = true;
        this.isAnimating = true;
        theStateManager.AnimationsPlaying++;
    }
Ejemplo n.º 22
0
 public void ToggleOccupant(PlayerStone player)
 {
     occupant = player;
 }
Ejemplo n.º 23
0
    public void MoveMe()
    {
        // Make sure each player can only move their own stones
        if (m_StateManager.m_CurrentPlayerId != m_PlayerId)
        {
            return;
        }

        // Don't allow for stones to move if no roll has taken place
        if (m_StateManager.m_IsDoneRolling == false)
        {
            return;
        }

        // Don't allow player to roll again once they have moved
        if (m_StateManager.m_IsDoneClicking == true)
        {
            return;
        }

        int spacesToMove = m_StateManager.m_DiceTotal;

        if (spacesToMove == 0)
        {
            return;
        }

        moveQueue = GetTilesAhead(spacesToMove);
        GameTile finalTile = moveQueue[moveQueue.Length - 1];

        if (finalTile == null)
        {
            m_ScoreMe = true;
        }
        else
        {
            if (CanLegallyMoveTo(finalTile) == false)
            {
                finalTile = m_CurrentTile;
                moveQueue = null;
                return;
            }

            // If opponent's stone in on our space remove their stone from the space
            if (finalTile.m_PlayerStone != null)
            {
                m_StoneToBop = finalTile.m_PlayerStone;
                m_StoneToBop.m_CurrentTile.m_PlayerStone = null;
                m_StoneToBop.m_CurrentTile = null;
            }
        }

        this.transform.SetParent(null);

        // Remove our stone from the old tile
        if (m_CurrentTile != null)
        {
            m_CurrentTile.m_PlayerStone = null;
        }

        m_CurrentTile = finalTile;
        if (finalTile.m_IsScoringTile == false)
        {
            finalTile.m_PlayerStone = this;
        }

        moveQueueIndex = 0;

        m_StateManager.m_IsDoneClicking = true;
        this.m_IsAnimating = true;
        m_StateManager.m_AnimationsPlaying++;
    }
Ejemplo n.º 24
0
    public void MoveMe()
    {
        //is this the correct player?
        if (theStateManager.CurrentPlayerId != PlayerId)
        {
            return;
        }

        //have we rolled the dice?
        if (theStateManager.IsDoneRolling == false)
        {
            //we haven't move yet.
            return;
        }
        if (theStateManager.IsDoneClicking == true)
        {
            //we've already done a move
            return;
        }
        int spacesToMove = theStateManager.DiceTotal;

        //where should we end up.

        moveQueue = GetTilesAhead(spacesToMove);
        Tile FinalTile = moveQueue[moveQueue.Length - 1];

        // if the destination is legal!

        if (FinalTile == null && CanLegallyMoveto(FinalTile) == true)
        {
            return;
        }

        else
        {
            if (CanLegallyMoveto(FinalTile) == false)
            {
                //not allowed
                FinalTile = currentTile;
                moveQueue = null;
                return;
            }

            // kik it out.
            if (FinalTile.PlayerStone != null)
            {
                stoneToBop = FinalTile.PlayerStone;
                stoneToBop.currentTile.PlayerStone = null;
                stoneToBop.currentTile             = null;
            }
        }

        this.transform.SetParent(null);

        //remove ourselves from our old tile
        if (currentTile != null)
        {
            currentTile.PlayerStone = null;
        }

        // set our current tile to the new tile.
        currentTile = FinalTile;


        if (FinalTile.IsScoringSpace == false) //scoring tiles are always empty.
        {
            FinalTile.PlayerStone = this;
        }


        moveQueueIndex = 0;


        theStateManager.IsDoneClicking = true;
        this.isAnimating = true;
        theStateManager.AnimationsPlaying++;
    }
Ejemplo n.º 25
0
    void OnMouseUp()
    {
        // TODO: Check if mouse is over a UI element, ignore command if true

        // Is this correct player?
        if (stateManager.CurrentPlayerId != playerId)
        {
            return;
        }

        // Have we rolled the dice
        if (stateManager.IsDoneRolling == false)
        {
            // We can't move yet
            return;
        }

        if (stateManager.IsDoneClicking == true)
        {
            // We already done a move
            return;
        }

        int spacesToMove = stateManager.DiceTotal;

        moveQueue = GetTilesAhead(spacesToMove);
        Tile finalTile = moveQueue [moveQueue.Length - 1];

        if (finalTile == null)
        {
            // Scoring stone
            scoreMe = true;
        }
        else
        {
            if (CanLegallyMoveTo(finalTile) == false)
            {
                // Not allowed
                finalTile = currentTile;
                moveQueue = null;
                // stateManager.IsDoneClicking = false;
                return;
            }

            // If there is enemy tile in legal space, kick it out
            if (finalTile.PlayerStone != null)
            {
                stoneToBop = finalTile.PlayerStone;
                stoneToBop.currentTile.PlayerStone = null;
                stoneToBop.currentTile             = null;
                // finalTile.PlayerStone.ReturnToStorage ();
            }
        }

        this.transform.SetParent(null);          // Become Batman

        // Remove ourselves	from our old tile
        if (currentTile != null)
        {
            currentTile.PlayerStone = null;
        }

        // Put ourselves in our new tile
        finalTile.PlayerStone = this;

        moveQueueIndex = 0;
        currentTile    = finalTile;
        stateManager.IsDoneClicking = true;
        this.isAnimating            = true;
    }