Ejemplo n.º 1
0
    //   [PunRPC]
    public void MakeFill()
    {
        //GroundSpawner.instance.spawnedGroundPieces[index].SetSnakeOwner(Player);



        List <GroundPiece> newOwnedGroundPieces = new List <GroundPiece>();

        foreach (GroundPiece groundPiece in Player.tailGroundPieces)
        {
            newOwnedGroundPieces.Add(groundPiece);
            groundPiece.SetSnakeOwner(Player);
            Player.isFill = true;
        }

        GroundPiece[] groundPiecesToCheck = Poly.GetGroundPiecesToCheck(Player);

        foreach (GroundPiece piece in groundPiecesToCheck)
        {
            piece.tempHasToBeChecked = true;

            if (piece.snakeOwener != Player)
            {
                piece.ownerIDForCheck = 1;
            }
            else
            {
                piece.ownerIDForCheck = 0;
            }
        }

        Poly.FloodFill(groundPiecesToCheck[0], 1, 2);

        foreach (GroundPiece piece in groundPiecesToCheck)
        {
            if (piece.ownerIDForCheck == 1)
            {
                newOwnedGroundPieces.Add(piece);
                piece.SetSnakeOwner(Player);
                Player.isFill = true;
            }

            piece.tempHasToBeChecked = false;
        }

        foreach (GroundPiece piece in newOwnedGroundPieces)
        {
            piece.pieceWhenCollected.sr.color = Player.spriteColor;
            piece.ShowCollectedPiece(Player.collectedPieceSprite);
            Player.energy += 0.025f;
        }


        Player.isCollectingNewGroundPieces = false;
        Player.tailGroundPieces            = new List <GroundPiece>();
    }
Ejemplo n.º 2
0
Archivo: Snake.cs Proyecto: akil03/BC
    public void CheckReachedGroundPiece(GroundPiece pieceToCheck)
    {
        if (pieceToCheck.collectingSnake != null)
        {
            KillSnake(pieceToCheck.collectingSnake);
        }

        if (pieceToCheck.snakeOwener != this)
        {
            if (isCollectingNewGroundPieces == false)
            {
                isCollectingNewGroundPieces = true;
                AI.Reset();
            }
            pieceToCheck.SetCollectingSnake(this);
        }
        else
        {
            if (isCollectingNewGroundPieces)
            {
                List <GroundPiece> newOwnedGroundPieces = new List <GroundPiece> ();

                foreach (GroundPiece groundPiece in tailGroundPieces)
                {
                    newOwnedGroundPieces.Add(groundPiece);
                    groundPiece.SetSnakeOwner(this);
                }

                GroundPiece[] groundPiecesToCheck = Poly.GetGroundPiecesToCheck(this);

                foreach (GroundPiece piece in groundPiecesToCheck)
                {
                    piece.tempHasToBeChecked = true;

                    if (piece.snakeOwener != this)
                    {
                        piece.ownerIDForCheck = 1;
                    }
                    else
                    {
                        piece.ownerIDForCheck = 0;
                    }
                }

                Poly.FloodFill(groundPiecesToCheck [0], 1, 2);

                if (!isBot)
                {
                    SoundsManager.instance.Play(fillClip);
                }


                foreach (GroundPiece piece in groundPiecesToCheck)
                {
                    if (piece.ownerIDForCheck == 1)
                    {
                        newOwnedGroundPieces.Add(piece);
                        piece.SetSnakeOwner(this);
                    }

                    piece.tempHasToBeChecked = false;
                }
                scoreCount = 0;

                foreach (GroundPiece piece in newOwnedGroundPieces)
                {
                    piece.pieceWhenCollected.sr.color = spriteColor;
                    piece.ShowCollectedPiece(collectedPieceSprite);
                    scoreCount++;
                }
                scoreCount *= 50 * scoreMultiplier;

                if (!isBot)
                {
                    totalScore += scoreCount;
                    fov         = 60 + (0.02f * ownedGroundPieces.Count);
                    fov         = Mathf.Clamp(fov, 60, 80);
                    GUIManager.instance.ScorePop.OnScore(scoreCount);
                    GUIManager.instance.scoreText.text = totalScore.ToString();
                    GUIManager.instance.gameCam.DOFieldOfView(fov, 1);
                    ScoreHandler.instance.SetScore(totalScore);
                }


                if (!isBot && !isDead)
                {
                    //ScoreHandler.instance.SetScore (ownedGroundPieces.Count);
                }

                isCollectingNewGroundPieces = false;
                tailGroundPieces            = new List <GroundPiece> ();
            }
        }
    }
Ejemplo n.º 3
0
Archivo: Snake.cs Proyecto: akil03/bx
    public void CheckReachedGroundPiece(GroundPiece pieceToCheck)
    {
        //		if (pieceToCheck == null)
        //			return;
        if (pieceToCheck.collectingSnake != null)
        {
            //KillSnake (pieceToCheck.collectingSnake);
            if (PhotonNetwork.inRoom && pieceToCheck.collectingSnake._networkSnake.isCollecting)
            {
                KillSnake(pieceToCheck.collectingSnake);
            }
            else
            {
                KillSnake(pieceToCheck.collectingSnake);
            }
        }
        if (pieceToCheck.snakeOwener != this)
        {
            if (isCollectingNewGroundPieces == false)
            {
                isCollectingNewGroundPieces = true;
                AI.Reset();
            }
            //if (PhotonNetwork.inRoom && isLocal)
            //{
            //    PhotonView.Get(_networkSnake.gameObject).RPC("MakeTrail", PhotonTargets.All, pieceToCheck.indexInGrid);
            //}
            //else
            pieceToCheck.SetCollectingSnake(this);
        }
        else
        {
            if (isCollectingNewGroundPieces)
            {
                //if (PhotonNetwork.inRoom && isLocal)
                //{
                //    PhotonView.Get(_networkSnake.gameObject).RPC("MakeFill", PhotonTargets.All);
                //    return;
                //}
                List <GroundPiece> newOwnedGroundPieces = new List <GroundPiece>();
                foreach (GroundPiece groundPiece in tailGroundPieces)
                {
                    newOwnedGroundPieces.Add(groundPiece);
                    groundPiece.SetSnakeOwner(this);
                    isFill = true;
                }
                GroundPiece[] groundPiecesToCheck = Poly.GetGroundPiecesToCheck(this);
                foreach (GroundPiece piece in groundPiecesToCheck)
                {
                    piece.tempHasToBeChecked = true;

                    if (piece.snakeOwener != this)
                    {
                        piece.ownerIDForCheck = 1;
                    }
                    else
                    {
                        piece.ownerIDForCheck = 0;
                    }
                }
                Poly.FloodFill(groundPiecesToCheck[0], 1, 2);

                foreach (GroundPiece piece in groundPiecesToCheck)
                {
                    if (piece.ownerIDForCheck == 1)
                    {
                        newOwnedGroundPieces.Add(piece);
                        piece.SetSnakeOwner(this);
                        isFill = true;
                    }
                    piece.tempHasToBeChecked = false;
                }

                foreach (GroundPiece piece in newOwnedGroundPieces)
                {
                    piece.pieceWhenCollected.sr.color = spriteColor;
                    piece.ShowCollectedPiece(collectedPieceSprite);
                    energy += 0.025f;
                }

                if (!isBot)
                {
                    ScoreHandler.instance.SetScore(ownedGroundPieces.Count);
                }

                isCollectingNewGroundPieces = false;
                tailGroundPieces            = new List <GroundPiece>();
            }
        }

        if (PhotonNetwork.inRoom)
        {
            _networkSnake.isCollecting = isCollectingNewGroundPieces;
        }


        if (isFill && !isBot)
        {
            isFill = false;
            SoundsManager.instance.Play(FillSound);
        }
    }