コード例 #1
0
        //called by any external component to build tower, uses buildInfo
        public static string BuildTower(UnitTower tower)
        {
            if(buildInfo==null) return "Select a Build Point First";

            UnitTower sampleTower=GetSampleTower(tower);

            //check if there are sufficient resource
            List<int> cost=sampleTower.GetCost();
            int suffCost=ResourceManager.HasSufficientResource(cost);
            if(suffCost==-1){
                ResourceManager.SpendResource(cost);

                GameObject towerObj=(GameObject)Instantiate(tower.gameObject, buildInfo.position, buildInfo.platform.thisT.rotation);
                UnitTower towerInstance=towerObj.GetComponent<UnitTower>();
                towerInstance.InitTower(instance.towerCount+=1);
                towerInstance.Build();

                //clear the build info and indicator for build manager
                ClearBuildPoint();

                return "";
            }

            return "Insufficient Resource";
        }
コード例 #2
0
ファイル: BuildManager.cs プロジェクト: toooooooo/BEER
 public static void AddNewTower(UnitTower newTower)
 {
     if (instance.towerList.Contains(newTower)) return;
       instance.towerList.Add(newTower);
       instance.AddNewSampleTower(newTower);
       if (onAddNewTowerE != null) onAddNewTowerE(newTower);
 }
コード例 #3
0
ファイル: BuildManager.cs プロジェクト: mroslander/BoomBalls
        //called by any external component to build tower, uses buildInfo
        public static string BuildTower(UnitTower tower)
        {
            if(buildInfo==null) return "Select a Build Point First";

            //dont allow building of resource tower before game started
            if(tower.type==_TowerType.Resource && !GameControl.IsGameStarted()){
                return "Cant Build Tower before spawn start";
            }

            UnitTower sampleTower=GetSampleTower(tower);

            //check if there are sufficient resource
            List<int> cost=sampleTower.GetCost();
            int suffCost=ResourceManager.HasSufficientResource(cost);
            if(suffCost==-1){
                ResourceManager.SpendResource(cost);

                GameObject towerObj=(GameObject)Instantiate(tower.gameObject, buildInfo.position, buildInfo.platform.thisT.rotation);
                UnitTower towerInstance=towerObj.GetComponent<UnitTower>();
                towerInstance.InitTower(instance.towerCount+=1);
                towerInstance.Build();

                //register the tower to the platform
                if(buildInfo.platform!=null) buildInfo.platform.BuildTower(buildInfo.position, towerInstance);

                //clear the build info and indicator for build manager
                ClearBuildPoint();

                return "";
            }

            return "Insufficient Resource";
        }
コード例 #4
0
		public void _AddNewTower(UnitTower newTower){
			int count=buttonList.Count;
			buttonList.Add(buttonList[count-1].Clone("button"+(count), new Vector3(55, 0, 0)));
			buttonList[count].imageIcon.sprite=newTower.iconSprite;
			
			EventTrigger trigger = buttonList[count].rootObj.GetComponent<EventTrigger>();
			EventTrigger.Entry entry=SetupTriggerEntry();
			trigger.triggers.Add(entry);
		}
コード例 #5
0
ファイル: TowerHighlighter.cs プロジェクト: toooooooo/BEER
    // Use this for initialization
    void Start()
    {
        myRenderers = GetComponentsInChildren<MeshRenderer>();
        myRenderersColors = new List<Color>(myRenderers.Length);
        for (int i = 0; i < myRenderers.Length; i++)
        {
            myRenderersColors.Add(myRenderers[i].material.color);
        }

        unitTowerT = GetComponent<TDTK.UnitTower>();
    }
コード例 #6
0
ファイル: TowerHighlighter.cs プロジェクト: tscheipel/BEER
    // Use this for initialization
    void Start()
    {
        myRenderers = GetComponentsInChildren<MeshRenderer>();
        myRenderersColors = new List<Color>(myRenderers.Length);
        for (int i = 0; i < myRenderers.Length; i++)
        {
            myRenderersColors.Add(myRenderers[i].material.color);
        }

        unitTowerT = GetComponent<TDTK.UnitTower>();
    }
コード例 #7
0
ファイル: PlatformTD.cs プロジェクト: Yaroslavich/Scripts
        public void BuildTower(Vector3 pos, UnitTower tower)
        {
            //pathfinding related code, only call if this platform is walkable;
            if(!walkable) return;

            NodeTD node=PathFinder.GetNearestNode(pos, nodeGraph);
            node.walkable=false;
            tower.SetPlatform(this, node);

            //if the node has been check before during CheckForBlock(), just use the altPath
            if(node==nextBuildNode){
                for(int i=0; i<subPathList.Count; i++){
                    if(subPathList[i].IsNodeInPath(node)) subPathList[i].SwitchToSubPath();
                }
                return;
            }

            for(int i=0; i<subPathList.Count; i++){
                if(subPathList[i].IsNodeInPath(node)) subPathList[i].SearchNewPath(nodeGraph);
            }
        }
コード例 #8
0
ファイル: BuildManager.cs プロジェクト: toooooooo/BEER
        //called by any external component to build tower, uses buildInfo
        public static string BuildTower(UnitTower tower)
        {
            if (buildInfo == null) return "Select a Build Point First";

              UnitTower sampleTower = GetSampleTower(tower);

              /***/
              // check if there's energy reciving tower
              if (tower.electricityNeeded && !tower.electricityReciever && !tower.electricityFacility)
              {
            LayerMask maskTarget = 1 << LayerManager.LayerTower();

            Collider[] cols = Physics.OverlapSphere(buildInfo.position, 1000 /*GetRange()*/, maskTarget);

            if (cols.Length > 0)
            {
              tower.electicitySources.Clear();
              // find all electric facility
              for (int i = 0; i < cols.Length; i++)
              {
            // if it's not electric reciever skip
            if (!cols[i].gameObject.GetComponent<UnitTower>().electricityReciever)
              continue;

            //float test = cols[i].gameObject.GetComponent<UnitTower>().GetRange();
            //float test2 = Vector3.Distance(cols[i].gameObject.GetComponent<UnitTower>().transform.position, buildInfo.position);

            // if this tower is in range of electricityReciever
            if (Vector3.Distance(cols[i].gameObject.GetComponent<UnitTower>().transform.position, buildInfo.position) <= cols[i].gameObject.GetComponent<UnitTower>().GetRange())
            {
              tower.electicitySources.Add(cols[i].gameObject.GetComponent<UnitTower>());
            }
              }

              if (tower.electicitySources.Count == 0)
              {
            // set electricity source for tower weapon
            return "There is not enough electricity";
              }
            }
            else
              return "There is not enough electricity";
              }
              /***/

              //check if there are sufficient resource
              List<int> cost = sampleTower.GetCost();
              int suffCost = ResourceManager.HasSufficientResource(cost);
              if (suffCost == -1)
              {
            ResourceManager.SpendResource(cost);

            GameObject towerObj = (GameObject)Instantiate(tower.gameObject, buildInfo.position, buildInfo.platform.thisT.rotation);
            UnitTower towerInstance = towerObj.GetComponent<UnitTower>();
            towerInstance.InitTower(instance.towerCount += 1, buildInfo.platform);
            towerInstance.Build();

            // if new electricity reciver is placed search for all towers in it's range and add itself as electricity source
            if (tower.electricityReciever)
            {
              LayerMask maskTarget = 1 << LayerManager.LayerTower();

              Collider[] cols = Physics.OverlapSphere(buildInfo.position, tower.GetRange(), maskTarget);

              if (cols.Length > 0)
              {
            UnitTower tmp_tow;
            for (int i = 0; i < cols.Length; i++)
            {
              tmp_tow = cols[i].gameObject.GetComponent<UnitTower>();

              if (tmp_tow.electricityReciever || tmp_tow.electricityFacility)
                continue;

              tmp_tow.electicitySources.Add(towerInstance);
            }
              }
            }

            //clear the build info and indicator for build manager
            ClearBuildPoint();

            return "";
              }

              return "Insufficient Resource";
        }
コード例 #9
0
ファイル: UnitTower.cs プロジェクト: Pringlez/Alien-Danger-TD
 public void SetAsSampleTower(UnitTower tower)
 {
     isSampleTower=true;
     srcTower=tower;
     thisT.position=new Vector3(0, 9999, 0);
 }
コード例 #10
0
		public static bool TowerUseShootObject(UnitTower tower){
			_TowerType type=tower.type;
			if(type==_TowerType.Turret) return true;
			return false;
		}
コード例 #11
0
ファイル: BuildManager.cs プロジェクト: toooooooo/BEER
        public bool UpdatePathMaps(UnitTower tow, bool destroy = false)
        {
            int index_z = (int)Mathf.Round(tow.Platform.transform.position.z - platform_min_z) / 2;
              int index_x = (int)Mathf.Round(tow.Platform.transform.position.x - platform_min_x) / 2;

              if (index_z < 0)
            return true;

              beerMap[index_x, index_z + 1] = destroy;  // false -> new tower build there

              // Check if the last paths are still walkable
              // exit if true
              if (lastPathOne.Count >= 0 && lastPathTwo.Count >= 0)
              {
            bool lastPathOK = true;

            for (int i = 0; i < lastPathOne.Count; i++)
            {
              if (beerMap[lastPathOne[i].X, lastPathOne[i].Y] == false)
            lastPathOK = false;
            }

            for (int i = 0; i < lastPathTwo.Count; i++)
            {
              if (beerMap[lastPathTwo[i].X, lastPathTwo[i].Y] == false)
            lastPathOK = false;
            }

            if (lastPathOK)
              return true;
              }

              if (!GenerateGlobalPaths())
              {
            beerMap[index_x, index_z + 1] = !destroy;
            GenerateGlobalPaths();
            return false;
              }

              // TODO position of this SpawnManager functions ?
              // Here becazse GenerateGlobalPaths is called at startup
              // Waves not generated at that time
              for (int i = 0; i < SpawnManager.instance.waveList.Count; i++)
              {
            SpawnManager.instance.waveGenerator.UpdateWavePath(SpawnManager.instance.waveList[i]);
              }

              UnitCreep[] creeps = ObjectPoolManager.FindObjectsOfType<UnitCreep>();
              foreach (UnitCreep creep in creeps)
              {
            // Problem with creeps not in the maze -> between start and normal platforms
            // or between normal platforms and goal
            // No new Path, if creep is already past the last tower row
            if (creep.transform.position.z > platform_min_z)
            {
              int c_z;
              if (creep.transform.position.z > platform_max_z)
            c_z = 34;
              else
            c_z = Mathf.CeilToInt(creep.transform.position.z - platform_min_z) / 2; // Changed to CeilToInt and not round

              int c_x = (int)Mathf.Round(creep.transform.position.x - platform_min_x) / 2;
              parameters = new PathFindingParameters(new Point(c_x, c_z), pt_goal, beerMap, nodeMap);
              pf = new PathFinder(parameters);

              PathTD pt = pf.FindPathTD(creep.transform, "CreepCustomPath");

              creep.SetNewPath(pt);
            }
              }

              //Object[] towers = GameObject.FindObjectsOfType(typeof(UnitTower));

              //Object[] platforms = GameObject.FindObjectsOfType(typeof(PlatformTD));

              //Object[] paths = GameObject.FindObjectsOfType(typeof(PathTD));

              //SpawnManager.ChangeDefaultPath(paths[0] as PathTD);
              return true;
        }
コード例 #12
0
 public static Vector3 DrawStat(UnitStat stat, float startX, float startY, float statContentHeight, UnitTower tower)
 {
     return(DrawStat(stat, startX, startY, statContentHeight, tower, null));
 }
コード例 #13
0
        public bool UpdatePathMaps(UnitTower tow, bool destroy = false)
        {
            int index_z = (int)Mathf.Round(tow.Platform.transform.position.z - platform_min_z) / 2;
            int index_x = (int)Mathf.Round(tow.Platform.transform.position.x - platform_min_x) / 2;

            if (index_z < 0)
            {
                return(true);
            }

            beerMap[index_x, index_z + 1] = destroy; // false -> new tower build there


            // Check if the last paths are still walkable
            // exit if true
            if (lastPathOne.Count >= 0 && lastPathTwo.Count >= 0)
            {
                bool lastPathOK = true;

                for (int i = 0; i < lastPathOne.Count; i++)
                {
                    if (beerMap[lastPathOne[i].X, lastPathOne[i].Y] == false)
                    {
                        lastPathOK = false;
                    }
                }

                for (int i = 0; i < lastPathTwo.Count; i++)
                {
                    if (beerMap[lastPathTwo[i].X, lastPathTwo[i].Y] == false)
                    {
                        lastPathOK = false;
                    }
                }

                if (lastPathOK)
                {
                    return(true);
                }
            }


            if (!GenerateGlobalPaths())
            {
                beerMap[index_x, index_z + 1] = !destroy;
                GenerateGlobalPaths();
                return(false);
            }

            // TODO position of this SpawnManager functions ?
            // Here becazse GenerateGlobalPaths is called at startup
            // Waves not generated at that time
            for (int i = 0; i < SpawnManager.instance.waveList.Count; i++)
            {
                SpawnManager.instance.waveGenerator.UpdateWavePath(SpawnManager.instance.waveList[i]);
            }

            UnitCreep[] creeps = ObjectPoolManager.FindObjectsOfType <UnitCreep>();
            foreach (UnitCreep creep in creeps)
            {
                // Problem with creeps not in the maze -> between start and normal platforms
                // or between normal platforms and goal
                // No new Path, if creep is already past the last tower row
                if (creep.transform.position.z > platform_min_z)
                {
                    int c_z;
                    if (creep.transform.position.z > platform_max_z)
                    {
                        c_z = 34;
                    }
                    else
                    {
                        c_z = Mathf.CeilToInt(creep.transform.position.z - platform_min_z) / 2; // Changed to CeilToInt and not round
                    }
                    int c_x = (int)Mathf.Round(creep.transform.position.x - platform_min_x) / 2;
                    parameters = new PathFindingParameters(new Point(c_x, c_z), pt_goal, beerMap, nodeMap);
                    pf         = new PathFinder(parameters);

                    PathTD pt = pf.FindPathTD(creep.transform, "CreepCustomPath");

                    creep.SetNewPath(pt);
                }
            }

            //Object[] towers = GameObject.FindObjectsOfType(typeof(UnitTower));

            //Object[] platforms = GameObject.FindObjectsOfType(typeof(PlatformTD));

            //Object[] paths = GameObject.FindObjectsOfType(typeof(PathTD));

            //SpawnManager.ChangeDefaultPath(paths[0] as PathTD);
            return(true);
        }
コード例 #14
0
        Vector2 DrawUnitConfigurator(float startX, float startY, List <UnitTower> towerList)
        {
            float maxWidth = 0;

            UnitTower tower = towerList[selectID];


            float cachedY = startY;
            float cachedX = startX;

            startX += 65;               //startY+=20;

            int type = (int)tower.type;

            cont = new GUIContent("Tower Type:", "Type of the tower. Each type of tower serve a different function");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            contL = new GUIContent[towerTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(towerTypeLabel[i], towerTypeTooltip[i]);
            }
            type       = EditorGUI.Popup(new Rect(startX + 80, startY, width - 40, 15), new GUIContent(""), type, contL);
            tower.type = (_TowerType)type;
            startX     = cachedX;

            v3 = DrawIconAndName(tower, startX, startY);      startY = v3.y;


            startX = cachedX;
            spaceX = 110;

            cachedY = startY;
            v3      = DrawUnitDefensiveSetting(tower, startX, startY, objHList, objHLabelList);         //startY=v3.y;


            if (startX + spaceX + width > maxWidth)
            {
                maxWidth = startX + spaceX + width;
            }


            startY  = cachedY;
            startX += spaceX + width + 35;



            if (TowerDealDamage(tower))
            {
                int targetMode = (int)tower.targetMode;
                cont = new GUIContent("Target Mode:", "Determine which type of unit the tower can target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                contL = new GUIContent[targetModeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(targetModeLabel[i], targetModeTooltip[i]);
                }
                targetMode       = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), targetMode, contL);
                tower.targetMode = (_TargetMode)targetMode;
                startY          += spaceY;
            }

            v3 = DrawUnitOffensiveSetting(tower, startX, startY, objHList, objHLabelList);            startY = v3.y + spaceY;


            if (startX + spaceX + width > maxWidth)
            {
                maxWidth = startX + spaceX + width;
            }



            string[]         weaponNameList = EditorDBManager.GetFPSWeaponNameList();
            List <FPSWeapon> weaponList     = EditorDBManager.GetFPSWeaponList();
            int weaponID = 0;

            if (tower.FPSWeaponID != -1)
            {
                for (int i = 0; i < weaponList.Count; i++)
                {
                    if (weaponList[i].prefabID == tower.FPSWeaponID)
                    {
                        weaponID = i + 1; break;
                    }
                }
            }
            cont = new GUIContent("FPS Weapon:", "Weapon tied to this tower when using FPS mode");
            GUI.Label(new Rect(startX, startY, 120, height), cont);
            weaponID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponID, weaponNameList);
            if (weaponID == 0)
            {
                tower.FPSWeaponID = -1;
            }
            else
            {
                tower.FPSWeaponID = weaponList[weaponID - 1].prefabID;
            }



            //if(startY>maxHeight) maxHeight=startY;
            float maxY = startY;

            startY = 300;

            startX = cachedX; cachedY = startY;


            cont = new GUIContent("Building Effect:", "The effect object to be spawned when the tower start a building process\nThis is entirely optional");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            tower.buildingEffect = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.buildingEffect, typeof(GameObject), false);
            startY += 20;
            cont    = new GUIContent("Built Effect:", "The effect object to be spawned when the tower has finish a build process\nThis is entirely optional");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            tower.builtEffect = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.builtEffect, typeof(GameObject), false);
            startY           += 40;



            string[] towerNameList = EditorDBManager.GetTowerNameList();

            cont = new GUIContent("Prev lvl Tower:", "Tower prefab which this current selected tower is upgrade from. If blank then this is the base tower (level 1). ");
            GUI.Label(new Rect(startX, startY, 120, height), cont);
            int ID = -1;

            for (int i = 0; i < towerList.Count; i++)
            {
                if (towerList[i] == tower.prevLevelTower)
                {
                    ID = i + 1;
                }
            }
            ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, 105, height), ID, towerNameList);
            if (GUI.Button(new Rect(startX + 215, startY, 48, 15), "Select"))
            {
                if (tower.prevLevelTower != null)
                {
                    SelectTower(ID - 1);
                }
            }


            cont = new GUIContent("lvl within Prefab:", "");
            GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
            if (GUI.Button(new Rect(startX + spaceX, startY, 50, 15), "-1"))
            {
                if (tower.stats.Count > 1)
                {
                    tower.stats.RemoveAt(tower.stats.Count - 1);
                }
            }
            if (GUI.Button(new Rect(startX + 165, startY, 50, 15), "+1"))
            {
                tower.stats.Add(tower.stats[tower.stats.Count - 1].Clone());
            }

            if (tower.nextLevelTowerList.Count == 0)
            {
                tower.nextLevelTowerList.Add(null);
            }

            cont = new GUIContent("Next lvl Tower 1:", "Tower prefab to be used beyond the stats level specified for this prefab");
            GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
            ID = -1;
            for (int i = 0; i < towerList.Count; i++)
            {
                if (towerList[i] == tower.nextLevelTowerList[0])
                {
                    ID = i + 1;
                }
            }
            ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, 105, height), ID, towerNameList);
            if (ID > 0 && towerList[ID - 1] != tower)
            {
                if (tower.nextLevelTowerList[0] != null)
                {
                    tower.nextLevelTowerList[0].prevLevelTower = null;
                }

                tower.nextLevelTowerList[0]      = towerList[ID - 1];
                towerList[ID - 1].prevLevelTower = tower;
            }
            else if (ID == 0)
            {
                tower.nextLevelTowerList[0] = null;
            }
            if (GUI.Button(new Rect(startX + 215, startY, 48, 15), "Select"))
            {
                if (tower.nextLevelTowerList[0] != null)
                {
                    SelectTower(ID - 1);
                }
            }

            if (tower.nextLevelTowerList[0] == null)
            {
                if (tower.nextLevelTowerList.Count > 1 && tower.nextLevelTowerList[1] != null)
                {
                    tower.nextLevelTowerList[0] = tower.nextLevelTowerList[1];
                    tower.nextLevelTowerList.RemoveAt(1);
                }
            }

            if (tower.nextLevelTowerList[0] != null)
            {
                if (tower.nextLevelTowerList.Count < 2)
                {
                    tower.nextLevelTowerList.Add(null);
                }

                //startX+=295;
                cont = new GUIContent("Next lvl Tower 2:", "Tower prefab to be used beyond the stats level specified for this prefab");
                GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
                ID = -1;
                for (int i = 0; i < towerList.Count; i++)
                {
                    if (towerList[i] == tower.nextLevelTowerList[1])
                    {
                        ID = i + 1;
                    }
                }
                ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, 105, height), ID, towerNameList);
                if (ID > 0 && towerList[ID - 1] != tower && !tower.nextLevelTowerList.Contains(towerList[ID - 1]))
                {
                    if (tower.nextLevelTowerList[1] != null)
                    {
                        tower.nextLevelTowerList[1].prevLevelTower = null;
                    }

                    tower.nextLevelTowerList[1]      = towerList[ID - 1];
                    towerList[ID - 1].prevLevelTower = tower;
                }
                else if (ID == 0)
                {
                    tower.nextLevelTowerList[1] = null;
                }
                if (GUI.Button(new Rect(startX + 215, startY, 48, 15), "Select"))
                {
                    if (tower.nextLevelTowerList[1] != null)
                    {
                        SelectTower(ID - 1);
                    }
                }

                //GUI.Label(new Rect(startX+270, startY, 200, height), "(for alternate upgrade path)");
                //startX=cachedX;
            }



            startY = Mathf.Max(maxY + 20, 460);
            startX = cachedX;

            float maxHeight        = 0;
            float maxContentHeight = 0;

            minimiseStat = EditorGUI.Foldout(new Rect(startX, startY, width, height), minimiseStat, "Show Stats");
            if (!minimiseStat)
            {
                startY += spaceY;
                startX += 15;

                int lvl = GetStatsLevelStartOffset(tower);

                if (tower.stats.Count == 0)
                {
                    tower.stats.Add(new UnitStat());
                }
                for (int i = 0; i < tower.stats.Count; i++)
                {
                    EditorGUI.LabelField(new Rect(startX, startY, width, height), "Level " + (lvl + i + 1) + " Stats");
                    v3 = DrawStat(tower.stats[i], startX, startY + spaceY, statContentHeight, tower);
                    if (maxContentHeight < v3.z)
                    {
                        maxContentHeight = v3.z;
                    }
                    //statContentHeight=v3.z;
                    startX = v3.x + 10;
                    if (startX > maxWidth)
                    {
                        maxWidth = startX;
                    }
                    if (maxHeight < v3.y)
                    {
                        maxHeight = v3.y;
                    }
                }
                statContentHeight = maxContentHeight;
                startY            = maxHeight;
            }

            startX  = cachedX;
            startY += spaceY;


            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Unit general description (to be used in runtime): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            tower.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 530, 50), tower.desp, style);

            startX = maxWidth - cachedX + 80;

            return(new Vector2(startX, startY));
        }
コード例 #15
0
		public static void Building(UnitTower tower){ instance.StartCoroutine(instance._Building(tower)); }
コード例 #16
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            List <UnitTower> towerList = EditorDBManager.GetTowerList();

            if (GUI.Button(new Rect(window.position.width - 120, 5, 100, 25), "Save"))
            {
                EditorDBManager.SetDirtyTower();
            }

            EditorGUI.LabelField(new Rect(5, 7, 150, 17), "Add new tower:");
            UnitTower newTower = null;

            newTower = (UnitTower)EditorGUI.ObjectField(new Rect(100, 7, 140, 17), newTower, typeof(UnitTower), false);
            if (newTower != null)
            {
                int newSelectID = EditorDBManager.AddNewTower(newTower);
                if (newSelectID != -1)
                {
                    SelectTower(newSelectID);
                }
            }


            float startX = 5;
            float startY = 50;

            if (minimiseList)
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>"))
                {
                    minimiseList = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<"))
                {
                    minimiseList = true;
                }
            }
            Vector2 v2 = DrawUnitList(startX, startY, towerList);

            startX = v2.x + 25;

            if (towerList.Count == 0)
            {
                return;
            }

            cont = new GUIContent("Tower Prefab:", "The prefab object of the tower\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            EditorGUI.ObjectField(new Rect(startX + 90, startY, 185, height), towerList[selectID].gameObject, typeof(GameObject), false);

            cont = new GUIContent("Disable in BuildManager:", "When checked, tower won't appear on BuildManager list and thus can't be built\nThis is to mark towers that can only be upgrade from a built tower or unlock from perk");
            EditorGUI.LabelField(new Rect(startX + 295, startY, width, height), cont);
            towerList[selectID].disableInBuildManager = EditorGUI.Toggle(new Rect(startX + 440, startY, 185, height), towerList[selectID].disableInBuildManager);

            startY += spaceY + 10;


            Rect visibleRect = new Rect(startX, startY, window.position.width - startX - 10, window.position.height - startY - 5);
            Rect contentRect = new Rect(startX, startY, contentWidth - startY, contentHeight);

            //~ GUI.color=new Color(.8f, .8f, .8f, 1f);
            //~ GUI.Box(visibleRect, "");
            //~ GUI.color=Color.white;

            scrollPos2 = GUI.BeginScrollView(visibleRect, scrollPos2, contentRect);

            v2            = DrawUnitConfigurator(startX, startY, towerList);
            contentWidth  = v2.x;
            contentHeight = v2.y;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                EditorDBManager.SetDirtyTower();
            }
        }
コード例 #17
0
        Vector2 DrawUnitList(float startX, float startY, List <UnitTower> towerList)
        {
            float width = 260;

            if (minimiseList)
            {
                width = 60;
            }

            if (!minimiseList)
            {
                if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up"))
                {
                    if (selectID > 0)
                    {
                        UnitTower tower = towerList[selectID];
                        towerList[selectID]     = towerList[selectID - 1];
                        towerList[selectID - 1] = tower;
                        selectID -= 1;

                        if (selectID * 35 < scrollPos1.y)
                        {
                            scrollPos1.y = selectID * 35;
                        }
                    }
                }
                if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down"))
                {
                    if (selectID < towerList.Count - 1)
                    {
                        UnitTower tower = towerList[selectID];
                        towerList[selectID]     = towerList[selectID + 1];
                        towerList[selectID + 1] = tower;
                        selectID += 1;

                        if (listVisibleRect.height - 35 < selectID * 35)
                        {
                            scrollPos1.y = (selectID + 1) * 35 - listVisibleRect.height + 5;
                        }
                    }
                }
            }


            listVisibleRect = new Rect(startX, startY, width + 15, window.position.height - startY - 5);
            listContentRect = new Rect(startX, startY, width, towerList.Count * 35 + 5);

            GUI.color = new Color(.8f, .8f, .8f, 1f);
            GUI.Box(listVisibleRect, "");
            GUI.color = Color.white;

            scrollPos1 = GUI.BeginScrollView(listVisibleRect, scrollPos1, listContentRect);


            startY += 5;      startX += 5;

            for (int i = 0; i < towerList.Count; i++)
            {
                EditorUtilities.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), towerList[i].iconSprite);

                if (minimiseList)
                {
                    if (selectID == i)
                    {
                        GUI.color = new Color(0, 1f, 1f, 1f);
                    }
                    if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), ""))
                    {
                        SelectTower(i);
                    }
                    GUI.color = Color.white;

                    continue;
                }



                if (selectID == i)
                {
                    GUI.color = new Color(0, 1f, 1f, 1f);
                }
                if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150, 30), towerList[i].unitName))
                {
                    SelectTower(i);
                }
                GUI.color = Color.white;

                if (deleteID == i)
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel"))
                    {
                        deleteID = -1;
                    }

                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm"))
                    {
                        if (selectID >= deleteID)
                        {
                            SelectTower(Mathf.Max(0, selectID - 1));
                        }
                        EditorDBManager.RemoveTower(deleteID);
                        deleteID = -1;
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove"))
                    {
                        deleteID = i;
                    }
                }
            }

            GUI.EndScrollView();

            return(new Vector2(startX + width, startY));
        }
コード例 #18
0
ファイル: UIOverlay.cs プロジェクト: tscheipel/BEER
 public static void Building(UnitTower tower)
 {
     instance.StartCoroutine(instance._Building(tower));
 }
コード例 #19
0
        public string _PurchasePerk(Perk perk, bool useRsc = true)
        {
            string text = perk.Purchase(useRsc);

            if (text != "")
            {
                return(text);
            }

            if (!purchasedIDList.Contains(perk.ID))
            {
                purchasedIDList.Add(perk.ID);
            }
            SavePurchasedPerk();

            TDTK.OnPerkPurchased(perk);

            //process the prereq for other perk
            for (int i = 0; i < perkList.Count; i++)
            {
                Perk perkTemp = perkList[i];
                if (perkTemp.purchased || perkTemp.prereq.Count == 0)
                {
                    continue;
                }
                perkTemp.prereq.Remove(perk.ID);
            }


            perkPoint += 1;
            TDTK.OnPerkPoint();

            if (perk.type == _PerkType.NewTower)
            {
                UnitTower tower = TDTK.GetDBTower(perk.itemIDList[0]);
                unlockedTowerList.Add(tower);
                BuildManager.AddNewTower(tower);
            }
            else if (perk.type == _PerkType.NewAbility)
            {
                Ability ability = TDTK.GetDBAbility(perk.itemIDList[0]);
                unlockedAbilityList.Add(ability);
                AbilityManager.AddNewAbility(ability);
            }
            else if (perk.type == _PerkType.NewFPSWeapon)
            {
                FPSWeapon weapon = TDTK.GetDBFpsWeapon(perk.itemIDList[0]);
                unlockedWeaponList.Add(weapon);
                FPSControl.AddNewWeapon(weapon);
            }

            else if (perk.type == _PerkType.GainLife)
            {
                GameControl.GainLife((int)Random.Range(perk.value, perk.valueAlt));
            }
            else if (perk.type == _PerkType.LifeCap)
            {
                lifeCap += (int)perk.value; GameControl.GainLife(0);
            }
            else if (perk.type == _PerkType.LifeRegen)
            {
                lifeRegen += perk.value;
            }
            else if (perk.type == _PerkType.LifeWaveClearedBonus)
            {
                lifeWaveClearedBonus += (int)perk.value;
            }

            else if (perk.type == _PerkType.GainRsc)
            {
                List <int> valueList = new List <int>();
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    valueList.Add((int)perk.valueRscList[i]);
                }
                ResourceManager.GainResource(valueList, null, false);                   //dont pass multiplier and dont use multiplier
            }
            else if (perk.type == _PerkType.RscRegen)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRegen[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscCreepKilledGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscCreepKilledGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscWaveClearedGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscWaveClearedGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscResourceTowerGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRscTowerGain[i] += perk.valueRscList[i];
                }
            }

            else if (perk.type == _PerkType.Tower)
            {
                ModifyTowerModifier(globalTowerModifier, perk);
            }
            else if (perk.type == _PerkType.TowerSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = TowerModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkTowerModifier towerModifier = new PerkTowerModifier();
                        towerModifier.prefabID = perk.itemIDList[i];
                        towerModifierList.Add(towerModifier);
                        ID = towerModifierList.Count - 1;
                    }
                    ModifyTowerModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.Ability)
            {
                ModifyAbilityModifier(globalAbilityModifier, perk);
            }
            else if (perk.type == _PerkType.AbilitySpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = AbilityModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.abilityID = perk.itemIDList[i];
                        abilityModifierList.Add(abilityModifier);
                        ID = abilityModifierList.Count - 1;
                    }
                    ModifyAbilityModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.FPSWeapon)
            {
                ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk);
            }
            else if (perk.type == _PerkType.FPSWeaponSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = FPSWeaponModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkFPSWeaponModifier weaponModifier = new PerkFPSWeaponModifier();
                        weaponModifier.prefabID = perk.itemIDList[i];
                        FPSWeaponModifierList.Add(weaponModifier);
                        ID = FPSWeaponModifierList.Count - 1;
                    }
                    ModifyFPSWeaponModifierInList(ID, perk);
                }
            }

            else if (perk.type == _PerkType.EnergyRegen)
            {
                energyRegen += perk.value;
            }
            else if (perk.type == _PerkType.EnergyIncreaseCap)
            {
                energyCap += perk.value;
            }
            else if (perk.type == _PerkType.EnergyCreepKilledBonus)
            {
                energyCreepKilledBonus += perk.value;
            }
            else if (perk.type == _PerkType.EnergyWaveClearedBonus)
            {
                energyWaveClearedBonus += perk.value;
            }

            return("");
        }
コード例 #20
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));
        }
コード例 #21
0
ファイル: TDTK.cs プロジェクト: toooooooo/BEER
 public static void OnTowerConstructed(UnitTower tower)
 {
     if (onTowerConstructedE != null) onTowerConstructedE(tower);
 }
コード例 #22
0
        public void _SelectTower(UnitTower tower)
        {
            _ClearSelectedTower();

            selectedTower=tower;

            float range=tower.GetRange();

            Transform indicatorT=rangeIndicator;

            if(indicatorT!=null){
                indicatorT.parent=tower.thisT;
                indicatorT.position=tower.thisT.position;
                indicatorT.localScale=new Vector3(2*range, 1, 2*range);

                indicatorT.gameObject.SetActive(true);
            }
        }
コード例 #23
0
ファイル: TDTK.cs プロジェクト: toooooooo/BEER
 public static void OnTowerSold(UnitTower tower)
 {
     if (onTowerSoldE != null) onTowerSoldE(tower);
 }
コード例 #24
0
		public static void PreBuildTower(UnitTower tower){
			PlatformTD platform=null;
			LayerMask mask=1<<LayerManager.LayerPlatform();
			Collider[] cols=Physics.OverlapSphere(tower.thisT.position, _gridSize, mask);
			if(cols.Length>0) platform=cols[0].gameObject.GetComponent<PlatformTD>();
			
			if(platform!=null){
				Vector3 buildPos=GetTilePos(platform.thisT, tower.thisT.position);
				tower.thisT.position=buildPos;
				tower.thisT.rotation=platform.thisT.rotation;
			}
			else Debug.Log("no platform found for pre-placed tower");
			
			tower.InitTower(instance.towerCount+=1);
		}
コード例 #25
0
 public static void SelectTower(UnitTower tower)
 {
     instance._SelectTower(tower);
 }
コード例 #26
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));
        }
コード例 #27
0
		//called when a tower building is initated in DragNDrop, use the sample tower as the model and set it in DragNDrop mode
		public static string BuildTowerDragNDrop(UnitTower tower){ return instance._BuildTowerDragNDrop(tower); }
コード例 #28
0
 //Call by inherited class UnitTower, caching inherited UnitTower instance to this instance
 public void SetSubClass(UnitTower unit)
 {
     unitT            = unit;
     subClass         = _UnitSubClass.Tower;
     gameObject.layer = LayerManager.LayerTower();
 }
コード例 #29
0
 public static Vector3 DrawUnitOffensiveSetting(UnitTower unit, float startX, float startY, List <GameObject> objHList, string[] objHLabelList)
 {
     return(DrawUnitOffensiveSetting(unit, null, startX, startY, objHList, objHLabelList));
 }
コード例 #30
0
        public string GetDespStats()
        {
            if (!IsTower() || stats[currentActiveStat].useCustomDesp)
            {
                return(stats[currentActiveStat].desp);
            }

            UnitTower tower = unitT;

            string text = "";

            if (tower.type == _TowerType.Turret || tower.type == _TowerType.AOE)
            {
                float currentDmgMin = GetDamageMin();
                float currentDmgMax = GetDamageMax();
                if (currentDmgMax > 0)
                {
                    if (currentDmgMin == currentDmgMax)
                    {
                        text += "Damage:		 "+ currentDmgMax.ToString("f0");
                    }
                    else
                    {
                        text += "Damage:		 "+ currentDmgMin.ToString("f0") + "-" + currentDmgMax.ToString("f0");
                    }
                }

                float currentAOE = GetAOERadius();
                if (currentAOE > 0)
                {
                    text += " (AOE)";
                }
                //if(currentAOE>0) text+="\nAOE Radius: "+currentAOE;

                float critChance = GetCritChance();
                if (critChance > 0)
                {
                    text += "\nCritical:		 "+ (critChance * 100).ToString("f0") + "%";
                }

                if (text != "")
                {
                    text += "\n";
                }

                Stun stun = GetStun();
                if (stun.IsValid())
                {
                    text += "\nChance to stuns target";
                }

                Slow slow = GetSlow();
                if (slow.IsValid())
                {
                    text += "\nSlows target";
                }

                Dot   dot    = GetDot();
                float dotDmg = dot.GetTotalDamage();
                if (dotDmg > 0)
                {
                    text += "\nDead " + dotDmg.ToString("f0") + " over " + dot.duration.ToString("f0") + "s";
                }
            }
            else if (tower.type == _TowerType.Support)
            {
                Buff buff = GetBuff();

                if (buff.damageBuff > 0)
                {
                    text += "Damage Buff: " + ((buff.damageBuff) * 100).ToString("f0") + "%";
                }
                if (buff.cooldownBuff > 0)
                {
                    text += "\nCooldown Buff: " + ((buff.cooldownBuff) * 100).ToString("f0") + "%";
                }
                if (buff.rangeBuff > 0)
                {
                    text += "\nRange Buff: " + ((buff.rangeBuff) * 100).ToString("f0") + "%";
                }
                if (buff.criticalBuff > 0)
                {
                    text += "\nRange Buff: " + ((buff.criticalBuff) * 100).ToString("f0") + "%";
                }

                if (text != "")
                {
                    text += "\n";
                }

                if (buff.regenHP > 0)
                {
                    float regenValue    = buff.regenHP;
                    float regenDuration = 1;
                    if (buff.regenHP < 1)
                    {
                        regenValue    = 1;
                        regenDuration = 1 / buff.regenHP;
                    }
                    text += "\nRegen " + regenValue.ToString("f0") + "HP every " + regenDuration.ToString("f0") + "s";
                }
            }

            return(text);
        }
コード例 #31
0
		public static bool TowerTargetHostile(UnitTower tower){
			_TowerType type=tower.type;
			if(type==_TowerType.Turret || type==_TowerType.AOE || type==_TowerType.Mine) return true;
			return false;
		}
コード例 #32
0
 public static void ShowIndicator(UnitTower tower)
 {
     instance.indicatorCursor.SetActive(true);
     instance.indicatorCursor.transform.position = tower.thisT.position;
     instance.indicatorCursor.transform.rotation = tower.thisT.rotation;
 }
コード例 #33
0
		public static bool TowerUseShootObjectT(UnitTower tower){
			_TowerType type=tower.type;
			if(type==_TowerType.AOE || type==_TowerType.Mine) return true;
			return false;
		}
コード例 #34
0
 //called when a tower building is initated in DragNDrop, use the sample tower as the model and set it in DragNDrop mode
 public static string BuildTowerDragNDrop(UnitTower tower)
 {
     return(instance._BuildTowerDragNDrop(tower));
 }
コード例 #35
0
        //called by any external component to build tower, uses buildInfo
        public static string BuildTower(UnitTower tower)
        {
            if (buildInfo == null)
            {
                return("Select a Build Point First");
            }

            UnitTower sampleTower = GetSampleTower(tower);

            /***/
            // check if there's energy reciving tower
            if (tower.electricityNeeded && !tower.electricityReciever && !tower.electricityFacility)
            {
                LayerMask maskTarget = 1 << LayerManager.LayerTower();

                Collider[] cols = Physics.OverlapSphere(buildInfo.position, 1000 /*GetRange()*/, maskTarget);

                if (cols.Length > 0)
                {
                    tower.electicitySources.Clear();
                    // find all electric facility
                    for (int i = 0; i < cols.Length; i++)
                    {
                        // if it's not electric reciever skip
                        if (!cols[i].gameObject.GetComponent <UnitTower>().electricityReciever)
                        {
                            continue;
                        }

                        //float test = cols[i].gameObject.GetComponent<UnitTower>().GetRange();
                        //float test2 = Vector3.Distance(cols[i].gameObject.GetComponent<UnitTower>().transform.position, buildInfo.position);

                        // if this tower is in range of electricityReciever
                        if (Vector3.Distance(cols[i].gameObject.GetComponent <UnitTower>().transform.position, buildInfo.position) <= cols[i].gameObject.GetComponent <UnitTower>().GetRange())
                        {
                            tower.electicitySources.Add(cols[i].gameObject.GetComponent <UnitTower>());
                        }
                    }

                    if (tower.electicitySources.Count == 0)
                    {
                        // set electricity source for tower weapon
                        return("There is not enough electricity");
                    }
                }
                else
                {
                    return("There is not enough electricity");
                }
            }
            /***/


            //check if there are sufficient resource
            List <int> cost     = sampleTower.GetCost();
            int        suffCost = ResourceManager.HasSufficientResource(cost);

            if (suffCost == -1)
            {
                ResourceManager.SpendResource(cost);

                GameObject towerObj      = (GameObject)Instantiate(tower.gameObject, buildInfo.position, buildInfo.platform.thisT.rotation);
                UnitTower  towerInstance = towerObj.GetComponent <UnitTower>();
                towerInstance.InitTower(instance.towerCount += 1, buildInfo.platform);
                towerInstance.Build();



                // if new electricity reciver is placed search for all towers in it's range and add itself as electricity source
                if (tower.electricityReciever)
                {
                    LayerMask maskTarget = 1 << LayerManager.LayerTower();

                    Collider[] cols = Physics.OverlapSphere(buildInfo.position, tower.GetRange(), maskTarget);

                    if (cols.Length > 0)
                    {
                        UnitTower tmp_tow;
                        for (int i = 0; i < cols.Length; i++)
                        {
                            tmp_tow = cols[i].gameObject.GetComponent <UnitTower>();

                            if (tmp_tow.electricityReciever || tmp_tow.electricityFacility)
                            {
                                continue;
                            }

                            tmp_tow.electicitySources.Add(towerInstance);
                        }
                    }
                }



                //clear the build info and indicator for build manager
                ClearBuildPoint();

                return("");
            }

            return("Insufficient Resource");
        }
コード例 #36
0
 public static bool InDragNDrop()
 {
     return(UseDragNDrop() && UnitTower.InDragNDrop());
 }
コード例 #37
0
ファイル: Unit.cs プロジェクト: mroslander/BoomBalls
 //Call by inherited class UnitTower, caching inherited UnitTower instance to this instance
 public void SetSubClass(UnitTower unit)
 {
     unitT=unit;
     subClass=_UnitSubClass.Tower;
     gameObject.layer=LayerManager.LayerTower();
 }
コード例 #38
0
 public static void ExitDragNDrop()
 {
     UnitTower.InDragNDrop();
 }
コード例 #39
0
ファイル: TDTK.cs プロジェクト: toooooooo/BEER
 public static void OnNewTower(UnitTower tower)
 {
     if (onNewTowerE != null) onNewTowerE(tower);
 }
コード例 #40
0
        public void AddNewSampleTower(UnitTower newTower)
        {
            UnitTower towerInstance = CreateSampleTower(newTower);

            sampleTowerList.Add(towerInstance);
        }
コード例 #41
0
ファイル: TDTK.cs プロジェクト: toooooooo/BEER
 public static void OnTowerConstructing(UnitTower tower)
 {
     if (onTowerConstructingE != null) onTowerConstructingE(tower);
 }
コード例 #42
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUI.changed = false;
            Undo.RecordObject(instance, "BuildManager");

            serializedObject.Update();

            EditorGUILayout.Space();


            srlPpt = serializedObject.FindProperty("buildMode");
            EditorGUI.BeginChangeCheck();

            cont  = new GUIContent("Build Mode:", "");
            contL = new GUIContent[buildModeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(buildModeLabel[i], buildModeTooltip[i]);
            }
            int type = EditorGUILayout.Popup(cont, srlPpt.enumValueIndex, contL);

            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.enumValueIndex = type;
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Grid Size:", "The grid size of the grid on the platform");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("gridSize"), cont);

            cont = new GUIContent("AutoAdjustTextureToGrid:", "Check to let the BuildManager reformat the texture tiling of the platform to fix the gridsize");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("autoAdjustTextureToGrid"), cont);


            EditorGUILayout.Space();

            cont = new GUIContent("DisableBuildInPlay:", "When checked, the player cannot build tower when there are active creep in the game");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("disableBuildWhenInPlay"), cont);

            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showTowerList = EditorGUILayout.Foldout(showTowerList, "Show Tower List");
            EditorGUILayout.EndHorizontal();
            if (showTowerList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableTowerIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailableTowerIDList = new List <int>();
                    for (int i = 0; i < towerDB.towerList.Count; i++)
                    {
                        if (towerDB.towerList[i].disableInBuildManager)
                        {
                            continue;
                        }
                        instance.unavailableTowerIDList.Add(towerDB.towerList[i].prefabID);
                    }
                }
                EditorGUILayout.EndHorizontal();

                int disableCount = 0;
                for (int i = 0; i < towerDB.towerList.Count; i++)
                {
                    UnitTower tower = towerDB.towerList[i];

                    if (tower.disableInBuildManager)
                    {
                        if (instance.unavailableTowerIDList.Contains(tower.prefabID))
                        {
                            instance.unavailableTowerIDList.Remove(tower.prefabID);
                        }
                        disableCount += 1;
                        continue;
                    }

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    TDEditor.DrawSprite(rect, tower.iconSprite, tower.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(tower.unitName, GUILayout.ExpandWidth(false));

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailableTowerIDList.Contains(tower.prefabID) ? true : false;
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the tower in this level"), flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailableTowerIDList.Contains(tower.prefabID))
                        {
                            instance.unavailableTowerIDList.Add(tower.prefabID);
                        }
                        else if (flag)
                        {
                            instance.unavailableTowerIDList.Remove(tower.prefabID);
                        }
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }

                if (disableCount > 0)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(" - " + disableCount + " Towers are disabled in BuildManager");
                }
            }


            EditorGUILayout.Space();
            EditorGUILayout.Space();


            if (GUILayout.Button("Open TowerEditor"))
            {
                UnitTowerEditorWindow.Init();
            }


            EditorGUILayout.Space();


            DefaultInspector();

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
コード例 #43
0
ファイル: TDTK.cs プロジェクト: toooooooo/BEER
 public static void OnTowerUpgraded(UnitTower tower)
 {
     if (onTowerUpgradedE != null) onTowerUpgradedE(tower);
 }
コード例 #44
0
ファイル: UITowerInfo.cs プロジェクト: tscheipel/BEER
 void OnTowerUpgraded(UnitTower tower)
 {
     Show(tower, true);
 }
コード例 #45
0
		IEnumerator _Building(UnitTower tower){
			Slider bar=GetUnusedBuildingBar();
			Transform barT=bar.transform;
			while(tower!=null && tower.IsInConstruction()){
				bar.value=tower.GetBuildProgress();
				
				if(mainCam==null){
					mainCam=Camera.main;
					continue;
				}
				
				Vector3 screenPos = mainCam.WorldToScreenPoint(tower.thisT.position+new Vector3(0, 0, 0));
				barT.localPosition=(screenPos+new Vector3(0, -20, 0))/UI.GetScaleFactor();
				bar.gameObject.SetActive(true);
				
				yield return null;
			}
			bar.gameObject.SetActive(false);
		}
コード例 #46
0
ファイル: UITowerInfo.cs プロジェクト: tscheipel/BEER
 public static void Show(UnitTower tower, bool showControl = false)
 {
     instance._Show(tower, showControl);
 }
コード例 #47
0
        public void _ClearSelectedTower()
        {
            selectedTower=null;

            rangeIndicatorObj.SetActive(false);
            rangeIndicator.parent=thisT;
        }
コード例 #48
0
ファイル: UnitTower.cs プロジェクト: Pringlez/Alien-Danger-TD
 public void SetAsSampleTower(UnitTower tower)
 {
     isSampleTower  = true;
     srcTower       = tower;
     thisT.position = new Vector3(0, 9999, 0);
 }
コード例 #49
0
		public static void ShowIndicator(UnitTower tower){
			instance.indicatorCursor.SetActive(true);
			instance.indicatorCursor.transform.position=tower.thisT.position;
			instance.indicatorCursor.transform.rotation=tower.thisT.rotation;
		}
コード例 #50
0
		public UnitTower CreateSampleTower(UnitTower towerPrefab){
			GameObject towerObj=(GameObject)Instantiate(towerPrefab.gameObject);
			
			towerObj.transform.parent=transform;
			if(towerObj.GetComponent<Collider>()!=null) Destroy(towerObj.GetComponent<Collider>());
			Utility.DestroyColliderRecursively(towerObj.transform);
			towerObj.SetActive(false);
			
			UnitTower towerInstance=towerObj.GetComponent<UnitTower>();
			towerInstance.SetAsSampleTower(towerPrefab);
			
			return towerInstance;
		}
コード例 #51
0
		public string _BuildTowerDragNDrop(UnitTower tower){
			
			UnitTower sampleTower=GetSampleTower(tower);
			List<int> cost=sampleTower.GetCost();
			
			int suffCost=ResourceManager.HasSufficientResource(cost);
			if(suffCost==-1){
				sampleTower.thisObj.SetActive(true);
				GameControl.SelectTower(sampleTower);
				UnitTower towerInstance=sampleTower;
				towerInstance.StartCoroutine(towerInstance.DragNDropRoutine());
				
				return "";
			}
			
			return "Insufficient Resource   "+suffCost;
		}
コード例 #52
0
 public static void AddNewTower(UnitTower newTower)
 {
     instance._AddNewTower(newTower);
 }
コード例 #53
0
		public void AddNewSampleTower(UnitTower newTower){
			UnitTower towerInstance=CreateSampleTower(newTower);
			sampleTowerList.Add(towerInstance);
		}
コード例 #54
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();

            cont = new GUIContent("Grid Object:", "The grid object to show when build tower");
            instance.gridBuild = (GameObject)EditorGUILayout.ObjectField(cont, instance.gridBuild, typeof(GameObject), true);

            cont = new GUIContent("Grid Size:", "The grid size of the grid on the platform");
            instance.gridSize = EditorGUILayout.FloatField(cont, instance.gridSize);

            cont = new GUIContent("AutoSearchForPlatform:", "Check to let the BuildManager automatically serach of all the build platform in game\nThis will override the BuildPlatform list");
            instance.autoSearchForPlatform = EditorGUILayout.Toggle(cont, instance.autoSearchForPlatform);

            cont = new GUIContent("AutoAdjustTextureToGrid:", "Check to let the BuildManager reformat the texture tiling of the platform to fix the gridsize");
            instance.AutoAdjustTextureToGrid = EditorGUILayout.Toggle(cont, instance.AutoAdjustTextureToGrid);

            EditorGUILayout.Space();

            if (GUILayout.Button("Enable All Towers On All Platforms") && !Application.isPlaying)
            {
                EnableAllToweronAllPlatform();
            }

            cont = new GUIContent("Build Platforms", "Build Platform in this level\nOnly applicable when AutoSearchForPlatform is unchecked");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPlatforms = EditorGUILayout.Foldout(showPlatforms, cont);
            EditorGUILayout.EndHorizontal();

            if (showPlatforms)
            {
                cont = new GUIContent("Build Platforms:", "The grid size of the grid on the platform");
                float listSize = instance.buildPlatforms.Count;
                listSize = EditorGUILayout.FloatField("    Size:", listSize);

                //if(!EditorGUIUtility.editingTextField && listSize!=instance.buildPlatforms.Count){
                if (listSize != instance.buildPlatforms.Count)
                {
                    while (instance.buildPlatforms.Count < listSize)
                    {
                        instance.buildPlatforms.Add(null);
                    }
                    while (instance.buildPlatforms.Count > listSize)
                    {
                        instance.buildPlatforms.RemoveAt(instance.buildPlatforms.Count - 1);
                    }
                }

                for (int i = 0; i < instance.buildPlatforms.Count; i++)
                {
                    instance.buildPlatforms[i] = (PlatformTD)EditorGUILayout.ObjectField("    Element " + i, instance.buildPlatforms[i], typeof(PlatformTD), true);
                }
            }


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showTowerList = EditorGUILayout.Foldout(showTowerList, "Show Tower List");
            EditorGUILayout.EndHorizontal();
            if (showTowerList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableTowerIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailableTowerIDList = new List <int>();
                    for (int i = 0; i < towerList.Count; i++)
                    {
                        instance.unavailableTowerIDList.Add(towerList[i].prefabID);
                    }
                }
                EditorGUILayout.EndHorizontal();

                //scrollPosition = GUILayout.BeginScrollView (scrollPosition);

                for (int i = 0; i < towerList.Count; i++)
                {
                    UnitTower tower = towerList[i];

                    if (tower.disableInBuildManager)
                    {
                        continue;
                    }

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, tower.iconSprite, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(tower.unitName, GUILayout.ExpandWidth(false));

                    bool flag = !instance.unavailableTowerIDList.Contains(tower.prefabID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                           //switch it around in runtime
                    }
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the tower in this level"), flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableTowerIDList.Remove(tower.prefabID);
                        }
                        else
                        {
                            if (!instance.unavailableTowerIDList.Contains(tower.prefabID))
                            {
                                instance.unavailableTowerIDList.Add(tower.prefabID);
                            }
                        }
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }

                //GUILayout.EndScrollView ();
            }

            EditorGUILayout.Space();

            int cursorMode = (int)instance.cursorIndicatorMode;

            cont     = new GUIContent("Tile Cursor Mode:", "The way to indicate a tile on a grid when it's currently being hovered on by the cursor");
            contList = new GUIContent[cursorIndModeLabel.Length];
            for (int i = 0; i < contList.Length; i++)
            {
                contList[i] = new GUIContent(cursorIndModeLabel[i], cursorIndModeTooltip[i]);
            }
            cursorMode = EditorGUILayout.Popup(cont, cursorMode, contList);
            instance.cursorIndicatorMode = (BuildManager._CursorIndicatorMode)cursorMode;

            EditorGUILayout.Space();



            if (GUILayout.Button("Open TowerEditor"))
            {
                UnitTowerEditorWindow.Init();
            }
            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
コード例 #55
0
		public static UnitTower GetSampleTower(UnitTower tower){
			for(int i=0; i<instance.sampleTowerList.Count; i++){
				if(instance.sampleTowerList[i].prefabID==tower.prefabID) return instance.sampleTowerList[i];
			}
			return null;
		}
コード例 #56
0
ファイル: GameControl.cs プロジェクト: tscheipel/BEER
 public static void SelectTower(UnitTower tower)
 {
     instance._SelectTower(tower);
 }