GameObject AddBeautyFilterOptions(Beauty beautyitem) { GameObject option = Instantiate(BeautyFilter_UIExample); option.transform.SetParent(BeautyOptionContentTrans, false); option.transform.localScale = Vector3.one; option.transform.localPosition = Vector3.zero; option.name = beautyitem.name; option.GetComponentInChildren <Text>().text = beautyitem.name; option.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(beautyitem.type, beautyitem.iconid_0); if (BeautyGOs.ContainsKey(beautyitem)) { BeautyGOs.Remove(beautyitem); } BeautyGOs.Add(beautyitem, option); option.GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { if (go != currentSelected) { currentSelected = go; foreach (var bgo in BeautyGOs) { bgo.Value.transform.Find("Image_bg").gameObject.SetActive(false); } go.transform.Find("Image_bg").gameObject.SetActive(true); } rtt.SetItemParams(BeautySkinItemName, "filter_name", beautyitem.paramword); rtt.SetItemParamd(BeautySkinItemName, "filter_level", beautyitem.defaultvalue); BeautySkin_Slider.value = beautyitem.defaultvalue; }); return(option); }
public void PrintData() { PrintMessage("Beauty", Beauty.ToString(), Utilities.Getmark(1, Beauty)); PrintMessage("Smarts", Smarts.ToString(), Utilities.Getmark(4, Smarts)); PrintMessage("Phisics", Phisics.ToString(), Utilities.Getmark(7, Phisics)); PrintAllData(arr); }
public Appearance() { description = new List <string>(); theAge = new Age(); theBeauty = new Beauty(); theDexterity = new Dexterity(); theGrooming = new Grooming(); theHeight = new Height(); theStrength = new Strength(); theWeight = new Weight(); }
void SwitchBeautyOptionUIState(Beauty bi, GameObject go) { if (bi.ifenable) { go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(0, bi.iconid_0); go.GetComponentInChildren <Text>().color = highlightColor; } else { go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(0, bi.iconid_1); go.GetComponentInChildren <Text>().color = normalColor; } }
public void Load() { DataList3.DataSource = op.SelectImage("手机", 5); DataList3.DataBind(); DataList4.DataSource = op.SelectImage("电器城", 5); DataList4.DataBind(); DataList5.DataSource = op.SelectImage("西西超市", 5); DataList5.DataBind(); DataList6.DataSource = op.SelectImage("西西生活", 5); DataList6.DataBind(); DataList7.DataSource = op.SelectImage("有我你更美", 5); DataList7.DataBind(); DataList8.DataSource = op.SelectImage("智能硬件", 5); DataList8.DataBind(); midImage.DataSource = op.SelectImage("pimage", 5); midImage.DataBind(); DataList9.DataSource = op.SelectImage("手机", 10); DataList9.DataBind(); DataList10.DataSource = op.SelectImage("电器城", 10); DataList10.DataBind(); DataList11.DataSource = op.SelectImage("西西超市", 10); DataList11.DataBind(); DataList12.DataSource = op.SelectImage("西西生活", 10); DataList12.DataBind(); DataList13.DataSource = op.SelectImage("智能硬件", 10); DataList13.DataBind(); DataList14.DataSource = op.SelectImage("有我你更美", 10); DataList14.DataBind(); DataList15.DataSource = op.SelectImage("办公设备", 10); DataList15.DataBind(); DataList16.DataSource = op.SelectImage("西西商城", 10); DataList16.DataBind(); DataList17.DataSource = op.SelectNewInfo(10); DataList17.DataBind(); Phone.DataSource = op.SelectPhone(10); Phone.DataBind(); Life.DataSource = op.SelectImage("西西生活", 10); Life.DataBind(); Electric.DataSource = op.SelectImage("电器城", 10); Electric.DataBind(); Beauty.DataSource = op.SelectImage("有我你更美", 10); Beauty.DataBind(); }
public ActionResult Beauty(Beauty beauty, HttpPostedFileBase ImageFile) { string fileName = Path.GetFileNameWithoutExtension(ImageFile.FileName); string extension = Path.GetExtension(ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; beauty.ImagePath = "~/Beauty/" + fileName; fileName = Path.Combine(Server.MapPath("~/Beauty/"), fileName); ImageFile.SaveAs(fileName); dbContext.beauties.Add(beauty); dbContext.SaveChanges(); return(View("DisplayBeauty")); }
void SwitchBeautyOptionUIState(Beauty bi, GameObject go) { var bg = go.transform.Find("Image_bg"); if (bg) { if (Math.Abs(bi.currentvalue - bi.disablevalue) < 0.01) { bg.gameObject.SetActive(false); } else { bg.gameObject.SetActive(true); } } }
GameObject AddBeautySkinOptions(int name, Beauty beautyitem) { beautyitem.currentvalue = (float)rtt.GetItemParamd(BeautySkinItemName, beautyitem.paramword); GameObject option = Instantiate(BeautySkin_UIExample); option.transform.SetParent(BeautyOptionContentTrans, false); option.transform.localScale = Vector3.one; option.transform.localPosition = Vector3.zero; option.name = name.ToString(); option.GetComponentInChildren <Text>().text = beautyitem.name; option.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(beautyitem.type, beautyitem.iconid_0); if (BeautyGOs.ContainsKey(beautyitem)) { BeautyGOs.Remove(beautyitem); } BeautyGOs.Add(beautyitem, option); SwitchBeautyOptionUIState(beautyitem, option); return(option); }
GameObject AddBeautySkinOptions(int name, Beauty beautyitem) { beautyitem.currentvalue = (float)rtt.GetItemParamd(BeautySkinItemName, beautyitem.paramword); beautyitem.ifenable = beautyitem.currentvalue == beautyitem.disablevalue ? false : true; GameObject option = Instantiate(BeautySkin_UIExample); option.transform.SetParent(BeautyOptionContentTrans, false); option.transform.localScale = Vector3.one; option.transform.localPosition = Vector3.zero; option.name = name.ToString(); var txt = option.GetComponentInChildren <Text>(); txt.text = beautyitem.name; if (BeautyGOs.ContainsKey(beautyitem)) { BeautyGOs.Remove(beautyitem); } BeautyGOs.Add(beautyitem, option); SwitchBeautyOptionUIState(beautyitem, option); return(option); }
public Dictionary <int, string> Get() { return(Beauty.GetBeauty()); }
IEnumerator OpenBeautySkinUI(BeautySkinType type) { if (type == BeautySkinType.None) { yield return(LoadBeautyBundle()); yield return(LoadMakeupBundle()); } currentBeautySkinType = type; currentItemType = ItemType.Beauty; CloseAllBeautySkinContent(); GameObject panel = BeautySkinContentPanels[0]; BeautyOptionContentTrans.localPosition = Vector3.zero; var layout = BeautyOptionContentTrans.GetComponent <HorizontalLayoutGroup>(); layout.padding.left = 20; layout.padding.right = 20; BeautySkinContentPanels[3].SetActive(true); ClearBeautySkinOptions(); if (type == BeautySkinType.BeautySkin) { BeautySkinSelecterOptions[0].GetComponent <Text>().color = highlightColor; AddBeautySkinOptions(0, BeautyConfig.beautySkin_1[0]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { Beauty bi = BeautyConfig.beautySkin_1[0]; if (currentSelected != go) { currentSelected = go; UnSelectAllBeautySkinOptions(); go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(bi.type, bi.iconid_1); go.GetComponentInChildren <Text>().color = highlightColor; BeautySkinContentPanels[2].SetActive(false); BeautySkinContentPanels[1].SetActive(false); } else { bi.currentvalue = bi.currentvalue == bi.disablevalue ? bi.maxvalue : bi.disablevalue; rtt.SetItemParamd(BeautySkinItemName, BeautyConfig.beautySkin_1[0].paramword, bi.currentvalue); SwitchBeautyOptionUIState(bi, go); } }); GameObject bgo1 = AddBeautySkinOptions(1, BeautyConfig.beautySkin_1[2]); bgo1.GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { Beauty bi1 = BeautyConfig.beautySkin_1[1]; Beauty bi2 = BeautyConfig.beautySkin_1[2]; if (currentSelected != go) { currentSelected = go; UnSelectAllBeautySkinOptions(); go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(bi2.type, bi2.iconid_1); go.GetComponentInChildren <Text>().color = highlightColor; BeautySkinContentPanels[2].SetActive(false); BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = bi2.maxvalue; BeautySkin_Slider.value = bi2.currentvalue; BeautySkin_Slider.onValueChanged.AddListener(delegate { bi2.currentvalue = BeautySkin_Slider.value; rtt.SetItemParamd(BeautySkinItemName, bi2.paramword, bi2.currentvalue); SwitchBeautyOptionUIState(bi2, go); }); BeautySkinContentPanels[1].SetActive(true); } else { bi1.currentvalue++; bi1.currentvalue = bi1.currentvalue % (bi1.maxvalue + 1); //0~2 循环 //bi1.currentvalue = bi1.currentvalue == bi1.disablevalue ? bi1.maxvalue : bi1.disablevalue; if (bi1.currentvalue == 0) { go.GetComponentInChildren <Text>().text = "清晰磨皮"; } else if (bi1.currentvalue == 1) { go.GetComponentInChildren <Text>().text = "重度磨皮"; } else if (bi1.currentvalue == 2) { go.GetComponentInChildren <Text>().text = "精细磨皮"; } rtt.SetItemParamd(BeautySkinItemName, BeautyConfig.beautySkin_1[1].paramword, bi1.currentvalue); } }); if (BeautyConfig.beautySkin_1[1].currentvalue == 0) { bgo1.GetComponentInChildren <Text>().text = "清晰磨皮"; } else if (BeautyConfig.beautySkin_1[1].currentvalue == 1) { bgo1.GetComponentInChildren <Text>().text = "重度磨皮"; } else if (BeautyConfig.beautySkin_1[1].currentvalue == 2) { bgo1.GetComponentInChildren <Text>().text = "精细磨皮"; } for (int i = 3; i < BeautyConfig.beautySkin_1.Length; i++) { AddBeautySkinOptions(i, BeautyConfig.beautySkin_1[i]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { if (currentSelected != go) { Beauty bi = null; foreach (var bgo in BeautyGOs) { if (bgo.Value == go) { bi = bgo.Key; } } if (bi == null) { Debug.Log("Undefined BeautyGO!!! name=" + go.name); return; } currentSelected = go; UnSelectAllBeautySkinOptions(); go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(bi.type, bi.iconid_1); go.GetComponentInChildren <Text>().color = highlightColor; BeautySkinContentPanels[2].SetActive(false); BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = bi.maxvalue; BeautySkin_Slider.value = bi.currentvalue; BeautySkin_Slider.onValueChanged.AddListener(delegate { bi.currentvalue = BeautySkin_Slider.value; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.currentvalue); SwitchBeautyOptionUIState(bi, go); }); BeautySkinContentPanels[1].SetActive(true); } }); } panel.SetActive(true); BeautySkinContentPanels[4].SetActive(true); } else if (type == BeautySkinType.BeautyShape) { BeautySkinSelecterOptions[1].GetComponent <Text>().color = highlightColor; GameObject bgo1 = AddBeautySkinOptions(1, BeautyConfig.beautySkin_2[0]); bgo1.GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { if (currentSelected != go) { Beauty bi = BeautyConfig.beautySkin_2[0]; currentSelected = go; UnSelectAllBeautySkinOptions(); go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(bi.type, bi.iconid_1); go.GetComponentInChildren <Text>().color = highlightColor; BeautySkinContentPanels[1].SetActive(false); BeautySkinContentPanels[2].SetActive(true); } }); bgo1.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(BeautyConfig.beautySkin_2[0].type, BeautyConfig.beautySkin_2[0].iconid_1); bgo1.GetComponentInChildren <Text>().color = highlightColor; for (int i = 1; i < BeautyConfig.beautySkin_2.Length; i++) { AddBeautySkinOptions(i, BeautyConfig.beautySkin_2[i]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { if (currentSelected != go) { Beauty bi = null; foreach (var bgo in BeautyGOs) { if (bgo.Value == go) { bi = bgo.Key; } } if (bi == null) { Debug.Log("Undefined BeautyGO!!! name=" + go.name); return; } currentSelected = go; UnSelectAllBeautySkinOptions(); go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(bi.type, bi.iconid_1); go.GetComponentInChildren <Text>().color = highlightColor; BeautySkinContentPanels[2].SetActive(false); BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = bi.maxvalue; BeautySkin_Slider.value = bi.currentvalue; BeautySkin_Slider.onValueChanged.AddListener(delegate { bi.currentvalue = BeautySkin_Slider.value; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.currentvalue); SwitchBeautyOptionUIState(bi, go); }); BeautySkinContentPanels[1].SetActive(true); } }); } for (int i = 0; i < BeautySkin_FaceShape.Length; i++) { BeautySkin_FaceShape[i].GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { BeautyConfig.beautySkin_2[0].currentvalue = int.Parse(go.name); OpenBeautyShapeUI(); }); } if (BeautyConfig.beautySkin_2[0].currentvalue == -1) { BeautyConfig.beautySkin_2[0].currentvalue = 4; } else if (BeautyConfig.beautySkin_2[0].currentvalue == -5) { BeautyConfig.beautySkin_2[0].currentvalue = 3; } OpenBeautyShapeUI(); panel.SetActive(true); BeautySkinContentPanels[1].SetActive(false); BeautySkinContentPanels[2].SetActive(true); BeautySkinContentPanels[4].SetActive(true); } else if (type == BeautySkinType.BeautyFilter) { BeautySkinSelecterOptions[2].GetComponent <Text>().color = highlightColor; string currentfiltername = rtt.GetItemParams(BeautySkinItemName, "filter_name"); foreach (var bi in BeautyConfig.beautySkin_3) { GameObject go = AddBeautyFilterOptions(bi); if (string.Compare(bi.paramword, currentfiltername, true) == 0) { currentSelected = go; go.transform.Find("Image_bg").gameObject.SetActive(true); } } BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = 1; BeautySkin_Slider.value = (float)rtt.GetItemParamd(BeautySkinItemName, "filter_level"); BeautySkin_Slider.onValueChanged.AddListener(delegate { rtt.SetItemParamd(BeautySkinItemName, "filter_level", BeautySkin_Slider.value); }); panel.SetActive(true); BeautySkinContentPanels[1].SetActive(true); BeautySkinContentPanels[2].SetActive(false); BeautySkinContentPanels[4].SetActive(true); } else if (type == BeautySkinType.MakeupGroup) { BeautySkinSelecterOptions[3].GetComponent <Text>().color = highlightColor; foreach (var mg in BeautyConfig.makeupGroup_1) { GameObject go = AddMakeupOptions(mg); if (string.Compare(mg.name, currentSelectedMakeupName, true) == 0) { //currentSelected = go; //go.transform.Find("Image_bg").gameObject.SetActive(true); go.GetComponent <AddClickEvent>().onClick(go); } } if (string.Compare(BeautyConfig.makeupGroup_1[0].name, currentSelectedMakeupName, true) != 0) { BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = 1; BeautySkin_Slider.value = (float)rtt.GetItemParamd(MakeupItemName, "makeup_intensity"); BeautySkin_Slider.onValueChanged.AddListener(delegate { rtt.SetItemParamd(MakeupItemName, "makeup_intensity", BeautySkin_Slider.value); float v = BeautySkin_Slider.value * currentMakeupfilterV; v = v > 1 ? 1 : v; v = v < 0 ? 0 : v; rtt.SetItemParamd(BeautySkinItemName, "filter_level", v); }); BeautySkinContentPanels[1].SetActive(true); } else { BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkinContentPanels[1].SetActive(false); } panel.SetActive(true); BeautySkinContentPanels[2].SetActive(false); BeautySkinContentPanels[4].SetActive(true); } BeautySkinContent.SetActive(true); BeautySkinSelecter.SetActive(true); }
void OpenBeautySkinUI(BeautySkinType type) { currentBeautySkinType = type; currentItemType = ItemType.Beauty; StartCoroutine(rtt.LoadItem(ItemConfig.beautySkin[0])); CloseAllBeautySkinContent(); GameObject panel = BeautySkinContentPanels[0]; panel.GetComponent <ScrollRect>().content.localPosition = Vector3.zero; BeautySkinContentPanels[3].gameObject.SetActive(true); ClearBeautySkinOptions(); if (type == BeautySkinType.BeautySkin) { BeautySkinSelecterOptions[0].GetComponent <Text>().color = highlightColor; AddBeautySkinOptions(0, BeautyConfig.beautySkin_1[0]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { Beauty bi = null; foreach (var bgo in BeautyGOs) { if (bgo.Value == go) { bi = bgo.Key; } } if (bi == null) { Debug.Log("Undefined BeautyGO!!! name=" + go.name); return; } if (currentSelected != go) { currentSelected = go; UnSelectAllBeautySkinOptions(); go.transform.Find("Image_bg").gameObject.SetActive(true); BeautySkinContentPanels[2].SetActive(false); BeautySkinContentPanels[1].SetActive(false); } //else { bi.ifenable = !bi.ifenable; bi.currentvalue = bi.ifenable ? 1 : 0; rtt.SetItemParamd(BeautySkinItemName, BeautyConfig.beautySkin_1[0].paramword, bi.currentvalue); SwitchBeautyOptionUIState(bi, go); } }); GameObject bgo1 = AddBeautySkinOptions(1, BeautyConfig.beautySkin_1[1]); bgo1.GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { Beauty bi = null; foreach (var bgo in BeautyGOs) { if (bgo.Value == go) { bi = bgo.Key; } } if (bi == null) { Debug.Log("Undefined BeautyGO!!! name=" + go.name); return; } if (currentSelected != go) { currentSelected = go; UnSelectAllBeautySkinOptions(); go.transform.Find("Image_bg").gameObject.SetActive(true); BeautySkinContentPanels[2].SetActive(false); BeautySkinContentPanels[1].SetActive(false); } //else { bi.ifenable = !bi.ifenable; bi.currentvalue = bi.ifenable ? 1 : 0; if (bi.ifenable) { go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(0, bi.iconid_0); go.GetComponentInChildren <Text>().text = "朦胧磨皮"; } else { go.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(0, bi.iconid_1); go.GetComponentInChildren <Text>().text = "清晰磨皮"; } rtt.SetItemParamd(BeautySkinItemName, BeautyConfig.beautySkin_1[1].paramword, bi.currentvalue); } }); if (BeautyConfig.beautySkin_1[1].ifenable) { bgo1.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(0, BeautyConfig.beautySkin_1[1].iconid_0); bgo1.GetComponentInChildren <Text>().text = "朦胧磨皮"; } else { bgo1.GetComponentInChildren <Image>().sprite = uisprites.GetSprite(0, BeautyConfig.beautySkin_1[1].iconid_1); bgo1.GetComponentInChildren <Text>().text = "清晰磨皮"; } bgo1.GetComponentInChildren <Text>().color = highlightColor; for (int i = 2; i < BeautyConfig.beautySkin_1.Length - 1; i++) { AddBeautySkinOptions(i, BeautyConfig.beautySkin_1[i]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { Beauty bi = null; foreach (var bgo in BeautyGOs) { if (bgo.Value == go) { bi = bgo.Key; } } if (bi == null) { Debug.Log("Undefined BeautyGO!!! name=" + go.name); return; } if (currentSelected != go) { currentSelected = go; UnSelectAllBeautySkinOptions(); go.transform.Find("Image_bg").gameObject.SetActive(true); BeautySkinContentPanels[2].SetActive(false); BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = bi.maxvalue; BeautySkin_Slider.value = bi.currentvalue; BeautySkin_Slider.onValueChanged.AddListener(delegate { bi.currentvalue = BeautySkin_Slider.value; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.currentvalue); }); if (!bi.ifenable) { bi.ifenable = true; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.currentvalue); SwitchBeautyOptionUIState(bi, go); } BeautySkinContentPanels[1].SetActive(true); } else { bi.ifenable = !bi.ifenable; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.ifenable ? bi.currentvalue : bi.disablevalue); SwitchBeautyOptionUIState(bi, go); BeautySkinContentPanels[1].SetActive(bi.ifenable); } }); } AddBeautySkinOptions(BeautyConfig.beautySkin_1.Length - 1, BeautyConfig.beautySkin_1[BeautyConfig.beautySkin_1.Length - 1]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { foreach (var bgo in BeautyGOs) { bgo.Key.currentvalue = bgo.Key.defaultvalue; rtt.SetItemParamd(BeautySkinItemName, bgo.Key.paramword, bgo.Key.currentvalue); bgo.Key.ifenable = bgo.Key.currentvalue == bgo.Key.disablevalue ? false : true; SwitchBeautyOptionUIState(bgo.Key, bgo.Value); } currentSelected = null; UnSelectAllBeautySkinOptions(); BeautySkinContentPanels[2].SetActive(false); BeautySkinContentPanels[1].SetActive(false); }); panel.SetActive(true); } else if (type == BeautySkinType.BeautyShape) { BeautySkinSelecterOptions[1].GetComponent <Text>().color = highlightColor; AddBeautySkinOptions(0, BeautyConfig.beautySkin_2[0]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { Beauty bi = null; foreach (var bgo in BeautyGOs) { if (bgo.Value == go) { bi = bgo.Key; } } if (bi == null) { Debug.Log("Undefined BeautyGO!!! name=" + go.name); return; } if (currentSelected != go) { currentSelected = go; UnSelectAllBeautySkinOptions(); go.transform.Find("Image_bg").gameObject.SetActive(true); BeautySkinContentPanels[1].SetActive(false); BeautySkinContentPanels[2].SetActive(true); } }); for (int i = 1; i < BeautyConfig.beautySkin_2.Length - 1; i++) { AddBeautySkinOptions(i, BeautyConfig.beautySkin_2[i]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { Beauty bi = null; foreach (var bgo in BeautyGOs) { if (bgo.Value == go) { bi = bgo.Key; } } if (bi == null) { Debug.Log("Undefined BeautyGO!!! name=" + go.name); return; } if (currentSelected != go) { currentSelected = go; UnSelectAllBeautySkinOptions(); go.transform.Find("Image_bg").gameObject.SetActive(true); BeautySkinContentPanels[2].SetActive(false); BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = bi.maxvalue; BeautySkin_Slider.value = bi.currentvalue; BeautySkin_Slider.onValueChanged.AddListener(delegate { bi.currentvalue = BeautySkin_Slider.value; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.currentvalue); }); if (!bi.ifenable) { bi.ifenable = true; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.currentvalue); SwitchBeautyOptionUIState(bi, go); } BeautySkinContentPanels[1].SetActive(true); } else { bi.ifenable = !bi.ifenable; rtt.SetItemParamd(BeautySkinItemName, bi.paramword, bi.ifenable ? bi.currentvalue : bi.disablevalue); SwitchBeautyOptionUIState(bi, go); BeautySkinContentPanels[1].SetActive(bi.ifenable); } }); } AddBeautySkinOptions(BeautyConfig.beautySkin_2.Length - 1, BeautyConfig.beautySkin_2[BeautyConfig.beautySkin_2.Length - 1]).GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { foreach (var bgo in BeautyGOs) { if (bgo.Key.paramword != BeautyConfig.beautySkin_2[0].paramword) { bgo.Key.currentvalue = bgo.Key.defaultvalue; rtt.SetItemParamd(BeautySkinItemName, bgo.Key.paramword, bgo.Key.currentvalue); bgo.Key.ifenable = bgo.Key.currentvalue == bgo.Key.disablevalue ? false : true; SwitchBeautyOptionUIState(bgo.Key, bgo.Value); } } currentSelected = null; UnSelectAllBeautySkinOptions(); BeautySkinContentPanels[2].SetActive(false); BeautySkinContentPanels[1].SetActive(false); }); for (int i = 0; i < BeautySkin_FaceShape.Length; i++) { BeautySkin_FaceShape[i].GetComponent <AddClickEvent>().AddListener(delegate(GameObject go) { BeautyConfig.beautySkin_2[0].currentvalue = int.Parse(go.name); BeautyConfig.beautySkin_2[0].ifenable = BeautyConfig.beautySkin_2[0].currentvalue == BeautyConfig.beautySkin_2[0].disablevalue ? false : true; SwitchBeautyOptionUIState(BeautyConfig.beautySkin_2[0], BeautyGOs[BeautyConfig.beautySkin_2[0]]); OpenBeautyShapeUI(); }); } if (BeautyConfig.beautySkin_2[0].currentvalue == -1) { BeautyConfig.beautySkin_2[0].currentvalue = 4; } OpenBeautyShapeUI(); panel.SetActive(true); BeautySkinContentPanels[1].SetActive(false); BeautySkinContentPanels[2].SetActive(true); } else if (type == BeautySkinType.BeautyFilter) { BeautySkinSelecterOptions[2].GetComponent <Text>().color = highlightColor; string currentfiltername = rtt.GetItemParams(BeautySkinItemName, "filter_name"); foreach (var bi in BeautyConfig.beautySkin_3) { GameObject go = AddBeautyFilterOptions(bi); if (string.Compare(bi.paramword, currentfiltername, true) == 0) { currentSelected = go; go.transform.Find("Image_bg").gameObject.SetActive(true); } } BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = 1; BeautySkin_Slider.value = (float)rtt.GetItemParamd(BeautySkinItemName, "filter_level"); BeautySkin_Slider.onValueChanged.AddListener(delegate { rtt.SetItemParamd(BeautySkinItemName, "filter_level", BeautySkin_Slider.value); }); panel.SetActive(true); BeautySkinContentPanels[1].SetActive(true); BeautySkinContentPanels[2].SetActive(false); } else if (type == BeautySkinType.Filter) { BeautySkinSelecterOptions[3].GetComponent <Text>().color = highlightColor; string currentfiltername = rtt.GetItemParams(BeautySkinItemName, "filter_name"); foreach (var bi in BeautyConfig.beautySkin_4) { GameObject go = AddBeautyFilterOptions(bi); var test = string.Compare(bi.paramword, currentfiltername, true); if (string.Compare(bi.paramword, currentfiltername, true) == 0) { currentSelected = go; go.transform.Find("Image_bg").gameObject.SetActive(true); } } BeautySkin_Slider.onValueChanged.RemoveAllListeners(); BeautySkin_Slider.minValue = 0; BeautySkin_Slider.maxValue = 1; BeautySkin_Slider.value = (float)rtt.GetItemParamd(BeautySkinItemName, "filter_level"); BeautySkin_Slider.onValueChanged.AddListener(delegate { rtt.SetItemParamd(BeautySkinItemName, "filter_level", BeautySkin_Slider.value); }); panel.SetActive(true); BeautySkinContentPanels[1].SetActive(true); BeautySkinContentPanels[2].SetActive(false); } BeautySkinContent.SetActive(true); BeautySkinSelecter.SetActive(true); }
//Skapar upp objekt av Klassen ChirstmasGifts //TODO: Bygg ut på switchen så att man kan köpa passande julklappar static void BuyGifts() { bool keepBuying = true; while (keepBuying) { int counter = 1; Console.WriteLine("Who do you wanna buy gifts for?"); foreach (Human person in listOfPersons) { Console.WriteLine($"{counter}. {person.FirstName} {person.LastName}"); counter++; } int choice = Convert.ToInt32(Console.ReadLine()); Human personToGift = listOfPersons[choice - 1]; Console.WriteLine("What do you wanna buy?"); Console.WriteLine("1. Beauty gifts"); Console.WriteLine("2. Clothes"); Console.WriteLine("3. Technology"); Console.WriteLine("4. Toy"); choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: Beauty Maskarra = new Beauty("Pink", "Glossy glowing black", 199, "Loreal, you is worth it:)"); personToGift.ListOfGifts.Add(Maskarra); Console.WriteLine($"Added a {Maskarra.Name} to the list"); break; case 2: Clothes byxor = new Clothes("Jeans", "Levis", "30/34", 999, "Levis UltraSlim 2020 Limited Edition"); personToGift.ListOfGifts.Add(byxor); Console.WriteLine($"Added a {byxor.Name} to the list"); break; case 3: Technology techy = new Technology(6, true, "Samsung Ultra lazer hair remover", 1999, "lifesaver"); personToGift.ListOfGifts.Add(techy); Console.WriteLine($"Added a {techy.Name} to the list"); break; case 4: Toys toy = new Toys(3, "Peppa pigs magic train", 899, "Kids"); personToGift.ListOfGifts.Add(toy); Console.WriteLine($"Added a {toy.Name} to the list"); break; } Console.WriteLine("Do you want to continue=? q to quit"); if (Console.ReadLine() == "q") { keepBuying = false; } } }
public async Task <IHttpActionResult> POST() { string postData = Request.Content.ReadAsStringAsync().Result; //剖析JSON var messageObject = isRock.LineBot.Utility.Parsing(postData).events.FirstOrDefault(); if (!await VaridateSignature(Request)) { isRock.LineBot.Utility.ReplyMessage(messageObject.replyToken, "驗證失敗", ChannelAccessToken); return(Ok()); } //取得user說的話 string message = messageObject.message.text; //回覆訊息 string reply = string.Empty; //Message = "你說了:" + item.message.text; string id = string.Empty; LineUserInfo userInfo = GetUserInfoAndId(messageObject, out id); string ownKey = userInfo.userId + "Own"; var regex = new Regex("\\D", RegexOptions.IgnoreCase); try { if (message == "大樂透") { var numbers = GetLetou(); var letouMsg = Letou.Instance.Compare(numbers); reply = $"給你一組幸運號碼: {numbers}\\n"; reply += letouMsg; } else if (message == "安安9527" || message == "9527安安" || message == "安安") { Utility.ReplyMessageWithJSON(messageObject.replyToken, Demo.Show(), ChannelAccessToken); } else if (message.Contains("抽")) { var beauty = Beauty.GetBeauty(); var random = new Random(new Random().Next(1, beauty.Count())); var image = beauty[random.Next(1, beauty.Count())]; Utility.ReplyImageMessage(messageObject.replyToken, image, image, ChannelAccessToken); return(Ok()); } else if (message.Contains("美食")) { var eat = new Eat(); var data = await eat.GetEatData(message.Replace("美食", "")); var list = new List <TemplateModel>(); var model = new TemplateModel(); model.template = new CarouselModel(); model.template.columns = new List <ThumbnailImageModel>(); foreach (var item in data.response.Where(x => x.restaurant != null).Take(10)) { model.template.columns.Add(new ThumbnailImageModel() { thumbnailImageUrl = item.restaurant.cover_url, title = item.restaurant.name, text = item.address, defaultAction = new UriModel() { label = "瀏覽網誌", uri = item.url.IndexOf('-') > 0 ? item.url.Substring(0, item.url.IndexOf('-')) : item.url }, actions = new List <ActionModel>() { new UriModel() { label = "導航", uri = $"https://www.google.com.tw/maps/place/{item.restaurant.address}" } } }); } list.Add(model); if (model.template.columns.Count > 0) { Utility.ReplyMessageWithJSON(messageObject.replyToken, JsonConvert.SerializeObject(list), ChannelAccessToken); } else { reply = "查無資料..."; } } else if (message.Contains("天氣")) { var area = message.Replace("天氣", "").Replace("台", "臺").Trim(); var data = (await Weather.Instance.GetData()).records.location.FirstOrDefault(x => x.locationName.Contains(area)); var dic = new Dictionary <string, string>(); foreach (var item in data.weatherElement.OrderBy(x => x.elementName)) { foreach (var time in item.time) { var key = $"{time.startTime}~{time.endTime}"; if (!dic.Keys.Contains(key)) { dic.Add(key, ""); } switch (item.elementName) { case "Wx": dic[key] += $"天氣:{time.parameter.parameterName}\\n"; break; case "PoP": dic[key] += $"降雨機率:{time.parameter.parameterName}%\\n"; break; case "MinT": dic[key] += $"低溫:{time.parameter.parameterName}C\\n"; break; case "CI": dic[key] += $"適度:{time.parameter.parameterName}\\n"; break; case "MaxT": dic[key] += $"高溫:{time.parameter.parameterName}C\\n"; break; default: break; } } } foreach (var item in dic) { reply += $"{item.Key}\\n{item.Value}"; } if (reply == string.Empty) { reply = "查無資料... 試試台北天氣"; } } else if (message.ToLower().Contains("ubike")) { var data = await UBike.Instance.GetAllData(); var mday = data.FirstOrDefault().mday; var refreshTime = new DateTime(Convert.ToInt16(mday.Substring(0, 4)), Convert.ToInt16(mday.Substring(4, 2)), Convert.ToInt16(mday.Substring(6, 2)), Convert.ToInt16(mday.Substring(8, 2)), Convert.ToInt16(mday.Substring(10, 2)), Convert.ToInt16(mday.Substring(12, 2))); var location = message.ToLower().Replace("ubike", "").Trim(); if (location == "三重家") { foreach (var item in data.Where(x => x.sno == "1008" || x.sno == "1010")) { reply += $"[{item.sarea}-{item.sna}]車{item.sbi}空{item.bemp}\\n"; } if (reply == string.Empty) { reply = "查無資料..."; } else { reply += $"更新時間{refreshTime.ToString("yyyy/MM/dd HH:mm:ss")}"; } } else if (location.Contains("區")) { foreach (var item in data.Where(x => x.sarea == location)) { reply += $"[{item.sarea}-{item.sna}]車{item.sbi}空{item.bemp}\\n"; } if (reply == string.Empty) { reply = "查無資料..."; } else { reply += $"更新時間{refreshTime.ToString("yyyy/MM/dd HH:mm:ss")}"; } } else if (location != string.Empty) { foreach (var item in data.Where(x => x.sna.Contains(location))) { reply += $"[{item.sarea}-{item.sna}]車{item.sbi}空{item.bemp}\\n"; } if (reply == string.Empty) { reply = "查無資料..."; } else { reply += $"更新時間{refreshTime.ToString("yyyy/MM/dd HH:mm:ss")}"; } } } else if (message == "大樂透機率") { reply = Letou.Instance.GetHighRateNumbers(); } else if (message.Contains("大樂透")) { var numbers = message.Split(' ')?[1]; if (numbers != null && numbers.Split(',').Count() == 6) { reply = Letou.Instance.Compare(numbers); } } //else if (LuisMaster.HitLuis(message,out string luisMessage)) //{ // reply = $"{luisMessage}"; //} else if (message.Contains("打球了")) { bool isFriday = false; DateTime date = DateTime.Now; if (date.DayOfWeek == DayOfWeek.Friday) { reply = $"今晚7點半,高品打老虎"; } else { while (!isFriday) { if (date.DayOfWeek == DayOfWeek.Friday) { isFriday = true; } else { date = date.AddDays(1); } } reply = $"{date.ToString("yyyy/M/d")} 星期五 晚上7點半, 高品集合~~"; } } else if (message == "猜數字") { reply = $"{userInfo.displayName} 開始猜數字 , 請輸入: 4位數字 (ex:1234) , 時間20分鐘"; var number = new GuessNum().GenNum(); var policy = new CacheItemPolicy { AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(20) }; cache.Set(ownKey, number, policy); cache.Set($"{ownKey}Count", 0, policy); cache.Remove(id); } else if (!regex.IsMatch(message) && message.Length == 4 && cache[ownKey] != null && cache[id] == null) { var ans = cache[ownKey].ToString(); int.TryParse(cache[$"{ownKey}Count"].ToString(), out int count); count++; var compare = new GuessNum().Compare(ans, message, out string errorMessage); if (compare.A == 4) { reply = $"恭喜你猜對了 : {message} [你一共猜了{count}次]"; cache.Remove(ownKey); cache.Remove($"{ownKey}Count"); } else if (errorMessage != string.Empty) { reply += $"{errorMessage}"; } else { reply += $"{message}==>{compare.A} A {compare.B} B ...己經猜了{count}次"; cache[$"{ownKey}Count"] = count; } } else if (message == "一起猜") { reply = $"大家開始猜數字 , 請輸入: 4位數字 (ex:1234) , 時間20分鐘"; var number = new GuessNum().GenNum(); var policy = new CacheItemPolicy { AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(20) }; cache.Set(id, number, policy); cache.Set($"{id}Count", 0, policy); } else if (!regex.IsMatch(message) && message.Length == 4 && cache[id] != null) { var ans = cache[id].ToString(); int.TryParse(cache[$"{id}Count"].ToString(), out int count); count++; var compare = new GuessNum().Compare(ans, message, out string errorMessage); if (compare.A == 4) { reply += $"恭喜猜對了 : {message} [一共猜了{count}次]" + cache.Remove(id); cache.Remove($"{id}Count"); } else if (errorMessage != string.Empty) { reply += $"{errorMessage}"; } else { reply += $"{message}==>{compare.A} A {compare.B} B ...己經猜了{count}次"; cache[$"{id}Count"] = count; } } else if (message.Contains("PM2.5")) { var word = message.Split('的'); if (word.Length == 2 && word[1].Contains("PM2.5")) { var area = word[0].Replace("台", "臺"); var air = new AirQuality(); var model = air.GetList().Where(x => x.county.Contains(area) || x.Site.Contains(area)); if (model.Count() > 0) { foreach (var item in model) { reply += $"{item.county}{item.Site}的PM2.5為[{item.PM25}], {item.Status}\\n"; } reply += $"更新時間:{model.FirstOrDefault().DataCreationDate.Value}"; } else { reply = "查無資料 , 有可能打錯關鍵字, 可以試試 新北市的PM2.5 或 三重的PM2.5"; } } } //回覆API OK isRock.LineBot.Utility.ReplyMessage(messageObject.replyToken, $"{reply}", ChannelAccessToken); //Utility.ReplyMessageWithJSON(messageObject.replyToken,FlexMessage(), ChannelAccessToken); return(Ok()); } catch (Exception ex) { //isRock.LineBot.Utility.ReplyMessage(messageObject.replyToken, $"{ex.Message} \nitem.source.type {messageObject.source.type}", ChannelAccessToken); return(Ok()); } }