当前位置: 首页>>代码示例>>C#>>正文


C# Building.GetComponent方法代码示例

本文整理汇总了C#中Building.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Building.GetComponent方法的具体用法?C# Building.GetComponent怎么用?C# Building.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Building的用法示例。


在下文中一共展示了Building.GetComponent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssignBuildingProject

    public override void AssignBuildingProject(Building newProject)
    {
        building = (newProject != null);
        currentProject = newProject;

        // Move to unit to the object to build
        if (newProject != null) {
            SetNewPath (newProject.GetComponent<Collider> ().ClosestPointOnBounds (transform.position), false);
        }
    }
开发者ID:jgirald,项目名称:ES2015C,代码行数:10,代码来源:CivilUnit.cs

示例2: Awake

	void Awake ()
	{
		image.sprite = sprite_built;

		image.transform.localScale = Vector3.one;

		my_building_prefab = root.InstantiateChild<Building> (generic_building_prefab);
		my_building_prefab.definition = definition;
		my_building_prefab.GetComponent<SpriteRenderer> ().sprite = sprite_built;
		my_building_prefab.gameObject.SetActive (false);
	}
开发者ID:louisgv,项目名称:QuackHack2016,代码行数:11,代码来源:TowerShopItem.cs

示例3: StartProduce

    public void StartProduce(Building building)
    {
        building.InConstruction.SubtractMilliseconds(((GlobalTimer)building.subject).RefreshTime);

        Timer.setTime(building.InConstruction.span);

        if(building.InConstruction.span.TotalSeconds <= 0 )
        {
            building.GetComponent<MoveTimerText>().Remove();
            building.iProduce = building.GetDefaultProduce();
            building.InConstruction.active = false;
            building.DefaultInitialize();
            Debug.Log(building.gameObject.name + " Koniec produkcij");

        }
    }
开发者ID:Lukasz199312,项目名称:ClickCraft,代码行数:16,代码来源:ConstructionProduce.cs

示例4: CreateBuilding

    //Puts the building to be created to the building property of the building placement class
    public void CreateBuilding(Building g,string buildingName)
    {
        //Cancel the selection of building
        selection.cancel(true);
        switch (buildingName) {
        case "Barracks":

            buildingConstructed = ((Barracks)Instantiate (g, transform.position,transform.rotation));
            break;
        case "Question":

            buildingConstructed = ((QuestionBuilding)Instantiate (g, transform.position,transform.rotation));
            break;
        case "Archery":

            buildingConstructed = ((Archery)Instantiate (g, transform.position,transform.rotation));
            break;
        case "Research":

            buildingConstructed = ((ResearchBuilding)Instantiate (g, transform.position,transform.rotation));
            break;
        case "Tower":

            buildingConstructed = ((Tower)Instantiate (g, transform.position,transform.rotation));
            break;
        default:
            break;

        }

        //We need to assign the transparent sprite which will be displayed as during the construction process
        //together with the original sprite and invalid sprite
        original = Resources.Load (buildingName,typeof(Sprite)) as Sprite;

        //Put the transparent template by changing the material
        originalRender = buildingConstructed.GetComponent<SpriteRenderer>();
        originalRender.sprite = original;
        originalRender.color = Color.gray;

        //Disable collider to have full transparent construction
        buildingConstructed.gameObject.GetComponent<BoxCollider2D>().enabled = false;
        //Change the layer mask to default as it is not a obstacle yet!
        buildingConstructed.gameObject.layer = 0;
    }
开发者ID:Rakosi,项目名称:CodeNConquer,代码行数:45,代码来源:BuildingPlacement.cs

示例5: CreateBuildingIA

 public void CreateBuildingIA(GameObject building, Vector3 coords)
 {
     creationBuilding = (GameObject)Instantiate (building, coords, Quaternion.identity);
     creationBuildingConstruction = (GameObject)Instantiate (building, coords, Quaternion.identity);
     creationBuildingConstruction.SetActive (false);
     float wood = owner.GetResourceAmount (RTSObject.ResourceType.Wood);
     if (wood >= creationBuildingConstruction.GetComponent<Building> ().cost) {
         Debug.Log ("Tenemos suficiente madera");
         creationBuildingConstruction.SetActive (true);
         currentProject = creationBuildingConstruction.GetComponent<Building> ();
         currentProject.hitPoints = 0;
         currentProject.needsBuilding = true;
         currentProject.owner = owner;
         var guo = new GraphUpdateObject (currentProject.GetComponent<BoxCollider> ().bounds);
         guo.updatePhysics = true;
         AstarPath.active.UpdateGraphs (guo);
         owner.resourceAmounts [RTSObject.ResourceType.Wood] -= currentProject.cost;
         SetNewPath (coords, false);
     }
 }
开发者ID:jgirald,项目名称:ES2015C,代码行数:20,代码来源:CivilUnit.cs

示例6: CreateBuilding

    public void CreateBuilding(string buildingName, Vector3 buildPoint, Unit creator)
    {
        if (tempBuilding)
            if (!tempBuilding.UnderConstruction() && !tempBuilding.Constructed())
                Destroy(tempBuilding.gameObject);

        GameObject newBuilding = (GameObject)Instantiate(ResourceManager.GetBuilding(buildingName), buildPoint, new Quaternion());
        tempBuilding = newBuilding.GetComponent< Building >();
        if (tempBuilding) {
            tempBuilding.ObjectId = ResourceManager.GetNewObjectId();
        /*			tempBuilding.SetPlayer(this);*/
            tempBuilding.name = tempBuilding.name.Substring(0,tempBuilding.name.IndexOf("("));
            tempBuilding.name = tempBuilding.name.Trim();
            tempCreator = creator;
            findingPlacement = true;
            tempBuilding.SetTransparentMaterial(notAllowedMaterial, true);
            tempBuilding.GetComponent<NavMeshObstacle>().enabled = false;
        } else Destroy(newBuilding);
    }
开发者ID:sentonnes,项目名称:RTS-Framework,代码行数:19,代码来源:Player.cs

示例7: PlaceBuilding

    /**
     * Places a building on the given tile
     */
    public void PlaceBuilding(Building prefab, Tile tile, bool created)
    {
        // Exit if supplied tile is null
        if (tile == null) {
            Debug.LogError("Cannot place building because tile is null");
            return;
        }
        else {
            prefab.created = created;
            Building newBuilding = tile.PlaceBuilding (prefab);

            if (newBuilding != null) {
                if (created){
                    newBuilding.ConstructionAnimation ();
                    SoundManager.soundManager.playConstruction();
                }

                // Sets the new building's parent to our convenience object
                newBuilding.transform.SetParent(buildings.transform);
                alreadyPlacedDownBuildings.Add(BuildingPanel.SubstringBuilding(prefab.name));

                // TODO this feels pretty iffy
                if ( !isTileTaken(tile.index)) {

                    SaveState.state.addBuilding(tile.index, newBuilding);

                    if (prefab.GetComponent<ResidenceBuilding>() == null)
                    {

                    }

                }

                GameManager.gameManager.SpawnPoofs();
            } else {
                Debug.Log("You cannot afford this building");
                return;
            }
        }
    }
开发者ID:,项目名称:,代码行数:43,代码来源:

示例8: MakeButton

    /**
     * Generates a button
     */
    public Button MakeButton(string path, Vector3 position, Building b, int index)
    {
        // Build new game object and attach components
        GameObject go = new GameObject();
        Button button = go.AddComponent<Button>();
        Image image = go.AddComponent<Image>();
        ButtonDragScript bds = go.AddComponent<ButtonDragScript>();

        // Attach a text object to the button
        Image buildingInfo = Instantiate(PrefabManager.prefabManager.buildingInfo);
        buildingInfo.transform.SetParent(go.transform);
        buildingInfo.rectTransform.localPosition = new Vector3(0, 40, 0);

        Text text = buildingInfo.GetComponentInChildren<Text>();
        text.text = b.name;
        text.font = (Font)Resources.Load("Font/Candara");
        text.color = Color.black;

        // Attach a cost object to the object
        buildingInfo = Instantiate(PrefabManager.prefabManager.buildingInfo);
        buildingInfo.transform.SetParent(go.transform);
        buildingInfo.rectTransform.localPosition = new Vector3(0, -40, 0);
        Text textCost = buildingInfo.GetComponentInChildren<Text>();
        ResourceBuildingInformation rbi;
        DecorationBuildingInformation dbi;
        if (SaveState.state.buildingInformationManager.ResourceBuildingInformationDict.TryGetValue(b.name, out rbi))
        {
            buildingCostsResource[index,0] = rbi.FireCost;
            buildingCostsResource[index,1] = rbi.WaterCost;
            buildingCostsResource[index,2] = rbi.AirCost;
            buildingCostsResource[index,3] = rbi.EarthCost;
            buildingCostResourceCount++;
        }
        else if (SaveState.state.buildingInformationManager.DecorationBuildingInformationDict.TryGetValue(b.name, out dbi))
        {
            buildingCostsDecorative[index, 0] = dbi.FireCost;
            buildingCostsDecorative[index, 1] = dbi.WaterCost;
            buildingCostsDecorative[index, 2] = dbi.AirCost;
            buildingCostsDecorative[index, 3] = dbi.EarthCost;
            buildingCostDecorativeCount++;
        }
        textCost.font = (Font)Resources.Load("Font/Candara");
        textCost.color = Color.black;

        // Set the name and parent of the game object
        go.transform.SetParent(this.transform.Find(path));
        go.name = b.name;

        // Rect Transform stuff
        button.GetComponent<RectTransform>().sizeDelta = new Vector2(90, 70);

        // Image component stuff
        SpriteRenderer sr = b.GetComponent<SpriteRenderer>();
        image.sprite = sr.sprite;

        button.transform.position = position;
        bds.building = b;
        return button;
    }
开发者ID:,项目名称:,代码行数:62,代码来源:


注:本文中的Building.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。