//This is called by our selectDialog using the Dialog.onCompletedCallback. It passes the name of the selected answer. public void itemSelected(string answer) { characterGo.SendMessage("Side", SendMessageOptions.DontRequireReceiver); if (type == types.dresserWithClothes) { if (canChangeColor && answer == changeColorString) { //Create a color picker and tell it to send us messages about it's state GameObject cpo = Instantiate(colorPicker); ColorPicker cp = cpo.GetComponent <ColorPicker>(); cp.addMessageObject(gameObject); BlubberAnimation ba = characterGo.GetComponent <BlubberAnimation>(); if (ba) { cp.highlightColor(ba.getColor()); } } else { if (answer == nakedString) { characterGo.SendMessage("removeNonessentialDresses", SendMessageOptions.DontRequireReceiver); } DressObject d = dressList.Find(e => e.name == answer); if (d) { characterGo.SendMessage("removeNonessentialDresses", SendMessageOptions.DontRequireReceiver); GameObject newDress = Instantiate(d.gameObject, characterGo.transform); SpriteRenderer dressRenderer = newDress.GetComponent <SpriteRenderer>() as SpriteRenderer; dressRenderer.enabled = true; characterGo.SendMessage("addDressObject", newDress, SendMessageOptions.DontRequireReceiver); if (sceneSettingsGO != null) { sceneSettingsGO.objectCreated(newDress); } } base.Close("", characterGo); } } if (type == types.spawnItemSelect) { int index = inventoryNames.IndexOf(answer); if (index != -1) { instantiateInventoryItem(index); } base.Close("", characterGo); } }
public void Start() { cont = GetComponent <CharacterController2D>(); blubberAnim = GetComponent <BlubberAnimation>(); global = GameObject.FindWithTag("global").GetComponent <Global>(); }