public void SetTileMapTransparent()
    {
        tm         = GetComponent <Tilemap>();
        tmpColor   = tm.color;
        tmpColor.a = 0f;

        // first find all tile locations and set to transparent
        tileLocs.Clear();
        tileLocs = Script_Utils.AddTileLocs(tileLocs, tm,
                                            tileLoc => {
            tm.SetTileFlags(tileLoc, TileFlags.None);
            tm.SetColor(tileLoc, tmpColor);
        }
                                            );
    }
Esempio n. 2
0
    /// <summary>
    /// Position and activate the spike
    /// </summary>
    public void RandomSpikes(
        List <Vector3Int> attackTileLocs,
        Tilemap tilemap,
        Grid _attackGrid
        )
    {
        didHit     = false;
        attackGrid = _attackGrid;
        if (isInUse)
        {
            return;
        }
        isInUse = true;

        if (Debug.isDebugBuild && Const_Dev.IsDevMode)
        {
            attackGrid.gameObject.SetActive(true);
        }

        // get all available attack tilemap positions
        attackTileLocs.Clear();
        attackTileLocs = Script_Utils.AddTileLocs(attackTileLocs, tilemap, null);

        // set each spike to a random position to attack
        for (int i = 0; i < spikes.Length; i++)
        {
            int        randomIdx       = Random.Range(0, attackTileLocs.Count);
            Vector3Int tileToAttackLoc = attackTileLocs[randomIdx];
            // this is what is affecting Timeline to not offset correctly
            Vector3 spikeAttackPos = attackGrid.CellToWorld(tileToAttackLoc);
            spikes[i].position = spikeAttackPos;

            attackTileLocs.RemoveAt(randomIdx);
        }

        SpikeSequence();
    }