當前位置: 首頁>>代碼示例>>C#>>正文


C# TDTK.UnitTower類代碼示例

本文整理匯總了C#中TDTK.UnitTower的典型用法代碼示例。如果您正苦於以下問題:C# UnitTower類的具體用法?C# UnitTower怎麽用?C# UnitTower使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UnitTower類屬於TDTK命名空間,在下文中一共展示了UnitTower類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildTower

        //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";
        }
開發者ID:Pringlez,項目名稱:Alien-Danger-TD,代碼行數:26,代碼來源:BuildManager.cs

示例2: BuildTower

        //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";
        }
開發者ID:mroslander,項目名稱:BoomBalls,代碼行數:34,代碼來源:BuildManager.cs

示例3: AddNewTower

 public static void AddNewTower(UnitTower newTower)
 {
     if (instance.towerList.Contains(newTower)) return;
       instance.towerList.Add(newTower);
       instance.AddNewSampleTower(newTower);
       if (onAddNewTowerE != null) onAddNewTowerE(newTower);
 }
開發者ID:toooooooo,項目名稱:BEER,代碼行數:7,代碼來源:BuildManager.cs

示例4: _AddNewTower

		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);
		}
開發者ID:ahvdesign,項目名稱:Tower-Defense-Q,代碼行數:9,代碼來源:UIBuildButton.cs

示例5: Start

    // 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>();
    }
開發者ID:toooooooo,項目名稱:BEER,代碼行數:12,代碼來源:TowerHighlighter.cs

示例6: BuildTower

        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);
            }
        }
開發者ID:Yaroslavich,項目名稱:Scripts,代碼行數:21,代碼來源:PlatformTD.cs

示例7: OnTowerUpgraded

 public static void OnTowerUpgraded(UnitTower tower)
 {
     if (onTowerUpgradedE != null) onTowerUpgradedE(tower);
 }
開發者ID:toooooooo,項目名稱:BEER,代碼行數:4,代碼來源:TDTK.cs

示例8: OnTowerSold

 public static void OnTowerSold(UnitTower tower)
 {
     if (onTowerSoldE != null) onTowerSoldE(tower);
 }
開發者ID:toooooooo,項目名稱:BEER,代碼行數:4,代碼來源:TDTK.cs

示例9: CreateSampleTower

		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;
		}
開發者ID:jrobison93,項目名稱:Museum-of-Aviation-Exhibit,代碼行數:13,代碼來源:BuildManager.cs

示例10: PreBuildTower

		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);
		}
開發者ID:jrobison93,項目名稱:Museum-of-Aviation-Exhibit,代碼行數:15,代碼來源:BuildManager.cs

示例11: BuildTowerDragNDrop

		//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); }
開發者ID:jrobison93,項目名稱:Museum-of-Aviation-Exhibit,代碼行數:2,代碼來源:BuildManager.cs

示例12: _SelectTower

        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);
            }
        }
開發者ID:Pringlez,項目名稱:Alien-Danger-TD,代碼行數:18,代碼來源:GameControl.cs

示例13: SelectTower

 public static void SelectTower(UnitTower tower)
 {
     instance._SelectTower(tower);
 }
開發者ID:Pringlez,項目名稱:Alien-Danger-TD,代碼行數:4,代碼來源:GameControl.cs

示例14: Building

		public static void Building(UnitTower tower){ instance.StartCoroutine(instance._Building(tower)); }
開發者ID:ahvdesign,項目名稱:Tower-Defense-Q,代碼行數:1,代碼來源:UIOverlay.cs

示例15: UpdatePathMaps

        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;
        }
開發者ID:toooooooo,項目名稱:BEER,代碼行數:80,代碼來源:BuildManager.cs


注:本文中的TDTK.UnitTower類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。