Beispiel #1
0
        private void PictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int mX = (e.X / 32);
            int mY = (e.Y / 32);

            if (editMode == false)
            {
                if (itemsArray[mX, mY] != null)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        if (itemsArray[mX, mY].on)
                        {
                            if (itemsArray[mX, mY].count)
                            {
                                itemsArray[mX, mY].counter++;
                            }

                            if (itemsArray[mX, mY].level < itemsArray[mX, mY].iconsId.Length - 1)
                            {
                                if (itemsArray[mX, mY].name == "Timer_StartDone")
                                {
                                    timeended = DateTime.Now;
                                    timerend  = true;
                                }
                                //if (itemsArray)
                                if (itemsArray[mX, mY].bottle)
                                {
                                    if (itemsArray[mX, mY].level == 0)
                                    {
                                        itemsArray[mX, mY].level += 2;
                                    }
                                    else
                                    {
                                        if (itemsArray[mX, mY].level < 6)
                                        {
                                            itemsArray[mX, mY].level++;
                                        }
                                    }
                                }
                                else
                                {
                                    itemsArray[mX, mY].level++;
                                }
                                //drawIcons();
                            }
                            else
                            {
                                if (itemsArray[mX, mY].level == itemsArray[mX, mY].iconsId.Length - 1)
                                {
                                    if (itemsArray[mX, mY].loop == true)
                                    {
                                        itemsArray[mX, mY].level = 0;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (itemsArray[mX, mY].name == "Timer_Start" || itemsArray[mX, mY].name == "Timer_StartDone")
                            {
                                for (int x = 0; x < widthIcons; x++)
                                {
                                    for (int y = 0; y < heightIcons; y++)
                                    {
                                        if (itemsArray[x, y] != null)
                                        {
                                            if (itemsArray[x, y].name == "Timer")
                                            {
                                                timerpospixel  = new Point(x * 32, y * 32);
                                                timer2.Enabled = true;
                                                timer          = true;
                                                timestarted    = DateTime.Now;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            if (itemsArray[mX, mY].name == "Timer_Done")
                            {
                                timeended = DateTime.Now;
                                timerend  = true;
                            }
                            itemsArray[mX, mY].on = true;
                            //drawIcons();
                        }
                        TimeSpan objt = DateTime.Now.Subtract(timestarted);
                        if (itemsArray[mX, mY].loop == false)
                        {
                            item_found.Add(itemsArray[mX, mY].name + " Added at " + objt.Hours.ToString("D2") + ":" + objt.Minutes.ToString("D2") + ":" + objt.Seconds.ToString("D2"));
                        }
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        if (itemsArray[mX, mY].on)
                        {
                            if (itemsArray[mX, mY].name == "Timer_Start" || itemsArray[mX, mY].name == "Timer_StartDone")
                            {
                                if (itemsArray[mX, mY].level == 0)
                                {
                                    timer = false;
                                }
                            }


                            if (itemsArray[mX, mY].count == false)
                            {
                                if (itemsArray[mX, mY].name == "Timer_Done" || itemsArray[mX, mY].name == "Timer_StartDone")
                                {
                                    timerend = false;
                                }
                                TimeSpan objt = DateTime.Now.Subtract(timestarted);
                                if (itemsArray[mX, mY].loop == false)
                                {
                                    item_found.Add(itemsArray[mX, mY].name + " Removed at " + objt.Hours.ToString("D2") + ":" + objt.Minutes.ToString("D2") + ":" + objt.Seconds.ToString("D2"));
                                }
                                if (itemsArray[mX, mY].level > 0)
                                {
                                    itemsArray[mX, mY].level--;
                                    if (itemsArray[mX, mY].bottle)
                                    {
                                        if (itemsArray[mX, mY].level == 1)
                                        {
                                            itemsArray[mX, mY].level--;
                                        }
                                    }
                                }
                                else if (itemsArray[mX, mY].level == 0)
                                {
                                    if (itemsArray[mX, mY].loop == false)
                                    {
                                        itemsArray[mX, mY].on = false;
                                    }
                                }
                            }
                            else
                            {
                                itemsArray[mX, mY].counter--;
                            }
                        }
                    }
                }
            }
            else
            {
                if (e.Button == MouseButtons.Right)
                {
                    ItemSelectorForm itemForm = new ItemSelectorForm();
                    if (itemForm.ShowDialog() == DialogResult.OK)
                    {
                        if (itemForm.selectedItem == 255)
                        {
                            itemsArray[mX, mY] = null;
                        }
                        else
                        {
                            itemsArray[mX, mY] = itemsList[itemForm.selectedItem];
                        }
                    }
                }
            }
            DrawIcons();
        }
Beispiel #2
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int mX = (e.X / 32);
            int mY = (e.Y / 32);

            if (editMode == false)
            {
                if (itemsArray[mX, mY] != null)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        if (itemsArray[mX, mY].on)
                        {
                            if (itemsArray[mX, mY].level < itemsArray[mX, mY].iconsId.Length - 1)
                            {
                                //if (itemsArray)
                                if (itemsArray[mX, mY].bottle)
                                {
                                    if (itemsArray[mX, mY].level == 0)
                                    {
                                        itemsArray[mX, mY].level += 2;
                                    }
                                    else
                                    {
                                        if (itemsArray[mX, mY].level < 6)
                                        {
                                            itemsArray[mX, mY].level++;
                                        }
                                    }
                                }
                                else
                                {
                                    itemsArray[mX, mY].level++;
                                }
                                //drawIcons();
                            }
                            else
                            {
                                if (itemsArray[mX, mY].level == itemsArray[mX, mY].iconsId.Length - 1)
                                {
                                    if (itemsArray[mX, mY].loop == true)
                                    {
                                        itemsArray[mX, mY].level = 0;
                                    }
                                }
                            }
                        }
                        else
                        {
                            itemsArray[mX, mY].on = true;
                            //drawIcons();
                        }
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        if (itemsArray[mX, mY].on)
                        {
                            if (itemsArray[mX, mY].level > 0)
                            {
                                itemsArray[mX, mY].level--;
                                if (itemsArray[mX, mY].bottle)
                                {
                                    if (itemsArray[mX, mY].level == 1)
                                    {
                                        itemsArray[mX, mY].level--;
                                    }
                                }
                            }
                            else if (itemsArray[mX, mY].level == 0)
                            {
                                if (itemsArray[mX, mY].loop == false)
                                {
                                    itemsArray[mX, mY].on = false;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (e.Button == MouseButtons.Right)
                {
                    ItemSelectorForm itemForm = new ItemSelectorForm();
                    if (itemForm.ShowDialog() == DialogResult.OK)
                    {
                        if (itemForm.selectedItem == 255)
                        {
                            itemsArray[mX, mY] = null;
                        }
                        else
                        {
                            itemsArray[mX, mY] = itemsList[itemForm.selectedItem];
                        }
                    }
                }
            }
            drawIcons();
        }