Ejemplo n.º 1
0
        protected float DrawCreepVisualEffect(float startX, float startY, UnitCreep creep)
        {
            string textF = "Visual Setting ";          //+(!foldVisual ? "(show)" : "(hide)");

            foldVisual = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldVisual, textF, TDE.foldoutS);
            if (!foldVisual)
            {
                return(startY);
            }

            startX += 12;

            startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectSpawn, "Spawn Effect", "OPTIONAL: The effect object to spawn when the creep is spawned");
            startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectDestroyed, "Destroyed Effect", "OPTIONAL: The effect object to spawn when the creep is destroyed");
            startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectDestination, "Destination Effect", "OPTIONAL: The effect object to spawn when the creep reach the destination");

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Spawn:", "OPTIONAL - The audio clip to play when the unit is spawned");
            creep.soundSpawn          = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundSpawn, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound -Destination:", "OPTIONAL - The audio clip to play when the unit reaches destination");
            creep.soundDestination    = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundDestination, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Destroyed:", "OPTIONAL - The audio clip to play when the unit is destroyed");
            creep.soundDestroyed      = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundDestroyed, typeof(AudioClip), true);

            return(startY);
        }
Ejemplo n.º 2
0
        public void ClearBuffOnTarget(UnitCreep tgtCreep)
        {
            tgtCreep.supportSrcList.Remove(this);

            bool hasSimilarBuff = false;

            for (int n = 0; n < tgtCreep.supportSrcList.Count; n++)
            {
                if (tgtCreep.supportSrcList[n].prefabID == prefabID)
                {
                    hasSimilarBuff = true; break;
                }
            }

            if (!hasSimilarBuff)
            {
                for (int n = 0; n < tgtCreep.allEffectList.Count; n++)
                {
                    if (!tgtCreep.allEffectList[n].FromCreep())
                    {
                        continue;
                    }
                    if (tgtCreep.allEffectList[n].srcPrefabID != prefabID)
                    {
                        continue;
                    }

                    tgtCreep.allEffectList[n].durationRemain = 0;
                    break;
                }
            }
        }
		void Awake(){
			if(type==_AniType.None) return;
			
			unitCreep=gameObject.GetComponent<UnitCreep>();
			
			if(type==_AniType.Legacy){
				aniInstance=aniRootObj.GetComponent<Animation>();
				if(aniInstance!=null){
					InitAnimation();
					unitCreep.SetAnimationComponent(this);
				}
			}
			
			if(type==_AniType.Mecanim){
				if(anim==null) anim=aniRootObj.GetComponent<Animator>();
				if(anim!=null) unitCreep.SetAnimationComponent(this);
				
				AnimatorOverrideController overrideController = new AnimatorOverrideController();
				overrideController.runtimeAnimatorController = anim.runtimeAnimatorController;
				
				//overrideController["Assigned Animation Clip Name In The Controller"] = New Clip To Be Assigned;
				//overrideController["DummySpawn"] = clipSpawn!=null ? clipSpawn : null;
				overrideController["DummyMove"] = clipMove!=null ? clipMove : null;
				overrideController["DummyDestination"] = clipDestination!=null ? clipDestination : null;
				overrideController["DummyDestroyed"] = clipDead!=null ? clipDead : null;
				
				//if no spawn animation has been assigned, use move animation instead otherwise there will be an delay, bug maybe?
				AnimationClip spawn = clipSpawn!=null ? clipSpawn : clipMove;
				overrideController["DummySpawn"] = spawn!=null ? spawn : null;
				
				anim.runtimeAnimatorController = overrideController;
			}
		}
Ejemplo n.º 4
0
        public int GetUnitNearestNodeID(UnitCreep unit)
        {
            NodeTD n1 = platform.GetNearestNode(unit.GetTargetPos(), 1);                //get walkable only
            NodeTD n2 = platform.GetNearestNode(unit.GetLastTargetPos(), 1);

            return((Vector3.Distance(unit.GetPos(), n1.pos) > Vector3.Distance(unit.GetPos(), n2.pos)) ? n2.ID : n1.ID);
        }
Ejemplo n.º 5
0
        public static int AddNewCreep(UnitCreep newCreep)
        {
            if (creepList.Contains(newCreep))
            {
                return(-1);
            }

            int ID = GenerateNewID(creepIDList);

            newCreep.prefabID = ID;
            creepIDList.Add(ID);
            creepList.Add(newCreep);

            UpdateCreepNameList();

            if (newCreep.stats.Count == 0)
            {
                newCreep.stats.Add(new UnitStat());
            }

            while (newCreep.valueRscMin.Count < rscList.Count)
            {
                newCreep.valueRscMin.Add(0);
            }
            while (newCreep.valueRscMax.Count < rscList.Count)
            {
                newCreep.valueRscMax.Add(0);
            }

            SetDirtyCreep();

            return(creepList.Count - 1);
        }
Ejemplo n.º 6
0
 public static event CreepDestroyedHandler onCreepDestroyedE;                    //indicate the creep has been destroyed
 public static void OnUnitCreepDestroyed(UnitCreep unit)
 {
     if (onCreepDestroyedE != null)
     {
         onCreepDestroyedE(unit);
     }
 }
Ejemplo n.º 7
0
 //void OnUnitDestroyed(Unit unit){ if(newWaveSound!=null) _PlaySound(newWaveSound); }
 void OnCreepDestination(UnitCreep creep)
 {
     if (newWaveSound != null)
     {
         _PlaySound(newWaveSound);
     }
 }
Ejemplo n.º 8
0
 public static void OnCreepReachDestination(UnitCreep creep)
 {
     if (!creep.IsDestroyed())
     {
         instance.OnUnitCleared(creep);
     }
 }
Ejemplo n.º 9
0
 void OnCreepDestination(UnitCreep creep)
 {
     if (creepReachDestinationSound != null)
     {
         _PlaySound(creepReachDestinationSound);
     }
 }
Ejemplo n.º 10
0
 public static void OnCreepDestination(UnitCreep creep)
 {
     if (onCreepDestinationE != null)
     {
         onCreepDestinationE(creep);
     }
 }
Ejemplo n.º 11
0
        public float CreepDestroyed()
        {
            List <int> rscGain = new List <int>();

            for (int i = 0; i < valueRscMin.Count; i++)
            {
                rscGain.Add(Random.Range(valueRscMin[i], valueRscMax[i]));
            }
            ResourceManager.GainResource(rscGain, PerkManager.GetRscCreepKilled());

            AbilityManager.GainEnergy(valueEnergyGain + (int)PerkManager.GetEnergyWaveClearedModifier());

            if (spawnUponDestroyed != null && spawnUponDestroyedCount > 0)
            {
                for (int i = 0; i < spawnUponDestroyedCount; i++)
                {
                    Vector3    posOffset = new Vector3(Random.Range(-0.5f, 0.5f), 0, Random.Range(-0.5f, 0.5f));
                    GameObject obj       = ObjectPoolManager.Spawn(spawnUponDestroyed, thisT.position + posOffset, thisT.rotation);
                    UnitCreep  unit      = obj.GetComponent <UnitCreep>();

                    unit.waveID = waveID;
                    int ID = SpawnManager.AddDestroyedSpawn(unit);
                    unit.Init(path, ID, waveID, this);
                }
            }

            if (aniInstance != null)
            {
                return(aniInstance.PlayDead());
            }

            return(0);
        }
Ejemplo n.º 12
0
        void SpawnSubCreep(UnitCreep prefab, float orHP = -1, float orSH = -1, float orSpd = -1, int orRscExp = -1, List <int> orRsc = null)
        {
            Vector3 dir      = (subPath[subWpIdx] - GetPos()).normalized;
            Vector3 spawnPos = GetPos() + dir * Random.Range(-.5f, .5f);

            //~ GameObject unitObj=(GameObject)Instantiate(prefab.gameObject, spawnPos, thisT.rotation);
            GameObject unitObj      = ObjectPoolManager.Spawn(prefab.gameObject, spawnPos, thisT.rotation);
            UnitCreep  unitInstance = unitObj.GetComponent <UnitCreep>();

            unitInstance.SetHP(orHP);
            unitInstance.SetSH(orSH);
            unitInstance.SetSpeed(orSpd);
            if (orRsc != null)
            {
                unitInstance.rscGainOnDestroyed = orRsc;
            }

            //~ if(orHP>0) unitInstance.SetHP(orHP);
            //~ if(orSH>0) unitInstance.SetSH(orSH);
            //~ if(orSpd>0) unitInstance.SetSpeed(orSpd);
            //~ if(orRsc!=null) unitInstance.rscGainOnDestroyed=orRsc;

            unitInstance.Init(waveIdx, path, wpIdx, subWpIdx, false, reverse, new List <Path>(prevPathList), subPath);

            SpawnManager.SubUnitSpawned(unitInstance);
            //SpawnManager.SubUnitSpawned(unitInstance, waveIdx);
        }
Ejemplo n.º 13
0
        protected float DrawShootEffectObject(float startX, float startY, UnitStat stat, Unit unit, bool isTower = true)
        {
            bool showShootObj = false;

            if (isTower)
            {
                UnitTower tower = isTower ? unit.gameObject.GetComponent <UnitTower>() : null;
                if (tower.type == _TowerType.Turret)
                {
                    showShootObj = true;
                }
            }
            else
            {
                UnitCreep creep = !isTower?unit.gameObject.GetComponent <UnitCreep>() : null;

                if (creep.type == _CreepType.Offense)
                {
                    showShootObj = true;
                }
            }

            if (showShootObj)
            {
                cont = new GUIContent("ShootObject:", "The shoot-object used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.shootObject = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, 3 * widthS + 15, height), stat.shootObject, typeof(ShootObject), false);
            }
            else
            {
                cont = new GUIContent("EffectObject:", "The effect-object used by the unit.\nSpawned on shoot-point at every cooldown");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.effectObject = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, 3 * widthS + 15, height), stat.effectObject, typeof(GameObject), false);

                cont = new GUIContent(" - AutoDestroy:", "Check if the effect object needs to be removed from the game");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (stat.effectObject != null)
                {
                    stat.autoDestroyEffect = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), stat.autoDestroyEffect);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", ""));
                }

                cont = new GUIContent(" - EffectDuration:", "The delay in seconds before the effect object is destroyed");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (stat.effectObject != null && stat.autoDestroyEffect)
                {
                    stat.effectDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), stat.effectDuration);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", ""));
                }
            }

            return(startY + 5);
        }
Ejemplo n.º 14
0
 public static int GetPrefabIndex(UnitCreep creep)
 {
     if (creep == null)
     {
         return(-1);
     }
     return(GetPrefabIndex(creep.prefabID));
 }
Ejemplo n.º 15
0
        void ShiftItem(int dir)
        {
            UnitCreep creep = creepDB.creepList[selectID];

            creepDB.creepList[selectID]       = creepDB.creepList[selectID + dir];
            creepDB.creepList[selectID + dir] = creep;
            selectID += dir;
        }
Ejemplo n.º 16
0
 public List <int> GetRsc(UnitCreep unit, List <int> overrideList = null)
 {
     if (mulRsc >= 0)
     {
         overrideList = RscManager.ApplyMultiplier(new List <int>(unit.rscGainOnDestroyed), mulRsc);
     }
     return(overrideList);
 }
Ejemplo n.º 17
0
 void Awake()
 {
     unit = gameObject.GetComponent <UnitCreep>();
     if (spriteRenderer == null)
     {
         spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
     }
 }
Ejemplo n.º 18
0
        private void ShiftItem(int dir)
        {
            UnitCreep creep = CreepDB.GetList()[selectID];

            CreepDB.GetList()[selectID]       = CreepDB.GetList()[selectID + dir];
            CreepDB.GetList()[selectID + dir] = creep;
            selectID += dir;
        }
Ejemplo n.º 19
0
        public int _AddDestroyedSpawn(UnitCreep unit)
        {
            activeUnitCount += 1;

            waveList[unit.waveID].activeUnitCount += 1;

            return(totalSpawnCount += 1);
        }
Ejemplo n.º 20
0
 void OnUnitReachDestination(UnitCreep creep)
 {
     //only execute if creep is dead
     //when using path-looping the creep would be still active and wouldnt set it's dead flag to true
     if (creep.dead)
     {
         OnUnitCleared(creep);
     }
 }
Ejemplo n.º 21
0
 private static void RefreshCreep_Remove(UnitCreep creep)
 {
     for (int i = 0; i < creepList.Count; i++)
     {
         if (creepList[i].spawnUponDestroyed == creep.gameObject)
         {
             creepList[i].spawnUponDestroyed = null;
         }
     }
 }
Ejemplo n.º 22
0
        public static void RemoveCreep(int listID)
        {
            UnitCreep removedCreep = creepList[listID];

            creepIDList.Remove(creepList[listID].prefabID);
            creepList.RemoveAt(listID);
            UpdateCreepNameList();
            SetDirtyCreep();
            RefreshCreep_Remove(removedCreep);
        }
Ejemplo n.º 23
0
        public void _CreepDestroyed(UnitCreep creep, bool reachDest = false)
        {
            RemoveActiveUnit(creep);

            int waveIdx = GetListIndexFromWaveIndex(creep.waveIdx);

            if (reachDest)
            {
                waveList[waveIdx].clean = false;
            }

            waveList[waveIdx].activeUnitCount -= 1;
            if (waveList[waveIdx].CheckClear())                 //wave cleared
            {
                if (waveList[waveIdx].IsCleared())
                {
                    Debug.LogWarning("Error? Wave already cleared?");
                    return;
                }
                else
                {
                    AudioManager.OnWaveCleared();
                    waveList[waveIdx].Cleared();                        //cleared=true;
                    Debug.Log("Wave-" + creep.waveIdx + " cleared");
                }

                if (IsEndlessMode() || !OnFinalWave())
                {
                    if (spawnCDType == _SpawnCDType.None)
                    {
                        ReadyToSpawn();
                    }
                    if (spawnCDType == _SpawnCDType.Cleared)
                    {
                        if (skippable)
                        {
                            ReadyToSpawn();
                        }
                        StartSpawnCountDown(waveList[waveIdx].timeToNextWave);
                    }
                }
                else
                {
                    bool allCleared = true;
                    for (int i = 0; i < waveList.Count; i++)
                    {
                        allCleared &= waveList[i].cleared;
                    }
                    if (allCleared)
                    {
                        GameControl.EndGame();
                    }
                }
            }
        }
Ejemplo n.º 24
0
        void OnUnitDestroyed(Unit unit)
        {
            if (!unit.IsCreep())
            {
                return;
            }

            UnitCreep creep = unit.GetUnitCreep();

            OnUnitCleared(creep);
        }
Ejemplo n.º 25
0
        public void _OnCreepReachDestination(UnitCreep unit)
        {
            playerLife = Mathf.Max(0, playerLife - unit.lifeCost);

            TDTK.OnLife(-unit.lifeCost);

            if (playerLife <= 0)
            {
                GameOver();
            }
        }
Ejemplo n.º 26
0
        private static void RefreshRsc()
        {
            for (int i = 0; i < towerList.Count; i++)
            {
                UnitTower tower = towerList[i];
                for (int n = 0; n < tower.stats.Count; n++)
                {
                    UnitStat stat = tower.stats[n];

                    while (stat.cost.Count < rscList.Count)
                    {
                        stat.cost.Add(0);
                    }
                    while (stat.cost.Count > rscList.Count)
                    {
                        stat.cost.RemoveAt(stat.cost.Count - 1);
                    }

                    while (stat.rscGain.Count < rscList.Count)
                    {
                        stat.rscGain.Add(0);
                    }
                    while (stat.rscGain.Count > rscList.Count)
                    {
                        stat.rscGain.RemoveAt(stat.rscGain.Count - 1);
                    }
                }
            }

            for (int i = 0; i < creepList.Count; i++)
            {
                UnitCreep creep = creepList[i];

                while (creep.valueRscMin.Count < rscList.Count)
                {
                    creep.valueRscMin.Add(0);
                }
                while (creep.valueRscMin.Count > rscList.Count)
                {
                    creep.valueRscMin.RemoveAt(creep.valueRscMin.Count - 1);
                }

                while (creep.valueRscMax.Count < rscList.Count)
                {
                    creep.valueRscMax.Add(0);
                }
                while (creep.valueRscMax.Count > rscList.Count)
                {
                    creep.valueRscMax.RemoveAt(creep.valueRscMax.Count - 1);
                }
            }
        }
Ejemplo n.º 27
0
 //Call by inherited class UnitCreep, caching inherited UnitCreep instance to this instance
 public void SetSubClass(UnitCreep unit)
 {
     unitC    = unit;
     subClass = _UnitSubClass.Creep;
     if (!unitC.flying)
     {
         gameObject.layer = LayerManager.LayerCreep();
     }
     else
     {
         gameObject.layer = LayerManager.LayerCreepF();
     }
 }
Ejemplo n.º 28
0
        public static void SubUnitSpawned(UnitCreep creep)         //, int waveIdx){
        {
            AddActiveUnit(creep);
            instance.totalCreepCount += 1;    creep.instanceID = instance.totalCreepCount;

            int waveIdx = instance.GetListIndexFromWaveIndex(creep.waveIdx);

            instance.waveList[waveIdx].activeUnitCount += 1;
            if (instance.waveList[waveIdx].cleared)
            {
                Debug.LogWarning("Spawning subwave for cleared wave?");
            }
        }
Ejemplo n.º 29
0
        private int _NewItem(UnitCreep creep)
        {
            if (CreepDB.GetList().Contains(creep))
            {
                return(selectID);
            }

            creep.prefabID = TDE.GenerateNewID(CreepDB.GetPrefabIDList());

            CreepDB.GetList().Add(creep);
            CreepDB.UpdateLabel();

            return(CreepDB.GetList().Count - 1);
        }
Ejemplo n.º 30
0
        int _NewItem(UnitCreep creep)
        {
            if (creepDB.creepList.Contains(creep))
            {
                return(selectID);
            }

            creep.prefabID = GenerateNewID(creepIDList);
            creepIDList.Add(creep.prefabID);

            creepDB.creepList.Add(creep);

            UpdateLabel_Creep();

            return(creepDB.creepList.Count - 1);
        }
Ejemplo n.º 31
0
        private static void RefreshRsc()
        {
            for (int i = 0; i < towerList.Count; i++)
            {
                UnitTower tower = towerList[i];
                for (int n = 0; n < tower.stats.Count; n++)
                {
                    UnitStat stat = tower.stats[n];
                }
            }

            for (int i = 0; i < creepList.Count; i++)
            {
                UnitCreep creep = creepList[i];
            }
        }
Ejemplo n.º 32
0
		//parent unit is for unit which is spawned from destroyed unit
		public void Init(PathTD p, int ID, int wID, UnitCreep parentUnit=null){
			Init();
			
			path=p;
			instanceID=ID;
			waveID=wID;
			
			float dynamicX=Random.Range(-path.dynamicOffset, path.dynamicOffset);
			float dynamicZ=Random.Range(-path.dynamicOffset, path.dynamicOffset);
			pathDynamicOffset=new Vector3(dynamicX, 0, dynamicZ);
			thisT.position+=pathDynamicOffset;
			
			if(parentUnit==null){
				waypointID=1;
				subWaypointID=0;
				subPath=path.GetWPSectionPath(waypointID);
			}
			else{
				//inherit stats and path from parent unit
				waypointID=parentUnit.waypointID;
				subWaypointID=parentUnit.subWaypointID;
				subPath=parentUnit.subPath;
				
				fullHP=parentUnit.fullHP*parentUnit.spawnUnitHPMultiplier;
				fullShield=parentUnit.fullShield*parentUnit.spawnUnitHPMultiplier;
				HP=fullHP; shield=fullShield;
			}
			
			distFromDestination=CalculateDistFromDestination();
			
			if(type==_CreepType.Offense){
				StartCoroutine(ScanForTargetRoutine());
				StartCoroutine(TurretRoutine());
			}
			if(type==_CreepType.Support){
				StartCoroutine(SupportRoutine());
			}
		}
Ejemplo n.º 33
0
        void OnUnitReachDestination(UnitCreep unit)
        {
            playerLife=Mathf.Max(0, playerLife-unit.lifeCost);

            if(onLifeE!=null) onLifeE(-unit.lifeCost);

            if(playerLife<=0){
                gameState=_GameState.Over;
                if(onGameOverE!=null) onGameOverE(playerWon);
            }
        }
Ejemplo n.º 34
0
        void OnUnitCleared(UnitCreep creep)
        {
            int waveID=creep.waveID;

            activeUnitCount-=1;

            Wave wave=null;
            if(spawnLimit==_SpawnLimit.Finite) wave=waveList[waveID];
            else if(spawnLimit==_SpawnLimit.Infinite){
                for(int i=0; i<waveList.Count; i++){
                    if(waveList[i].waveID==waveID){
                        wave=waveList[i];
                        break;
                    }
                }

                if(wave==null){
                    Debug.Log("error!");
                    return;
                }
            }

            wave.activeUnitCount-=1;
            if(wave.spawned && wave.activeUnitCount==0){
                wave.cleared=true;
                waveClearedCount+=1;
                //Debug.Log("wave"+(waveID+1)+ " is cleared");

                ResourceManager.GainResource(wave.rscGainList, PerkManager.GetRscWaveKilled());
                GameControl.GainLife(wave.lifeGain+PerkManager.GetLifeWaveClearedModifier());
                AbilityManager.GainEnergy(wave.energyGain+(int)PerkManager.GetEnergyWaveClearedModifier());

                if(spawnLimit==_SpawnLimit.Infinite) waveList.Remove(wave);

                if(IsAllWaveCleared()){
                    GameControl.GameWon();
                }
                else{
                    if(spawnMode==_SpawnMode.Round && onEnableSpawnE!=null) onEnableSpawnE();
                }
            }

            if(!IsAllWaveCleared() && activeUnitCount==0 && !spawning){
                if(spawnMode==_SpawnMode.WaveCleared) SpawnWaveFinite();
            }
        }
Ejemplo n.º 35
0
        public int _AddDestroyedSpawn(UnitCreep unit)
        {
            activeUnitCount+=1;

            if(spawnLimit==_SpawnLimit.Finite) waveList[unit.waveID].activeUnitCount+=1;
            else if(spawnLimit==_SpawnLimit.Infinite){
                for(int i=0; i<waveList.Count; i++){
                    if(waveList[i].waveID==unit.waveID){
                        waveList[i].activeUnitCount+=1;
                        break;
                    }
                }
            }

            return totalSpawnCount+=1;
        }
		private static void RefreshCreep_Remove(UnitCreep creep){
			
		}
Ejemplo n.º 37
0
		public static Vector3 DrawStat(UnitStat stat, float startX, float startY, float statContentHeight, UnitTower tower, UnitCreep creep){
			
			List<Rsc> rscList=EditorDBManager.GetRscList();
			
			float width=150;
			float fWidth=35;
			float spaceX=130;
			float height=18;
			float spaceY=height+2;
			
			//startY-=spaceY;
			
			GUI.Box(new Rect(startX, startY, 220, statContentHeight-startY), "");
			
			startX+=10;	startY+=10;
			
			if(tower!=null){
				
				cont=new GUIContent("Construct Duration:", "The time in second it takes to construct (if this is the first level)/upgrade (if this is not the first level)");
				EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
				stat.buildDuration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buildDuration);
				
				cont=new GUIContent("Deconstruct Duration:", "The time in second it takes to deconstruct if the unit is in this level");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.unBuildDuration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.unBuildDuration);
			
				
				if(stat.cost.Count!=rscList.Count){
					while(stat.cost.Count>rscList.Count) stat.cost.RemoveAt(stat.cost.Count-1);
					while(stat.cost.Count<rscList.Count) stat.cost.Add(0);
				}
				cont=new GUIContent("Build/Upgrade Cost:", "The resource required to build/upgrade to this level");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				int count=0;	startY+=spaceY; 	float cachedX=startX;
				for(int i=0; i<rscList.Count; i++){
					EditorUtilities.DrawSprite(new Rect(startX+10, startY-1, 20, 20), rscList[i].icon);
					stat.cost[i]=EditorGUI.IntField(new Rect(startX+30, startY, fWidth, height), stat.cost[i]);
					count+=1; 	startX+=65;
					if(count==3){ startY+=spaceY; startX=cachedX; }
				}
				startX=cachedX;	startY+=5;
				
				startY+=spaceY+5;
			}
			
			
			
			if((tower && TowerUseShootObject(tower)) || (creep && creep.type==_CreepType.Offense)){
				cont=new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
				EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
				stat.shootObject=(ShootObject)EditorGUI.ObjectField(new Rect(startX+spaceX-50, startY, 4*fWidth-20, height), stat.shootObject, typeof(ShootObject), false);
				startY+=5;
			}
			
			if(tower && TowerUseShootObjectT(tower)){
				cont=new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
				EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
				stat.shootObjectT=(Transform)EditorGUI.ObjectField(new Rect(startX+spaceX-50, startY, 4*fWidth-20, height), stat.shootObjectT, typeof(Transform), false);
				startY+=5;
			}
				
			if((tower &&  TowerDealDamage(tower)) || (creep && creep.type==_CreepType.Offense)){
				cont=new GUIContent("Damage(Min/Max):", "");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.damageMin=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.damageMin);
				stat.damageMax=EditorGUI.FloatField(new Rect(startX+spaceX+fWidth, startY, fWidth, height), stat.damageMax);
				
				cont=new GUIContent("Cooldown:", "Duration between each attack");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.cooldown=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.cooldown);
				
				
				cont=new GUIContent("Range:", "Effect range of the unit");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.range=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.range);
				
				//~ cont=new GUIContent("Range(Min/Max):", "");
				//~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				//~ stat.minRange=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.minRange);
				//~ stat.range=EditorGUI.FloatField(new Rect(startX+spaceX+fWidth, startY, fWidth, height), stat.range);
				
				cont=new GUIContent("AOE Radius:", "Area-of-Effective radius. When the shootObject hits it's target, any other hostile unit within the area from the impact position will suffer the same target as the target.\nSet value to >0 to enable. ");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.aoeRadius=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.aoeRadius);
				
				
				
				cont=new GUIContent("Hit Chance:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's dodgeChance. Assume two targets with 0 dodgeChance and .2 dodgeChance and the hitChance set to 1, the unit will always hits the target and have 20% chance to miss the second target.");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.hit=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.hit);
				
				if(!creep){	
					cont=new GUIContent("Dodge Chance:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's hitChance. Assume two attackers with 1 hitChance and .8 hitChance and the dodgeChance set to .2, the chances to dodge attack from each attacker are 20% and 40% respectively.");
					EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
					stat.dodge=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.dodge);
				}
				
				
				cont=new GUIContent("Stun", "");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
				
				cont=new GUIContent("        - Chance:", "Chance to stun the target in each successful attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.stun.chance=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.stun.chance);
				
				cont=new GUIContent("        - Duration:", "The stun duration in second");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.stun.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.stun.duration);
				
				
				
				cont=new GUIContent("Critical", "");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
				
				cont=new GUIContent("            - Chance:", "Chance to score critical hit in attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.crit.chance=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.crit.chance);
				
				cont=new GUIContent("            - Multiplier:", "Damage multiplier for successful critical hit. Takes value from 0 and above with with 0.5 being 50% of normal damage as bonus");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.crit.dmgMultiplier=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.crit.dmgMultiplier);
				
				
				
				cont=new GUIContent("Slow", "");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
				
				cont=new GUIContent("         - Duration:", "The effect duration in second");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.slow.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.slow.duration);
				
				cont=new GUIContent("         - Multiplier:", "Move speed multiplier. Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.slow.slowMultiplier=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.slow.slowMultiplier);
				
				
				
				cont=new GUIContent("Dot", "Damage over time");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
				
				cont=new GUIContent("        - Duration:", "The effect duration in second");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.dot.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.dot.duration);
				
				cont=new GUIContent("        - Interval:", "Duration between each tick. Damage is applied at each tick.");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.dot.interval=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.dot.interval);
				
				cont=new GUIContent("        - Damage:", "Damage applied at each tick");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.dot.value=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.dot.value);
				
				
				
				cont=new GUIContent("InstantKill", "");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
				
				cont=new GUIContent("                - Chance:", "The chance to instant kill the target. Takes value from 0-1 with 0 being 0% and 1 being 100%");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.instantKill.chance=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.instantKill.chance);
				
				cont=new GUIContent("        - HP Threshold:", "The HP threshold of the target in order for the instantKill to become valid. Take value from 0-1 with 0.3 being 30% of the fullHP.");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.instantKill.HPThreshold=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.instantKill.HPThreshold);
				
				
				cont=new GUIContent("Damage Shield Only:", "When checked, unit will only inflict shield damage");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.damageShieldOnly=EditorGUI.Toggle(new Rect(startX+spaceX, startY, fWidth, height), stat.damageShieldOnly);
				
				cont=new GUIContent("Shield Break:", "The chance of the unit's attack to damage target's shield and disable shield regen permenantly\nTakes value from 0-1 with 0 being 0% and 1 being 100%");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.shieldBreak=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.shieldBreak);
				
				cont=new GUIContent("Shield Pierce:", "The chance of the unit's attack to bypass target's shield and damage HP directly\nTakes value from 0-1 with 0 being 0% and 1 being 100%");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.shieldPierce=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.shieldPierce);
			}
			
			
			
			if((tower && tower.type==_TowerType.Support) || (creep && creep.type==_CreepType.Support)){
				cont=new GUIContent("Range:", "Effect range of the unit");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.range=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.range);
				startY+=5;
				
				cont=new GUIContent("Buff:", "Note: Buffs from multple tower doesnt stack, however when there's difference in the buff strength, the stronger buff applies. A tower can gain maximum dmage buff from one source and maximum range buff from another");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
				
				cont=new GUIContent("        - Damage:", "Damage buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in damage");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.buff.damageBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.damageBuff);
				
				cont=new GUIContent("        - Cooldown:", "Dooldown buff multiplier. Takes value from 0-1 with 0.2 being reduce cooldown by 20%");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.buff.cooldownBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.cooldownBuff);
				
				cont=new GUIContent("        - Range:", "Range buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in range");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.buff.rangeBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.rangeBuff);
				
				cont=new GUIContent("        - Critical:", "Critical hit chance buff modifier. Takes value from 0 and above with 0.25 being 25% increase in critical hit chance");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.buff.criticalBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.criticalBuff);
				
				cont=new GUIContent("        - Hit:", "Hit chance buff modifier. Takes value from 0 and above with .2 being 20% increase in hit chance");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.buff.hitBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.hitBuff);
				
				cont=new GUIContent("        - Dodge:", "Dodge chance buff modifier. Takes value from 0 and above with 0.15 being 15% increase in dodge chance");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.buff.dodgeBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.dodgeBuff);
				
				cont=new GUIContent("        - HP Regen:", "HP Regeneration Buff. Takes value from 0 and above with 2 being gain 2HP second ");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.buff.regenHP=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.regenHP);
			}
			
			
			if(tower && tower.type==_TowerType.Resource){
				if(stat.rscGain.Count!=rscList.Count){
					while(stat.rscGain.Count>rscList.Count) stat.rscGain.RemoveAt(stat.rscGain.Count-1);
					while(stat.rscGain.Count<rscList.Count) stat.rscGain.Add(0);
				}
				cont=new GUIContent("Resource Gain:", "The resource gain by unit at each cooldown interval\nOnly applicable to ResourceTower");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				int count=0;	startY+=spaceY; 	float cachedX=startX;
				for(int i=0; i<rscList.Count; i++){
					EditorUtilities.DrawSprite(new Rect(startX+10, startY-1, 20, 20), rscList[i].icon);
					stat.rscGain[i]=EditorGUI.IntField(new Rect(startX+30, startY, fWidth, height), stat.rscGain[i]);
					count+=1; 	startX+=65;
					if(count==3){ startY+=spaceY; startX=cachedX; }
				}
				startX=cachedX;	startY+=5;
			}
			
			
			if(tower){
				startY+=10;
				cont=new GUIContent("Custom Description:", "Check to use use custom description. If not, the default one (generated based on the effect) will be used");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				stat.useCustomDesp=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), stat.useCustomDesp);
				if(stat.useCustomDesp){
					GUIStyle style=new GUIStyle("TextArea");
					style.wordWrap=true;
					stat.desp=EditorGUI.TextArea(new Rect(startX, startY+spaceY-3, 200, 90), stat.desp, style);
					startY+=90;
				}
			}
			
			
			
			
			statContentHeight=startY+spaceY+5;
			
			return new Vector3(startX+220, startY, statContentHeight);
		}
		//void OnUnitDestroyed(Unit unit){ if(newWaveSound!=null) _PlaySound(newWaveSound); }
		void OnCreepDestination(UnitCreep creep){ if(newWaveSound!=null) _PlaySound(newWaveSound); }
Ejemplo n.º 39
0
 void OnUnitReachDestination(UnitCreep creep)
 {
     //only execute if creep is dead
     //when using path-looping the creep would be still active and wouldnt set it's dead flag to true
     if(creep.dead) OnUnitCleared(creep);
 }
Ejemplo n.º 40
0
		private static void RefreshCreep_Remove(UnitCreep creep){
			for(int i=0; i<creepList.Count; i++){
				if(creepList[i].spawnUponDestroyed==creep.gameObject){
					creepList[i].spawnUponDestroyed=null;
				}
			}
		}
Ejemplo n.º 41
0
 internal void SetTarget(UnitCreep unitCreep)
 {
     assignedTarget = unitCreep;
 }
Ejemplo n.º 42
0
		public static Vector3 DrawStat(UnitStat stat, float startX, float startY, float statContentHeight,  UnitCreep creep){
			return DrawStat(stat, startX, startY, statContentHeight, null, creep);
		}
Ejemplo n.º 43
0
        public static Vector3 DrawUnitOffensiveSetting(UnitTower tower, UnitCreep creep, float startX, float startY, List<GameObject> objHList, string[] objHLabelList)
        {
            float cachedX=startX;
            //float cachedY=startY;

            Unit unit=null;
            if(tower!=null) unit=tower;
            if(creep!=null) unit=creep;

            if(tower && TowerUseShootObject(tower)){
                cont=new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
                shootPointFoldout=EditorGUI.Foldout(new Rect(startX, startY+=spaceY, spaceX, height), shootPointFoldout, cont);
                int shootPointCount=unit.shootPoints.Count;
                shootPointCount=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), shootPointCount);

                //if(!EditorGUIUtility.editingTextField && shootPointCount!=unit.shootPoints.Count){
                if(shootPointCount!=unit.shootPoints.Count){
                    while(unit.shootPoints.Count<shootPointCount) unit.shootPoints.Add(null);
                    while(unit.shootPoints.Count>shootPointCount) unit.shootPoints.RemoveAt(unit.shootPoints.Count-1);
                }

                if(shootPointFoldout){
                    for(int i=0; i<unit.shootPoints.Count; i++){
                        //GetObjectID(unit.shootPoints[i]);
                        int objID=GetObjectIDFromHList(unit.shootPoints[i], objHList);
                        EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), "    - Element "+(i+1));
                        objID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), objID, objHLabelList);
                        unit.shootPoints[i] = (objHList[objID]==null) ? null : objHList[objID].transform;
                    }
                }

                if(unit.shootPoints.Count>1){
                    cont=new GUIContent("Shots delay Between ShootPoint:", "Delay in second between shot fired at each shootPoint. When set to zero all shootPoint fire simulteneously");
                    EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width+60, height), cont);
                    unit.delayBetweenShootPoint=EditorGUI.FloatField(new Rect(startX+spaceX+90, startY-1, 55, height-1), unit.delayBetweenShootPoint);
                }
            }

            if(tower && TowerUseTurret(tower)){
                //GetObjectID(unit.turretObject);
                int objID=GetObjectIDFromHList(unit.turretObject, objHList);
                cont=new GUIContent("TurretObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). When left unassigned, no aiming will be done.");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                objID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), objID, objHLabelList);
                unit.turretObject = (objHList[objID]==null) ? null : objHList[objID].transform;

                //GetObjectID(unit.barrelObject);
                objID=GetObjectIDFromHList(unit.barrelObject, objHList);
                cont=new GUIContent("BarrelObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). This is only required if the unit barrel and turret rotates independently on different axis");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                objID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), objID, objHLabelList);
                unit.barrelObject = (objHList[objID]==null) ? null : objHList[objID].transform;

                cont=new GUIContent("Aim Rotate In x-axis:", "Check if the unit turret/barrel can rotate in x-axis (elevation)");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                unit.rotateTurretAimInXAxis=EditorGUI.Toggle(new Rect(startX+spaceX+20, startY, 40, height), unit.rotateTurretAimInXAxis);
            }

            //~ GUI.Box(new Rect(cachedX, cachedY, spaceX+width, startY-cachedY+spaceY), "");

            return new Vector3(cachedX, startY, spaceX+width);
        }
Ejemplo n.º 44
0
 //Call by inherited class UnitCreep, caching inherited UnitCreep instance to this instance
 public void SetSubClass(UnitCreep unit)
 {
     unitC=unit;
     subClass=_UnitSubClass.Creep;
     if(!unitC.flying) gameObject.layer=LayerManager.LayerCreep();
     else gameObject.layer=LayerManager.LayerCreepF();
 }
Ejemplo n.º 45
0
        public int _AddDestroyedSpawn(UnitCreep unit)
        {
            activeUnitCount+=1;

            waveList[unit.waveID].activeUnitCount+=1;

            return totalSpawnCount+=1;
        }
		public static int AddNewCreep(UnitCreep newCreep){
			if(creepList.Contains(newCreep)) return -1;
			
			int ID=GenerateNewID(creepIDList);
			newCreep.prefabID=ID;
			creepIDList.Add(ID);
			creepList.Add(newCreep);
			
			UpdateCreepNameList();
			
			if(newCreep.stats.Count==0) newCreep.stats.Add(new UnitStat());
			
			while(newCreep.valueRscMin.Count<rscList.Count) newCreep.valueRscMin.Add(0);
			while(newCreep.valueRscMax.Count<rscList.Count) newCreep.valueRscMax.Add(0);
			
			SetDirtyCreep();
			
			return creepList.Count-1;
		}
Ejemplo n.º 47
0
        void OnUnitCleared(UnitCreep creep)
        {
            int waveID=creep.waveID;

            activeUnitCount-=1;

            Wave wave=waveList[waveID];

            wave.activeUnitCount-=1;
            if(wave.spawned && wave.activeUnitCount==0){
                wave.cleared=true;
                waveClearedCount+=1;
                Debug.Log("wave"+(waveID+1)+ " is cleared");

                ResourceManager.GainResource(wave.rscGainList);
                GameControl.GainLife(wave.lifeGain);

                if(IsAllWaveCleared()){
                    GameControl.GameWon();
                }
                else{
                    if(spawnMode==_SpawnMode.Round && onEnableSpawnE!=null) onEnableSpawnE();
                }
            }

            if(!IsAllWaveCleared() && activeUnitCount==0 && !spawning){
                if(spawnMode==_SpawnMode.WaveCleared) SpawnWaveFinite();
            }
        }
Ejemplo n.º 48
0
        void OnUnitReachDestination(UnitCreep unit)
        {
            playerLife=Mathf.Max(0, playerLife-unit.lifeCost);

            if(onLifeE!=null) onLifeE(-unit.lifeCost);

            if(playerLife<=0){
                if (gameState != _GameState.Over) {
                    gameState = _GameState.Over;
                    StopGame(false);
                }
            }
        }
Ejemplo n.º 49
0
 public static int AddDestroyedSpawn(UnitCreep unit)
 {
     return instance._AddDestroyedSpawn(unit);
 }
Ejemplo n.º 50
0
 public static void OnCreepDestination(UnitCreep creep)
 {
     if (onCreepDestinationE != null) onCreepDestinationE(creep);
 }
Ejemplo n.º 51
0
		public static Vector3 DrawUnitOffensiveSetting(UnitCreep unit, float startX, float startY, List<GameObject> objHList, string[] objHLabelList){
			return DrawUnitOffensiveSetting(null, unit, startX, startY, objHList, objHLabelList);
		}
Ejemplo n.º 52
0
        public static Vector3 DrawStat(UnitStat stat, float startX, float startY, float statContentHeight, UnitTower tower, UnitCreep creep)
        {
            List<Rsc> rscList=EditorDBManager.GetRscList();

            float width=150;
            float fWidth=35;
            float spaceX=130;
            float height=18;
            float spaceY=height+2;

            //startY-=spaceY;

            GUI.Box(new Rect(startX, startY, 220, statContentHeight-startY), "");

            startX+=10;	startY+=10;

            if(tower!=null){

                cont=new GUIContent("Construct Duration:", "The time in second it takes to construct (if this is the first level)/upgrade (if this is not the first level)");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.buildDuration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buildDuration);

                cont=new GUIContent("Deconstruct Duration:", "The time in second it takes to deconstruct if the unit is in this level");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.unBuildDuration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.unBuildDuration);

                if(stat.cost.Count!=rscList.Count){
                    while(stat.cost.Count>rscList.Count) stat.cost.RemoveAt(stat.cost.Count-1);
                    while(stat.cost.Count<rscList.Count) stat.cost.Add(0);
                }
                cont=new GUIContent("Build/Upgrade Cost:", "The resource required to build/upgrade to this level");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                int count=0;	startY+=spaceY; 	float cachedX=startX;
                for(int i=0; i<rscList.Count; i++){
                    EditorUtilities.DrawSprite(new Rect(startX+10, startY-1, 20, 20), rscList[i].icon);
                    stat.cost[i]=EditorGUI.IntField(new Rect(startX+30, startY, fWidth, height), stat.cost[i]);
                    count+=1; 	startX+=65;
                    if(count==3){ startY+=spaceY; startX=cachedX; }
                }
                startX=cachedX;	startY+=5;

                startY+=spaceY+5;
            }

            if((tower && TowerUseShootObject(tower))){
                cont=new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.shootObject=(ShootObject)EditorGUI.ObjectField(new Rect(startX+spaceX-50, startY, 4*fWidth-20, height), stat.shootObject, typeof(ShootObject), false);
                startY+=5;
            }

            if(tower && TowerUseShootObjectT(tower)){
                cont=new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.shootObjectT=(Transform)EditorGUI.ObjectField(new Rect(startX+spaceX-50, startY, 4*fWidth-20, height), stat.shootObjectT, typeof(Transform), false);
                startY+=5;
            }

            if((tower && TowerDealDamage(tower))){
                cont=new GUIContent("Damage(Min/Max):", "");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.damageMin=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.damageMin);
                stat.damageMax=EditorGUI.FloatField(new Rect(startX+spaceX+fWidth, startY, fWidth, height), stat.damageMax);

                cont=new GUIContent("Cooldown:", "Duration between each attack");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.cooldown=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.cooldown);

            cont = new GUIContent("Electricity needed:", "The amount of enery consumed for one shot");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stat.electricityNeedForShoot = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.electricityNeedForShoot);

            /*
                cont=new GUIContent("Clip Size:", "The amount of attack the unit can do before the unit needs to reload\nWhen set to <0 the unit will never need any reload");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.clipSize=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.clipSize);
                stat.clipSize=Mathf.Round(stat.clipSize);

                cont=new GUIContent("Reload Duration:", "");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.reloadDuration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.reloadDuration);
                */

            cont =new GUIContent("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.range=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.range);

                cont=new GUIContent("AOE Radius:", "Area-of-Effective radius. When the shootObject hits it's target, any other hostile unit within the area from the impact position will suffer the same target as the target.\nSet value to >0 to enable. ");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.aoeRadius=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.aoeRadius);

                cont=new GUIContent("Stun", "");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;

                cont=new GUIContent("        - Chance:", "Chance to stun the target in each successful attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.stun.chance=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.stun.chance);

                cont=new GUIContent("        - Duration:", "The stun duration in second");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.stun.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.stun.duration);

                cont=new GUIContent("Critical", "");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;

                cont=new GUIContent("            - Chance:", "Chance to score critical hit in attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.crit.chance=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.crit.chance);

                cont=new GUIContent("            - Multiplier:", "Damage multiplier for successful critical hit. Takes value from 0 and above with with 0.5 being 50% of normal damage as bonus");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.crit.dmgMultiplier=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.crit.dmgMultiplier);

                cont=new GUIContent("Slow", "");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;

                cont=new GUIContent("         - Duration:", "The effect duration in second");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.slow.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.slow.duration);

                cont=new GUIContent("         - Multiplier:", "Move speed multiplier. Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.slow.slowMultiplier=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.slow.slowMultiplier);

                cont=new GUIContent("Dot", "Damage over time");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;

                cont=new GUIContent("        - Duration:", "The effect duration in second");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.dot.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.dot.duration);

                cont=new GUIContent("        - Interval:", "Duration between each tick. Damage is applied at each tick.");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.dot.interval=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.dot.interval);

                cont=new GUIContent("        - Damage:", "Damage applied at each tick");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.dot.value=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.dot.value);

            }

            if((tower && tower.type==_TowerType.Support)){
                cont=new GUIContent("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.range=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.range);
                startY+=5;

                cont=new GUIContent("Buff:", "Note: Buffs from multple tower doesnt stack, however when there's difference in the buff strength, the stronger buff applies. A tower can gain maximum dmage buff from one source and maximum range buff from another");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;

                cont=new GUIContent("        - Damage:", "Damage buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in damage");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.buff.damageBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.damageBuff);

                cont=new GUIContent("        - Cooldown:", "Dooldown buff multiplier. Takes value from 0-1 with 0.2 being reduce cooldown by 20%");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.buff.cooldownBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.cooldownBuff);

                cont=new GUIContent("        - Range:", "Range buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in range");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.buff.rangeBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.rangeBuff);

                cont=new GUIContent("        - Critical:", "Critical hit chance buff modifier. Takes value from 0 and above with 0.25 being 25% increase in critical hit chance");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.buff.criticalBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.criticalBuff);

                cont=new GUIContent("        - HP Regen:", "HP Regeneration Buff. Takes value from 0 and above with 2 being gain 2HP second ");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.buff.regenHP=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.buff.regenHP);
            }

              if ((tower && tower.type == _TowerType.Electric))
              {
            cont = new GUIContent("Range:", "Effect range of the unit");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stat.range = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.range);

            cont = new GUIContent("Max Electricity:", "Maximal energy capacity of the electric facility.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stat.electricityMaxStored = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.electricityMaxStored);

            cont = new GUIContent("Elec. Regeneration:", "The electricity generated by this tower.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stat.electricityRegenerationRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.electricityRegenerationRate);

            cont = new GUIContent("Elec. Receive Rate:", "The electricity received with every drone.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stat.electricityReceiveRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.electricityReceiveRate);
              }

              if (tower){
                startY+=10;
                cont=new GUIContent("Custom Description:", "Check to use use custom description. If not, the default one (generated based on the effect) will be used");
                EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                stat.useCustomDesp=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), stat.useCustomDesp);
                if(stat.useCustomDesp){
                    GUIStyle style=new GUIStyle("TextArea");
                    style.wordWrap=true;
                    //~ cont=new GUIContent("Description(to be used in runtime): ", "");
                    //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, 200, 20), cont);
                    stat.desp=EditorGUI.TextArea(new Rect(startX, startY+spaceY-3, 200, 90), stat.desp, style);
                    startY+=90;
                }
            }

            statContentHeight=startY+spaceY+5;

            return new Vector3(startX+220, startY, statContentHeight);
        }
Ejemplo n.º 53
0
		public static Vector3 DrawUnitOffensiveSetting(UnitTower tower, UnitCreep creep, float startX, float startY, List<GameObject> objHList, string[] objHLabelList){
			float cachedX=startX;
			//float cachedY=startY;
			
			Unit unit=null;
			if(tower!=null) unit=tower;
			if(creep!=null) unit=creep;
			
			
			
			if(tower && TowerDealDamage(tower) || (creep && creep.type==_CreepType.Offense)){
				string[] damageTypeLabel=EditorDBManager.GetDamageTypeLabel();
				cont=new GUIContent("Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
				EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
				unit.damageType=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), unit.damageType, damageTypeLabel);
			}
			
			if(tower && TowerUseShootObject(tower) || (creep && creep.type==_CreepType.Offense)){
				cont=new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
				shootPointFoldout=EditorGUI.Foldout(new Rect(startX, startY+=spaceY, spaceX, height), shootPointFoldout, cont);
				int shootPointCount=unit.shootPoints.Count;
				shootPointCount=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), shootPointCount);
				
				if(shootPointCount!=unit.shootPoints.Count){
					while(unit.shootPoints.Count<shootPointCount) unit.shootPoints.Add(null);
					while(unit.shootPoints.Count>shootPointCount) unit.shootPoints.RemoveAt(unit.shootPoints.Count-1);
				}
					
				if(shootPointFoldout){
					for(int i=0; i<unit.shootPoints.Count; i++){
						int objID=GetObjectIDFromHList(unit.shootPoints[i], objHList);
						EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), "    - Element "+(i+1));
						objID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), objID, objHLabelList);
						unit.shootPoints[i] = (objHList[objID]==null) ? null : objHList[objID].transform;
					}
				}
				
				if(unit.shootPoints.Count>1){
					cont=new GUIContent("Shots delay Between ShootPoint:", "Delay in second between shot fired at each shootPoint. When set to zero all shootPoint fire simulteneously");
					EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width+60, height), cont);
					unit.delayBetweenShootPoint=EditorGUI.FloatField(new Rect(startX+spaceX+90, startY-1, 55, height-1), unit.delayBetweenShootPoint);
				}
			}
			
			
			if(tower && TowerUseTurret(tower) || (creep && creep.type==_CreepType.Offense)){
				int objID=GetObjectIDFromHList(unit.turretObject, objHList);
				cont=new GUIContent("TurretObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). When left unassigned, no aiming will be done.");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				objID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), objID, objHLabelList);
				unit.turretObject = (objHList[objID]==null) ? null : objHList[objID].transform;
				
				objID=GetObjectIDFromHList(unit.barrelObject, objHList);
				cont=new GUIContent("BarrelObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). This is only required if the unit barrel and turret rotates independently on different axis");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				objID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), objID, objHLabelList);
				unit.barrelObject = (objHList[objID]==null) ? null : objHList[objID].transform;
				
				cont=new GUIContent("Aim Rotate In x-axis:", "Check if the unit turret/barrel can rotate in x-axis (elevation)");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				unit.rotateTurretAimInXAxis=EditorGUI.Toggle(new Rect(startX+spaceX+20, startY, 40, height), unit.rotateTurretAimInXAxis);
			}
			
			
			if(tower && TowerTargetHostile(tower) || (creep && creep.type==_CreepType.Offense)){
				cont=new GUIContent("Directional Targeting:", "Check if the unit should only target hostile unit from a fixed direction");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				unit.directionalTargeting=EditorGUI.Toggle(new Rect(startX+spaceX+20, startY, 40, height), unit.directionalTargeting);
				
				if(unit.directionalTargeting){
					startX+=spaceX+50;
					
					cont=new GUIContent("- FOV:", "Field-Of-View of the directional targeting");
					EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
					unit.dirScanFOV=EditorGUI.FloatField(new Rect(startX+60, startY, 40, height), unit.dirScanFOV);
					
					if(tower!=null){
						cont=new GUIContent("- Angle:", "The y-axis angle in clock-wise (from transform local space) which the directional targeting will be aim towards\n0: +ve z-axis\n90: +ve x-axis\n180: -ve z-axis\n270: -ve x-axis");
						EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
						unit.dirScanAngle=EditorGUI.FloatField(new Rect(startX+60, startY, 40, height), unit.dirScanAngle);
					}
				}
			}
			
			return new Vector3(cachedX, startY, spaceX+width);
		}
Ejemplo n.º 54
0
        void OnUnitCleared(UnitCreep creep)
        {
            int waveID=creep.waveID;

            activeUnitCount-=1;

            Wave wave=null;
            if(spawnLimit==_SpawnLimit.Finite) wave=waveList[waveID];
            else if(spawnLimit==_SpawnLimit.Infinite){
                for(int i=0; i<waveList.Count; i++){
                    if(waveList[i].waveID==waveID){
                        wave=waveList[i];
                        break;
                    }
                }

                if(wave==null){
                    Debug.Log("error!");
                    return;
                }
            }

            wave.activeUnitCount-=1;
            if(wave.spawned && wave.activeUnitCount==0){
                wave.cleared=true;
                waveClearedCount+=1;
                Debug.Log("wave"+(waveID+1)+ " is cleared");

                if(spawnLimit==_SpawnLimit.Infinite) waveList.Remove(wave);

                if(IsAllWaveCleared()){
                    if (GameControl.GetGameState() != _GameState.Over) {
                        GameControl.StopGame(true);
                    }
                }
                else{
                    if(spawnMode==_SpawnMode.Round && onEnableSpawnE!=null) onEnableSpawnE();
                }
            }

            if(!IsAllWaveCleared() && activeUnitCount==0 && !spawning){
                if(spawnMode==_SpawnMode.WaveCleared) SpawnWaveFinite();
            }
        }