Exemple #1
0
    public bool EnemyAround()
    {
        if (Physics.Raycast(transform.position, Vector3.down, out hitInfo))
        {
            if (hitInfo.transform.CompareTag("Floor"))
            {
                //Debug.Log("Piece is above tile: (" + hitInfo.transform.GetComponent<SCR_FloorTileInfo>().xPos + "," + hitInfo.transform.GetComponent<SCR_FloorTileInfo>().yPos + ")");
                tileBelow = hitInfo.transform.GetComponent <SCR_FloorTileInfo>();
            }
        }

        if (tileBelow.xPos == 4 && tileBelow.yPos == 5 ||
            tileBelow.xPos == 5 && tileBelow.yPos == 6 ||
            tileBelow.xPos == 5 && tileBelow.yPos == 4 ||
            tileBelow.xPos == 8 && tileBelow.yPos == 6 ||
            tileBelow.xPos == 8 && tileBelow.yPos == 4 ||
            tileBelow.xPos == 9 && tileBelow.yPos == 5)
        {
            if (tileBelow.xPos == 4 && tileBelow.yPos == 5 ||
                tileBelow.xPos == 5 && tileBelow.yPos == 6 ||
                tileBelow.xPos == 5 && tileBelow.yPos == 4)
            {
                if (!enemyLeftDestroyed)
                {
                    Instantiate(destroyPrefab, enemyLeft.transform.position, Quaternion.identity);
                    Destroy(enemyLeft);
                    enemyLeftDestroyed = true;
                }
            }

            if (tileBelow.xPos == 8 && tileBelow.yPos == 6 ||
                tileBelow.xPos == 8 && tileBelow.yPos == 4 ||
                tileBelow.xPos == 9 && tileBelow.yPos == 5)
            {
                if (!enemyRightDestroyed)
                {
                    Instantiate(destroyPrefab, enemyRight.transform.position, Quaternion.identity);
                    Destroy(enemyRight);
                    enemyRightDestroyed = true;
                }
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #2
0
    private void Update()
    {
        if (!GetComponent <UnitStatus>().isSelected)
        {
            return;
        }

        //Cast ray beneath unit to check which tile it's on
        if (Physics.Raycast(transform.position, Vector3.down, out hitInfo) && !b_tileSet)
        {
            if (hitInfo.transform.CompareTag("Floor"))
            {
                //Debug.Log("Piece is above tile: (" + hitInfo.transform.GetComponent<SCR_FloorTileInfo>().xPos + "," + hitInfo.transform.GetComponent<SCR_FloorTileInfo>().yPos + ")");
                tileBelow = hitInfo.transform.GetComponent <SCR_FloorTileInfo>();
                b_tileSet = true;
            }
        }
    }