Пример #1
0
        private void Update()
        {
            if (_inputHandler.GetArrowDirection() != Direction.None)
            {
                _alienCook.TryMove(_inputHandler.GetArrowDirection());
            }

            _alienCook.Move(Time.deltaTime, _path);

            if (_inputHandler.ClickedTile() != null)
            {
                var currentTile = _inputHandler.ClickedTile();

                if (currentTile.Type == TileType.Box ||
                    currentTile.Type == TileType.Kitchen ||
                    currentTile.Type == TileType.Pan)
                {
                    var closestFloorTile = _grid.GetClosestFloorTile(_alienCook.Position.Value, currentTile);

                    if (closestFloorTile != null)
                    {
                        _pathfinder.FindPath(_alienCook.Position.Value, closestFloorTile.Position);
                        _path = _pathfinder.Path;
                    }

                    _alienCook.TryToInteract(currentTile);
                }


                if (currentTile.Type == TileType.Floor)
                {
                    _pathfinder.FindPath(_alienCook.Position.Value, currentTile.Position);
                    _path = _pathfinder.Path;
                }
            }
        }