示例#1
0
    private void Start()
    {
        for (int i = 0; i < towerPrefabs.Count; i++)
        {
            whereIsBuffer = towerPrefabs[i].GetComponentInChildren <WhereIs>();
            fighterBuffer = whereIsBuffer.GetFighter();
            towerScripts.Add((Tower)whereIsBuffer.GetFighter());
        }

        UIManager.Instance.InitializeBuildUI();
        UIManager.Instance.InitializeGameStateUI(money, waveSpawns.Count);

        StartCoroutine(GenerateEnemyPrefabs());
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Input.GetButtonDown("Fire"))
        {
            if (Physics.Raycast(ray, out hit, 1000f, FighterVision - 5)) //-1 to invert mask, -4 to ignore raycast
            {
                SelectActiveCell(false);

                if (hit.collider.gameObject.GetComponent <CellManager>() != null)
                {
                    selectedCell   = hit.collider.gameObject.GetComponent <CellManager>();
                    cellController = selectedCell.controller;
                    UIManager.Instance.BuildUI(cellController);
                    selectedCell.Selected(true);
                    //TODO controller calls build UI
                }

                else if (hit.collider.gameObject.GetComponent <WhereIs>() != null)
                {
                    whereIsBuffer = hit.collider.gameObject.GetComponent <WhereIs>();
                    fighterBuffer = whereIsBuffer.GetFighter();
                    if (fighterInFocus != null)
                    {
                        fighterInFocus.ToggleInFocus(false);
                    }
                    fighterInFocus = fighterBuffer;
                    fighterInFocus.ToggleInFocus(true);
                    UIManager.Instance.TrackFighter(fighterInFocus, whereIsBuffer, fighterBuffer.GetFighterType() == typeof(Tower));
                }
            }
        }
    }
示例#3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.isTrigger)
     {
         return;
     }
     if (other.GetComponent <WhereIs>() != null)
     {
         whereIsBuffer = other.GetComponent <WhereIs>();
         fighterBuffer = whereIsBuffer.GetFighter();
         fighterBuffer.SetTerrainSpeedModifier(speedModifier);
         fighterBuffer.RecalculateSpeed();
         fighters.Add(other.gameObject);
     }
 }
示例#4
0
    public bool Build(int gridID, int towerID)
    {
        if (CellControllers[gridID].CanBuild() && GameState.Instance.CanAfford(towerID, true))
        {
            GameObject tower = Instantiate(GameState.Instance.GetTowerPrefab(towerID));
            tower.transform.SetParent(TowerParent);
            tower.transform.position = CellControllers[gridID].transform.position;
            whereIsBuffer            = tower.GetComponent <WhereIs>();
            towerBuffer = (Tower)whereIsBuffer.GetFighter();
            towerBuffer.Place(gridID);
            //tower.GetComponentInChildren<Fighter>().SpawnCheck();

            GridTowers[cellController.GetGridReference()] = tower;
            cellController.SetTower(tower.GetComponentInChildren <Tower>().GetGameStateID());

            SelectActiveCell(false);
            UIManager.Instance.TrackFighter(towerBuffer, whereIsBuffer, true);
            towerBuffer.ToggleInFocus(true);
        }

        return(false);
    }