예제 #1
0
    private void Awake()
    {
        int pixelRealEstate = (int)(tilePrefab.GetComponent <RectTransform>().sizeDelta.y *size);

        if (Screen.height < pixelRealEstate)
        {
            size = Screen.height / (int)tilePrefab.GetComponent <RectTransform>().sizeDelta.y;
            //size = size;
        }

        tiles = new GameTile[size * size];

        // Large and possibly incorrect assignment which is supposed to move the board to be centred in the screen as it's made
        GetComponent <RectTransform>().anchoredPosition = new Vector2(
            -size * tilePrefab.GetComponent <RectTransform>().sizeDelta.x / 2,
            -size * tilePrefab.GetComponent <RectTransform>().sizeDelta.y / 2);

        for (int i = 0, k = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                CreateTile(j, i, k++);
            }
        }

        for (int i = 0; i < numberOfStarts; i++)
        {
            MakeMaxValue(Random.Range(0, tiles.Length));
        }
    }
예제 #2
0
    //  Returns true if character moves to tile, false otherwise
    public bool MoveToTile(GameTile tile)
    {
        bool willMove = IsTileMovable(tile);

        if (willMove)
        {
            // Get tile 'floor'
            float   tileMidHeight = tile.GetComponent <MeshFilter> ().sharedMesh.bounds.extents.y;
            Vector3 tilePosition  = tile.transform.position;
            Vector3 tileFloor     = new Vector3(tilePosition.x, tilePosition.y + tileMidHeight, tilePosition.z);

            // Move character 'feet' to tile 'floor'
            float   characterMidHeight = GetComponent <MeshFilter> ().sharedMesh.bounds.extents.y;
            Vector3 characterCenter    = GetComponent <MeshFilter> ().sharedMesh.bounds.center;
            transform.position = new Vector3(tileFloor.x, tileFloor.y + characterMidHeight, tileFloor.z);

            // Changed occupied tile to current tile
            TileOccupied.IsOccupied = false;
            tile.IsOccupied         = true;
            TileOccupied            = tile;

            // Change current Coordinates
            Coordinates = tile.Coordinates;
        }

        return(willMove);
    }
예제 #3
0
    public void assignTileTypeToHex(GameTile tile, TileType tileType)
    {
        Renderer hexRenderer = tile.GetComponent <Renderer> ();

        hexRenderer.material = materialsDictionary [tileType];

        tile.tileType = tileType;
    }
예제 #4
0
    void HandleTouch()
    {
        GameTile tile = board.GetTile(TouchRay);

        if (tile != null)
        {
            GetComponent <NavMeshAgent>().SetDestination(tile.GetComponent <Transform>().position);
        }
    }
예제 #5
0
    private IEnumerator LinkTile(GameTile t1, GameTile t2)
    {
        yield return(new WaitForEndOfFrame());

        if (!t1.ContainsTileLink(t2))
        {
            GameObject   link       = Instantiate(tileLinkPrefab, t1.transform);
            LineRenderer linkLine   = link.GetComponent <LineRenderer>();
            Vector2      toPosition = t2.GetComponent <RectTransform>().anchoredPosition - t1.GetComponent <RectTransform>().anchoredPosition;
            linkLine.SetPosition(1, toPosition);

            t1.AddTileLink(t2);
        }
    }
예제 #6
0
    private void ReplaceTileWith(GameTile original, GameTile prefabNew)
    {
        GameTile g = Instantiate(prefabNew) as GameTile;

        g.transform.position = original.transform.position;
        g.transform.rotation = original.transform.rotation;
        g.nextTile           = original.nextTile.transform;
        foreach (Transform t in original.transform)
        {
            DestroyImmediate(t.gameObject);
        }
        g.transform.SetParent(original.transform);

        DestroyImmediate(original.GetComponent <MeshRenderer>());
        DestroyImmediate(original);
    }
예제 #7
0
    public void SetPosition(int row, int col)
    {
        Row = row;
        Col = col;

        GameTile t = GameManager.GameMap.CheckMap(Row, Col);

        if (t == null)
        {
            button.image.color = noTileColor;
        }
        else
        {
            button.image.color = t.GetComponent <Renderer>().material.color;
        }
    }
예제 #8
0
 private void chillOutTileColor(GameTile tile)
 {
     tile.GetComponent <SpriteRenderer>().color =
         Color.Lerp(Color.green, Color.yellow, 0.5f);
 }
예제 #9
0
 private void resetTileColor(GameTile tile)
 {
     tile.GetComponent <SpriteRenderer>().color =
         getTileColor(tile);
 }
    protected override void ActivateBadTile(GameTile curTile)
    {
        if (_arrowTransform)
            _arrowTransform.gameObject.SetActive(false);

        if (!IsImune)
        {
            GameOver(false);
            Destroy(gameObject);
        }
        else
        {
            GameMap.LowerNeighbourDangerCounter(_playerController.PlayerPosition);
            HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
            Destroy(curTile.GetComponent<GameTile>().HiddenObject);
            AudioManager.Instance.PlaySound("KrakenDiesSfx");
            ++CurKrakenAmmount;
        }
    }
예제 #11
0
 public static TweenerCore <Color, Color, ColorOptions> BornAnimation(this GameTile gameTile)
 {
     gameTile.GetComponent <SpriteRenderer>().DOFade(0f, 0f);
     gameTile.transform.DOScale(1f, 0.2f);
     return(gameTile.GetComponent <SpriteRenderer>().DOFade(1f, 0.4f));
 }
예제 #12
0
 private void LinkTiles(GameTile prevTile, int linkIndex)
 {
     if (prevTile != null)
     {
         _goalLines[linkIndex] = Instantiate(tileLinkPrefab, prevTile.transform);
         LineRenderer linkLine = _goalLines[linkIndex].GetComponent <LineRenderer>();
         linkLine.startColor = linkLine.endColor = _goalLinks[linkIndex].goalColor;
         Vector2 toPosition = this.GetComponent <RectTransform>().anchoredPosition - prevTile.GetComponent <RectTransform>().anchoredPosition;
         linkLine.SetPosition(1, toPosition);
     }
 }