Clothe Shop finished

This commit is contained in:
Lukas Moungos
2020-01-30 21:36:40 +01:00
parent 834c5cb22d
commit 559c45b401
45 changed files with 4443 additions and 18098 deletions

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using ReallifeGamemode.Database.Entities;
namespace ReallifeGamemode.Server.Shop.Clothing
{
public class Clothe : ShopClothe
{
public string clothe;
public int undershirtId;
public int torsoId;
}
}

View File

@@ -1,92 +1,52 @@
using GTANetworkAPI;
using System;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using System.Linq;
using Newtonsoft.Json;
using ReallifeGamemode.Server.Extensions;
namespace ReallifeGamemode.Server.Shop.Clothing
{
public class ClotheShop
{
public int category { get; set; } = 1;
public int category { get; set; }
public Vector3 vector { get; set; }
public List<ShopClothe> clotheList = new List<ShopClothe>();
public ClotheShop(int category)
public ClotheShop(int category, Vector3 vector)
{
this.category = category;
this.vector = vector;
LoadClothes();
}
public void LoadClothes()
{
using (var dbContext = new DatabaseContext())
{
clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category);
}
}
[Command("buyclothes")]
public void LoadShopNUI(Client client)
{
LoadClothes();
bool gender = client.GetUser().GetCharacter().Gender;
List<ShopClothe> tops = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 11);
List<ShopClothe> legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4);
List<ShopClothe> shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6);
List<ShopClothe> accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7);
using (var dbContext = new DatabaseContext())
List<Array> clothes = new List<Array>
{
List<Clothe> clothes = new List<Clothe>();
bool gender = client.GetUser().Character.Gender;
foreach (var clothe in clotheList)
{
if(clothe.TypeId == "clothes" )
{
switch (clothe.ComponentId)
{
case 11: //tops
List<ClothCombination> combinations = dbContext.ClothCombinations.Where(c => c.Top == clothe.ClotheId && c.Gender == gender).ToList();
foreach (var combination in combinations)
{
var top = new Clothe
{
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
ClotheId = clothe.ClotheId,
Gender = gender,
TypeId = "clothes",
clothe = "clothes",
Category = category,
Price = clothe.Price,
undershirtId = combination.Undershirt,
torsoId = combination.Torso
};
clothes.Add(top);
}
break;
default: //everything else
var garment = new Clothe
{
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
ClotheId = clothe.ClotheId,
Gender = gender,
TypeId = "clothes",
clothe = "clothes",
Category = category,
Price = clothe.Price,
undershirtId = -1, //will not be used unless top
torsoId = -1 //will not be used unless top
};
clothes.Add(garment);
break;
tops.ToArray(),
legs.ToArray(),
shoes.ToArray(),
accessoires.ToArray()
};
}
}
}
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
}
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
}
}
}