Ejemplo n.º 1
0
    void Update()
    {
        if (Input.GetMouseButton(1))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                Vector2 tilePos = LevelHelpers.TilePosFromWorldPos(hit.point);

                LevelTile tile = LevelController.Instance.Model.Tiles[(int)tilePos.x, (int)tilePos.y];

                if (tile != null && !digList.Contains(tile))
                {
                    AddDigTile(tile);
                }
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator CheckDig()
    {
        while (true)
        {
            Vector3 tileInFront = transform.position + transform.forward * DigDistance;

            Vector2 tilePosition = LevelHelpers.TilePosFromWorldPos(tileInFront);

            LevelTile tile = LevelController.Instance.Model.Tiles[(int)tilePosition.x, (int)tilePosition.y];

            if (!tile.Opened)
            {
                ActionQueue queue = GetComponent <ActionQueue>();

                queue.InsertBeforeCurrent(new DigAction(gameObject, tilePosition));

                yield return(new WaitForSeconds(DigTime));
            }

            yield return(0);
        }
    }
Ejemplo n.º 3
0
    public bool PositionIsValidLandingZone(Vector3 destination)
    {
        Vector2 tilePos = LevelHelpers.TilePosFromWorldPos(destination);

        LevelModel model = LevelController.Instance.Model;

        int x = (int)tilePos.x;
        int z = (int)tilePos.y;

        if (!LevelHelpers.TileIsInBounds(model, x, z))
        {
            return(false);
        }

        LevelTile tile = model.Tiles[x, z];

        if (tile.Opened)
        {
            return(true);
        }

        return(false);
    }