예제 #1
0
        public override void AssignValues(List<ActionParameter> parameters)
        {
            if (isPlayer)
            {
                if (KickStarter.player && KickStarter.player.spriteChild != null && KickStarter.player.spriteChild.GetComponent <FollowTintMap>())
                {
                    followTintMap = KickStarter.player.spriteChild.GetComponent <FollowTintMap>();
                }
                else
                {
                    ACDebug.LogWarning ("Could not find a FollowTintMap component on the Player - be sure to place one on the sprite child.");
                }
            }
            else
            {
                followTintMap = AssignFile <FollowTintMap> (parameters, followTintMapParameterID, followTintMapConstantID, followTintMap);
            }

            if (tintMapMethod == TintMapMethod.ChangeTintMap && !followDefault)
            {
                newTintMap = AssignFile <TintMap> (parameters, newTintMapParameterID, newTintMapConstantID, newTintMap);
            }

            if (timeToChange < 0f)
            {
                timeToChange = 0f;
            }
        }
예제 #2
0
        override public void AssignValues(List <ActionParameter> parameters)
        {
            if (isPlayer)
            {
                if (KickStarter.player && KickStarter.player.spriteChild != null && KickStarter.player.spriteChild.GetComponent <FollowTintMap>())
                {
                    followTintMap = KickStarter.player.spriteChild.GetComponent <FollowTintMap>();
                }
                else
                {
                    ACDebug.LogWarning("Could not find a FollowTintMap component on the Player - be sure to place one on the sprite child.");
                }
            }
            else
            {
                followTintMap = AssignFile <FollowTintMap> (parameters, followTintMapParameterID, followTintMapConstantID, followTintMap);
            }

            if (tintMapMethod == TintMapMethod.ChangeTintMap && !followDefault)
            {
                newTintMap = AssignFile <TintMap> (parameters, newTintMapParameterID, newTintMapConstantID, newTintMap);
            }

            if (timeToChange < 0f)
            {
                timeToChange = 0f;
            }
        }
예제 #3
0
        public override void AssignValues(List <ActionParameter> parameters)
        {
            if (isPlayer)
            {
                Player player = AssignPlayer(playerID, parameters, playerParameterID);
                if (player != null && player.spriteChild != null)
                {
                    runtimeFollowTintMap = player.spriteChild.GetComponent <FollowTintMap>();
                }
            }
            else
            {
                runtimeFollowTintMap = AssignFile <FollowTintMap> (parameters, followTintMapParameterID, followTintMapConstantID, followTintMap);
            }

            if (tintMapMethod == TintMapMethod.ChangeTintMap && !followDefault)
            {
                runtimeNewTintMap = AssignFile <TintMap> (parameters, newTintMapParameterID, newTintMapConstantID, newTintMap);
            }

            if (timeToChange < 0f)
            {
                timeToChange = 0f;
            }
        }
예제 #4
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            tintMapMethod = (TintMapMethod)EditorGUILayout.EnumPopup("Change to make:", tintMapMethod);

            isPlayer = EditorGUILayout.Toggle("Affect Player?", isPlayer);
            if (!isPlayer)
            {
                followTintMapParameterID = Action.ChooseParameterGUI("FollowTintMap:", parameters, followTintMapParameterID, ParameterType.GameObject);
                if (followTintMapParameterID >= 0)
                {
                    followTintMapConstantID = 0;
                    followTintMap           = null;
                }
                else
                {
                    followTintMap = (FollowTintMap)EditorGUILayout.ObjectField("FollowTintMap:", followTintMap, typeof(FollowTintMap), true);

                    followTintMapConstantID = FieldToID <FollowTintMap> (followTintMap, followTintMapConstantID);
                    followTintMap           = IDToField <FollowTintMap> (followTintMap, followTintMapConstantID, false);
                }
            }

            if (tintMapMethod == TintMapMethod.ChangeTintMap)
            {
                followDefault = EditorGUILayout.Toggle("Use scene's default TintMap?", followDefault);
                if (!followDefault)
                {
                    newTintMapParameterID = Action.ChooseParameterGUI("New TintMap:", parameters, newTintMapParameterID, ParameterType.GameObject);
                    if (newTintMapParameterID >= 0)
                    {
                        newTintMapConstantID = 0;
                        followTintMap        = null;
                    }
                    else
                    {
                        newTintMap = (TintMap)EditorGUILayout.ObjectField("New TintMap:", newTintMap, typeof(TintMap), true);

                        newTintMapConstantID = FieldToID <TintMap> (newTintMap, newTintMapConstantID);
                        newTintMap           = IDToField <TintMap> (newTintMap, newTintMapConstantID, false);
                    }
                }
            }
            else if (tintMapMethod == TintMapMethod.ChangeIntensity)
            {
                newIntensity = EditorGUILayout.Slider("New intensity:", newIntensity, 0f, 1f);
                isInstant    = EditorGUILayout.Toggle("Change instantly?", isInstant);
                if (!isInstant)
                {
                    timeToChange = EditorGUILayout.FloatField("Time to change (s):", timeToChange);
                    if (timeToChange > 0f)
                    {
                        willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
                    }
                }
            }

            AfterRunningOption();
        }
예제 #5
0
        /**
         * <summary>Creates a new instance of the 'Object: Change Tint map' Action, set to change the active TintMap</summary>
         * <param name = "followTintMap">The FollowTintMap to update</param>
         * <param name = "newTintMap">The new TintMap to assign to the FollowTintMap</param>
         * <returns>The generated Action</returns>
         */
        public static ActionTintMap CreateNew_ChangeTintMap(FollowTintMap followTintMap, TintMap newTintMap)
        {
            ActionTintMap newAction = (ActionTintMap)CreateInstance <ActionTintMap>();

            newAction.tintMapMethod = TintMapMethod.ChangeTintMap;
            newAction.followTintMap = followTintMap;
            newAction.newTintMap    = newTintMap;
            return(newAction);
        }
예제 #6
0
        /**
         * <summary>Creates a new instance of the 'Object: Change Tint map' Action, set to change a FollowTintMap's intensity</summary>
         * <param name = "followTintMap">The FollowTintMap to update</param>
         * <param name = "newIntensity">The FollowTintMap's new target intensity</param>
         * <param name = "transitionTime">The duration, in seconds, of the transition to the new intensity</param>
         * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param>
         * <returns>The generated Action</returns>
         */
        public static ActionTintMap CreateNew_ChangeIntensity(FollowTintMap followTintMap, float newIntensity, float transitionTime = 0f, bool waitUntilFinish = false)
        {
            ActionTintMap newAction = (ActionTintMap)CreateInstance <ActionTintMap>();

            newAction.tintMapMethod = TintMapMethod.ChangeIntensity;
            newAction.followTintMap = followTintMap;
            newAction.newIntensity  = newIntensity;
            newAction.timeToChange  = transitionTime;
            newAction.isInstant     = (transitionTime <= 0f);
            newAction.willWait      = waitUntilFinish;
            return(newAction);
        }
예제 #7
0
        public override void OnInspectorGUI()
        {
            FollowTintMap _target = (FollowTintMap)target;

            _target.useDefaultTintMap = EditorGUILayout.Toggle("Use scene's default TintMap?", _target.useDefaultTintMap);
            if (!_target.useDefaultTintMap)
            {
                _target.tintMap = (TintMap)EditorGUILayout.ObjectField("TintMap to use:", _target.tintMap, typeof(TintMap), true);
            }
            _target.affectChildren = EditorGUILayout.Toggle("Affect children too?", _target.affectChildren);
            _target.intensity      = EditorGUILayout.Slider("Effect intensity:", _target.intensity, 0f, 1f);

            UnityVersionHandler.CustomSetDirty(_target);
        }
예제 #8
0
        override public void AssignConstantIDs(bool saveScriptsToo, bool fromAssetFile)
        {
            if (saveScriptsToo)
            {
                FollowTintMap obToUpdate = followTintMap;
                if (isPlayer)
                {
                    if (!fromAssetFile && GameObject.FindObjectOfType <Player>() != null)
                    {
                        obToUpdate = GameObject.FindObjectOfType <Player>().GetComponentInChildren <FollowTintMap>();
                    }

                    if (obToUpdate == null && AdvGame.GetReferences().settingsManager != null)
                    {
                        Player player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                        obToUpdate = player.GetComponentInChildren <FollowTintMap>();
                    }
                }

                AddSaveScript <RememberVisibility> (obToUpdate);
            }
            AssignConstantID <TintMap> (newTintMap, newTintMapConstantID, newTintMapParameterID);
        }
예제 #9
0
        override public void AssignValues(List <ActionParameter> parameters)
        {
            if (isPlayer)
            {
                if (KickStarter.player && KickStarter.player.spriteChild != null && KickStarter.player.spriteChild.GetComponent <FollowTintMap>())
                {
                    runtimeFollowTintMap = KickStarter.player.spriteChild.GetComponent <FollowTintMap>();
                }
            }
            else
            {
                runtimeFollowTintMap = AssignFile <FollowTintMap> (parameters, followTintMapParameterID, followTintMapConstantID, followTintMap);
            }

            if (tintMapMethod == TintMapMethod.ChangeTintMap && !followDefault)
            {
                runtimeNewTintMap = AssignFile <TintMap> (parameters, newTintMapParameterID, newTintMapConstantID, newTintMap);
            }

            if (timeToChange < 0f)
            {
                timeToChange = 0f;
            }
        }
예제 #10
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            tintMapMethod = (TintMapMethod) EditorGUILayout.EnumPopup ("Change to make:", tintMapMethod);

            isPlayer = EditorGUILayout.Toggle ("Affect Player?", isPlayer);
            if (!isPlayer)
            {
                followTintMapParameterID = Action.ChooseParameterGUI ("FollowTintMap:", parameters, followTintMapParameterID, ParameterType.GameObject);
                if (followTintMapParameterID >= 0)
                {
                    followTintMapConstantID = 0;
                    followTintMap = null;
                }
                else
                {
                    followTintMap = (FollowTintMap) EditorGUILayout.ObjectField ("FollowTintMap:", followTintMap, typeof (FollowTintMap), true);

                    followTintMapConstantID = FieldToID <FollowTintMap> (followTintMap, followTintMapConstantID);
                    followTintMap = IDToField <FollowTintMap> (followTintMap, followTintMapConstantID, false);
                }
            }

            if (tintMapMethod == TintMapMethod.ChangeTintMap)
            {
                followDefault = EditorGUILayout.Toggle ("Use scene's default TintMap?", followDefault);
                if (!followDefault)
                {
                    newTintMapParameterID = Action.ChooseParameterGUI ("New TintMap:", parameters, newTintMapParameterID, ParameterType.GameObject);
                    if (newTintMapParameterID >= 0)
                    {
                        newTintMapConstantID = 0;
                        followTintMap = null;
                    }
                    else
                    {
                        newTintMap = (TintMap) EditorGUILayout.ObjectField ("New TintMap:", newTintMap, typeof (TintMap), true);

                        newTintMapConstantID = FieldToID <TintMap> (newTintMap, newTintMapConstantID);
                        newTintMap = IDToField <TintMap> (newTintMap, newTintMapConstantID, false);
                    }
                }
            }
            else if (tintMapMethod == TintMapMethod.ChangeIntensity)
            {
                newIntensity = EditorGUILayout.Slider ("New intensity:", newIntensity, 0f, 1f);
                isInstant = EditorGUILayout.Toggle ("Change instantly?", isInstant);
                if (!isInstant)
                {
                    timeToChange = EditorGUILayout.FloatField ("Time to change (s):", timeToChange);
                    if (timeToChange > 0f)
                    {
                        willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);
                    }
                }
            }

            AfterRunningOption ();
        }
예제 #11
0
        /**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        public override string SaveData()
        {
            VisibilityData visibilityData = new VisibilityData();

            visibilityData.objectID      = constantID;
            visibilityData.savePrevented = savePrevented;

            SpriteFader spriteFader = GetComponent <SpriteFader>();

            if (spriteFader)
            {
                visibilityData.isFading = spriteFader.isFading;
                if (spriteFader.isFading)
                {
                    if (spriteFader.fadeType == FadeType.fadeIn)
                    {
                        visibilityData.isFadingIn = true;
                    }
                    else
                    {
                        visibilityData.isFadingIn = false;
                    }

                    visibilityData.fadeTime      = spriteFader.fadeTime;
                    visibilityData.fadeStartTime = spriteFader.fadeStartTime;
                }
                visibilityData.fadeAlpha = GetComponent <SpriteRenderer>().color.a;
            }
            else if (saveColour)
            {
                SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();
                Color          _color         = spriteRenderer.color;
                visibilityData.colourR = _color.r;
                visibilityData.colourG = _color.g;
                visibilityData.colourB = _color.b;
                visibilityData.colourA = _color.a;
            }

            FollowTintMap followTintMap = GetComponent <FollowTintMap>();

            if (followTintMap)
            {
                visibilityData = followTintMap.SaveData(visibilityData);
            }

            if (limitVisibility)
            {
                visibilityData.isOn = !limitVisibility.isLockedOff;
            }
            else
            {
                Renderer _renderer = GetComponent <Renderer>();
                if (_renderer)
                {
                    visibilityData.isOn = _renderer.enabled;
                }
                else
                {
                    Canvas canvas = GetComponent <Canvas>();
                    if (canvas)
                    {
                        visibilityData.isOn = canvas.enabled;
                    }
                    else if (affectChildren)
                    {
                        Renderer[] renderers = GetComponentsInChildren <Renderer>();
                        foreach (Renderer childRenderer in renderers)
                        {
                            visibilityData.isOn = childRenderer.enabled;
                            break;
                        }
                    }
                }
            }

            return(Serializer.SaveScriptData <VisibilityData> (visibilityData));
        }
예제 #12
0
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public override void LoadData(string stringData)
        {
            VisibilityData data = Serializer.LoadScriptData <VisibilityData> (stringData);

            if (data == null)
            {
                loadedData = false;
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            SpriteFader spriteFader = GetComponent <SpriteFader>();

            if (spriteFader)
            {
                if (data.isFading)
                {
                    if (data.isFadingIn)
                    {
                        spriteFader.Fade(FadeType.fadeIn, data.fadeTime, data.fadeAlpha);
                    }
                    else
                    {
                        spriteFader.Fade(FadeType.fadeOut, data.fadeTime, data.fadeAlpha);
                    }
                }
                else
                {
                    spriteFader.EndFade();
                    spriteFader.SetAlpha(data.fadeAlpha);
                }
            }
            else
            {
                if (saveColour)
                {
                    SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();
                    if (spriteRenderer)
                    {
                        Color _color = new Color(data.colourR, data.colourG, data.colourB, data.colourA);
                        spriteRenderer.color = _color;
                    }
                }
            }

            FollowTintMap followTintMap = GetComponent <FollowTintMap>();

            if (followTintMap)
            {
                followTintMap.LoadData(data);
            }

            if (limitVisibility)
            {
                limitVisibility.isLockedOff = !data.isOn;
            }
            else
            {
                Renderer renderer = GetComponent <Renderer>();
                if (renderer)
                {
                    renderer.enabled = data.isOn;
                }
                else
                {
                    Canvas canvas = GetComponent <Canvas>();
                    if (canvas)
                    {
                        canvas.enabled = data.isOn;
                    }
                }
            }

            if (affectChildren)
            {
                Renderer[] renderers = GetComponentsInChildren <Renderer>();
                foreach (Renderer _renderer in renderers)
                {
                    _renderer.enabled = data.isOn;
                }
            }

            loadedData = true;
        }