public void reloadUI() {
            if(_table == null) {
                return;
            }
            double currentMoneyOfTable = 0;
            foreach(KeyValuePair<int, Order> entry in OrderManager.getInstance().OrderList) {
                if(entry.Value != null
                    && entry.Value.TableId == _table.TableId
                    && (entry.Value.MoneyReceive < entry.Value.BillMoney || entry.Value.BillMoney == 0)) {
                    currentMoneyOfTable += (double)(entry.Value.BillMoney - entry.Value.MoneyReceive);
                }
            }
            TextBlockTableId.Text = "Bàn số " + _table.TableId.ToString();
            if (currentMoneyOfTable > 0) {
                ImageState.Source = (ImageSource)GridParent.FindResource("ImageGreenDot");

                TextBlockState.Text = "Đang sử dụng";
                TextBlockState.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF18FA00"));

                TextBlockMoney.Text = UtilFuction.formatMoney((decimal)currentMoneyOfTable) + " VND";
            } else {
                ImageState.Source = (ImageSource)GridParent.FindResource("ImageGrayDot");

                TextBlockState.Text = "Chưa sử dụng";
                TextBlockState.Foreground = new SolidColorBrush(Colors.White);

                TextBlockMoney.Text = "Mở bàn";
            }
        }
    // Use this for initialization
    void Start()
    {
        Player1 = GameObject.Find("Player1");
        Player2 = GameObject.Find("Player2");

        MenuUI = GameObject.Find("Menu UI");

        Grid_P2 = GameObject.Find("GridParent P2").GetComponent <GridParent>();
        //flip grid parent 2, so that the column orientation is the same as grid p1
        Grid_P2.transform.rotation = Quaternion.Euler(0f, 180f, 0f);

        Grid_P1 = GameObject.Find("GridParent P1").GetComponent <GridParent>();

        phase_text       = GameObject.Find("Phase").GetComponent <Text>();
        player_turn_text = GameObject.Find("Turn").GetComponent <Text>();
        turn_number_text = GameObject.Find("Turn number").GetComponent <Text>();

        DraftP1 = GameObject.Find("DraftP1").transform;
        DraftP2 = GameObject.Find("DraftP2").transform;

        DraftUI         = GameObject.Find("Draft UI");
        P1_drafted      = DraftUI.transform.Find("P1 drafted").GetComponent <Text>();
        P2_drafted      = DraftUI.transform.Find("P2 drafted").GetComponent <Text>();
        hero_info_panel = GameObject.Find("Hero Info Panel").transform;

        hero_name = hero_info_panel.Find("Hero_name").GetComponent <Text>();
        hero_hp   = hero_info_panel.Find("HP_value").GetComponent <Text>();
        hero_dmg  = hero_info_panel.Find("DMG_value").GetComponent <Text>();
        hero_init = hero_info_panel.Find("INIT_value").GetComponent <Text>();
        hero_abil = hero_info_panel.Find("ABIL_name").GetComponent <Text>();

        PlanUI     = GameObject.Find("Plan UI");
        P1_actions = PlanUI.transform.Find("P1_actions").GetComponent <Text>();
        P2_actions = PlanUI.transform.Find("P2_actions").GetComponent <Text>();

        ResolveUI = GameObject.Find("Resolve UI");
        ResolveUI.SetActive(true);

        EndUI = GameObject.Find("End UI");
        Winner_playername_text = EndUI.transform.Find("Winner Playername").GetComponent <Text>();

        GridUI = GameObject.Find("Grid UI");

        AnimationUI          = GameObject.Find("Animation UI");
        animator_ui          = AnimationUI.GetComponent <Animator>();
        animation_phase_text = AnimationUI.transform.Find("Phase Text").GetComponent <Text>();
        animation_turn_text  = AnimationUI.transform.Find("Turn Text").GetComponent <Text>();


        GridUI.SetActive(false);
        EndUI.SetActive(false);
        PlanUI.SetActive(false);
        DraftUI.SetActive(false);
        ResolveUI.SetActive(false);
        AnimationUI.SetActive(false);

        //set first state
        SetCurrentGameState(GameState.Menu);
    }
Beispiel #3
0
    private void SetPlayerTurnActionPhase()
    {
        switch (GameManager.instance.CurrentTurn)
        {
        case PlayerTurn.Player1:
            own_tag        = "HeroP1";
            target_tag     = "HeroP2";
            enemy_list     = GameManager.instance.HeroList_P2;
            allies_list    = GameManager.instance.HeroList_P1;
            player_grid    = GameManager.instance.Grid_P1;
            player_actions = p1_actions;
            break;

        case PlayerTurn.Player2:
            own_tag        = "HeroP2";
            target_tag     = "HeroP1";
            enemy_list     = GameManager.instance.HeroList_P1;
            allies_list    = GameManager.instance.HeroList_P2;
            player_grid    = GameManager.instance.Grid_P2;
            player_actions = p2_actions;
            break;
        }
    }
    void OnEnable()
    {
        if (!IsInit && ItemPerObj != null)
        {
            m_AttrDic.Clear();
            IsInit = true;
            int  hasCount  = 0;
            bool iscontain = true;
            bool isEnough  = true;
            Dictionary <int, List <Tab_Belle> > allDataDic = TableManager.GetBelle();
            if (allDataDic != null && GridParent != null)
            {
                foreach (KeyValuePair <int, List <Tab_Belle> > pair in allDataDic)
                {
                    GameObject go = GameObject.Instantiate(ItemPerObj) as GameObject;
                    if (go != null)
                    {
                        go.transform.name          = pair.Key.ToString();
                        go.transform.parent        = GridParent;
                        go.transform.localPosition = Vector3.zero;
                        go.transform.localScale    = Vector3.one;
                        m_GoFindIdDic.Add(go, pair.Key);
                        iscontain = BelleData.OwnedBelleMap.ContainsKey(pair.Key);
                        if (!iscontain)
                        {
                            go.transform.name = "z" + go.transform.name;
                        }

                        isEnough = BelleData.RedPointBelleIds.Contains(pair.Key);                        //魔灵碎片是否足够生成魂器
                        if (isEnough)
                        {
                            go.transform.name = "y" + go.transform.name;
                        }


                        SetItemInfo(pair.Value[0], go, iscontain);
                        if (iscontain)
                        {
                            ++hasCount;
                            Belle curBelleData = BelleData.OwnedBelleMap[pair.Key];
                            curBelleData.UpdateAttrMap();
                            Dictionary <int, int> attrDic = curBelleData.attrMap;
                            foreach (KeyValuePair <int, int> attrpair in attrDic)
                            {
                                if (m_AttrDic.ContainsKey(attrpair.Key))
                                {
                                    m_AttrDic[attrpair.Key] += attrpair.Value;
                                }
                                else
                                {
                                    m_AttrDic.Add(attrpair.Key, attrpair.Value);
                                }
                            }
                            m_CombatAllValue += BelleData.GetPowerNum(curBelleData.attrMap);
                        }
                    }
                }
                Transform tf = transform.Find("labelBattle");
                if (tf != null)
                {
                    UILabel ul = tf.GetComponent <UILabel>();
                    if (ul != null)
                    {
                        ul.text = m_CombatAllValue.ToString();
                    }
                }
                tf = transform.Find("ProcessBar/processbarFront");
                if (tf != null)
                {
                    UISprite us = tf.GetComponent <UISprite>();
                    if (us != null)
                    {
                        us.fillAmount = (float)hasCount / allDataDic.Count;
                    }
                }
                if (CollectLabelLeft != null && CollectLabelRight != null)
                {
                    CollectLabelLeft.text  = hasCount.ToString();
                    CollectLabelRight.text = allDataDic.Count.ToString();
                }
                if (AttrTypeName.Length == AttrData.Length)
                {
                    int labelcount = AttrData.Length;
                    int num        = 0;
                    foreach (KeyValuePair <int, int> attrdicpair in m_AttrDic)
                    {
                        if (num < labelcount && AttrTypeName[num] != null && AttrData[num] != null)
                        {
                            AttrTypeName[num].text = GCGame.Utils.GetAttrTypeString(attrdicpair.Key);
                            AttrData[num].text     = "+" + attrdicpair.Value;
                            AttrTypeName[num].gameObject.SetActive(true);
                            AttrData[num].gameObject.SetActive(true);
                            ++num;
                        }
                    }
                    for (int start = num; start < labelcount; ++start)
                    {
                        if (AttrTypeName[start] != null && AttrData[start] != null)
                        {
                            AttrTypeName[start].gameObject.SetActive(false);
                            AttrData[start].gameObject.SetActive(false);
                        }
                    }
                }
                UIGrid ug = GridParent.GetComponent <UIGrid>();
                if (ug != null)
                {
                    ug.repositionNow = true;
                }
            }
            ShowDefaultModel();
        }
        BelleItemsShowRedPoint();
    }