Exemplo n.º 1
0
 private void StartedBuilding(TowerInterface tower)
 {
     BuildingProgressSlider.gameObject.SetActive(true);
     BuildingProgressSlider.SetMaxValue(tower.tower.MaxHealth);
     BuildingProgressSlider.SetValue(0f);
     BuildingProgressSlider.SetValueOverTime(tower.tower.MaxHealth, tower.tower.BuildTime * MapController.singleton.BuildTimeMultiplier);
 }
    private void SelectTower()
    {
        TowerInterface tower = GetTowerInterface();

        if (currentTower == tower)
        {
            return;
        }

        if (tower != null && tower.GetState() == TowerInterface.State.Building)
        {
            return;
        }

        if (currentTower != null)
        {
            currentTower.materialChanger.RevertMaterial();
        }

        currentTower = tower;

        if (currentTower != null)
        {
            currentTower.materialChanger.ChangeMaterial(HighlightMaterial);
        }
    }
    private void ServerRepairTower(TowerInterface tower, NetworkConnectionToClient conn = null)
    {
        if (tower == null || tower.GetState() != TowerInterface.State.Default)
        {
            ClientFinishedOrCanceledRepairingTower();
        }

        Repairing = ServerRepairingTower(tower);
        StartCoroutine(Repairing);
    }
    private void ServerDeleteTower(TowerInterface tower)
    {
        if (tower == null)
        {
            return;
        }

        tower.tower.SellTower(MapController.singleton.TowerRefundPercentage);
        tower.tower.ServerDestroy();
    }
    private void DeleteTower()
    {
        TowerInterface tower = selectTowerController.currentTower;

        if (tower == null)
        {
            return;
        }

        ServerDeleteTower(tower);
    }
    private void RepairTower()
    {
        TowerInterface tower = selectTowerController.currentTower;

        if (tower == null)
        {
            return;
        }

        playerInterface.SetState(PlayerInterface.State.Interacting);

        ServerRepairTower(tower);
    }
    public void AddTowerToPlayer(TowerInterface tower, NetworkConnectionToClient conn)
    {
        if (tower == null || conn == null)
        {
            return;
        }

        if (!players.Exists(item => item.networkConnection.connectionId == conn.connectionId))
        {
            return;
        }

        Player player = players.Find(item => item.networkConnection.connectionId == conn.connectionId);

        player.towers.Add(tower);
    }
    public void RemoveTowerFromPlayer(TowerInterface tower)
    {
        if (tower == null)
        {
            return;
        }

        if (!players.Exists(item => item.towers.Contains(tower)))
        {
            return;
        }

        Player player = players.Find(item => item.towers.Contains(tower));

        player.towers.Remove(tower);
    }
    private IEnumerator ServerRepairingTower(TowerInterface tower)
    {
        float ManaPerHealth = (tower.tower.Cost * 0.2f) / tower.tower.MaxHealth;

        while (tower.tower.GetHealth() < tower.tower.MaxHealth)
        {
            float Difference = tower.tower.MaxHealth - tower.tower.GetHealth();
            Difference = Mathf.Min(Difference, 0.5f);

            if (ClientMoneyController.singleton.Money - (ManaPerHealth * Difference) < 0)
            {
                break;
            }

            tower.tower.Damage(-Difference);
            ClientMoneyController.singleton.RemoveMoney(ManaPerHealth * Difference);

            yield return(new WaitForSeconds(0.1f * MapController.singleton.BuildTimeMultiplier));
        }

        ClientFinishedOrCanceledRepairingTower();
    }
Exemplo n.º 10
0
 private void FinishedBuilding(TowerInterface tower)
 {
     BuildingProgressSlider.StopValueOverTime();
     BuildingProgressSlider.SetValue(0f);
     BuildingProgressSlider.gameObject.SetActive(false);
 }
Exemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        switch (poolType)
        {
        case PoolType.Hazzard:
            for (int i = 0; i < Amount; i++)
            {
                GameObject g = Instantiate(pooledObject, transform.position, Quaternion.identity, transform);
                Hazzard    h = g.GetComponent <Hazzard>();
                h.Reset();
                poolList.Add(h);
            }

            break;


        case PoolType.Projectile:
            for (int i = 0; i < Amount; i++)
            {
                GameObject g = Instantiate(pooledObject, transform.position, Quaternion.identity, transform);
                Projectile h = g.GetComponent <Projectile>();

                h.gameObject.SetActive(false);

                projectileList.Add(h);

                //h.Reset();
                //poolList.Add(h);
            }

            break;


        case PoolType.EnemyProjectile:


            for (int i = 0; i < Amount; i++)
            {
                GameObject      g = Instantiate(pooledObject, transform.position, Quaternion.identity, transform);
                EnemyProjectile h = g.GetComponent <EnemyProjectile>();

                h.gameObject.SetActive(false);

                eProjectileList.Add(h);

                //h.Reset();
                //poolList.Add(h);
            }

            break;


        case PoolType.Tower:

            for (int i = 0; i < Amount; i++)
            {
                GameObject     g = Instantiate(pooledObject, transform.position, Quaternion.identity, transform);
                TowerInterface h = g.transform.GetComponentInChildren <TowerInterface>();

                towerInterfaceList.Add(h);

                g.SetActive(false);

                towerList.Add(g);



                //h.Reset();
                //poolList.Add(h);
            }
            TowerListSum = towerList.ToArray().Length;


            if (readyTowers)
            {
                towerList[0].transform.position = readyTower1.position;
                towerList[0].transform.rotation = readyTower1.rotation;
                towerList[0].SetActive(true);

                towerList[1].transform.position = readyTower2.position;
                towerList[1].transform.rotation = readyTower2.rotation;
                towerList[1].SetActive(true);

                index = 2;
            }

            break;


        case PoolType.Collectable:

            for (int i = 0; i < Amount; i++)
            {
                GameObject     g = Instantiate(pooledObject, transform.position, Quaternion.identity, transform);
                TowerInterface h = g.transform.GetComponentInChildren <TowerInterface>();

                //towerInterfaceList.Add(h);

                g.SetActive(false);

                collectableList.Add(g);



                //h.Reset();
                //poolList.Add(h);
            }


            break;
        }
    }