Exemplo n.º 1
0
    // Assigns the PanelIcon to the Panel based on the Sprite in the Slot at the Panel's Location
    public void SetEachPanelIcons()
    {
        PanelIcon icon       = PanelIcon.NULL;
        int       panelIndex = -1;

        foreach (Image image in icons)
        {
            // Ignore the last image since it's offscreen
            if (image.rectTransform.GetSiblingIndex() == image.rectTransform.parent.childCount - 1)
            {
                //Debug.LogWarning("Time: " + Time.time + " | " + "Image: " + image.name + " | " + "Index: " + panelIndex);
                continue;
            }

            // Determine the PanelIcon based on the Sprite (would be better with two-way lookup table)
            if (image.sprite == Panel.panelSprites[PanelIcon.Apple])
            {
                icon = PanelIcon.Apple;
            }
            else if (image.sprite == Panel.panelSprites[PanelIcon.Kiwi])
            {
                icon = PanelIcon.Kiwi;
            }
            else if (image.sprite == Panel.panelSprites[PanelIcon.Lemon])
            {
                icon = PanelIcon.Lemon;
            }
            else if (image.sprite == Panel.panelSprites[PanelIcon.Orange])
            {
                icon = PanelIcon.Orange;
            }
            else if (image.sprite == Panel.panelSprites[PanelIcon.Peach])
            {
                icon = PanelIcon.Peach;
            }
            else if (image.sprite == Panel.panelSprites[PanelIcon.Pear])
            {
                icon = PanelIcon.Pear;
            }
            else if (image.sprite == Panel.panelSprites[PanelIcon.Pomegranate])
            {
                icon = PanelIcon.Pomegranate;
            }
            else if (image.sprite == Panel.panelSprites[PanelIcon.Watermelon])
            {
                icon = PanelIcon.Watermelon;
            }

            // Change the fruit on the panel of the icon where the image is
            panelIndex = image.rectTransform.GetSiblingIndex();
            //Debug.Log("Time: " + Time.time + " | " + "Image: " + image.name + " | " + "Index: " + panelIndex);
            panels[panelIndex].SetImage(image);
            panels[panelIndex].SetFruit(icon);
        }
    }
Exemplo n.º 2
0
        public void PanelEventC(object sender, EventArgs e)
        {
            Control   ctrl      = (Control)sender;
            PanelIcon panelIcon = ctrl.Tag as PanelIcon;
            string    clickInfo = string.Empty;

            switch (panelIcon.Index)
            {
            case 0:
                clickInfo = "时间设置";
                break;
            }
            this.label1.Text = string.Format("您选择了 {0}", clickInfo);
        }
Exemplo n.º 3
0
    // Determines the payout based on predefined pay tables/permutations of the icons
    private void EvaluateBoard()
    {
        PayTableLine tableLine  = PayTableLine.HorizontalTop; // Start with first PayTableLine, horizontal top row
        int          slotIndex  = slots.Length - 1;           // current slotIndex; starts at top right, moves left
        int          panelIndex = 0;                          // current panelIndex; starts at top, moves down
        // panelIndedx will remain 0 for the first row's pay table

        PanelIcon referencePanel = 0; // the icon of reference panel we are comparing to
        PanelIcon nextPanel      = 0; // the icon of each subsequent neighboring icon to compare

        int localMaxOccurance = 1;    // the current largest combination of the same icon
        int localMaxIndex     = 0;    // where the index of the currentMaxOccurance starts

        // For the absMax found in this search
        PanelIcon absMaxPanel     = 0; // the icon associated with absMaxOccurance
        int       absMaxOccurance = 1; // the highest recorded combination of the same icon
        int       absMaxIndex     = 0; // where the index of the absMaxOcc starts

        // Main Loop For Each PayTableLine:
        StartCoroutine(EvaluateEachPayline());


        // Local Function that picks panelIndex based on current PayTableLine and slotIndex
        void PanelIndexFromPayline()
        {
            switch (tableLine)
            {
            case PayTableLine.HorizontalTop:
                panelIndex = 0;
                break;

            case PayTableLine.HorizontalOuter:
                panelIndex = 1;
                break;

            case PayTableLine.HorizontalInner:
                panelIndex = 2;
                break;

            case PayTableLine.HorizontalBottom:
                panelIndex = 3;
                break;

            case PayTableLine.BigVTop:
                if (slotIndex == 0 || slotIndex == slots.Length - 1)
                {
                    panelIndex = 0;
                }
                else if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 1;
                }
                else
                {
                    panelIndex = 2;
                }
                break;

            case PayTableLine.BigVBottom:
                if (slotIndex == 0 || slotIndex == slots.Length - 1)
                {
                    panelIndex = 1;
                }
                else if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 2;
                }
                else
                {
                    panelIndex = 3;
                }
                break;

            case PayTableLine.BigABottom:
                if (slotIndex == 0 || slotIndex == slots.Length - 1)
                {
                    panelIndex = 3;
                }
                else if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 2;
                }
                else
                {
                    panelIndex = 1;
                }
                break;

            case PayTableLine.BigATop:
                if (slotIndex == 0 || slotIndex == slots.Length - 1)
                {
                    panelIndex = 2;
                }
                else if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 1;
                }
                else
                {
                    panelIndex = 0;
                }
                break;

            case PayTableLine.WTop:
                if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 1;
                }
                else
                {
                    panelIndex = 0;
                }
                break;

            case PayTableLine.WMiddle:
                if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 2;
                }
                else
                {
                    panelIndex = 1;
                }
                break;

            case PayTableLine.WBottom:
                if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 3;
                }
                else
                {
                    panelIndex = 2;
                }
                break;

            case PayTableLine.MTop:
                if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 0;
                }
                else
                {
                    panelIndex = 1;
                }
                break;

            case PayTableLine.MMiddle:
                if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 1;
                }
                else
                {
                    panelIndex = 2;
                }
                break;

            case PayTableLine.MBottom:
                if (slotIndex == 1 || slotIndex == slots.Length - 2)
                {
                    panelIndex = 2;
                }
                else
                {
                    panelIndex = 3;
                }
                break;
            }
        }

        // Local Coroutine Function to Evaluate All Paylines Procedurally
        IEnumerator EvaluateEachPayline()
        {
            // Only start this after all Slot reels have finished spinning
            yield return(waitForAllSlotsDone);

            // Main Loop For Each PayTableLine:
            for (int i = 1; i <= /*14*/ Enum.GetNames(typeof(PayTableLine)).Length - 1; i++)
            {
                // Reset the counters and change the PayTableLine
                tableLine       = (PayTableLine)i;
                slotIndex       = slots.Length - 1;
                absMaxPanel     = 0;
                absMaxOccurance = 1;
                absMaxIndex     = 0;

                // Pick the panel based on the current payline
                PanelIndexFromPayline();

                // Start at the right-most panel in this row
                referencePanel = slots[slotIndex].GetPanels()[panelIndex].GetFruit();
                localMaxIndex  = slotIndex;
                //Debug.LogWarning("Time: " + Time.time + " | " + "ReferencePanel: " + referencePanel + " | " +
                //                "slotIndex: " + slotIndex + " | " + "localMaxIndex: " + localMaxIndex);

                // Move the slotIndex to the left, and pick the panel based on the current payline
                slotIndex--;
                PanelIndexFromPayline();

                nextPanel = slots[slotIndex].GetPanels()[panelIndex].GetFruit();
                //Debug.Log("Time: " + Time.time + " | " + "NextPanel: " + nextPanel + " | " +
                //           "slotIndex: " + slotIndex);

                while (slotIndex >= -1)
                {
                    // Keep track of the same occurances
                    if (nextPanel == referencePanel /* && !((slotIndex + 1) < absMaxOccurance) && !()*/)
                    {
                        //Debug.Log("Time: " + Time.time + " | " + "Same icon found! Continuing search...");
                        localMaxOccurance++;
                    }
                    // The chain is broken
                    else
                    {
                        //Debug.Log("Time: " + Time.time + " | " + "Local chain broken..." + " | " +
                        //        "LocalMaxOcc: " + localMaxOccurance + " | " +
                        //        "AbsMaxOcc (BEFORE): " + absMaxOccurance);

                        // Update the winning panel and streak if needed
                        if (CalculateScore(referencePanel, localMaxOccurance) > CalculateScore(absMaxPanel, absMaxOccurance))
                        {
                            absMaxPanel     = referencePanel;
                            absMaxOccurance = localMaxOccurance;
                            absMaxIndex     = localMaxIndex;

                            //Debug.Log("Time: " + Time.time + " | " + "Updating AbsMax..." + " | " +
                            //    "AbsMaxOcc: " + absMaxOccurance + " | " + "AbsMaxIndex: " + absMaxIndex);
                        }

                        // Try the next panel to the left and reset the occurance counters

                        referencePanel    = nextPanel;
                        localMaxOccurance = 1;
                        localMaxIndex     = slotIndex;
                        //Debug.LogWarning("Time: " + Time.time + " | " + "ReferencePanel: " + referencePanel + " | " +
                        //    "slotIndex: " + slotIndex + " | " + "localMaxIndex: " + localMaxIndex);
                    }

                    // Move the slotIndex to the left, and pick the panel based on the current payline
                    slotIndex--;
                    PanelIndexFromPayline();

                    if (slotIndex < 0)
                    {
                        nextPanel = PanelIcon.NULL;
                    }
                    else
                    {
                        nextPanel = slots[slotIndex].GetPanels()[panelIndex].GetFruit();
                    }

                    //Debug.Log("Time: " + Time.time + " | " + "NextPanel: " + nextPanel + " | " +
                    //          "slotIndex: " + slotIndex);
                }

                // Report the max occurance and pay the player if needed
                int pointsGained = CalculateScore(absMaxPanel, absMaxOccurance);

                //Debug.Log("Time: " + Time.time + "| " + "PayTableLine: " + tableLine + " | " +
                //    "Icon: " + absMaxPanel + " | " +
                //    "AbsMaxOcc: " + absMaxOccurance + " | " + "AbsMaxIndex: " + absMaxIndex + " | " +
                //    "Points: " + pointsGained);


                // Display the winning configuration's PayTableLine as a Coroutine
                if (pointsGained > 0)
                {
                    yield return(delayBeforeShowingWin);

                    AudioManager.instance.Play(AudioName.Payout);
                    GameManager.instance.gainedText.text = "+" + pointsGained;
                    yield return(DisplayWinningPayline());
                }

                // Update Score UI // TODO: Make this a EventListner triggered UI update thing.
                GameManager.instance.score          += pointsGained;
                GameManager.instance.scoreText.text  = GameManager.instance.score.ToString("D7");
                GameManager.instance.gainedText.text = "";
            }

            // Reset the isSpinning lock
            this.isSpinning = false;
            // Spin again if AutoSpin is enabled
            if (autoSpin.isOn)
            {
                Spin();
            }
            else
            {
                this.spinButton.interactable = true;
            }
        }

        // Determines the points based on the PanelIcon and its max occurance
        int CalculateScore(PanelIcon icon, int maxOccurance)
        {
            int answer = 0;

            int comboMultipler = 0;

            switch (maxOccurance)
            {
            default:
                comboMultipler = 0;
                break;

            case 3:
                comboMultipler = 1;
                break;

            case 4:
                comboMultipler = 3;
                break;

            case 5:
                comboMultipler = 5;
                break;
            }

            answer = Panel.panelScores[icon] * comboMultipler;

            return(answer);
        }

        // Coroutine to show the winning panels animation
        IEnumerator DisplayWinningPayline()
        {
            // Determine the affected panels in the PayTableLine to highlight/dim
            switch (tableLine)
            {
            case PayTableLine.HorizontalTop:
                affectedPanels[0] = slots[0].GetPanels()[0];
                affectedPanels[1] = slots[1].GetPanels()[0];
                affectedPanels[2] = slots[2].GetPanels()[0];
                affectedPanels[3] = slots[3].GetPanels()[0];
                affectedPanels[4] = slots[4].GetPanels()[0];
                break;

            case PayTableLine.HorizontalOuter:
                affectedPanels[0] = slots[0].GetPanels()[1];
                affectedPanels[1] = slots[1].GetPanels()[1];
                affectedPanels[2] = slots[2].GetPanels()[1];
                affectedPanels[3] = slots[3].GetPanels()[1];
                affectedPanels[4] = slots[4].GetPanels()[1];
                break;

            case PayTableLine.HorizontalInner:
                affectedPanels[0] = slots[0].GetPanels()[2];
                affectedPanels[1] = slots[1].GetPanels()[2];
                affectedPanels[2] = slots[2].GetPanels()[2];
                affectedPanels[3] = slots[3].GetPanels()[2];
                affectedPanels[4] = slots[4].GetPanels()[2];
                break;

            case PayTableLine.HorizontalBottom:
                affectedPanels[0] = slots[0].GetPanels()[3];
                affectedPanels[1] = slots[1].GetPanels()[3];
                affectedPanels[2] = slots[2].GetPanels()[3];
                affectedPanels[3] = slots[3].GetPanels()[3];
                affectedPanels[4] = slots[4].GetPanels()[3];
                break;

            case PayTableLine.BigVTop:
                affectedPanels[0] = slots[0].GetPanels()[0];
                affectedPanels[1] = slots[1].GetPanels()[1];
                affectedPanels[2] = slots[2].GetPanels()[2];
                affectedPanels[3] = slots[3].GetPanels()[1];
                affectedPanels[4] = slots[4].GetPanels()[0];
                break;

            case PayTableLine.BigVBottom:
                affectedPanels[0] = slots[0].GetPanels()[1];
                affectedPanels[1] = slots[1].GetPanels()[2];
                affectedPanels[2] = slots[2].GetPanels()[3];
                affectedPanels[3] = slots[3].GetPanels()[2];
                affectedPanels[4] = slots[4].GetPanels()[1];
                break;

            case PayTableLine.BigABottom:
                affectedPanels[0] = slots[0].GetPanels()[3];
                affectedPanels[1] = slots[1].GetPanels()[2];
                affectedPanels[2] = slots[2].GetPanels()[1];
                affectedPanels[3] = slots[3].GetPanels()[2];
                affectedPanels[4] = slots[4].GetPanels()[3];
                break;

            case PayTableLine.BigATop:
                affectedPanels[0] = slots[0].GetPanels()[2];
                affectedPanels[1] = slots[1].GetPanels()[1];
                affectedPanels[2] = slots[2].GetPanels()[0];
                affectedPanels[3] = slots[3].GetPanels()[1];
                affectedPanels[4] = slots[4].GetPanels()[2];
                break;

            case PayTableLine.WTop:
                affectedPanels[0] = slots[0].GetPanels()[0];
                affectedPanels[1] = slots[1].GetPanels()[1];
                affectedPanels[2] = slots[2].GetPanels()[0];
                affectedPanels[3] = slots[3].GetPanels()[1];
                affectedPanels[4] = slots[4].GetPanels()[0];
                break;

            case PayTableLine.WMiddle:
                affectedPanels[0] = slots[0].GetPanels()[1];
                affectedPanels[1] = slots[1].GetPanels()[2];
                affectedPanels[2] = slots[2].GetPanels()[1];
                affectedPanels[3] = slots[3].GetPanels()[2];
                affectedPanels[4] = slots[4].GetPanels()[1];
                break;

            case PayTableLine.WBottom:
                affectedPanels[0] = slots[0].GetPanels()[2];
                affectedPanels[1] = slots[1].GetPanels()[3];
                affectedPanels[2] = slots[2].GetPanels()[2];
                affectedPanels[3] = slots[3].GetPanels()[3];
                affectedPanels[4] = slots[4].GetPanels()[2];
                break;

            case PayTableLine.MTop:
                affectedPanels[0] = slots[0].GetPanels()[1];
                affectedPanels[1] = slots[1].GetPanels()[0];
                affectedPanels[2] = slots[2].GetPanels()[1];
                affectedPanels[3] = slots[3].GetPanels()[0];
                affectedPanels[4] = slots[4].GetPanels()[1];
                break;

            case PayTableLine.MMiddle:
                affectedPanels[0] = slots[0].GetPanels()[2];
                affectedPanels[1] = slots[1].GetPanels()[1];
                affectedPanels[2] = slots[2].GetPanels()[2];
                affectedPanels[3] = slots[3].GetPanels()[1];
                affectedPanels[4] = slots[4].GetPanels()[2];
                break;

            case PayTableLine.MBottom:
                affectedPanels[0] = slots[0].GetPanels()[3];
                affectedPanels[1] = slots[1].GetPanels()[2];
                affectedPanels[2] = slots[2].GetPanels()[3];
                affectedPanels[3] = slots[3].GetPanels()[2];
                affectedPanels[4] = slots[4].GetPanels()[3];
                break;
            }

            // Change the PanelState of each panel based on if it's a win or lose
            for (int i = 0; i < affectedPanels.Length; i++)
            {
                if (i <= absMaxIndex && i >= (absMaxIndex - absMaxOccurance) + 1)
                {
                    affectedPanels[i].SetState(PanelState.Win);
                }
                else
                {
                    affectedPanels[i].SetState(PanelState.Lose);
                }
            }

            // View the winning arrangement for 1.5 seconds
            yield return(delayAfterShowingWin);

            // Reset all affected panels back to normal
            foreach (Panel panel in affectedPanels)
            {
                panel.SetState(PanelState.Default);
            }
        }
    }
Exemplo n.º 4
0
    // Setters

    // Potential TODO: Make an event listener if the fruit value changes dynamically to call this function
    // Sets the fruit and updates the image and value
    public void SetFruit(PanelIcon icon)
    {
        fruit            = icon;
        this.icon.sprite = panelSprites[fruit]; // Sets the sprite of the fruit
        points           = panelScores[fruit];  // Set the value of the fruit
    }
Exemplo n.º 5
0
        /// <summary>
        /// 处理工具栏中相关项的点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void PanelEvent(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (sender is Label)
                {
                    try
                    {
                        string key      = ((Label)sender).Text; //获得数据字典中的key 即功能项目的名称
                        string formText = "  " + key;
                        formName = Dictionary[key].ToString();  //获得数据字典中的 对应窗口的类名


                        if (!ShowChildrenForm(formText))
                        {
                            //以下是通过反射 获得该窗体的实例

                            Type t = Type.GetType(Global.namespceName + "." + formName);

                            CurrentForm = (Form)Activator.CreateInstance(t);



                            CurrentForm.MdiParent = this;
                            //设置窗体的标题
                            CurrentForm.Text = formText;
                            if (!CurrentForm.IsDisposed)
                            {
                                CurrentForm.WindowState = FormWindowState.Maximized;
                                CurrentForm.Show();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("该功能出现错误:" + ex.Message);
                    }
                }
                else
                {
                    PanelIcon pic = (PanelIcon)sender;
                    List <Outlook_Table_Jb_User> list    = (List <Outlook_Table_Jb_User>)table[pic.iconPanel];
                    Outlook_Table_Jb_User        jb_user = list[pic.Index];
                    try
                    {
                        string key      = jb_user.Itemname;    //获得数据字典中的key 即功能项目的名称
                        string formText = "  " + key;
                        formName = Dictionary[key].ToString(); //获得数据字典中的 对应窗口的类名

                        if (!ShowChildrenForm(formText))
                        {
                            //以下是通过反射 获得该窗体的实例
                            Type t = Type.GetType(Global.namespceName + "." + formName);
                            CurrentForm = (Form)Activator.CreateInstance(t);

                            CurrentForm.MdiParent = this;
                            //设置窗体的标题
                            CurrentForm.Text = "  " + key;
                            if (!CurrentForm.IsDisposed)
                            {
                                CurrentForm.WindowState = FormWindowState.Maximized;
                                CurrentForm.Show();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("该功能出现错误:" + ex.Message);
                    }
                }
            }
        }