// Use this for initialization
	void Start ()
	{
		aud = GetComponent<AudioSource>();
		sfx = aud.clip;
		AddHat();
		AddGlass();
		AddShoes();
		AddClothes();
		//Deactive(hats);
		//Deactive(glass);
		//Deactive(shoes);
		Deactive(accessories);
		hatIndex = PlayerStatistic.instance.hatIndex;
		glassIndex = PlayerStatistic.instance.glassIndex;
		shoesIndex = PlayerStatistic.instance.shoesIndex;
		clothesIndex = PlayerStatistic.instance.clothesIndex;

		currentHat = FindAccessories(hatIndex);
		currentHat.go.SetActive(true);

		currentGlass = FindAccessories(glassIndex);
		currentGlass.go.SetActive(true);

		currentShoes = FindAccessories(shoesIndex);
		if(currentShoes.go.GetComponent<SkinnedMeshRenderer>())
			currentShoes.go.GetComponent<SkinnedMeshRenderer>().enabled = true;
		else
			currentShoes.go.SetActive(true);

		currentClothes = FindAccessories(clothesIndex);
		if(currentClothes.go.GetComponent<SkinnedMeshRenderer>())
			currentClothes.go.GetComponent<SkinnedMeshRenderer>().enabled = true;
		else
			currentClothes.go.SetActive(true);

	}
Example #2
0
        private void button_Save_Click(object sender, RoutedEventArgs e)
        {
            try {

                MessageBoxResult res;
                res = MessageBox.Show("Вы уверены, что хотите сохранить товар?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (res == MessageBoxResult.Yes)
                {
                    if (textBox_Id.Text == "-1")
                    {
                        if (TypeGoods.SelectedItem == null)
                        {
                            MessageBox.Show("Вы кароч не сделали ниче для того чтобы всё работало", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Question);
                        }
                        else if (TypeGoods.SelectedItem.ToString() == "Оружие")
                        {
                            List<TextBox> s = WeaponGrid.Children.OfType<TextBox>().ToList();
                            foreach (TextBox q in s)
                            {
                                if (q.Text == "" || q.Text == "0")
                                {
                                    MessageBox.Show("Не все поля заполнены");
                                    return;
                                }
                            }
                            Weapon f = new Weapon();
                            f.Type = textBox_TypeWeap.Text;
                            f.CodeName = textBox_NameWeap.Text;
                            f.Automatic = textBox_Avtomat.Text;
                            f.Сaliber = Convert.ToDouble(textBox_Calibr.Text);
                            f.KillRange = Convert.ToInt32(textBox_KillRange.Text);
                            f.Ammunition = Convert.ToInt32(textBox_Ammunition.Text);
                            f.StartBulletSpeed = Convert.ToInt32(textBox_StartSpeed.Text);
                            f.Optic = checkBox.IsChecked.Value;
                            f.Info = textBox_Info.Text;
                            Goodss god = new Goodss()
                            {
                                Balance = Convert.ToInt32(textBox.Text),
                                PricePurchase = Convert.ToDouble(textBox1.Text),
                                SellPrice = Convert.ToDouble(textBox2.Text),
                                Weapon = f
                            };
                            db.Goodss.Add(god);
                            db.SaveChanges();
                            this.Close();
                        }
                        else if (TypeGoods.SelectedItem.ToString() == "Аксесуар")
                        {
                            List<TextBox> s =  AccessoriesGrid.Children.OfType<TextBox>().ToList();
                            foreach (TextBox q in s)
                            {
                                if (q.Text == "" || q.Text == "0")
                                {
                                    MessageBox.Show("Не все поля заполнены");
                                    return;
                                }
                            }
                            Accessories access = new Accessories();
                            access.Type = textBox_Type.Text;
                            access.Name = textBox_Name.Text;
                            access.Characteristics = textBox_Charact.Text;
                            Goodss god = new Goodss()
                            {
                                Accessories = access
                            };
                            god.Balance = Convert.ToInt32(textBox.Text);
                            god.PricePurchase = Convert.ToInt32(textBox1.Text);
                            god.SellPrice = Convert.ToInt32(textBox2.Text);
                            db.Goodss.Add(god);
                            db.SaveChanges();
                            this.Close();
                        }
                    }
                    else
                    {
                        Goodss f = db.Goodss.Find(Convert.ToInt32(textBox_Id.Text));
                        if (TypeGoods.SelectedItem.ToString() == "Оружие")
                        {
                            Weapon Weapons = db.Weapons.Find(Convert.ToInt32(textBox_Id.Text));
                            Weapons.Type = textBox_TypeWeap.Text;
                            Weapons.CodeName = textBox_NameWeap.Text;
                            Weapons.Automatic = textBox_Avtomat.Text;
                            Weapons.Сaliber = Convert.ToDouble(textBox_Calibr.Text);
                            Weapons.KillRange = Convert.ToInt32(textBox_KillRange.Text);
                            Weapons.Ammunition = Convert.ToInt32(textBox_Ammunition.Text);
                            Weapons.StartBulletSpeed = Convert.ToInt32(textBox_StartSpeed.Text);
                            Weapons.Optic = checkBox.IsChecked.Value;
                            Weapons.Info = textBox_Info.Text;
                            f.Balance = Convert.ToInt32(textBox.Text);
                            f.PricePurchase = Convert.ToInt32(textBox1.Text);
                            f.SellPrice = Convert.ToInt32(textBox2.Text);

                            db.SaveChanges();
                        }
                        else if (TypeGoods.SelectedItem.ToString() == "Аксесуар")
                        {
                            Accessories Accessoriess = db.Accessories.Find(Convert.ToInt32(textBox_Id.Text));
                            Accessoriess.Type = textBox_Type.Text;
                            Accessoriess.Name = textBox_Name.Text;
                            Accessoriess.Characteristics = textBox_Charact.Text;
                            f.Balance = Convert.ToInt32(textBox.Text);
                            f.PricePurchase = Convert.ToInt32(textBox1.Text);
                            f.SellPrice = Convert.ToInt32(textBox2.Text);

                            db.SaveChanges();

                        }
                        this.Close();
                    }
                }
            }
            catch
            {
                MessageBox.Show("Error");
            }
        }
	public void SelectClothesPrev(){
		aud.PlayOneShot(sfx);


		clothesIndex -= 1;
		
		if(clothesIndex <300)
			clothesIndex = 300 +totalClothes-1;
		
		currentClothes = FindAccessories(clothesIndex);
		if(currentClothes.available){
			Deactive(accessories,Type.Clothes);
			if(currentClothes.go.GetComponent<SkinnedMeshRenderer>())
				currentClothes.go.GetComponent<SkinnedMeshRenderer>().enabled = true;
			else
				currentClothes.go.SetActive(true);
			
			ActiveAcc();
		}else{
			clothesIndex -= 1;
			SelectClothesPrev();
		}
	}
	public void SelectShoesNext(){

		aud.PlayOneShot(sfx);


		shoesIndex += 1;
		
		if(shoesIndex >= 400 + totalShoes)
			shoesIndex = 400;
		
		currentShoes = FindAccessories(shoesIndex);
		if(currentShoes.available){
			Deactive(accessories,Type.Shoes);
			if(currentShoes.go.GetComponent<SkinnedMeshRenderer>())
				currentShoes.go.GetComponent<SkinnedMeshRenderer>().enabled = true;
			else
				currentShoes.go.SetActive(true);

			ActiveAcc();
		}else{
			shoesIndex += 1;
			SelectShoesNext();
		}
	}
	public void SelectGlassPrev(){
		
		aud.PlayOneShot(sfx);


		glassIndex -= 1;
		
		if(glassIndex <200)
			glassIndex = 200 + totalGlasses-1;
			
		currentGlass = FindAccessories(glassIndex);
		if(currentGlass.available){
			Deactive(accessories,Type.Glass);
			currentGlass.go.SetActive(true);
			ActiveAcc();
		}else{
			glassIndex -= 1;
			SelectGlassPrev();
		}
	}
	public void SelectHatPrev(){

		aud.PlayOneShot(sfx);


		hatIndex -= 1;

		if(hatIndex <100)
			hatIndex = 100 + totalHat-1;
		
		currentHat = FindAccessories(hatIndex);
		if(currentHat.available){
			Deactive(accessories,Type.Hat);
			currentHat.go.SetActive(true);
			ActiveAcc();
		}else{
			hatIndex -= 1;
			SelectHatPrev();
		}
		//}
	}