コード例 #1
0
    void ExplodeCell(Vector3 position, int areaCovered, Vector3 explosionDirection)
    {
        int        area      = areaCovered;
        Vector2    targetPos = position + explosionDirection;
        GameObject obj       = levelService.GetObjAtGrid(targetPos);

        area++;
        if (obj != null)
        {
            if (obj.GetComponent <FixedBlocks>() != null)
            {
                return;
            }
            else
            {
                Instantiate(explosionObj, targetPos, Quaternion.identity);
                levelService.EmptyGrid(position);

                if (area < explosionArea)
                {
                    ExplodeCell(transform.position + explosionDirection, area, explosionDirection);
                }
            }
        }
        else
        {
            Instantiate(explosionObj, targetPos, Quaternion.identity);
            if (area < explosionArea)
            {
                ExplodeCell(transform.position + explosionDirection, area, explosionDirection);
            }
        }
    }
コード例 #2
0
        private void CheckAvailableDirection(Vector3 direction)
        {
            GameObject obj = levelService.GetObjAtGrid(transform.position + direction);

            if (obj == null || obj.GetComponent <EnemyController>() != null)
            {
                gridPositions.Add(transform.position + direction);
            }
        }