// Nouvelle selection d'item // -1 = gauche _ 1 droite _ 2 haut _ -2 bas public void NextItem(int thisDir) { DOVirtual.DelayedCall(.1f, () => { CheckSelectItem(false); switch (thisDir) { case -1: currItemSeled = currItemSeled.LeftItem; ItemLeft(); break; case 1: currItemSeled = currItemSeled.RightItem; ItemRight(); break; case -2: currItemSeled = currItemSeled.DownItem; break; case 2: currItemSeled = currItemSeled.UpItem; break; } }); CheckSelectItem(true); }
// Selection d'un nouvelle item void CheckSelectItem(bool selected) { ItemModif thisItem = currItemSeled; if (selected) { thisItem.Selected = true; //Code du outline /* * thisItem.GetComponent<Outline>().transform.DOScale(2, .75f).OnComplete(() => { * thisItem.GetComponent<Outline>().DOFade(0, .25f); * DOVirtual.DelayedCall(.25f, () => { * thisItem.GetComponent<Outline>().DOFade(1, 0); * thisItem.GetComponent<Outline>().transform.DOScale(1, 0); * }); * }).SetLoops(-1,LoopType.Restart);*/ if (thisItem.ItemBought && thisItem.UseOtherColor) { thisItem.GetComponent <Image> ( ).color = thisItem.BoughtColorSelected; } else if (thisItem.UseColor) { thisItem.GetComponent <Image> ( ).color = thisItem.ColorSelected; } if (thisItem.ItemBought && thisItem.UseOtherSprite) { thisItem.GetComponent <Image> ( ).sprite = thisItem.BoughtSpriteSelected; } else { thisItem.GetComponent <Image> ( ).sprite = thisItem.SpriteSelected; } } else { thisItem.Selected = false; if (thisItem.ItemBought && thisItem.UseOtherColor) { thisItem.GetComponent <Image> ( ).color = thisItem.BoughtColorUnSelected; } else if (thisItem.UseColor) { thisItem.GetComponent <Image> ( ).color = thisItem.ColorUnSelected; } if (thisItem.ItemBought && thisItem.UseOtherSprite) { thisItem.GetComponent <Image> ( ).sprite = thisItem.BoughtSpriteUnselected; } else { thisItem.GetComponent <Image> ( ).sprite = thisItem.SpriteUnselected; } } }
//Changement de catégorie a item et inversement void ChangeToItem(bool goItem) { CatShop thisShop = currCatSeled; if (goItem && catCurrSelected) // Changement de cat a item { catCurrSelected = false; currItemSeled = thisShop.DefautItem; iconCategory.DOFade(0, .1f); textCategory.DOFade(0, .1f); barCategory.DOFade(0, .1f); transform.DORotate(new Vector3(moleculeContainer.transform.localEulerAngles.x, moleculeContainer.transform.localEulerAngles.y, -130), 1f); transform.DOLocalMoveX(transform.localPosition.x - 625, 1f); transform.DOLocalMoveY(transform.localPosition.y - 200, 1f); transform.DOScale(1.25f, 1f).OnComplete(() => { thisShop.GetComponent <Image>().DOFade(1, 0.1f); iconCategory.transform.DORotate(Vector3.zero, 0); textCategory.transform.DORotate(new Vector3(0, 0, 423), 0); barCategory.transform.DORotate(new Vector3(0, 0, 423), 0); iconCategory.transform.DOMoveX(thisShop.transform.position.x + 200, 0); iconCategory.transform.DOMoveY(thisShop.transform.position.y, 0); textCategory.transform.DOMoveY(moleculeContainer.transform.position.y + 300, 0); textCategory.transform.DOMoveX(moleculeContainer.transform.position.x - 90, 0); barCategory.transform.DOMoveX(moleculeContainer.transform.position.x - 90, 0); barCategory.transform.DOMoveY(moleculeContainer.transform.position.y + 300, 0); iconCategory.DOFade(1, .25f); textCategory.DOFade(1, .25f); barCategory.DOFade(1, .25f); }); //On remet les molécules de couleur au gris foreach (Transform cat in DefCatSelected.transform.parent) { cat.GetComponent <Image>().DOFade(0, 0.1f); } //Seul le premier item est centré thisShop.transform.GetChild(0).DOLocalMove(new Vector2(-280, 600), 0); thisShop.transform.GetChild(1).DOLocalMove(new Vector2(-525, 895), 0); DOVirtual.DelayedCall(1f, () => { foreach (Transform trans in thisShop.transform) { trans.GetComponent <CanvasGroup>().DOFade(1, 0.5f); trans.DOLocalRotate(new Vector3(0, 0, 130), 0); trans.DOScale(.75f, 0); } }); } else if (!goItem && !catCurrSelected) // Changement de item a cat { catCurrSelected = true; } }
void ItemLeft() { ItemModif thisItem = currItemSeled; thisItem.LeftItem.transform.DOLocalMove(new Vector2(-50, 340), .5f); thisItem.LeftItem.GetComponent <CanvasGroup>().DOFade(.75f, .2f); thisItem.LeftItem.transform.DOScale(.4f, .2f); thisItem.transform.DOLocalMove(new Vector2(-280, 600), .5f); thisItem.transform.DOScale(.75f, .2f); thisItem.GetComponent <CanvasGroup>().DOFade(1, .2f); }
public override void OpenThis(MenuTokenAbstract GetTok = null) { base.OpenThis(GetTok); fixBackShop.SetActive(true); currCatSeled = DefCatSelected; if (currItemSeled != currCatSeled.DefautItem) { CheckSelectItem(false); } currItemSeled = currCatSeled.DefautItem; CheckSelectItem(true); }
protected override void InitializeUi() { currCatSeled = DefCatSelected; currItemSeled = currCatSeled.DefautItem; fixBackShop = transform.parent.Find("GlobalBackGround/Shop").gameObject; moneyNumberPlayer = fixBackShop.transform.Find("MoneyMutation/MoneyNumber").GetComponent <Text> ( ); moneyNumberPlayer.text = "" + AllPlayerPrefs.GetIntValue(Constants.Coin); ItemModif[] checkAllItem = GetComponentsInChildren <ItemModif> (true); ItemModif currItem; string getCons = Constants.ItemBought; Dictionary <string, ItemModif> getItemConf = new Dictionary <string, ItemModif> ( ); allTempItem = new List <ItemModif> ( ); for (int a = 0; a < checkAllItem.Length; a++) { if (AllPlayerPrefs.GetBoolValue(getCons + checkAllItem [a].CatName + checkAllItem [a].ItemName)) { currItem = checkAllItem [a]; try{ getItemConf.Add(getCons + checkAllItem [a].CatName, currItem); }catch { Debug.Log("key same"); } currItem.GetComponent <Image> ( ).sprite = currItem.SpriteConfirm; if (currItem.UseColor) { currItem.GetComponent <Image> ( ).color = currItem.ColorConfirm; } } } CheckSelectItem(true); allConfirm = getItemConf; GlobalManager.GameCont.AllModifItem = getItemConf; GlobalManager.GameCont.AllTempsItem = allTempItem; }
void setItemToPlayer(ItemModif thisItem, PlayerController currPlayer) { if (thisItem.ModifSpecial) { currPlayer.ThisAct = thisItem.SpecAction; if (thisItem.SpecAction == SpecialAction.SlowMot) { currPlayer.SlowMotion = thisItem.SlowMotion; currPlayer.SpeedSlowMot = thisItem.SpeedSlowMot; currPlayer.SpeedDeacSM = thisItem.SpeedDeacSM; currPlayer.ReduceSlider = thisItem.ReduceSlider; currPlayer.RecovSlider = thisItem.RecovSlider; } } if (thisItem.ModifVie) { currPlayer.Life += thisItem.NombreVie; } }
// Selection d'une nouvelle catégorie void CheckSelectCat(bool selected) { CatShop thisShop = currCatSeled; if (selected) { CheckSelectItem(false); currItemSeled = thisShop.DefautItem; CheckSelectItem(true); thisShop.Selected = true; DOVirtual.DelayedCall(.1f, () => { iconCategory.GetComponent <Image>().DOFade(1, .1f); textCategory.DOFade(1, .1f); barCategory.transform.GetChild(0).transform.DOLocalMoveX(200, 0); barCategory.transform.GetChild(0).transform.DOLocalMoveX(0, .6f); textCategory.text = thisShop.NameCat; iconCategory.sprite = thisShop.SpriteSelected; thisShop.GetComponent <Image>().transform.DOScale(1.25f, .2f); //thisShop.GetComponent<Image>().DOFade(1f, .05f); iconCategory.GetComponent <Image>().sprite = thisShop.SpriteSelected; barCategory.transform.GetChild(0).GetComponent <Image>().DOColor(thisShop.ColorSelected, 0); if (textCategory.text == "ABILITIES") { textCategory.transform.DOMoveX(thisShop.GetComponent <Image>().transform.position.x - 55, 0); barCategory.transform.DOMoveX(thisShop.GetComponent <Image>().transform.position.x - 55, 0); iconCategory.transform.DOMoveX(thisShop.GetComponent <Image>().transform.position.x - 40, 0); } else { textCategory.transform.DOMoveX(thisShop.GetComponent <Image>().transform.position.x, 0); barCategory.transform.DOMoveX(thisShop.GetComponent <Image>().transform.position.x, 0); iconCategory.transform.DOMoveX(thisShop.GetComponent <Image>().transform.position.x, 0); } iconCategory.transform.DOMoveY(thisShop.GetComponent <Image>().transform.position.y + 160, 0); textCategory.transform.DOMoveY(thisShop.GetComponent <Image>().transform.position.y + 75, 0); barCategory.transform.DOMoveY(thisShop.GetComponent <Image>().transform.position.y + 75, 0); }); /* * iconCategory.transform.DOLocalMoveY(transform.localPosition.y + 10, .25f).OnComplete(() => { * iconCategory.transform.DOLocalMoveY(transform.localPosition.y - 10, .25f); * }).SetLoops(-1,LoopType.Restart);*/ //iconCategory.transform.DOKill(); //iconCategory.GetComponent<RainbowMove>().enabled = true; if (thisShop.UseColor) { thisShop.GetComponent <Image> ( ).color = thisShop.ColorSelected; } if (thisShop.UseSprite) { //thisShop.GetComponent<Image> ( ).sprite = thisShop.SpriteSelected; } } else { thisShop.Selected = false; //iconCategory.transform.DOKill(); iconCategory.GetComponent <Image>().DOFade(0, .1f); textCategory.DOFade(0, .1f); iconCategory.GetComponent <RainbowMove>().enabled = false; thisShop.GetComponent <Image>().transform.DOScale(.8f, .2f); // thisShop.GetComponent<Image>().DOFade(0, .2f); if (thisShop.UseColor) { //thisShop.GetComponent<Image> ( ).color = thisShop.ColorUnSelected; } if (thisShop.UseSprite) { //thisShop.GetComponent<Image> ( ).sprite = thisShop.SpriteUnSelected; } } }
// achete ou confirme un item public void BuyItem( ) { string getCons = Constants.ItemBought + currItemSeled.CatName; Dictionary <string, ItemModif> getAllBuy = allConfirm; if (AllPlayerPrefs.GetBoolValue(getCons + currItemSeled.ItemName)) { AllPlayerPrefs.SetStringValue(getCons + currItemSeled.ItemName, "Confirm"); ItemModif getThis; if (getAllBuy.TryGetValue(getCons, out getThis)) { AllPlayerPrefs.SetStringValue(getCons + getThis.ItemName, "ok"); if (getThis.UseOtherSprite) { getThis.GetComponent <Image> ( ).sprite = currItemSeled.BoughtSpriteUnselected; } else { getThis.GetComponent <Image> ( ).sprite = currItemSeled.SpriteUnselected; } if (getThis.UseColor) { if (getThis.UseOtherColor) { getThis.GetComponent <Image> ( ).color = currItemSeled.BoughtColorUnSelected; } else { getThis.GetComponent <Image> ( ).color = currItemSeled.ColorUnSelected; } } getAllBuy.Remove(getCons); } getThis = currItemSeled; getThis.GetComponent <Image> ( ).sprite = getThis.SpriteConfirm; if (getThis.UseColor) { getThis.GetComponent <Image> ( ).color = getThis.ColorConfirm; } getAllBuy.Add(getCons, getThis); } else { bool checkProg = false; ItemModif currIT = currItemSeled; if (currCatSeled.Progression) { if (currIT.UpItem.ItemBought || currIT.DownItem.ItemBought || currIT.LeftItem.ItemBought || currIT.RightItem.ItemBought) { checkProg = true; } } else { checkProg = true; } if (checkProg && AllPlayerPrefs.GetIntValue(Constants.Coin) > currIT.Price) { Debug.Log("buy"); AllPlayerPrefs.SetIntValue(Constants.Coin, -currIT.Price); if (currCatSeled.BuyForLife) { getAllBuy.Add(getCons, currItemSeled); AllPlayerPrefs.SetStringValue(getCons + currIT.ItemName); } else { allTempItem.Add(currItemSeled); } } } moneyNumberPlayer.text = "" + AllPlayerPrefs.GetIntValue(Constants.Coin); }
public override void OnInspectorGUI() { EditorGUILayout.LabelField("Inspector Item Info", EditorStyles.boldLabel); ItemModif myTarget = (ItemModif)target; serializedObject.Update( ); EditorGUILayout.PropertyField(ItemName); EditorGUILayout.PropertyField(Price); myTarget.CatName = myTarget.transform.parent.GetComponent <CatShop> ( ).NameCat; #region MainButton // Si l'item est acheté if (AllPlayerPrefs.GetBoolValue(Constants.ItemBought + myTarget.ItemName)) { myTarget.ItemBought = true; } else { myTarget.ItemBought = false; } EditorGUILayout.Space( ); // verification de l'utilisation de la couleur var buttonStyle = new GUIStyle(EditorStyles.miniButtonLeft); if (myTarget.UseColor) { buttonStyle.normal.textColor = Color.green; } else { buttonStyle.normal.textColor = Color.red; } EditorGUILayout.BeginHorizontal(); // Bouton d'utilisation de la couleur if (GUILayout.Button("UseColor", buttonStyle)) { myTarget.UseColor = !myTarget.UseColor; } // verification de l'utilisation de sprite buttonStyle = new GUIStyle(EditorStyles.miniButtonRight); if (myTarget.UseSprite) { buttonStyle.normal.textColor = Color.green; } else { buttonStyle.normal.textColor = Color.red; } // Bouton d'utilisation de sprite if (GUILayout.Button("UseSprite", buttonStyle)) { myTarget.UseSprite = !myTarget.UseSprite; } EditorGUILayout.EndHorizontal( ); #endregion #region Couleur // Ajout des différentes couleurs if (myTarget.UseColor) { EditorGUI.indentLevel = 1; EditorGUILayout.Space( ); EditorGUILayout.BeginHorizontal(); buttonStyle = new GUIStyle(EditorStyles.miniButton); if (myTarget.UseOtherColor) { buttonStyle.normal.textColor = Color.green; } else { buttonStyle.normal.textColor = Color.red; } if (GUILayout.Button("UseOtherColor", buttonStyle)) { myTarget.UseOtherColor = !myTarget.UseOtherColor; } if (myTarget.UseSprite) { EditorGUILayout.Space( ); buttonStyle = new GUIStyle(EditorStyles.miniButton); if (myTarget.UseOtherSprite) { buttonStyle.normal.textColor = Color.green; } else { buttonStyle.normal.textColor = Color.red; } if (GUILayout.Button("UseOtherSprite", buttonStyle)) { myTarget.UseOtherSprite = !myTarget.UseOtherSprite; } } EditorGUILayout.EndHorizontal( ); EditorGUILayout.Space( ); EditorGUILayout.LabelField("Color Information", EditorStyles.boldLabel); EditorGUILayout.PropertyField(ColorConfirm, Confirm); EditorGUILayout.PropertyField(ColorSelected, Select); EditorGUILayout.PropertyField(ColorUnSelected, UnSelect); if (myTarget.UseOtherColor) { EditorGUI.indentLevel = 2; EditorGUILayout.Space( ); EditorGUILayout.PropertyField(BoughtColorSelected, BuySelect); EditorGUILayout.PropertyField(BoughtColorUnSelected, BuyUnSelect); if (myTarget.ItemBought) { if (myTarget.Selected) { myTarget.GetComponent <Image> ( ).color = myTarget.BoughtColorSelected; } else { myTarget.GetComponent <Image> ( ).color = myTarget.BoughtColorUnSelected; } } } else { if (myTarget.Selected) { myTarget.GetComponent <Image> ( ).color = myTarget.ColorSelected; } else { myTarget.GetComponent <Image> ( ).color = myTarget.ColorUnSelected; } } } #endregion #region Sprite if (myTarget.SpriteConfirm == null) { myTarget.SpriteConfirm = myTarget.GetComponent <Image> ( ).sprite; } if (myTarget.SpriteSelected == null) { myTarget.SpriteSelected = myTarget.GetComponent <Image> ( ).sprite; } if (myTarget.SpriteUnselected == null) { myTarget.SpriteUnselected = myTarget.GetComponent <Image> ( ).sprite; } if (myTarget.BoughtSpriteSelected == null) { myTarget.BoughtSpriteSelected = myTarget.GetComponent <Image> ( ).sprite; } if (myTarget.BoughtSpriteUnselected == null) { myTarget.BoughtSpriteUnselected = myTarget.GetComponent <Image> ( ).sprite; } if (myTarget.UseSprite) { EditorGUI.indentLevel = 1; EditorGUILayout.Space( ); if (!myTarget.UseColor) { buttonStyle = new GUIStyle(EditorStyles.miniButton); if (myTarget.UseOtherSprite) { buttonStyle.normal.textColor = Color.green; } else { buttonStyle.normal.textColor = Color.red; } if (GUILayout.Button("UseOtherSprite", buttonStyle)) { myTarget.UseOtherSprite = !myTarget.UseOtherSprite; } EditorGUILayout.Space( ); } EditorGUILayout.LabelField("Sprite Information", EditorStyles.boldLabel); EditorGUILayout.PropertyField(SpriteConfirm, Confirm); EditorGUILayout.PropertyField(SpriteSelected, Select); EditorGUILayout.PropertyField(SpriteUnselected, UnSelect); if (myTarget.UseOtherSprite) { EditorGUI.indentLevel = 2; EditorGUILayout.Space( ); EditorGUILayout.PropertyField(BoughtSpriteSelected, BuySelect); EditorGUILayout.PropertyField(BoughtSpriteUnselected, BuyUnSelect); if (myTarget.ItemBought) { if (myTarget.Selected) { myTarget.GetComponent <Image> ( ).sprite = myTarget.BoughtSpriteSelected; } else { myTarget.GetComponent <Image> ( ).sprite = myTarget.BoughtSpriteUnselected; } } } else { if (myTarget.Selected) { myTarget.GetComponent <Image> ( ).sprite = myTarget.SpriteSelected; } else { myTarget.GetComponent <Image> ( ).sprite = myTarget.SpriteUnselected; } } EditorGUILayout.Space( ); } #endregion EditorGUI.indentLevel = 0; EditorGUILayout.LabelField("Around Information", EditorStyles.boldLabel); EditorGUILayout.PropertyField(RightItem); EditorGUILayout.PropertyField(LeftItem); EditorGUILayout.PropertyField(UpItem); EditorGUILayout.PropertyField(DownItem); EditorGUILayout.Space( ); EditorGUILayout.LabelField("Modification", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); #region Caract buttonStyle = new GUIStyle(EditorStyles.miniButton); if (myTarget.ModifVie) { buttonStyle.normal.textColor = Color.green; } else { buttonStyle.normal.textColor = Color.red; } if (GUILayout.Button("ModifVie", buttonStyle)) { myTarget.ModifVie = !myTarget.ModifVie; } if (myTarget.ModifVie) { myTarget.NombreVie = EditorGUILayout.IntField("NombreVie", myTarget.NombreVie); if (myTarget.NombreVie <= 0) { myTarget.NombreVie = 1; } } EditorGUILayout.EndHorizontal( ); buttonStyle = new GUIStyle(EditorStyles.miniButton); if (myTarget.ModifSpecial) { buttonStyle.normal.textColor = Color.green; } else { buttonStyle.normal.textColor = Color.red; } EditorGUILayout.BeginHorizontal(); #endregion #region SpecialAction if (GUILayout.Button("ModifSpecial", buttonStyle)) { myTarget.ModifSpecial = !myTarget.ModifSpecial; } if (myTarget.ModifSpecial) { EditorGUILayout.PropertyField(SpecAction); } else { myTarget.SpecAction = SpecialAction.Nothing; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 1; if (myTarget.SpecAction == SpecialAction.SlowMot) { EditorGUILayout.PropertyField(SlowMotion); EditorGUILayout.PropertyField(SpeedSlowMot); EditorGUILayout.PropertyField(SpeedDeacSM); EditorGUILayout.PropertyField(ReduceSlider); EditorGUILayout.PropertyField(RecovSlider); } #endregion serializedObject.ApplyModifiedProperties( ); EditorGUI.indentLevel = 0; if (myTarget.RightItem == null) { myTarget.RightItem = myTarget.GetComponent <ItemModif> ( ); } if (myTarget.LeftItem == null) { myTarget.LeftItem = myTarget.GetComponent <ItemModif> ( ); } if (myTarget.UpItem == null) { myTarget.UpItem = myTarget.GetComponent <ItemModif> ( ); } if (myTarget.DownItem == null) { myTarget.DownItem = myTarget.GetComponent <ItemModif> ( ); } /* * if ( myTarget.UpItem == null ) * { * myTarget.UpItem = myTarget.GetComponent<ItemModif> ( ); * } * if ( myTarget.DownItem == null ) * { * myTarget.DownItem = myTarget.GetComponent<ItemModif> ( ); * }*/ }