Ejemplo n.º 1
0
        public void LoadFromObject(GameObject towerGameObject)
        {
            DefenseTower unit = towerGameObject.GetComponent <DefenseTower>();

            maxHP = towerGameObject.GetComponent <DefenseTower>().maxHP;
            Attack attack = towerGameObject.GetComponent <Attack>();

            Damage       = attack.damage;
            DamageRate   = attack.damageRate;
            AttackRadius = attack.attackRadius;
            RotateSpeed  = unit.rotateSpeed;
        }
Ejemplo n.º 2
0
    public int Sell(GameObject tower)
    {
        int          gold          = 0;
        DefenseTower defense_tower = tower.GetComponent <DefenseTower>();

        if (defense_tower.Turret != null)
        {
            gold = (int)defense_tower.Turret.GetComponent <Unit>().Cost / 2;
            Player.instance.IncreaseGold(gold);
            defense_tower.RemoveTurret();
        }
        return(gold);
    }
Ejemplo n.º 3
0
    public bool Purchase(int weaponIndex, Transform tower)
    {
        DefenseTower selectedTower = tower.GetComponent <DefenseTower>();

        if (selectedTower.Turret == null)
        {
            GameObject turret = ModelManager.instance.CreateWeapon(Controller.weaponIndex, tower.GetChild(0));
            selectedTower.PlaceTurret(turret.transform);
            Player.instance.ReduceGold(turret.GetComponent <Unit>().Cost);
            return(true);
        }
        return(false);
    }
Ejemplo n.º 4
0
    public bool UpgradeWeapon(Transform tower)
    {
        DefenseTower selectedTower = tower.GetComponent <DefenseTower>();
        Upgrade      turret        = selectedTower.Turret.GetComponent <Upgrade>();

        if (selectedTower.Turret != null && turret.Upgradable() && Player.instance.EnoughGold(turret.UpgradeCost))
        {
            GameObject upgradedTurret = turret.UpgradeUnit();
            selectedTower.PlaceTurret(upgradedTurret.transform);
            Player.instance.ReduceGold(turret.UpgradeCost);
            return(true);
        }
        return(false);
    }
Ejemplo n.º 5
0
    // Display the weapon information
    public static void ShowWeaponInfo(bool show)
    {
        Controller.weaponInfo.SetActive(false);
        if (show && Controller.selected != null)
        {
            DefenseTower tower = Controller.selected.GetComponent <DefenseTower>();
            if (tower.Turret != null)
            {
                Text    upgradePrice = Controller.weaponInfo.transform.GetChild(1).GetChild(0).GetComponent <Text> ();
                Text    goldObtain   = Controller.weaponInfo.transform.GetChild(2).GetChild(0).GetComponent <Text> ();
                Upgrade weapon       = tower.Turret.GetComponent <Upgrade> ();

                upgradePrice.text = weapon.Upgradable() ? weapon.UpgradeCost + " Gold" : "N/A";
                goldObtain.text   = ((int)tower.Turret.GetComponent <Unit> ().Cost / 2) + " Gold";
                Controller.weaponInfo.transform.position = CameraMovement.mainCamera.WorldToScreenPoint(tower.transform.position) + new Vector3(0.0f, 80.0f);
                Controller.weaponInfo.SetActive(true);
            }
        }
    }
Ejemplo n.º 6
0
    private void SaveInPrefabs()
    {
        MainConfig config = LoadSaveData <MainConfig>(SavedGamesPath + NameDataSaveFile);

        PlayerUnit.GetComponent <Unit>().maxHP = config.PlayerUnit.maxHP;
        Attack attack = PlayerUnit.GetComponent <Attack>();

        attack.damage       = config.PlayerUnit.Damage;
        attack.damageRate   = config.PlayerUnit.DamageRate;
        attack.attackRadius = config.PlayerUnit.AttackRadius;
        PlayerUnit.GetComponent <Movement>().maxSpeed = config.PlayerUnit.maxSpeed;

        EnemyUnit.GetComponent <Unit>().maxHP = config.EnemyUnit.maxHP;
        attack              = EnemyUnit.GetComponent <Attack>();
        attack.damage       = config.EnemyUnit.Damage;
        attack.damageRate   = config.EnemyUnit.DamageRate;
        attack.attackRadius = config.EnemyUnit.AttackRadius;
        EnemyUnit.GetComponent <Movement>().maxSpeed = config.EnemyUnit.maxSpeed;

        Base _base = PlayerBase.GetComponent <Base>();

        _base.maxHP            = config.PlayerBase.maxHP;
        _base.spawnRate        = config.PlayerBase.SpawnRate;
        _base.ProduceRate      = config.PlayerBase.ProduceUnitRate;
        _base.MaxCountUnit     = config.PlayerBase.MaxUnit;
        _base.CurrentCountUnit = config.PlayerBase.StartCountUnit;
        attack              = PlayerBase.GetComponent <Attack>();
        attack.damage       = config.PlayerBase.Damage;
        attack.damageRate   = config.PlayerBase.DamageRate;
        attack.attackRadius = config.PlayerBase.AttackRadius;

        _base                  = NeutralBase.GetComponent <Base>();
        _base.maxHP            = config.NeutralBase.maxHP;
        _base.spawnRate        = config.NeutralBase.SpawnRate;
        _base.ProduceRate      = config.NeutralBase.ProduceUnitRate;
        _base.MaxCountUnit     = config.NeutralBase.MaxUnit;
        _base.CurrentCountUnit = config.NeutralBase.StartCountUnit;
        attack                 = NeutralBase.GetComponent <Attack>();
        attack.damage          = config.NeutralBase.Damage;
        attack.damageRate      = config.NeutralBase.DamageRate;
        attack.attackRadius    = config.NeutralBase.AttackRadius;

        _base                  = EnemyBase.GetComponent <Base>();
        _base.maxHP            = config.EnemyBase.maxHP;
        _base.spawnRate        = config.EnemyBase.SpawnRate;
        _base.ProduceRate      = config.EnemyBase.ProduceUnitRate;
        _base.MaxCountUnit     = config.EnemyBase.MaxUnit;
        _base.CurrentCountUnit = config.EnemyBase.StartCountUnit;
        attack                 = EnemyBase.GetComponent <Attack>();
        attack.damage          = config.EnemyBase.Damage;
        attack.damageRate      = config.EnemyBase.DamageRate;
        attack.attackRadius    = config.EnemyBase.AttackRadius;


        DefenseTower tower = PlayerTower.GetComponent <DefenseTower>();

        tower.maxHP         = config.PlayerTower.maxHP;
        tower.rotateSpeed   = config.PlayerTower.RotateSpeed;
        attack              = PlayerTower.GetComponent <Attack>();
        attack.damage       = config.PlayerTower.Damage;
        attack.damageRate   = config.PlayerTower.DamageRate;
        attack.attackRadius = config.PlayerTower.AttackRadius;

        tower               = EnemyTower.GetComponent <DefenseTower>();
        tower.maxHP         = config.EnemyTower.maxHP;
        tower.rotateSpeed   = config.EnemyTower.RotateSpeed;
        attack              = EnemyTower.GetComponent <Attack>();
        attack.damage       = config.EnemyTower.Damage;
        attack.damageRate   = config.EnemyTower.DamageRate;
        attack.attackRadius = config.EnemyTower.AttackRadius;
    }
Ejemplo n.º 7
0
 void Start()
 {
     if (!defenseTower)
         defenseTower = GetComponent<DefenseTower>();
 }