private void CreateTower()
        {
            Rectangle tempRect = new Rectangle(tileX, tileY, Engine.TileWidth, Engine.TileHeight);

            if (!towerManager.IsOnTower(tileX, tileY))
            {
                if (tower is ArrowTower)
                {
                    ArrowTower arrow = new ArrowTower(arrowTower,
                                                      new Vector2(tileX, tileY), bullet, 1, soundBank);
                    towerManager.AddTower(arrow);
                    money -= tower.Cost;
                    tower  = null;
                }

                else if (tower is SpikeTower)
                {
                    SpikeTower spike = new SpikeTower(spikeTower,
                                                      new Vector2(tileX, tileY), bullet, 1, soundBank);
                    towerManager.AddTower(spike);
                    //money -= tower.Cost;
                    money -= 1;
                    tower  = null;
                }

                else if (tower is BombTower)
                {
                    BombTower bomb = new BombTower(bombTower,
                                                   new Vector2(tileX, tileY), bullet, 1, soundBank);
                    towerManager.AddTower(bomb);
                    //money -= tower.Cost;
                    money -= 1;
                    tower  = null;
                }

                else if (tower is OneandOneTower)
                {
                    OneandOneTower oneandone = new OneandOneTower(bombTower,
                                                                  new Vector2(tileX, tileY), bullet, 1, soundBank);
                    towerManager.AddTower(oneandone);
                    money -= tower.Cost;
                    tower  = null;
                }
                if (tower is ofLoveTower)
                {
                    ofLoveTower love = new ofLoveTower(ofLoveTower,
                                                       new Vector2(tileX, tileY), bullet, 1, soundBank);
                    towerManager.AddTower(love);
                    money -= tower.Cost;
                    soundBank.PlayCue("liebe2");
                    tower = null;
                }
            }
        }
Exemple #2
0
    void UpdatePlacingTower()
    {
        Vector3    mpos = Input.mousePosition;
        Ray        r    = Camera.main.ScreenPointToRay(mpos);
        RaycastHit hit;

        if (Physics.Raycast(r, out hit, 1000, LayerMask.GetMask("terrain")))
        {
            m_TowerToManipulate.SetPosition(hit.point);

            bool canBuild = CanBuildTower(hit.point, m_TowerToManipulate);
            m_TowerToManipulate.SetBuildColor(canBuild);

            if (Input.GetMouseButtonDown(0))
            {
                if (!EventSystem.current.IsPointerOverGameObject() && canBuild)
                {
                    m_TowerManager.AddTower(m_TowerToManipulate);
                    m_TowerToManipulate.Construct();
                    m_TowerToManipulate.Unselect(0.0f);

                    m_Player.AddCoins(-m_TowerToManipulate.GetCost());
                    m_TowerToManipulate = null;

                    if (OnTowerConstructed != null)
                    {
                        OnTowerConstructed();
                    }

                    m_Player.SetState(Player.State.IDLE);
                }
            }
        }
    }
Exemple #3
0
 public void SelectTower()
 {
     if (isEnabled)
     {
         towerManager.AddTower(towerType);
     }
 }
Exemple #4
0
    // Build Tower functions ------------------------------------------------

    // Builds a tower on the given node and returns a reference to it
    public GameObject BuildTowerOnNode(Node node)
    {
        // If no tower is selected, return null
        if (towerToBuild == null)
        {
            Debug.Log("TowerBuilder: No tower selected");
            return(null);
        }

        // If not enough money, return null
        if (PlayerStats.GetMoney() - towerToBuild.cost < 0)
        {
            Debug.Log("TowerBuilder: Not enough money");
            return(null);
        }

        // Subtract money
        PlayerStats.AddMoney(-towerToBuild.cost);

        // Create tower
        GameObject t = (GameObject)Instantiate(towerToBuild.prefab, node.transform.position, Quaternion.identity);

        // Set row number
        int rowNum = GetNodeRowNumber(node);

        t.GetComponent <Tower>().SetRowNum(rowNum);

        // Set up targetting
        towerManager.AddTower(t, rowNum);

        // Reset towerToBuild
        towerToBuild = null;

        return(t);
    }
Exemple #5
0
 public void PlaceTower()
 {
     if (canPlace && TargetTower != null)
     {
         towerManager.AddTower(TargetTower);
         TargetTower = null;
     }
 }
Exemple #6
0
 void BuildTower()
 {
     //StopCoroutine (EventInstantiator ());
     towerToBuild             = buildManager.GetTowerToBuild();
     tower                    = (GameObject)Instantiate(currentBuildingTower, transform.position, transform.rotation);
     tower.transform.rotation = Quaternion.Euler(0, 0, 0);
     towerManager.AddTower(tower, shopScript.GetTowerToBuildIndex());
     buildManager.SetTowerToBuild(null);
     buildManager.SetSelectionTowerToBuild(null);
     towerManager.TowerDiselected();
     isAlreadBuilt = true;
 }
    protected override void Awake()
    {
        IsTower = true;
        base.Awake();
        buffRange = myTransform.Find("BuffRange");
        ColliderChild cc = buffRange.GetComponent <ColliderChild>();

        cc.triggerEnter      = BuffRangeEnter;
        cc.triggerExit       = BuffRangeExit;
        nova                 = buffRange.Find("magicCircleSingle").Find("auraWall").GetComponent <ParticleSystem>();
        buffGround           = buffRange.Find("magicCircleSingle").GetComponent <ParticleSystem>();
        characterInBuffRange = new List <BaseCharacterBehavior>();

        TowerFollowers       = new List <NPCController>();
        Followers            = new List <NPCController>();
        followerSpawnPoint   = myTransform.Find("SpawnPoint").position;
        createFollowerEffect = myTransform.Find("SpawnPoint").Find("magicGate").GetComponent <ParticleSystem>();

        TowerTarget = myTransform.Find("TowerTarget");
        TowerTarget.GetComponent <UIFollowTarget>().gameCamera = Camera.main;
        //TowerTarget.GetComponent<UIFollowTarget>().uiCamera = GameObject.Find("UI Root").GetComponentInChildren<Camera>();
        TowerTarget.gameObject.SetActive(false);
        TowerManager.AddTower(this);
        for (int i = 0; i < stationPosition.Length; i++)
        {
            stationPosition[i] = transform.Find("StationPoints").GetChild(i);
        }
        MainFlag = myTransform.Find("MainFlag");

        //CreatePlaneForEargleEye();
        Mesh       mesh         = ResourceLoader.Utilities.GetCirclePlane();
        GameObject eargleEyeImg = new GameObject();

        eargleEyeImgTransform = eargleEyeImg.transform;
        eargleEyeImg.name     = "EargleEyeImg";
        eargleEyeImg.AddComponent <MeshFilter>().mesh = mesh;
        MeshRenderer eargleEyeImgMeshRenderer = eargleEyeImg.AddComponent <MeshRenderer>();

        eargleEyeImgMeshRenderer.materials = new Material[] {
            new Material(Shader.Find("Sprites/Default"))
        };

        eargleEyeImgMeshRenderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
        eargleEyeImgMeshRenderer.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
        eargleEyeImg.layer                  = 12;
        eargleEyeImgTransform.parent        = myTransform;
        eargleEyeImgTransform.localPosition = Vector3.zero;
        eargleEyeImgTransform.position     += Vector3.up * 10f;
        eargleEyeImgTransform.localScale    = Vector3.one * 1.5f;
    }
Exemple #8
0
    private void AttemptToPlaceTower()
    {
        if (!ghostTower)
        {
            return;
        }

        if (!CanPlaceTowerHere(ghostTower, ToGridPosition(ghostTower.transform.position)))
        {
            return;
        }

        towerManager.AddTower(ghostTower);
        ghostTower.Enable();

        // TODO : continue to select or unselect ?
        ghostGameObject     = null;
        ghostTower          = null;
        ghostSpriteRenderer = null;
        // create a new selection of same prefab
        SelectTower();
    }
 public void AddTower()
 {
     TowerManager.AddTower(m_TowerManager.dndTower, TowerManager.CreatePlatformForTower(m_TowerManager.dndTower, TowerManager.GetGridSize()), 0);
 }
Exemple #10
0
 private void AddMasterTowerToTowerManager()
 {
     towerManager.AddTower(this.gameObject, masterTowerIndex);
 }