public Car(CarPartFactory factory, List <Tuning> tuninglist, string color, string type, string gumtype, int diameter, string etype, int volume) { this.factory = factory; this.factory.TuningValid(tuninglist); this.body = factory.CreateBody(color, type); this.wheel = factory.CreateWheel(gumtype, diameter); this.engine = factory.CreateEngine(etype, volume); this.Price = this.body.Price + 4 * this.wheel.Price + this.engine.Price; }
private void OnEnable() { ChangeTexture(); cpf = FindObjectOfType <CarPartFactory>(); c = FindObjectOfType <Car>(); scale = transform.localScale; rotation = transform.rotation; }
private void Start() { CarPartFactory carPartFactory = FindObjectOfType <CarPartFactory>(); Manufacturers[] allManufacturers = (Manufacturers[])Enum.GetValues(typeof(Manufacturers)); Manufacturers randomManufacturer = allManufacturers[UnityEngine.Random.Range(0, allManufacturers.Length - 1)]; TrySet(carPartFactory.Create(partType, randomManufacturer), null); }
void Start() { carPartFactory = FindObjectOfType <CarPartFactory>(); for (int c = 0; c < cols; ++c) { for (int r = 0; r < rows; ++r) { InteractiveSlot slot = Instantiate(slotPrefab) as InteractiveSlot; RectTransform slotTransform = slot.GetComponent <RectTransform>(); slotTransform.SetParent(GetComponent <RectTransform>(), false); slotTransform.anchoredPosition = new Vector2(slotTransform.rect.width * c, -slotTransform.rect.height * r); slots.Add(slot); } } }
static void Main(string[] args) { CarPartFactory factory = new CarPartFactory(); List <Tuning> tuninglist = new List <Tuning>(); tuninglist.Add(new Spoiler()); tuninglist.Add(new AudioSystem()); tuninglist.Add(new Turbo()); Car car = new Car(factory, tuninglist, "green", "coupe", "summer", 18, "gas", 3000); car.Assembly(); Console.ReadKey(); }
// Start is called before the first frame update void Start() { updateMoneyUI(); factory = FindObjectOfType <CarPartFactory>(); inv = FindObjectOfType <Inventory>(); var tabAreaSize = this.GetComponent <RectTransform>().sizeDelta.x; int itemI = 0; foreach (KeyValuePair <PartTypes, Dictionary <Manufacturers, Sprite> > partTypeEntry in factory.sprites) { foreach (KeyValuePair <Manufacturers, Sprite> manufacturerEntry in partTypeEntry.Value) { var manu = manufacturerEntry.Key; var partType = partTypeEntry.Key; var itemSprite = manufacturerEntry.Value; int cost = partCosts[partType]; string partName = Bolagsverket.GetName(manu) + makeReadable("_" + partType.ToString() + "_(" + cost.ToString() + "_$)"); var newItem = Instantiate(shopItem) as RectTransform; newItem.GetComponent <RectTransform>().position = new Vector3(0, itemI * (-1) * this.itemHeight, 0); newItem.GetComponent <RectTransform>().sizeDelta = new Vector2(0, this.itemHeight); newItem.SetParent(itemHolder, false); newItem.GetComponentInChildren <Text>().text = partName; newItem.GetComponentsInChildren <Image>()[1].sprite = itemSprite; newItem.GetComponent <Button>().onClick.AddListener(() => { var newPart = factory.Create(partType, manu); // Add to inventory (?) if (this.money >= cost) { inv.TryAddItem(newPart); this.changeMoney(-cost); } }); ++itemI; } } itemHolder.sizeDelta = new Vector2(0, itemI * this.itemHeight); }