예제 #1
0
        public void ExecuteOnTarget(HeroKitObject targetObject, ParticleSystem particlePrefab, bool changePosition, bool changeRotation)
        {
            // create a pool for this particle if it doesn't exist
            string poolName = particlePrefab.transform.name + " particle effects" + targetObject.transform.GetInstanceID();

            if (HeroKitDatabase.GetParticlePool(poolName, false) == null)
            {
                HeroKitDatabase.AddParticlePool(poolName, particlePrefab, 1, targetObject);
            }

            // change position of particle system
            Vector3 position = new Vector3();

            if (changePosition)
            {
                position = CoordinatesValue.GetValue(heroKitObject, 4, 5, 6, 7, 8, 9, new Vector3());
            }

            // change rotation
            Quaternion rotation = new Quaternion();

            if (changeRotation)
            {
                Vector3 eulerAngles = CoordinatesValue.GetValue(heroKitObject, 11, 12, 13, 14, 15, 16, new Vector3());
                rotation = Quaternion.Euler(eulerAngles);
            }

            // spawn the particle effect
            particleObject = HeroKitDatabase.SpawnParticle(poolName, position, rotation);

            // play the particle effect
            particleObject.Stop();
            particleObject.Play();
        }
예제 #2
0
        public void ExecuteOnTarget(ParticleSystem particleSystem, bool changePosition, bool changeRotation)
        {
            // get default rotation and positon
            Vector3    position = particleSystem.transform.localPosition;
            Quaternion rotation = particleSystem.transform.localRotation;

            // set the postion of the particle system
            if (changePosition)
            {
                position = CoordinatesValue.GetValue(heroKitObject, 4, 5, 6, 7, 8, 9, particleSystem.transform.localPosition);
                particleSystem.transform.localPosition = position;
            }

            // set the rotation of the particle system
            if (changeRotation)
            {
                Vector3 eulerAngles = CoordinatesValue.GetValue(heroKitObject, 11, 12, 13, 14, 15, 16, particleSystem.transform.localEulerAngles);
                rotation = Quaternion.Euler(eulerAngles);
                particleSystem.transform.localRotation = rotation;
            }

            // set the particle system on the script
            particles.particleObject = particleSystem;
            particleSystem.gameObject.SetActive(true);
            particles.Initialize();
        }
예제 #3
0
        /// <summary>
        /// 自动将最新采样数值添加到数组
        /// </summary>
        /// <param name="newValue">最新采样数值</param>
        public void AddNewValue(float newValue, float newAngle)
        {
            CoordinatesValue value;

            value.Value = newValue;
            //value.time = System.DateTime.Now;
            //TimeSpan sPan = value.time - StartTime;
            //value.getSecond = (value.time - StartTime).TotalSeconds;
            value.Angle = newAngle;
            if (value.Angle > XMaxValue)
            {
                //OldXMax = XMaxValue;0
                XMaxValue = (int)xMaxValue + 500;

                //if(XMaxValue%100==0)
                XScale = XMaxValue / 10;

                for (int i = 0; i < this.noteMessages.Count; i++)
                {
                    CoordinatesValue value1 = this.noteMessages[i];
                    value1.X        = xOffset + ((float)value1.Angle - XMinValue) / (XMaxValue - XMinValue) * (this.picCurveShow.Width - XOffset);
                    noteMessages[i] = value1;
                }
            }

            value.X  = xOffset + ((float)value.Angle - XMinValue) / (XMaxValue - XMinValue) * (this.picCurveShow.Width - XOffset);
            value.Y  = this.picCurveShow.Height - YOffset - (newValue - yMinValue) / (yMaxValue - yMinValue) * (this.picCurveShow.Height - yOffset);
            value.ID = this.noteMessages.Count;


            lock (thisLock)
            {
                this.noteMessages.Add(value);
            }
        }
예제 #4
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // Get the scene object
            string  sceneName      = UnityObjectFieldValue.GetValueA(heroKitObject, 0).sceneName;
            Vector3 cameraPosition = new Vector3();
            Vector3 cameraRotation = new Vector3();
            bool    runThis        = (sceneName != "");

            if (runThis)
            {
                bool useDefaultScene     = BoolValue.GetValue(heroKitObject, 1);
                bool removeNonPersistent = BoolValue.GetValue(heroKitObject, 2);
                bool saveCurrentScene    = !BoolValue.GetValue(heroKitObject, 3);

                // get position
                bool    getPosition     = BoolValue.GetValue(heroKitObject, 4);
                Vector3 defaultPosition = new Vector3(-999999, -999999, -999999);
                cameraPosition = (getPosition) ? CoordinatesValue.GetValue(heroKitObject, 5, 6, 7, 8, 9, 10, defaultPosition) : defaultPosition;

                // get rotation
                bool    getRotation     = BoolValue.GetValue(heroKitObject, 11);
                Vector3 defaultRotation = new Vector3(-999999, -999999, -999999);
                cameraRotation = (getRotation) ? CoordinatesValue.GetValue(heroKitObject, 12, 13, 14, 15, 16, 17, defaultRotation) : defaultRotation;

                // Save the current scene
                if (saveCurrentScene)
                {
                    SaveScene saveScene = new SaveScene();
                    saveScene.SaveSceneData(heroKitObject, false); // save scene objects
                    saveScene.SaveSceneData(heroKitObject, true);  // save persistent objects
                }

                // Load the scene. Load any cached data for the scene.
                HeroKitCommonScene.LoadScene(sceneName, useDefaultScene, removeNonPersistent, cameraPosition, cameraRotation);

                // set up update for long action
                eventID = heroKitObject.heroStateData.eventBlock;
                heroKitObject.heroState.heroEvent[eventID].waiting = true;
                updateIsDone = false;
                heroKitObject.longActions.Add(this);
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Scene ID: " + sceneName + "\n" +
                                      "Camera Position: " + cameraPosition + "\n" +
                                      "Camera Rotation: " + cameraRotation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // Return value
            return(-99);
        }
예제 #5
0
        // get rotation to use
        private Quaternion GetRotation()
        {
            bool       changeRotation = BoolValue.GetValue(heroKitObject, 13);
            Quaternion rotation       = new Quaternion();

            if (changeRotation)
            {
                Vector3 eulerAngles = CoordinatesValue.GetValue(heroKitObject, 14, 15, 16, 17, 18, 19, new Vector3());
                rotation = Quaternion.Euler(eulerAngles);
            }

            return(rotation);
        }
예제 #6
0
        // get position to use
        private Vector3 GetPosition()
        {
            // get position to spawn
            bool    changePosition = BoolValue.GetValue(heroKitObject, 6);
            Vector3 position       = new Vector3();

            if (changePosition)
            {
                position = CoordinatesValue.GetValue(heroKitObject, 7, 8, 9, 10, 11, 12, new Vector3());
            }

            return(position);
        }
예제 #7
0
        private void picCurveShow_SizeChanged(object sender, EventArgs e)
        {
            if (this.Width < 1 || this.Height < 1)
            {
                return;
            }
            if (this.noteMessages.Count > 0)
            {
                for (int i = 0; i < this.noteMessages.Count; i++)
                {
                    CoordinatesValue value1 = this.noteMessages[i];
                    value1.X        = xOffset + ((float)value1.Angle - XMinValue) / (XMaxValue - XMinValue) * (this.picCurveShow.Width - XOffset);
                    value1.Y        = this.picCurveShow.Height - YOffset - (value1.Value - yMinValue) / (yMaxValue - yMinValue) * (this.picCurveShow.Height - yOffset);
                    noteMessages[i] = value1;
                }
            }

            //ShowCurve();\\0820
        }
예제 #8
0
        public void ExecuteOnTarget(HeroKitObject targetObject)
        {
            Vector3 pos = CoordinatesValue.GetValue(heroKitObject, 2, 3, 4, 5, 6, 7, targetObject.transform.localPosition);

            // get nav mesh agent
            NavMeshAgent navMeshAgent = targetObject.GetHeroComponent <NavMeshAgent>("navMeshAgent");

            if (navMeshAgent == null)
            {
                navMeshAgent = targetObject.GetHeroComponent <NavMeshAgent>("navMeshAgent", true);
                navMeshAgent = HeroKitCommonRuntime.CreateNavMeshAgent(navMeshAgent);
            }

            // get the pathfinding script
            HeroPathfinding3D moveObject = targetObject.GetHeroComponent <HeroPathfinding3D>("HeroPathfinding3D", true);

            moveObject.navMeshAgent   = navMeshAgent;
            moveObject.navigationType = 2;
            moveObject.destination    = pos;
            moveObject.Initialize();
        }
예제 #9
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get the particle to play
            UnityObjectField unityObject    = UnityObjectFieldValue.GetValueA(heroKitObject, 0);
            ParticleSystem   particlePrefab = (unityObject.value != null) ? (ParticleSystem)unityObject.value : null;
            bool             runThis        = (particlePrefab != null);

            if (runThis)
            {
                // create a pool for this particle if it doesn't exist
                string poolName = particlePrefab.transform.name + " particle effects";
                if (HeroKitDatabase.GetParticlePool(poolName, false) == null)
                {
                    HeroKitDatabase.AddParticlePool(poolName, particlePrefab);
                }

                // get the positon to use for the particle
                Vector3 position       = particlePrefab.transform.localPosition;
                bool    changePosition = BoolValue.GetValue(heroKitObject, 1);
                if (changePosition)
                {
                    position = CoordinatesValue.GetValue(heroKitObject, 2, 3, 4, 5, 6, 7, particlePrefab.transform.localPosition);
                }

                // get the rotation to use for the particle
                Quaternion rotation       = particlePrefab.transform.localRotation;
                bool       changeRotation = BoolValue.GetValue(heroKitObject, 8);
                if (changeRotation)
                {
                    Vector3 eulerAngles = CoordinatesValue.GetValue(heroKitObject, 9, 10, 11, 12, 13, 14, particlePrefab.transform.localEulerAngles);
                    rotation = Quaternion.Euler(eulerAngles);
                }

                // spawn the particle effect
                particleObject = HeroKitDatabase.SpawnParticle(poolName, position, rotation);

                // should next action wait until this action is complete?
                wait = BoolValue.GetValue(heroKitObject, 15);

                // play the particle effect
                particleObject.Stop();
                particleObject.Play();

                // set up the long action
                eventID = heroKitObject.heroStateData.eventBlock;
                heroKitObject.heroState.heroEvent[eventID].waiting = wait;
                updateIsDone = false;
                heroKitObject.longActions.Add(this);
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Particle System: " + particleObject;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
예제 #10
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // Get the hero kit object to move
            HeroKitObject targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1, false)[0];

            // Get the scene object
            string sceneName = UnityObjectFieldValue.GetValueA(heroKitObject, 2).sceneName;

            // get new position for target object
            Vector3 defaultPosition = new Vector3(-999999, -999999, -999999);
            Vector3 targetPosition  = CoordinatesValue.GetValue(heroKitObject, 3, 4, 5, 6, 7, 8, defaultPosition);

            // get new rotation for target object
            Vector3 targetDirection = defaultPosition;
            int     directionType   = DropDownListValue.GetValue(heroKitObject, 9);

            switch (directionType)
            {
            case 1:     // retain
                break;

            case 2:     // left
                targetDirection.y = -90f;
                break;

            case 3:     // right
                targetDirection.y = 90f;
                break;

            case 4:     // up
                targetDirection.y = 0f;
                break;

            case 5:     // down
                targetDirection.y = 180f;
                break;

            case 6:     // custom
                targetDirection = CoordinatesValue.GetValue(heroKitObject, 10, 11, 12, 13, 14, 15, defaultPosition);
                break;
            }

            // move camera to object's position?
            bool moveCameraPos = BoolValue.GetValue(heroKitObject, 16);

            // move camera to object's rotation?
            bool moveCameraRotation = BoolValue.GetValue(heroKitObject, 17);

            // scene transition settings
            bool useDefaultScene     = BoolValue.GetValue(heroKitObject, 18);
            bool removeNonPersistent = BoolValue.GetValue(heroKitObject, 19);
            bool saveCurrentScene    = !BoolValue.GetValue(heroKitObject, 20);

            bool runThis = (targetObject != null && sceneName != "");

            // NEXT STEP:
            // save current scene,
            // check if object is persistant. if it is, load next scene, change direction and rotation of object.
            // if it isn't see what we can do to physically move it from one scene to another. Keep in mind that object could exist in two scenes after this (if it is saved in scene data)
            // maybe disable it in current scene and create a new verison in the next scene.

            if (runThis)
            {
                // Save the current scene
                if (saveCurrentScene)
                {
                    SaveScene saveScene = new SaveScene();
                    saveScene.SaveSceneData(heroKitObject, false); // save scene objects
                    saveScene.SaveSceneData(heroKitObject, true);  // save persistent objects
                }

                // Load the scene. Load any cached data for the scene.
                HeroKitCommonScene.LoadSceneWithObject(sceneName, useDefaultScene, removeNonPersistent,
                                                       targetPosition, targetDirection, targetObject, moveCameraPos, moveCameraRotation);
            }

            if (targetObject == null)
            {
                Debug.LogError("There is no object to move to the next scene! Terminating action early.");
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Scene: " + sceneName + "\n" +
                                      "Move this object: " + targetObject + "\n" +
                                      "To this position: " + targetPosition;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // Return value
            return(-99);
        }