public void PutItem(int id) { ItemCollector item = SkinController.skinController.getByID(id); switch (item.type) { case ItemType.Body: BodySpriteCollector body = (BodySpriteCollector) item; if (body.back == null) Back.sprite = null; else Back.sprite = body.back.sprite; Body.sprite = body.body.sprite; LeftEye.sprite = body.leftEye.sprite; RightEye.sprite = body.rightEye.sprite; LeftHand.sprite = body.leftArm.sprite; RightHand.sprite = body.rightArm.sprite; LeftLeg.sprite = body.leftLeg.sprite; RightLeg.sprite = body.rightLeg.sprite; break; case ItemType.Head: SingleSpriteCollector head = (SingleSpriteCollector) item; Head.sprite = head.sprite.sprite; break; case ItemType.Weapon: SingleSpriteCollector weapon = (SingleSpriteCollector) item; Weapon.sprite = weapon.sprite.sprite; break; } }
private void Start() { skinController = this; foreach (var t in Bodys) { items.Add(new BodySpriteCollector(t.GetComponent <BodyCollector>())); } for (int i = 0; i < Weapons.Count; i++) { int id = WeaponID[i]; SingleSpriteCollector single = new SingleSpriteCollector { id = id, type = ItemType.Weapon, sprite = Weapons[i] }; items.Add(single); } for (int i = 0; i < Heads.Count; i++) { int id = HeadID[i]; SingleSpriteCollector single = new SingleSpriteCollector { id = id, sprite = Heads[i], type = ItemType.Head }; items.Add(single); } }