Example #1
0
    // Use this for initialization
    void Start()
    {
        backButton     = transform.Find("BackButton").GetComponent <Button>();
        heroItemParent = transform.Find("HeroScrollView/Grid").transform;
        selfHeroItem   = transform.Find("HeroItem").GetComponent <HeroItemUI>();
        backButton.onClick.AddListener(OnBackEvent);

        heroItemList = new List <HeroItemUI>();

        AddHeroItem();

        selfHeroItem.SetData(BattleMgr.Instance.selfPlayerController.heroData.Username, BattleMgr.Instance.selfPlayerController.heroData.NickName,
                             BattleMgr.Instance.selfPlayerController.heroData.Hp, BattleMgr.Instance.selfPlayerController.heroData.KillCount, 0);

        //GameObject hud = Instantiate(Resources.Load("Prefabs/UI/HeroHud")) as GameObject;
        //hud.transform.SetParent(BattleMgr.Instance.selfPlayerController.transform, false);
        //hud.GetComponent<HeroHudUI>().SetData(BattleMgr.Instance.selfPlayerController.heroData.Username, BattleMgr.Instance.selfPlayerController.heroData.NickName,
        //    BattleMgr.Instance.selfPlayerController.heroData.Hp);

        MessageMediator.AddListener <string>(MessageMediatType.AddPlayer, AddOneHeroItem);
        MessageMediator.AddListener <string>(MessageMediatType.RemovePlayer, RemoveOnHeroItem);
    }