Пример #1
0
    // 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;
            }
        }
    }
Пример #2
0
    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);
    }
Пример #3
0
    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> ( );
         * }*/
    }