Inheritance: MonoBehaviour
コード例 #1
0
    private TowerBase tower;        //< The actual tower component this effect is for

    /**
     * Start is called before the first frame update
     */
    private void Start()
    {
        camControl = GameObject.Find("MainCamera");
        // Get component reference
        tower = GetComponent <TowerBase>();
        UpdateRadius();
        UpdateEffect(EffectState.Off);
    }
コード例 #2
0
 void Awake()
 {
     self = GetComponent<TowerBase>();
     gunLine = GetComponent<LineRenderer>();
     GetComponent<SphereCollider>().radius = Range;
     TowerList[towerCount] = self;
     towerCount++;
 }
コード例 #3
0
 public void OnPointerClick(PointerEventData eventData)
 {
     LevelUIBehavior.SelectedTowerBase.transform.position = transform.position;
     LevelUIBehavior.SelectedTowerBase.transform.rotation = transform.rotation;
     currentTower = LevelUIBehavior.SelectedTowerBase;
     LevelUIBehavior.SelectedTowerBase = null;
     currentTower.HideRadiusVisualizers();
 }
コード例 #4
0
    private TowerBase tower;        //< The actual tower component this effect is for

    /**
     * Start is called before the first frame update
     */
    private void Start()
    {
        // Get component reference
        tower = GetComponent <TowerBase>();

        UpdateRadius();
        UpdateEffect(EffectState.Off);
    }
コード例 #5
0
ファイル: Tower.cs プロジェクト: austinblakeslee/verthex
 public Tower(TowerBase towerBase, Faction faction, int _towerNum)
 {
     sections = new List<Section>();
     dotManager = new DotManager();
     this.towerBase = towerBase;
     this.faction = faction;
     towerNum = _towerNum;
 }
コード例 #6
0
    private void OnTriggerEnter(Collider col)
    {
        TowerBase tower = col.GetComponent <TowerBase>();

        tower.BuffRange(buffRange);
        tower.SetRateBoost(buffRate);
        tower.SetDamageBoost(buffDamage);
    }
コード例 #7
0
        public bool OnAttacked(float damage, TowerBase tower, List <EffectBase> effects)
        {
            AllEffects.UnionWith(effects);
            var healthDelta = damage * DamageReduction * DamageTypeReduction(tower.DamageType);

            tower.EnemyAttacked(Math.Min(healthDelta, Health));
            return(UpdateHealth(-healthDelta));
        }
コード例 #8
0
ファイル: PlayerData.cs プロジェクト: nmbswls/asdas
    public void gainTowerBase(string tid)
    {
        TowerBase     tb = GameStaticData.getInstance().getTowerBase(tid);
        TowerTemplate tt = new TowerTemplate();

        tt.tbase = tb;
        ownedTowers.Add(tt);
    }
コード例 #9
0
    IEnumerator WaitToBuildNewTower(TowerBase toSwap, TowerBase newOne, Transform transform)
    {
        yield return(new WaitForSecondsRealtime(2.5f));

        var newTower = Instantiate <TowerBase>(newOne, transform.position, transform.rotation);

        _towerManager.DoSwapTowerInitialization(toSwap, newTower);
    }
コード例 #10
0
 void Awake()
 {
     self = GetComponent<TowerBase>();
     gunLine = GetComponent<LineRenderer>();
     GetComponent<SphereCollider>().radius = Range;
     TowerList[towerCount] = self;
     towerCount++;
     shootableMask = LayerMask.GetMask("Shootable");
 }
コード例 #11
0
 public void SelectTower(TowerBase tower)
 {
     if (tower == selectedTower)
     {
         Debug.Log("같은 타워 클릭");
         return;
     }
     StartCoroutine(ChageSelect(tower));
 }
コード例 #12
0
 public void loadTowerInfo()
 {
     Object[] content = Resources.LoadAll("ScriptableObj/TowerBase");
     foreach (Object o in content)
     {
         TowerBase tb = (TowerBase)o;
         towerBaseInfo.Add(tb.tid, tb);
     }
 }
コード例 #13
0
        public void Load()
        {
            IsPaused = true;

            var snapshot = SaveUtils.Load();

            if (snapshot != null)
            {
                _isLoading = true;

                Gold  = snapshot.Gold;
                Lives = snapshot.Lives;
                UpdateGold(0);
                UpdateLives(0);

                if (IsWaveActive)
                {
                    var wave = _waves[_currWave % _waves.Length];
                    wave.OnCreateEnemy -= HandleCreateEnemy;
                    wave.OnWaveCleared -= HandleWaveCleared;
                    wave.IsActive       = false;
                    WavePreview.UpdateWave(null, -1);

                    foreach (Transform enemy in EnemiesParent)
                    {
                        Destroy(enemy.gameObject);
                    }
                }
                _currWave = snapshot.Wave;
                ResetWaveStatus();

                foreach (var tower in _activeTowers.Keys)
                {
                    Destroy(tower);
                }
                foreach (var tower in snapshot.Towers)
                {
                    RegisterTower(TowerBase.FromSnapshot(tower));
                }

                Items.Clear();
                Inventory.ResetItems();
                foreach (var item in snapshot.Items)
                {
                    AddItem(ItemBase.FromSnapshot(item));
                }

                TowerDetails.UpdateTarget(null, false);
                EnemyDetails.UpdateTarget(null, false);

                _snapshot  = snapshot;
                _isLoading = false;
            }

            IsPaused = false;
        }
コード例 #14
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag != "Tower")
        {
            return;
        }
        TowerBase tb = other.GetComponent <TowerBase>();

        towers.Add(tb);
    }
コード例 #15
0
    void Start()
    {
        parent    = GetComponentInParent <TowerBase>();
        animation = gameObject.GetComponent <Animator>();
        animation.SetFloat("gamespeed", gameSettings.gameSpeed);
        cannonParent     = gameObject.GetComponentInParent <CannonTower>();
        projectileDamage = cannonParent.damage;

        DamageEnemies();
    }
コード例 #16
0
    public override void FireBullet(TowerBase tower, TargetPoint target, float projectileSpeed)
    {
        base.FireBullet(tower, target, projectileSpeed);

        this.tower  = tower;
        this.target = target;
        speed       = projectileSpeed;

        transform.position = LaunchPoint;
    }
コード例 #17
0
    void Awake()
    {
        if (!m_tower)
        {
            m_tower = gameObject.GetComponent <TowerBase>();
        }

        // Do not need to call as RPC
        setDisableRotation(false);
    }
コード例 #18
0
    public TowerBase getTowerBase(string tid)
    {
        TowerBase data = null;

        if (!towerBaseInfo.TryGetValue(tid, out data))
        {
            data = towerBaseInfo ["t_default"];
        }
        return(data);
    }
コード例 #19
0
 /*
  * adds a AOE target to the tower base if there is no tower already there
  */
 public void AOE()
 {
     towerBase = HighlghtedGameObject.GetComponent <TowerBase>();
     if (towerBase.hasTower == false)
     {
         TowerPos           = HighlghtedGameObject.transform.position;
         towerBase.tower    = Instantiate(AOETower, TowerPos, Quaternion.identity);
         towerBase.hasTower = true;
     }
 }
コード例 #20
0
ファイル: Tower.cs プロジェクト: ImInfenix/TowerForge
    RangeIndicator rangeIndicator;     //Objet d'affichage de la portee

    //Initialise une tour a l'aide de sa base et de son arme
    public void Initialize(TowerBase towerBase, TowerWeapon towerWeapon)
    {
        TowerBase        = towerBase;                                 //Reference la base
        this.towerWeapon = towerWeapon;                               //Reference l'arme
        rangeIndicator   = GetComponentInChildren <RangeIndicator>(); //Reference l'objet de portee
        rangeIndicator.SetRange(towerWeapon.TowerRange);              //Met a jour la portee

        towerBase.associatedTower   = this;                           //Se definit comme tour de la base en entree
        towerWeapon.associatedTower = this;                           //Se definit comme tour de l'arme en entree
    }
コード例 #21
0
 //static access for applying a powerup to a single tower
 //used when building new towers
 public static void ApplyToSingleTower(TowerBase tBase, Upgrade upg)
 {
     for (int i = 0; i < instance.passivePowerUps.Count; i++)
     {
         if (instance.passivePowerUps[i].enabled)
         {
             instance.passivePowerUps[i].ApplyToTower(tBase, upg);
         }
     }
 }
コード例 #22
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == "Tower")
     {
         TowerBase tb = other.GetComponent <TowerBase>();
         if (towers.Contains(tb))
         {
             towers.Remove(tb);
         }
     }
 }
コード例 #23
0
ファイル: MouseHook.cs プロジェクト: fridgeBaron/Path-of-Doom
 void UpdateGrid(Vector3 gridPos = new Vector3())
 {
     if (TerrainGen.mapGenState == MapGen.done)
     {
         if (gridPos != Vector3.zero)
         {
             PathKeeper.pathKeeper.RecalcArea(PathType.normal, TerrainGen.GetGridPosition(hexHook.transform.position), 5, true);
         }
         TowerBase.UpdateTowerHexes();
     }
 }
コード例 #24
0
ファイル: TowerScript.cs プロジェクト: pav17/GGJ2020Try2
    void CalculateStats()
    {
        TowerBase   t_base   = tower_base.GetComponent <TowerBase>();
        TowerTurret t_turret = tower_turret.GetComponent <TowerTurret>();
        TowerCore   t_core   = tower_core.GetComponent <TowerCore>();

        shot_rate   = shot_rate_base * t_base.firerate_ratio * t_turret.firerate_ratio;
        shot_radius = shot_radius_base * t_turret.radius_ratio;
        shot_damage = (int)(shot_damage_base * t_turret.damage_ratio);
        bullet_type = t_core.bullet_type;
    }
コード例 #25
0
 private void InputManagerOnOnClick(MouseEventArgs mouseEventArgs)
 {
     if (IsVisible)
     {
         TowerBase placing = _towers.SingleOrDefault(t => t.TowerStateEnum == TowerStateEnum.Setup);
         if (placing != null)
         {
             placing.TowerStateEnum = TowerStateEnum.Active;
         }
     }
 }
コード例 #26
0
    public void CreateTower()
    {
        if (SelectedTowerBase != null)
        {
            DestroyTower();
        }
        var go = Instantiate(GameManager.TowerPrefab);

        SelectedTowerBase = go.GetComponent <TowerBase>();
        SelectedTowerBase.ShowRadiusVisualizers();
    }
コード例 #27
0
    void SwapTowers(TowerBase toSwap, TowerBase newOne)
    {
        var towerTransform = toSwap.transform;
        var particle       = Instantiate <ParticleSystem>(swapParticleSysPrefab, towerTransform.position, Quaternion.identity);

        particle.transform.position = new Vector3(particle.transform.position.x, particle.transform.position.y + 3, particle.transform.position.z);
        //particle.transform.position += (Camera.main.transform.position - particle.transform.position).normalized * 2f;
        particle.Play(true);
        Destroy(particle.gameObject, particle.main.duration);
        StartCoroutine(WaitToBuildNewTower(toSwap, newOne, towerTransform));
    }
コード例 #28
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < 6; i++)
     {
         status[i] = new TowerBase[6];
     }
     for (int i = 0; i < 6; i++)
     {
         wall[i] = new GameObject[6];
     }
 }
コード例 #29
0
        public void UpdateGold(int delta, TowerBase tower = null)
        {
            var goldAmount = 100f;

            if (tower != null)
            {
                goldAmount = tower.AllEffects.OfType <GoldEffect>().Select(effect => effect.Amount.Value).Prepend(100f).Max();
            }
            Gold         += (int)(delta * goldAmount / 100f);
            GoldText.text = Gold.ToString();
        }
コード例 #30
0
    // Use this for initialization
    void Start()
    {
        soundManager = SoundLocator.GetSoundManager();

        ChangeCurrenTower(towerBase);
        towerBase = GameObject.Find("MainTower").GetComponent <TowerBase>();
        towerBase.TextActivator(towerBase.children);
        if (SceneManager.GetActiveScene().name == "_Tutorial")
        {
            tutorialManager = GameObject.Find("TutorialManager").GetComponent <TutorialManager>();
        }
    }
コード例 #31
0
    public override void LaunchCannon(TowerBase tower, TargetPoint target, Vector3 launchVelocity, float explodeRadius)
    {
        base.LaunchCannon(tower, target, launchVelocity, explodeRadius);

        this.tower          = tower;
        this.target         = target;
        this.launchVelocity = launchVelocity;
        this.explodeRadius  = explodeRadius;

        targetPos          = target.Position;
        transform.position = LaunchPoint;
    }
コード例 #32
0
    public bool BuildTower(TowerBase obj)
    {
        if (tower || !obj || playerInside || EnemySpawner.CalculateAI(parent, coords.y, coords) == null)
        {
            return(false);
        }

        tower = Instantiate(obj, transform);

        EventBus.Post(new EventWorldChanged(parent));
        return(true);
    }
コード例 #33
0
    public ProjectileBase CopyProjectile(float DamageReduction = 1)
    {
        ProjectileBase newProj = TowerBase.GetNewProjectile();

        newProj.gameObject.SetActive(true);
        //
        newProj.setBaseTower(tower);
        newProj.SetProjectile(target, speed, damage, areaEffect, chainCount, chainDistanceMin, chainDistanceMax, forkCount, forkProjectiles, forkDamageLoss, true, false);
        newProj.SetParticleSystems(effect, explosion);
        newProj.SpawnParticles();
        return(newProj);
    }
コード例 #34
0
ファイル: GUILogic.cs プロジェクト: patte88/Monsters-Incoming
    //create active selection / floating tower on pressing a tower button
    public void InstantiateTower(int clickedButton)
    {
        //store the TowerManager tower index passed in as parameter
        index = clickedButton;

        //we clicked one of these tower buttons
        //if we already have a floating tower, destroy it and free selections
        if (SV.selection)
        {
            currentGrid = null;
            currentTower = null;
            Destroy(SV.selection);
        }

        //check if there are free grids left
        //no free grid left (list count is equal to grid count)
        if (gridScript.GridList.Count == gridScript.transform.GetChildCount())
        {
            //print a warning message
            StartCoroutine("DisplayError", "No free grids left for placing a new tower!");
            Debug.Log("No free grids left for placing a new tower!");
            return;
        }

        //initialize price array with total count of resources
        float[] price = new float[GameHandler.resources.Length];
        //cache selected upgrade options for further processment
        UpgOptions opt = towerScript.towerUpgrade[index].options[0];

        //loop through resources
        //get needed resources (buy price) of this tower from upgrade list
        for (int i = 0; i < price.Length; i++)
            price[i] = opt.cost[i];

        //check in case we have not enough resources left, abort purchase
        for (int i = 0; i < price.Length; i++)
        {
            if (GameHandler.resources[i] < price[i])
            {
                StartCoroutine("DisplayError", "Not enough resources for buying this tower!");
                Debug.Log("Not enough resources for buying this tower!");
                //destroy selection
                CancelSelection(true);
                return;
            }
        }

        //all checks went through, we are able to purchase this tower
        //instantiate selected tower from TowerManager prefab list and thus create a floating tower
        SV.selection = (GameObject)Instantiate(towerScript.towerPrefabs[index], new Vector3(0, -200, 0), Quaternion.identity);
        //get new base properties of this tower instance
        towerBase = SV.selection.GetComponentInChildren<TowerBase>();
        //change name of the gameobject holding this component to the defined one in TowerManager names list
        towerBase.gameObject.name = towerScript.towerNames[index];
        //parent tower to the container gameobject
        SV.selection.transform.parent = towerContainer;
        //get new upgrade properties of this tower instance
        upgrade = SV.selection.GetComponentInChildren<Upgrade>();
        //disable its base properties, so while moving/placing the tower around, it can not attack
        towerBase.enabled = false;
        //show all grid renderers to see where we could (or could not) place the tower
        gridScript.ToggleVisibility(true);
    }
コード例 #35
0
 //remove towers which are too far away
 //called by RangeTrigger.cs on OnTriggerExit()
 public void RemoveTower(TowerBase tower)
 {
     nearTowers.Remove(tower);
 }
コード例 #36
0
ファイル: Upgrade.cs プロジェクト: patte88/Monsters-Incoming
    void Start()
    {
        //don't execute further code when no upgrade options are defined but debug a warning
        if (options.Count == 0)
        {
            Debug.LogWarning("No upgrade options for tower " + gameObject.name +
                             " assigned! This will cause errors at runtime.");
            return;
        }

        //set collider radius to prefab/inspector defined radius
        sphereCol = transform.parent.FindChild("RangeTrigger").gameObject.GetComponent<SphereCollider>();
        sphereCol.radius = options[curLvl].radius;

        //get rangeIndicator gameObject
        rangeIndicator = transform.parent.FindChild("RangeIndicator");
        if(rangeIndicator) RangeChange();  //cause RangeIndicator to adjust its range

        //get towerbase reference
        towerScript = gameObject.GetComponent<TowerBase>();
    }
コード例 #37
0
 //we entered the range of a tower, add it to our nearTowers dictionary
 public void AddTower(TowerBase tower)
 {
     nearTowers.Add(tower);
 }
コード例 #38
0
    //initialize all needed variables,
    //and let the camera fly to the current tower position
    public void Initialize(GameObject guiObj, GameObject crosshair, GameObject aimIndicator,
                           float towerHeight, bool mobile)
    {
        //get scene main camera
        cam = Camera.main.transform;
        //set GUI gameobject passed in
        this.guiObj = guiObj;

        //recognized this application as non-mobile
        //set camera script desktop version
        if (!mobile)
        {
            //get camera control script of main camera
            camDesktop = cam.GetComponent<CameraControl>();
            //disable control script, so all standard movement is disabled
            //(we only want to rotate around while controlling our tower)
            camDesktop.enabled = false;
        }

        //get TowerBase.cs of tower we control (this gameobject)
        towerScript = gameObject.GetComponent<TowerBase>();
        //enable range indicator so it is always visible
        towerScript.rangeInd.renderer.enabled = true;
        //disable tower intelligence, since we want to self control this tower
        towerScript.CancelInvoke("CheckRange");

        //set current tower upgrade level through TowerBase.cs -> Upgrade.cs
        //(we cache them, so we don't need to call this every time in the functions below)
        curLvl = towerScript.upgrade.curLvl;
        //calculate next shot time in the future: last shot game time + delay
        shotTime = towerScript.lastShot + towerScript.upgrade.options[curLvl].shootDelay;
        //also cache attackable enemy type
        enemyType = towerScript.myTargets;

        //TowerRotate of TowerBase.cs is set: we have a turret that rotates
        if (towerScript.turret)
        {
            //get TowerRotation component and disable it:
            //our turret does not follow nearby enemies anymore
            //(we want our turret to follow our mouse/touch input.)
            towerRotScript = towerScript.turret.GetComponent<TowerRotation>();
            towerRotScript.enabled = false;
        }

        //set crosshair transform reference, since GUILogic.cs instantiated this prefab already
        cross = crosshair.transform;
        //set crosshair positioning behaviour
        centerCrosshair = mobile;

        //get LineRenderer component of the prefab instantiated by GameGUI.cs
        aimRend = aimIndicator.GetComponent<LineRenderer>();
        //set start and end position of LineRenderer
        //[0] = start position, [1] = end position, at first we initialize both to towers shoot position
        aimRend.SetPosition(0, towerScript.shotPos.position);
        aimRend.SetPosition(1, towerScript.shotPos.position);

        //call iTween to move the camera to our controlled tower position
        iTween.MoveTo(cam.gameObject, iTween.Hash("position", transform.position + new Vector3(0, towerHeight, 0), "time", 1, "easetype", iTween.EaseType.easeInOutExpo));
        //we don't want to move our crosshair until iTween's animation is completed and the camera reached its destination
        //StartCoroutine() doesn't support delay - and Invoke() doesn't support starting a coroutine
        //so we need to invoke another function in 1 second which then starts the coroutine
        Invoke("StartCoroutineUpdate", 1);
    }
コード例 #39
0
 void Start()
 {
     //get tower base script reference
     towerScript = transform.parent.gameObject.GetComponentInChildren<TowerBase>();
 }
コード例 #40
0
ファイル: GUILogic.cs プロジェクト: patte88/Monsters-Incoming
 //set components of the tower passed in for later use and access
 public void SetTowerComponents(GameObject tower)
 {
     upgrade = tower.GetComponent<Upgrade>();
     towerBase = tower.GetComponent<TowerBase>();
 }
コード例 #41
0
ファイル: Player.cs プロジェクト: austinblakeslee/verthex
 public void AddTower(TowerBase b, Faction f, int i)
 {
     this.towers[i] = new Tower(b, f, i);
 }
コード例 #42
0
 // Use this for initialization
 void Start()
 {
     for(int i=0;i<6;i++) status[i]=new TowerBase[6];
     for(int i=0;i<6;i++) wall[i]=new GameObject[6];
 }