public override void OnInit()
    {
        base.OnInit();

        m_ColorList = new List <ColorItem>();
        for (int i = 0; i < 5; ++i)
        {
            ColorItem elem = new ColorItem();
            elem.obj = FindChild("Sprite_Color" + (i));
            UIEventListener.Get(elem.obj).onClick = OnDropEnd;
            var texture = ComponentTool.FindChildComponent <UITexture>("Sprite_Color", elem.obj);
            elem.color = texture.color;

            m_ColorList.Add(elem);
        }

        m_FireworkPlanList = new List <FireworkPlanElement>();
        for (int i = 0; i < 7; ++i)
        {
            var objRoot = FindChild("Type_" + i);
            FireworkPlanElement elem = new FireworkPlanElement(objRoot);
            elem.SetStatus(true, ItemManager.Instance.IsExistItem(i));
            m_FireworkPlanList.Add(elem);
            UIEventListener.Get(objRoot).onClick = OnClickFire;;
        }

        m_ColorPanel = FindChildComponent <UISprite>("Sprite_ColorPanel");
        m_BlockBg    = FindChild("BlockBg");
        AddChildElementClickEvent(OnClickExit, "Button_Exit");
    }
    virtual public void Initialize(Ilife lifeData, string resourcePath, AssetType resourceType)
    {
        m_LifeData    = lifeData;
        m_iInstanceId = lifeData.GetInstanceId();

        m_ObjectInstance = GameObject.Instantiate(ResourceManager.Instance.LoadBuildInResource <GameObject>(resourcePath, resourceType));

        //load material
        string localpath = resourcePath.Substring(0, resourcePath.LastIndexOf('/'));

        m_NormalMaterial    = ResourceManager.Instance.LoadBuildInResource <Material>(localpath + "/Normal", AssetType.Char);
        m_HighlightMaterial = ResourceManager.Instance.LoadBuildInResource <Material>(localpath + "/SelectedHighlight", AssetType.Char);
        m_MeshRender        = ComponentTool.FindChildComponent <SkinnedMeshRenderer>("Body", m_ObjectInstance);
        if (null == m_NormalMaterial || null == m_HighlightMaterial || null == m_MeshRender)
        {
            Debuger.LogWarning("can't load mesh render or normal&highlight materials !");
        }

        //mark transform
        m_CharContainer = m_ObjectInstance.AddComponent <CharTransformContainer>();
        m_CharContainer.Initialize(lifeData.GetInstanceId(), lifeData);

        if (null == m_ObjectInstance)
        {
            Debuger.LogError("Can't load resource " + resourcePath);
        }
        m_AnimatorAgent = new AnimatorAgent(m_ObjectInstance);
    }
Beispiel #3
0
    public void Initialize()
    {
        UIWindowCameraRoot = ComponentTool.FindChild("UI_Root", null);
        if (null == UIWindowCameraRoot)
        {
            Debuger.LogError("can't load ui root ");
            return;
        }

        m_UIRoot              = UIWindowCameraRoot.GetComponent <UIRoot>();
        m_UICamera            = ComponentTool.FindChildComponent <Camera>("Camera", UIWindowCameraRoot);
        m_UpdateStore         = new List <Action>();
        m_RemoveingUpdateList = new List <Action>();
        m_bIsUpdateListBusy   = false;
        m_WindowStore         = new Dictionary <int, WindowBase>();
        m_WindowIndexStore    = new Dictionary <int, WindowIndexStruct>();
        m_LayerIndexStore     = new Dictionary <WindowLayer, LayerInfo>();
        m_ActivedWindowQueue  = new Dictionary <WindowLayer, List <WindowBase> >();

        m_LayerIndexStore.Add(WindowLayer.Window, new LayerInfo(0, 20, ComponentTool.FindChild("LayerWindow", UIWindowCameraRoot)));
        m_LayerIndexStore.Add(WindowLayer.Tip, new LayerInfo(21, 40, ComponentTool.FindChild("LayerTip", UIWindowCameraRoot)));

        //register window
        Definer.RegisterWindow();
        m_bIsOnUpdateStore = false;
    }
Beispiel #4
0
    public AIDebugerTreeNode(string name, GameObject template)
    {
        m_bIsRuntime = UIWindow_BTViewPanel.GetInstance == null;
        m_strName    = name;
        m_ChildList  = new List <AIDebugerTreeNode>();
        m_ObjRoot    = GameObject.Instantiate(template);
        m_ObjRoot.SetActive(true);

        m_ObjChildRoot   = ComponentTool.FindChild("Root", m_ObjRoot);
        m_LabelName      = ComponentTool.FindChildComponent <UILabel>("Label", m_ObjRoot);
        m_LabelName.text = name;
        if (!m_bIsRuntime)
        {
            UIEventListener.Get(m_ObjRoot).onDoubleClick = UIWindow_BTViewPanel.GetInstance.OnDoubleClick;
            UIEventListener.Get(m_ObjRoot).onClick       = UIWindow_BTViewPanel.GetInstance.OnClick;
        }
    }
        private void ReLoadScene()
        {
            if (!m_bIsResetByUI)
            {
                m_CurrentConfig = m_DiffMgr.GetDifficulty();
            }
            m_bIsResetByUI = false;

            m_ElementList = new List <PilesElement>();
            for (int i = 0; i < m_CurrentConfig.OptionList.Count; ++i)
            {
                string     name = m_CurrentConfig.OptionList[i].Name;
                GameObject elem = GameObject.Instantiate(m_ElementTemplate);
                elem.name = i.ToString();
                MeshRenderer renderer     = ComponentTool.FindChildComponent <MeshRenderer>("Option", elem);
                Material     elemMaterial =
                    new Material(ResourceManager.Instance.LoadBuildInResource <Material>("Piles/PilesMaterial",
                                                                                         AssetType.Materials));
                if (m_CurrentConfig.OptionList[i].IsVisable)
                {
                    elemMaterial.mainTexture = ResourceManager.Instance.LoadBuildInResource <Texture2D>(name,
                                                                                                        AssetType.Texture);
                }
                else
                {
                    elemMaterial.mainTexture = ResourceManager.Instance.LoadBuildInResource <Texture2D>(m_strEmptyTextureName,
                                                                                                        AssetType.Texture);
                }
                renderer.material = elemMaterial;
                elem.SetActive(true);
                m_ElementList.Add(new PilesElement(renderer.gameObject, elem, name, elemMaterial, m_CurrentConfig.OptionList[i].IsVisable));
                ComponentTool.Attach(m_ObjRoot.transform, elem.transform);
            }
            m_Grid = m_ObjRoot.GetComponent <RegularityGame.SimpleUIGrid>();
            m_Grid.Reposition();
            FixPosition();

            m_bIsInit = true;
        }
    public void ResetWindow(Regularity2DWindowParam param)
    {
        ClearWindow();

        for (int i = 0; i < param.m_PilesList.Count; ++i)
        {
            var          data = param.m_PilesList[i];
            PilesElement elem = new PilesElement();
            elem.m_RootObj = GameObject.Instantiate(m_PilesTemplate);
            elem.m_RootObj.transform.parent = m_PilesRoot.transform;
            elem.m_bIsVisable            = data.IsVisable;
            elem.m_SpriteItem            = ComponentTool.FindChildComponent <UISprite>("Sprite_Option", elem.m_RootObj);
            elem.m_SpriteItem.spriteName = elem.m_bIsVisable ? data.Name : "";
            elem.m_strName = data.Name;
            elem.m_RootObj.SetActive(true);
            elem.m_RootObj.transform.localScale = Vector3.one;
            m_PilesList.Add(elem);
        }

        for (int i = 0; i < param.m_OptionList.Count; ++i)
        {
            var           data = param.m_OptionList[i];
            OptionElement elem = new OptionElement();
            elem.m_RootObj = GameObject.Instantiate(m_OptionTemplate);
            elem.m_RootObj.transform.parent = m_OptionRoot.transform;
            elem.m_SpriteItem            = ComponentTool.FindChildComponent <UISprite>("Sprite_Option", elem.m_RootObj);
            elem.m_SpriteItem.spriteName = data;
            elem.m_RootObj.GetComponent <MyUIDragDropItem>().RegisterDragEndAction(OnDragEnd);
            elem.m_strName = data;
            elem.m_RootObj.SetActive(true);
            elem.m_RootObj.transform.localScale = Vector3.one;
            m_OptionList.Add(elem);
        }
        m_ResultCallBack = param.m_ResultCallBack;

        m_OptionRoot.repositionNow = true;
        m_PilesRoot.repositionNow  = true;
    }
Beispiel #7
0
 protected T FindChildComponent <T>(string childName) where T : Component
 {
     return(ComponentTool.FindChildComponent <T>(childName, m_ObjectRoot));
 }