Exemple #1
0
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName)
            {
                return;
            }

            // Put a shiny in the same location as the original
            GameObject shiny = ObjectCache.ShinyItem;

            shiny.name = _newShinyName;

            shiny.transform.position = new Vector3(_x, _y, shiny.transform.position.z);
            shiny.SetActive(true);

            // Force the new shiny to fall straight downwards
            PlayMakerFSM fsm   = FSMUtility.LocateFSM(shiny, "Shiny Control");
            FsmState     fling = fsm.GetState("Fling?");

            fling.ClearTransitions();
            fling.AddTransition("FINISHED", "Fling R");
            FlingObject flingObj = fsm.GetState("Fling R").GetActionsOfType <FlingObject>()[0];

            flingObj.angleMin = flingObj.angleMax = 270;

            // For some reason not setting speed manually messes with the object position
            flingObj.speedMin = flingObj.speedMax = 0.1f;
        }
        public static void FlingShinyDown(PlayMakerFSM shinyFsm)
        {
            FsmState fling = shinyFsm.GetState("Fling?");

            fling.ClearTransitions();
            fling.AddTransition("FINISHED", "Fling R");
            FlingObject flingObj = shinyFsm.GetState("Fling R").GetActionsOfType <FlingObject>()[0];

            flingObj.angleMin = flingObj.angleMax = 270;
            flingObj.speedMin = flingObj.speedMax = 0.1f;
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName)
            {
                return;
            }

            GameObject shiny = ObjectCache.ShinyItem;

            shiny.name = _newShinyName;

            if (_activeCheck.Invoke())
            {
                // Simply create the shiny to be active, as in CreateNewShiny

                shiny.transform.position = new Vector3(_x, _y, shiny.transform.position.z);

                shiny.SetActive(true);

                // Force the new shiny to fall straight downwards
                PlayMakerFSM fsm   = FSMUtility.LocateFSM(shiny, "Shiny Control");
                FsmState     fling = fsm.GetState("Fling?");
                fling.ClearTransitions();
                fling.AddTransition("FINISHED", "Fling R");
                FlingObject flingObj = fsm.GetState("Fling R").GetActionsOfType <FlingObject>()[0];
                flingObj.angleMin = flingObj.angleMax = 270;

                // For some reason not setting speed manually messes with the object position
                flingObj.speedMin = flingObj.speedMax = 0.1f;
            }
            else
            {
                // Inactive shiny needs a parent so we can find it later, so create a dummy object if necessary

                string parentName = string.IsNullOrEmpty(_parent) ? _newShinyName + " Parent" : _parent;

                if (GameObject.Find(parentName) is GameObject go)
                {
                    shiny.transform.SetParent(go.transform);
                    shiny.transform.localPosition = new Vector3(0, 0, shiny.transform.position.z);
                }
                else
                {
                    GameObject go2 = new GameObject()
                    {
                        name = parentName
                    };
                    go2.SetActive(true);
                    shiny.transform.SetParent(go2.transform);

                    shiny.SetActive(false);
                }
            }
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName)
            {
                return;
            }

            Scene currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();

            string[]   objectHierarchy = _objectName.Split('\\');
            int        i   = 1;
            GameObject obj = currentScene.FindGameObject(objectHierarchy[0]);

            while (i < objectHierarchy.Length)
            {
                obj = obj.FindGameObjectInChildren(objectHierarchy[i++]);
            }

            if (obj == null)
            {
                return;
            }

            // Put a shiny in the same location as the original
            GameObject shiny = ObjectCache.ShinyItem;

            shiny.name = _newShinyName;
            if (obj.transform.parent != null)
            {
                shiny.transform.SetParent(obj.transform.parent);
            }

            shiny.transform.position      = obj.transform.position;
            shiny.transform.localPosition = obj.transform.localPosition;
            shiny.SetActive(obj.activeSelf);

            // Force the new shiny to fall straight downwards
            PlayMakerFSM fsm   = FSMUtility.LocateFSM(shiny, "Shiny Control");
            FsmState     fling = fsm.GetState("Fling?");

            fling.ClearTransitions();
            fling.AddTransition("FINISHED", "Fling R");
            FlingObject flingObj = fsm.GetState("Fling R").GetActionsOfType <FlingObject>()[0];

            flingObj.angleMin = flingObj.angleMax = 270;

            // For some reason not setting speed manually messes with the object position
            flingObj.speedMin = flingObj.speedMax = 0.1f;

            // Destroy the original
            Object.Destroy(obj);
        }