Пример #1
0
Файл: Snake.cs Проект: 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> ();
            }
        }
    }
Пример #2
0
Файл: Snake.cs Проект: 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);
        }
    }