Exemple #1
0
    void Die()
    {
        flowManager.enemyList.Remove(this);
        if (state == StateType.kamikaze)
        {
            flowManager.ChangeGold(kamikazeBounty);
        }
        else if (state == StateType.charger)
        {
            flowManager.ChangeGold(chargerBounty);
        }
        else if (state == StateType.spawner)
        {
            flowManager.ChangeGold(spawnerBounty);
        }
        else if (state == StateType.destroyer)
        {
            flowManager.ChangeGold(destroyerBounty);
        }
        else if (state == StateType.coward)
        {
            flowManager.ChangeGold(cowardBounty);
        }

        Destroy(gameObject, 0.01f);
    }
Exemple #2
0
    public void BuildAt(buildType type, Vector3 pos)
    {
        Vector2Int localCoord = WorldToGrid(pos);

        pos = GridToWorld(localCoord);         // snaps to grid


        if (type == buildType.Demolish)
        {
            GameObject obj     = refMatrix[localCoord.x][localCoord.y];
            Tower      tScript = obj.GetComponent <Tower>();
            if (tScript != null)
            {
                tScript.Demolish();
            }
            else
            {
                Destroy(refMatrix[localCoord.x][localCoord.y], 0.01f);
            }
            aiMatrix[localCoord.y][localCoord.x] = 0;
        }
        else
        {
            if (refMatrix[localCoord.x][localCoord.y] == null)
            {
                GameObject newObj = null;
                if (type == buildType.Tower)
                {
                    newObj = Instantiate(towerPrefab, pos, Quaternion.identity);
                    flowManager.towerList.Add(newObj.GetComponent <Tower>());
                    flowManager.ChangeGold(-flowManager.towerCost);
                }
                else if (type == buildType.Wall)
                {
                    newObj = Instantiate(wallPrefab, pos, Quaternion.identity);
                    flowManager.ChangeGold(-flowManager.wallCost);
                }
                refMatrix[localCoord.x][localCoord.y] = newObj;
                aiMatrix[localCoord.y][localCoord.x]  = 1;
                Vector3 newPos = newObj.transform.position;
                newPos.y += newObj.transform.localScale.y / 2;
                newObj.transform.position = newPos;
            }
        }
    }