Пример #1
0
    public bool IsBlocked()
    {
        if (tile == null)
        {
            return(false);
        }

        Vector3 p0 = transform.position;
        Vector3 p1 = transform.position + tile.GetMovePattern().Step(this, transform.position);

        for (int i = 0; i < manager.transform.childCount; i++)
        {
            Ingredient ingredient = manager.transform.GetChild(i).GetComponent <Ingredient>();
            if (ingredient != null && ingredient != this)
            {
                Vector3 p2 = ingredient.transform.position;
                if ((p1 - p2).magnitude < 0.8f)
                {
                    return((p1 - p2).magnitude < (p0 - p2).magnitude);
                }
            }
        }

        return(false);
    }
Пример #2
0
    public void Update()
    {
        if (PauseMenu.PAUSED)
        {
            return;
        }

        if (tile == null)
        {
            if (died)
            {
                IngredientKillEffects.PlayDeathEffect((int)ingredientType - 1, transform.position, transform.parent);
                Game.GAME.AddScore(-INGREDIENT_PENALTY);
                PointLabel.SpawnAt(pointLabelPrefab, transform.parent, transform.position, -INGREDIENT_PENALTY);
                Debug.Log("-" + INGREDIENT_PENALTY + " points: Fell out of board or was crushed!");
            }
            Destroy(gameObject);
            return;
        }

        if (IsBlocked())
        {
            return;
        }

        IBoardMovePattern movePattern = tile.GetMovePattern();

        if (wait)
        {
            int           nextX    = boardX + (int)movePattern.NextTile(this).x;
            int           nextY    = boardY + (int)movePattern.NextTile(this).y;
            GameBoardTile nextTile = Game.BOARD.GetTile(nextX, nextY);
            if (tile is BaseTile && nextTile is BaseTile)
            {
                if (IsConveyerBeltAdjacent((BaseTile)tile, (BaseTile)nextTile))
                {
                    boardX             = nextX;
                    boardY             = nextY;
                    tile               = nextTile;
                    transform.position = tile.GetMovePattern().GetStart(this);
                    wait               = false;
                }
            }
            return;
        }

        transform.position += tile.GetMovePattern().Step(this, transform.position);
        transform.Rotate(tile.GetMovePattern().RotStep(this));
        if (movePattern.ReachedDestination(this, transform.position))
        {
            int nextX = boardX + (int)movePattern.NextTile(this).x;
            int nextY = boardY + (int)movePattern.NextTile(this).y;

            // This needs to go somewhere else! Yanderedev-Style Code. I know dammit. I dont have much time okay!!!
            if (nextX == 0 && nextY == -1)
            {
                died = false;
                CookingPlace pot = GameObject.Find("CookingPot1").GetComponent <CookingPlace>();
                pot.AddIngredient(ingredientType);
            }
            else if (nextX == 2 && nextY == -1)
            {
                died = false;
                CookingPlace pot = GameObject.Find("CookingPot2").GetComponent <CookingPlace>();
                pot.AddIngredient(ingredientType);
            }
            else if (nextX == -1 && nextY == 2)
            {
                died = false;
                CookingPlace pot = GameObject.Find("CookingPot3").GetComponent <CookingPlace>();
                pot.AddIngredient(ingredientType);
            }
            else if (nextX == 5 && nextY == 2)
            {
                died = false;
                CookingPlace pot = GameObject.Find("CookingPot4").GetComponent <CookingPlace>();
                pot.AddIngredient(ingredientType);
            }

            GameBoardTile nextTile = Game.BOARD.GetTile(nextX, nextY);
            if (nextTile == null)
            {
                tile = null;
            }
            else
            {
                wait = true;
            }
        }
    }