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


C# PlayerStats.GetComponent方法代码示例

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


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

示例1: SetPlayerStats

 /// <summary>
 /// Tie this HUD to a player's PlayerStats.cs script to visualize the correct player
 /// </summary>
 /// <param name="playerStats"></param>
 public void SetPlayerStats(PlayerStats playerStats)
 {
     ps = playerStats;
     pl = playerStats.GetComponent<PlayerLogic>();
     playerNameText.text = "";
     pl.CmdWhatNumberAmI();
     // Turn off world-space healthBar
     ps.GetComponentInChildren<Canvas>().enabled = false;
     #region Abilities
     try {
         ability1.sprite = ps.abilities[0].Icon;
         actionBar.GetComponentsInChildren<Image>()[0].sprite = ps.abilities[0].Icon;
         ability2.sprite = ps.abilities[1].Icon;
         actionBar.GetComponentsInChildren<Image>()[2].sprite = ps.abilities[1].Icon;
         ability3.sprite = ps.abilities[2].Icon;
         actionBar.GetComponentsInChildren<Image>()[4].sprite = ps.abilities[2].Icon;
         SetTooltips();
     } catch { Debug.Log("Actionbar (automatic) setup for abilities failed.."); }
     #endregion
     #region Inventory
     //Activate Inventory GO
     inventory.gameObject.SetActive(true);
     //Set count status text
     inventory.transform.FindChild("Banana").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().bananaCount;
     inventory.transform.FindChild("Stick").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("Sap").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("Leaf").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("BerryR").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryRCount;
     inventory.transform.FindChild("BerryG").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryGCount;
     inventory.transform.FindChild("BerryB").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryBCount;
     #endregion
     // TODO: Do stuff with setting up correct ability images
     SetCursorState(true);
     if (miniMap) foreach (MinimapBlip mmb in miniMap.GetComponentsInChildren<MinimapBlip>()) Destroy(mmb.gameObject); //Removes previous icons if players reconnect (important when they swap teams)
     SetupMiniMap(playerStats.transform);
 }
开发者ID:PeWiNi,项目名称:MonguinsAndBeyond,代码行数:40,代码来源:HUDScript.cs

示例2: saveGame

    void saveGame()
    {
        Debug.Log ("sauvegarde ...");
        GameObject player = GameObject.FindGameObjectWithTag("Player");
        Debug.Log ("recuperation player ...");

        ps = player.GetComponent<PlayerStats> ();
        Debug.Log (ps);

        Debug.Log ("sauvegarde de l'inventaire...");
        Debug.Log ("recuperation de la liste d'item dans l'inventaire...");
        List<Item> listItemInInv = ps.GetComponent<PlayerInventory> ().getMainInventory ().getItemsInInventory();
        Debug.Log ("recuperation des Id d'item dans l'inventaire...");
        List<int> idItem = new List<int>();
        for (int i = 0; i < listItemInInv.Count; i++) {
            idItem.Add(listItemInInv[i].getIdItem()) ;
        }
        Debug.Log ("sauvegarde des Id d'item dans le playersPrefs...");
        for (int i = 0; i < 16; i++) {
            PlayerPrefs.SetInt("inv_item_"+i,0) ;
        }
        for (int i = 0; i < idItem.Count; i++) {
            PlayerPrefs.SetInt("inv_item_"+i,idItem[i]) ;
        }

        Debug.Log ("sauvegarde des caractéristiques...");

        PlayerPrefs.SetInt("money",ps.getMoney()) ;
        PlayerPrefs.SetInt("exp",ps.getExp() ) ;
        PlayerPrefs.SetInt("level", ps.getLevel()) ;

        // sauvegarde des caractéristiques ;
        PlayerPrefs.SetInt("force", ps.getForce()) ;
        PlayerPrefs.SetInt("endurance" , ps.getEndurance()) ;
        PlayerPrefs.SetInt("intelligence", ps.getIntelligence() ) ;
        PlayerPrefs.SetInt("agilite", ps.getAgilite()) ;
        PlayerPrefs.SetInt("charisme", ps.getCharisme()) ;

        PlayerPrefs.SetInt ("level", Application.loadedLevel);
        Debug.Log ("sauvegarde terminé !");
    }
开发者ID:BoisArnaud,项目名称:Assets,代码行数:41,代码来源:Menu.cs


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