Exemple #1
0
    public void LoadTower(TowerParam _param)
    {
        // Applying param
        param = _param;

        gameObject.name = "Tower_" + param.title;

        // Visuals
        visual = Instantiate(param.model, transform.position, Quaternion.identity, transform).GetComponent <TowerVisualsBehavior>();
        if (visual != null)
        {
            visual.tower = this;
        }

        // Shooting behavior
        if (weapon == null)
        {
            weapon = GetComponent <WeaponBehavior>();
        }
        if (weapon == null)
        {
            weapon = gameObject.AddComponent <WeaponBehavior>();
        }
        weapon.tower = this;

        weapon.Load(
            param.damage * param.levelMultiplier[level],
            param.speed * param.levelMultiplier[level],
            param.range * param.levelMultiplier[level]
            );
    }