Ejemplo n.º 1
0
    // Use this for initialization
    new void Start()
    {
        base.Start();

        // Create Npc Icon grid
        for (int i = 0; i < 4; i++)
        {
            CSUI_NPCGrid npcGrid = Instantiate(m_NpcPart.m_Prefab) as CSUI_NPCGrid;
            npcGrid.transform.parent        = m_NpcPart.m_Root.transform;
            npcGrid.transform.localPosition = Vector3.zero;
            npcGrid.transform.localRotation = Quaternion.identity;
            npcGrid.transform.localScale    = Vector3.one;
            npcGrid.NpcIconRadio            = m_IconRadioRoot;
            npcGrid.m_UseDeletebutton       = false;
            UIEventListener.Get(npcGrid.gameObject).onActivate = m_DwelingsUI.OnNPCGridClick;
            m_NpcGirds.Add(npcGrid);
        }

        m_NpcPart.m_Root.repositionNow = true;

        // Set Npc
        for (int i = 0; i < m_NpcGirds.Count; i++)
        {
            if (i < m_Dwellings.m_NPCS.Length)
            {
                m_NpcGirds[i].m_Npc = m_Dwellings.m_NPCS[i];
            }
            else
            {
                m_NpcGirds[i].m_Npc = null;
            }
        }
    }
Ejemplo n.º 2
0
    //void OnNpcStateChangedListener (CSPersonnel csp, int prvState)
    //{
    //    if (ActiveNpcGrid == null || ActiveNpcGrid.m_Npc != csp)
    //        return;

    //    string npcName = csp.Name;
    //    string str = "The " + npcName;
    //    if (csp.State == CSConst.pstIdle)
    //        str += " is wandering aroud.";
    //    else if (csp.State == CSConst.pstPrepare)
    //        str += " is going to destination";
    //    else if (csp.State == CSConst.pstRest)
    //        str += " is resting, he will restore health.";
    //    else if (csp.State == CSConst.pstFollow)
    //        str += " is following you.";
    //    else if (csp.State == CSConst.pstDead)
    //        str += " died";
    //    else if (csp.State == CSConst.pstWork)
    //        str += " is working in the " + csp.WorkRoom.Name;
    //    else if (csp.State == CSConst.pstAtk)
    //        str += " is Fighting for the monster.";
    //    else
    //        str = "";

    //    CSUI_MainWndCtrl.ShowStatusBar(str);
    //}

    // NPC Grid DestroySelf
    void OnNPCGridDestroySelf(CSUI_NPCGrid grid)
    {
        if (grid != null && grid.m_Npc != null)
        {
            MessageBox_N.ShowYNBox(PELocalization.GetString(8000101), grid.m_Npc.KickOut);
        }
    }
Ejemplo n.º 3
0
    // CSUI_NPCGrid OnClick Event
    public void OnNPCGridClick(GameObject go, bool active)
    {
        if (!active)
        {
            return;
        }


        CSUI_NPCGrid npcGird = go.GetComponent <CSUI_NPCGrid>();

        m_ActiveNpc = npcGird.m_Npc;
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     // Create Npc Icon grid
     for (int i = 0; i < 4; i++)
     {
         CSUI_NPCGrid npcGrid = Instantiate(m_NpcPart.m_Prefab) as CSUI_NPCGrid;
         npcGrid.transform.parent        = m_NpcPart.m_Root.transform;
         npcGrid.transform.localPosition = Vector3.zero;
         npcGrid.transform.localRotation = Quaternion.identity;
         npcGrid.transform.localScale    = Vector3.one;
         npcGrid.NpcIconRadio            = m_NpcPart.m_Root.transform;
         m_NpcGirds.Add(npcGrid);
     }
     m_NpcPart.m_Root.repositionNow = true;
 }
Ejemplo n.º 5
0
    private CSUI_NPCGrid _createNPCGird(CSPersonnel npc, Transform root)
    {
        CSUI_NPCGrid npcGrid = Instantiate(m_NpcGridPrefab) as CSUI_NPCGrid;

        npcGrid.transform.parent = root;
        CSUtils.ResetLoacalTransform(npcGrid.transform);
        npcGrid.m_UseDeletebutton = true;
        npcGrid.OnDestroySelf     = OnNPCGridDestroySelf;

        npcGrid.m_Npc = npc;

        UICheckbox cb = npcGrid.gameObject.GetComponent <UICheckbox>();

        cb.radioButtonRoot = root;

        UIEventListener.Get(npcGrid.gameObject).onActivate = OnNPCGridActive;

        return(npcGrid);
    }
Ejemplo n.º 6
0
    // Add a NPC Grid in main UI
    public void AddPersonnel(CSPersonnel npc)
    {
        if (npc == null)
        {
            Debug.LogWarning("The giving npc is null.");
        }

        // Random Npc
        if (npc.IsRandomNpc)
        {
            CSUI_NPCGrid npcGrid = _createNPCGird(npc, m_OtherRootUI.transform);
            m_OtherRootUI.repositionNow = true;
            m_OtherGrids.Add(npcGrid);
        }
        // Main Line Npc
        else
        {
            CSUI_NPCGrid npcGrid = _createNPCGird(npc, m_MainLineRootUI.transform);
            m_MainLineRootUI.repositionNow = true;
            m_MainLineGrids.Add(npcGrid);
        }
        GridRange();
    }
Ejemplo n.º 7
0
    void _refreshNPCGrids()
    {
        if (CSUI_MainWndCtrl.Instance == null)
        {
            return;
        }

        mGridPageIndex = 0;


        List <CSUI_NPCGrid> npc_grids_list = null;

        if (Type == TypeEnu.Other)
        {
            npc_grids_list = m_OtherGrids;
            m_OtherRootUI.gameObject.transform.localPosition = Vector3.zero;
            m_OtherRootUI.repositionNow = true;
        }
        else
        {
            npc_grids_list = m_MainLineGrids;
            m_MainLineRootUI.gameObject.transform.localPosition = Vector3.zero;
            m_MainLineRootUI.repositionNow = true;
        }

        CSPersonnel[] npcs = CSUI_MainWndCtrl.Instance.Creator.GetNpcs();

        int Len = 0;

        if (m_NPCType == ENPCGridType.All)
        {
            for (int i = 0; i < npcs.Length; ++i)
            {
                if (Type == TypeEnu.Other && npcs[i].IsRandomNpc)
                {
                    // Already has a CSUI_NPCGrid? just replace the npc reference!
                    if (Len < npc_grids_list.Count)
                    {
                        npc_grids_list[Len].m_Npc = npcs[i];
                    }
                    else
                    {
                        CSUI_NPCGrid npcGrid = _createNPCGird(npcs[i], m_OtherRootUI.transform);
                        npc_grids_list.Add(npcGrid);
                    }

                    Len++;
                }
                else if (Type == TypeEnu.MainLine && !npcs[i].IsRandomNpc)
                {
                    // Already has a CSUI_NPCGrid? just replace the npc reference!
                    if (Len < npc_grids_list.Count)
                    {
                        npc_grids_list[Len].m_Npc = npcs[i];
                    }
                    else
                    {
                        CSUI_NPCGrid npcGrid = _createNPCGird(npcs[i], m_MainLineRootUI.transform);
                        npc_grids_list.Add(npcGrid);
                    }

                    Len++;
                }
            }
        }
        else
        {
            for (int i = 0; i < npcs.Length; ++i)
            {
                if ((int)m_NPCType == npcs[i].Occupation)
                {
                    if (Type == TypeEnu.Other && npcs[i].IsRandomNpc)
                    {
                        // Already has a CSUI_NPCGrid? just replace the npc reference!
                        if (Len < npc_grids_list.Count)
                        {
                            npc_grids_list[Len].m_Npc = npcs[i];
                        }
                        else
                        {
                            CSUI_NPCGrid npcGrid = _createNPCGird(npcs[i], m_OtherRootUI.transform);
                            npc_grids_list.Add(npcGrid);
                        }

                        Len++;
                    }
                    else if (Type == TypeEnu.MainLine && !npcs[i].IsRandomNpc)
                    {
                        // Already has a CSUI_NPCGrid? just replace the npc reference!
                        if (Len < npc_grids_list.Count)
                        {
                            npc_grids_list[Len].m_Npc = npcs[i];
                        }
                        else
                        {
                            CSUI_NPCGrid npcGrid = _createNPCGird(npcs[i], m_MainLineRootUI.transform);
                            npc_grids_list.Add(npcGrid);
                        }

                        Len++;
                    }
                }
            }
        }

        // Has redundant grid? just destroy it
        if (Len < npc_grids_list.Count)
        {
            for (int i = Len; i < npc_grids_list.Count;)
            {
                DestroyImmediate(npc_grids_list[i].gameObject);
                npc_grids_list.RemoveAt(i);
            }
        }

        if (npc_grids_list.Count != 0)
        {
            npc_grids_list[0].gameObject.GetComponent <UICheckbox>().isChecked = true;
            OnNPCGridActive(npc_grids_list[0].gameObject, true);
        }
        else
        {
            ActiveNpcGrid = null;
        }
    }