Ejemplo n.º 1
0
    void OnMouseDown()
    {
        switch (player.currentlySelected)
        {
        case PlayerScript.TowerType.Nothing:
            break;

        case PlayerScript.TowerType.Lumberjack:
            if (player.CurrentLumber >= 1)                     //TODO: Add cost of lumberjack
            {
                player.CurrentLumber -= 1;
                //SendMessage("Not enough lumber");

                GameObject lumberjack       = Instantiate(TimerjackTower, transform.position, Quaternion.identity) as GameObject;
                Woodcutter woodcutterScript = lumberjack.GetComponent <Woodcutter>();
                woodcutterScript.TreeList = gameObject.transform.parent.gameObject;
                woodcutterScript.player   = player;

                lumberjack.transform.SetParent(transform.parent.parent);
                Destroy(gameObject);
            }
            break;

        case PlayerScript.TowerType.BananaTower:
            if (player.CurrentLumber >= 3)                     //TODO: Add cost of bananaman
            {
                player.CurrentLumber -= 3;
                //SendMessage("Not enough lumber");
                Vector3 spawnPosition = transform.position;
                spawnPosition.y += BananaTower.transform.position.y;
                GameObject   banana            = Instantiate(BananaTower, spawnPosition, Quaternion.identity) as GameObject;
                CreateArrows bananaTowerScript = banana.GetComponent <CreateArrows>();
                bananaTowerScript.enemyList = gameObject.transform.parent.parent.FindChild("EnemyList").gameObject;
                bananaTowerScript.player    = player;
                banana.transform.SetParent(transform.parent.parent);
                Destroy(gameObject);
            }
            break;

        case PlayerScript.TowerType.ClusterTower:
            if (player.CurrentLumber >= 5)     //TODO: Add cost of bananaman
            {
                player.CurrentLumber -= 5;
                //SendMessage("Not enough lumber");
                Vector3 spawnPosition = transform.position;
                spawnPosition.y += ClusterTower.transform.position.y;
                GameObject    clusterBanana     = Instantiate(ClusterTower, spawnPosition, Quaternion.identity) as GameObject;
                CreateCluster bananaTowerScript = clusterBanana.GetComponent <CreateCluster>();
                bananaTowerScript.enemyList = gameObject.transform.parent.parent.FindChild("EnemyList").gameObject;
                bananaTowerScript.player    = player;
                clusterBanana.transform.SetParent(transform.parent.parent);
                Destroy(gameObject);
            }
            break;
        }
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        CreateArrows AG = arrowGenerator.GetComponent <CreateArrows>();

        aQueue = AG.getArrowQueue();
    }