Пример #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            itemObject object1 = new itemObject();

            object1 = (itemObject)comboBox1.SelectedItem;
            String head = object1.Value;

            String[] number = head.Split(' ');
            byte[]   temp   = new byte[10];
            if (number.Length == 10)
            {
                for (int i = 0; i < 10; i++)
                {
                    temp[i] = (byte)Convert.ToByte(number[i], 16);
                    Console.WriteLine(temp[i]);
                }
                PublicHead                  = temp;
                textBox_Header.Text         = head;
                talkback.audioDeal.projName = object1.ToString();
            }
            else
            {
                Console.WriteLine(number.Length);
                MessageBox.Show("头长度错误,应为10");
            }
        }
Пример #2
0
 // Switch between inventory and equipment //
 public void swap(int i, int e)
 {
     if (inventory [i].itemID == -1 && equipment [e].itemID != -1)
     {
         itemObject tmp = inventory [i];
         inventory [i] = equipment [e];
         equipment [e] = tmp;
         size++;
     }
     else if (inventory [i].itemID != -1 || equipment [e].itemID == -1)
     {
         if (inventory [i].itemType == 0)
         {
             if (e < 3)
             {
                 itemObject tmp = inventory [i];
                 inventory [i] = equipment [e];
                 equipment [e] = tmp;
                 size--;
             }
         }
         else if (inventory [i].itemType > 0)
         {
             if (e > 2)
             {
                 itemObject tmp = inventory [i];
                 inventory [i] = equipment [e];
                 equipment [e] = tmp;
                 size--;
             }
         }
     }
 }
Пример #3
0
        private void InitSetting()
        {
            string   fname   = Directory.GetCurrentDirectory() + "\\voice.txt";
            string   wavname = Directory.GetCurrentDirectory() + "\\P.501 中国语音.wav";
            FileInfo finfo   = new FileInfo(fname);
            FileInfo wavinfo = new FileInfo(wavname);

            if (finfo.Exists)
            {
                textBox3.AppendText(fname);
                try
                {
                    string            Path   = (string)textBox3.Text;
                    FileStream        file   = new FileStream(Path, FileMode.Open, FileAccess.Read);
                    StreamReader      reader = new StreamReader(file);
                    itemObject[]      item   = new itemObject[5];
                    string            line   = reader.ReadLine();
                    int               i      = 0;
                    string[]          Line   = new string[40];
                    List <itemObject> items  = new List <itemObject>();
                    string            path;
                    itemObject        itemTemp = new itemObject();
                    while (line != null)
                    {
                        Line = line.Split('/');

                        itemTemp = new itemObject(Line[1], Line[0]);
                        items.Add(itemTemp);
                        Console.WriteLine(itemTemp.Text);
                        Console.WriteLine(itemTemp.Value);
                        i++;
                        line = reader.ReadLine();
                        path = Directory.GetCurrentDirectory() + itemTemp.Text.ToString();
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(itemTemp.Text.ToString());
                        }
                    }
                    comboBox1.Items.Clear();
                    comboBox1.Items.AddRange(items.ToArray());

                    if (comboBox1.Items.Count > 0)
                    {
                        comboBox1.SelectedIndex = 0;
                    }
                    file.Close();
                }
                catch (Exception)
                {
                    Output.MessaggeOutput("Exception");
                }
            }
            if (wavinfo.Exists)
            {
                textBox2.AppendText(wavname);
            }
        }
Пример #4
0
 // Switch within the inventory //
 public void i2i(int i1, int i2)
 {
     if (inventory[i1].itemID != -1 || inventory[i2].itemID != -1)
     {
         itemObject tmp = inventory [i1];
         inventory [i1] = inventory [i2];
         inventory [i2] = tmp;
     }
 }
Пример #5
0
 // Switch within the equipment //
 public void e2e(int e1, int e2)
 {
     if ((e1 < 3 && e2 < 3) || (e1 > 2 && e2 > 2))
     {
         itemObject tmp = equipment [e1];
         equipment [e1] = equipment [e2];
         equipment [e2] = tmp;
     }
 }
Пример #6
0
    public bool addItem(itemObject i)
    {
        switch (i.itemType)
        {
        case 0:
            if (size < capacity)
            {
                inventory [size] = i;
                size++;
                return(true);
            }
            return(false);

        case 1:
            ammo.addAmmo(50, i.itemCode);
            return(true);

        case 2:
            if (size < capacity)
            {
                inventory [size] = i;
                size++;
                return(true);
            }
            return(false);

        case 3:
            if (size < capacity)
            {
                inventory [size] = i;
                size++;
                return(true);
            }
            return(false);

        case 4:
            // armor = i.itemCode;
            return(true);

        case 5:
            bagID = i.itemCode;
            //capacity = (bagID == 1) ? 23 : 31;
            return(true);

        case 6:
            mask = true;
            return(true);

        default:
            return(false);
        }
    }
Пример #7
0
        private void button6_Click(object sender, EventArgs e)
        {
            // if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox3.Text = openFileDialog1.FileName;
            }
            if (textBox3.Text != null)
            {
                try
                {
                    string            Path   = (string)textBox3.Text;
                    FileStream        file   = new FileStream(Path, FileMode.Open, FileAccess.Read);
                    StreamReader      reader = new StreamReader(file);
                    itemObject[]      item   = new itemObject[5];
                    string            line   = reader.ReadLine();
                    int               i      = 0;
                    string[]          Line   = new string[40];
                    List <itemObject> items  = new List <itemObject>();

                    itemObject itemTemp = new itemObject();
                    while (line != null)
                    {
                        Line = line.Split('/');

                        itemTemp = new itemObject(Line[1], Line[0]);
                        items.Add(itemTemp);
                        Console.WriteLine(itemTemp.Text);
                        Console.WriteLine(itemTemp.Value);
                        i++;
                        line = reader.ReadLine();
                    }
                    comboBox1.Items.Clear();
                    comboBox1.Items.AddRange(items.ToArray());

                    if (comboBox1.Items.Count > 0)
                    {
                        comboBox1.SelectedIndex     = 0;
                        talkback.audioDeal.projName = comboBox1.SelectedItem.ToString();
                    }
                    file.Close();
                }
                catch (Exception)
                {
                    Output.MessaggeOutput("Exception");
                }
            }
        }
Пример #8
0
    void useItem(int e)
    {
        itemObject i = inventory.equipment [e];

        if (i.itemType == 3)
        {
            float heal = 0.0f;

            switch (i.itemCode)
            {
            case 0:
                heal = 10.0f;
                break;

            case 1:
                heal = 20.0f;
                break;

            case 2:
                heal = 40.0f;
                break;

            case 3:
                heal = 60.0f;
                break;

            case 4:
                heal = 80.0f;
                break;

            case 5:
                heal = 100.0f;
                break;
            }

            if (health.health + heal >= 100.0f)
            {
                health.health = 100.0f;
            }
            else
            {
                health.health += heal;
            }
            inventory.equipment [e] = inventory.empty;
        }
    }