コード例 #1
0
ファイル: Sink.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            float           timeToWait   = FloatFieldValue.GetValueA(heroKitObject, 2) + Time.time;
            float           speed        = FloatFieldValue.GetValueA(heroKitObject, 3);

            wait = !BoolValue.GetValue(heroKitObject, 4);
            bool runThis = (targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                ExecuteOnTarget(targetObject[i], timeToWait, speed);
            }

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

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #2
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            float           force        = FloatFieldValue.GetValueA(heroKitObject, 2);

            wait = !BoolValue.GetValue(heroKitObject, 4);
            bool runThis = (targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                ExecuteOnTarget(targetObject[i], force);
            }

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

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Force: " + force;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #3
0
ファイル: ChangeMoveSpeed2D.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            float           speed        = FloatFieldValue.GetValueA(heroKitObject, 2);

            if (speed < 0)
            {
                speed = 0;
            }
            bool runThis = (targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                ExecuteOnTarget(targetObject[i], speed);
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Move Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #4
0
 private void SetPortraitInfo(int portraitID,
                              int changePortrait, int portraitSprite, int flipImage,
                              int changeScale, int newScale, int changeXPos,
                              int newXPos, int changeYPos, int newYPos, int changeZPos, int newZPos)
 {
     // get values for left portrait
     uiDialog.changePortrait[portraitID] = BoolValue.GetValue(heroKitObject, changePortrait);
     if (uiDialog.changePortrait[portraitID])
     {
         UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, portraitSprite);
         uiDialog.portraitSprite[portraitID] = (unityObject.value != null) ? (Sprite)unityObject.value : null;
         uiDialog.flipImage[portraitID]      = BoolValue.GetValue(heroKitObject, flipImage);
         uiDialog.changeScale[portraitID]    = BoolValue.GetValue(heroKitObject, changeScale);
         if (uiDialog.changeScale[portraitID])
         {
             uiDialog.newScale[portraitID] = FloatFieldValue.GetValueA(heroKitObject, newScale) * 0.01f;
         }
         uiDialog.changeXPos[portraitID] = BoolValue.GetValue(heroKitObject, changeXPos);
         if (uiDialog.changeXPos[portraitID])
         {
             uiDialog.newXPos[portraitID] = FloatFieldValue.GetValueA(heroKitObject, newXPos);
         }
         uiDialog.changeYPos[portraitID] = BoolValue.GetValue(heroKitObject, changeYPos);
         if (uiDialog.changeYPos[portraitID])
         {
             uiDialog.newYPos[portraitID] = FloatFieldValue.GetValueA(heroKitObject, newYPos);
         }
         uiDialog.changeZPos[portraitID] = BoolValue.GetValue(heroKitObject, changeZPos);
         if (uiDialog.changeZPos[portraitID])
         {
             uiDialog.newZPos[portraitID] = DropDownListValue.GetValue(heroKitObject, newZPos);
         }
     }
 }
コード例 #5
0
ファイル: FadeOutBGM.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            float           duration     = FloatFieldValue.GetValueA(heroKitObject, 2);
            bool            runThis      = (targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                ExecuteOnTarget(targetObject[i], duration);
            }

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

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

            return(-99);
        }
コード例 #6
0
ファイル: IfFloat.cs プロジェクト: antfitch/HeroKit
        // Check to see if an integer meets certain conditions in an if statement
        // This is used by both If and Else If
        public int Execute(HeroKitObject hko)
        {
            // assign variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionID      = heroKitObject.heroStateData.action;
            int currentIndent = heroKitObject.heroState.heroEvent[eventID].actions[actionID].indent;

            // evaluate the if statement
            int   comparison = DropDownListValue.GetValue(heroKitObject, 2);
            float value1     = FloatFieldValue.GetValueB(heroKitObject, 1);
            float value2     = FloatFieldValue.GetValueA(heroKitObject, 3);
            bool  evaluation = HeroActionCommonRuntime.CompareFloats(comparison, value1, value2);

            // next we need to get the action that we want the game loop to think just executed
            // this checks to see if the if statement should be run
            // if it should run, it disables the next conditional action if it is "Else" or "Else If"
            int thisAction = HeroActionCommonRuntime.RunConditionalIfAction(heroKitObject, eventID, actionID, currentIndent, evaluation);

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Float A: " + value1 + "\n" +
                                      "Float B: " + value2 + "\n" +
                                      "Result: " + evaluation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return the action that we want the game loop to think just executed
            return(thisAction);
        }
コード例 #7
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get field values
            SceneObjectValueData data = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);

            GameObject[] targetObject = HeroKitCommonRuntime.GetGameObjectsFromSceneObjects(data);
            Vector3      position     = new Vector3();
            bool         changeX      = false;
            bool         changeY      = false;
            bool         changeZ      = false;
            bool         runThis      = (targetObject != null && targetObject.Length > 0);

            // get value from first game object in list
            if (runThis)
            {
                position = targetObject[0].transform.localEulerAngles;

                changeX = BoolValue.GetValue(heroKitObject, 2);
                if (changeX)
                {
                    FloatFieldValue.SetValueB(heroKitObject, 3, position.x);
                }

                changeY = BoolValue.GetValue(heroKitObject, 4);
                if (changeY)
                {
                    FloatFieldValue.SetValueB(heroKitObject, 5, position.y);
                }

                changeZ = BoolValue.GetValue(heroKitObject, 6);
                if (changeZ)
                {
                    FloatFieldValue.SetValueB(heroKitObject, 7, position.z);
                }
            }

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string xStr         = (changeX) ? "X: " + position.x + " " : "";
                string yStr         = (changeY) ? "Y: " + position.y + " " : "";
                string zStr         = (changeZ) ? "Z: " + position.z + " " : "";
                string debugMessage = "Rotation coordinates: " + xStr + yStr + zStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #8
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionCount = heroKitObject.heroState.heroEvent[eventID].actions.Count;

            //-----------------------------------------
            // Get the game objects in the scene that match specific parameters
            //-----------------------------------------
            int                  actionType     = DropDownListValue.GetValue(heroKitObject, 0);
            int                  getHeroFieldID = 1;
            int                  objectCount    = IntegerFieldValue.GetValueA(heroKitObject, 2);
            GameObject           targetObject   = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0].gameObject;
            List <HeroKitObject> listObjects    = HeroObjectFieldValue.GetValueB(heroKitObject, 10);

            // convert list objects to array
            HeroKitObject[] arrayObjects = (listObjects != null) ? listObjects.ToArray() : null;

            bool getX = BoolValue.GetValue(heroKitObject, 4);
            bool getY = BoolValue.GetValue(heroKitObject, 5);
            bool getZ = BoolValue.GetValue(heroKitObject, 6);

            float x = (getX) ? FloatFieldValue.GetValueA(heroKitObject, 7) : 0;
            float y = (getY) ? FloatFieldValue.GetValueA(heroKitObject, 8) : 0;
            float z = (getZ) ? FloatFieldValue.GetValueA(heroKitObject, 9) : 0;

            Vector3 radius = new Vector3(x, y, z);

            // filter the hero kit objects in the scene
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsDistance(heroKitObject, arrayObjects, objectCount, radius, getX, getY, getZ, targetObject);

            // assign the hero kit objects to the list
            HeroActionCommonRuntime.AssignObjectsToList(heroKitObject, getHeroFieldID, filteredObjects, actionType);

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string xStr         = (getX) ? "X: " + x + " " : "";
                string yStr         = (getY) ? "Y: " + y + " " : "";
                string zStr         = (getZ) ? "Z: " + z + " " : "";
                string countStr     = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString();
                string debugMessage = "Get objects in this radius: " + xStr + yStr + zStr + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #9
0
ファイル: LoadSetting.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            string valueName = StringFieldValue.GetValueA(heroKitObject, 2);
            int    valueType = DropDownListValue.GetValue(heroKitObject, 0);
            bool   runThis   = (PlayerPrefs.HasKey(valueName));

            if (runThis)
            {
                // integer
                if (valueType == 1)
                {
                    int value = PlayerPrefs.GetInt(valueName);
                    IntegerFieldValue.SetValueB(heroKitObject, 1, value);
                }
                // float
                else if (valueType == 2)
                {
                    float value = PlayerPrefs.GetFloat(valueName);
                    FloatFieldValue.SetValueB(heroKitObject, 1, value);
                }
                // bool
                else if (valueType == 3)
                {
                    int  value    = PlayerPrefs.GetInt(valueName);
                    bool newValue = (value == 0) ? true : false;
                    BoolFieldValue.SetValueB(heroKitObject, 1, newValue);
                }
                // string
                else if (valueType == 4)
                {
                    string value = PlayerPrefs.GetString(valueName);
                    StringFieldValue.SetValueB(heroKitObject, 1, value);
                }
            }
            else
            {
                Debug.LogWarning(valueName + " was not found in player preferences.");
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Value Type (1=int, 2=float, 3=bool, 4=string): " + valueType + "\n" +
                                      "Value Name: " + valueName;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #10
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;

            //-----------------------------------------
            // Get the game objects in the scene that match specific parameters
            //-----------------------------------------
            int actionType     = DropDownListValue.GetValue(heroKitObject, 0);
            int getHeroFieldID = 1;
            int objectCount    = IntegerFieldValue.GetValueA(heroKitObject, 2);

            bool getX = BoolValue.GetValue(heroKitObject, 3);
            bool getY = BoolValue.GetValue(heroKitObject, 4);
            bool getZ = BoolValue.GetValue(heroKitObject, 5);

            float x = (getX) ? FloatFieldValue.GetValueA(heroKitObject, 6) : 0;
            float y = (getY) ? FloatFieldValue.GetValueA(heroKitObject, 7) : 0;
            float z = (getZ) ? FloatFieldValue.GetValueA(heroKitObject, 8) : 0;

            float radius = FloatFieldValue.GetValueA(heroKitObject, 9);

            Vector3 pos = new Vector3(x, y, z);

            // filter the hero kit objects in the scene
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsPosition(heroKitObject, HeroActionCommonRuntime.GetHeroObjectsInScene(), objectCount, pos, getX, getY, getZ, radius);

            // assign the hero kit objects to the list
            HeroActionCommonRuntime.AssignObjectsToList(heroKitObject, getHeroFieldID, filteredObjects, actionType);

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string xStr         = (getX) ? "X: " + x + " " : "";
                string yStr         = (getY) ? "Y: " + y + " " : "";
                string zStr         = (getZ) ? "Z: " + z + " " : "";
                string countStr     = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString();
                string debugMessage = "Get objects at this position: " + xStr + yStr + zStr + "\n" +
                                      "Maximum number of objects to get: " + objectCount + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #11
0
ファイル: ChangePosition.cs プロジェクト: antfitch/HeroKit
        public void ExecuteOnTarget(HeroKitObject targetObject, string childName)
        {
            Transform transform = null;

            if (childName == "")
            {
                transform = targetObject.transform;
            }
            else
            {
                transform = targetObject.GetHeroChildComponent <Transform>("Transform", childName);
            }


            Vector3 pos = transform.localPosition;

            // get the values to update
            bool changeX = BoolValue.GetValue(heroKitObject, 4);

            if (changeX)
            {
                pos.x      = FloatFieldValue.GetValueA(heroKitObject, 5);
                position.x = pos.x;
            }

            bool changeY = BoolValue.GetValue(heroKitObject, 6);

            if (changeY)
            {
                pos.y      = FloatFieldValue.GetValueA(heroKitObject, 7);
                position.y = pos.y;
            }

            bool changeZ = BoolValue.GetValue(heroKitObject, 8);

            if (changeZ)
            {
                pos.z      = FloatFieldValue.GetValueA(heroKitObject, 9);
                position.z = pos.z;
            }

            // update the transform
            transform.localPosition = pos;
        }
コード例 #12
0
ファイル: SaveSetting.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            string valueName = StringFieldValue.GetValueA(heroKitObject, 2);
            int    valueType = DropDownListValue.GetValue(heroKitObject, 0);

            // integer
            if (valueType == 1)
            {
                int value = IntegerFieldValue.GetValueA(heroKitObject, 1);
                PlayerPrefs.SetInt(valueName, value);
            }
            // float
            else if (valueType == 2)
            {
                float value = FloatFieldValue.GetValueA(heroKitObject, 1);
                PlayerPrefs.SetFloat(valueName, value);
            }
            // bool
            else if (valueType == 3)
            {
                bool value    = BoolFieldValue.GetValueA(heroKitObject, 1);
                int  newValue = (value) ? 1 : 0;
                PlayerPrefs.SetInt(valueName, newValue);
            }
            // string
            else if (valueType == 4)
            {
                string value = StringFieldValue.GetValueA(heroKitObject, 1);
                PlayerPrefs.SetString(valueName, value);
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Value Type (1=int, 2=float, 3=bool, 4=string): " + valueType + "\n" +
                                      "Value Name: " + valueName;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #13
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            float bottom = FloatFieldValue.GetValueA(heroKitObject, 0);
            float top    = FloatFieldValue.GetValueA(heroKitObject, 1);
            float result = HeroKitCommonRuntime.GetRandomFloat(bottom, top);

            FloatFieldValue.SetValueB(heroKitObject, 2, result);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Float: " + result + "\n" +
                                      "Bottom: " + bottom + "\n" +
                                      "Top: " + top;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #14
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            float intA      = FloatFieldValue.GetValueB(heroKitObject, 0);
            float intB      = FloatFieldValue.GetValueA(heroKitObject, 2);
            int   operation = DropDownListValue.GetValue(heroKitObject, 1);
            float result    = HeroActionCommonRuntime.PerformMathOnFloats(operation, intA, intB);

            FloatFieldValue.SetValueB(heroKitObject, 0, result);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "A: " + intA + "\n" +
                                      "B: " + intB + "\n" +
                                      "Result (A): " + result;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #15
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroObject heroObject    = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
            float      getThisObject = 0f;
            bool       runThis       = (heroObject != null);

            if (runThis)
            {
                getThisObject = FloatFieldValue.GetValueC(heroKitObject, 1, heroObject);
                FloatFieldValue.SetValueB(heroKitObject, 2, getThisObject);
            }

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

            return(-99);
        }
コード例 #16
0
ファイル: GetSliderValue.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            Slider slider = null;

            // object is hero kit object
            if (objectData.heroKitObject != null)
            {
                slider = objectData.heroKitObject[0].GetHeroComponent <Slider>("Slider");
            }

            // object is game object
            else if (objectData.gameObject != null)
            {
                slider = heroKitObject.GetGameObjectComponent <Slider>("Slider", false, objectData.gameObject[0]);
            }

            if (slider != null)
            {
                FloatFieldValue.SetValueB(heroKitObject, 2, slider.value);
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strGO        = (slider != null) ? slider.gameObject.name : "";
                string strValue     = (slider != null) ? slider.value.ToString() : "";
                string debugMessage = "Game Object: " + strGO + "\n" +
                                      "Value: " + strValue;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #17
0
ファイル: ChangeTextFloat.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            string stringForText            = FloatFieldValue.GetValueA(heroKitObject, 2).ToString();
            Text   text = null;

            // object is hero object
            if (objectData.heroKitObject != null)
            {
                text = objectData.heroKitObject[0].GetHeroComponent <Text>("Text");
            }

            // object is game object
            else if (objectData.gameObject != null)
            {
                text = heroKitObject.GetGameObjectComponent <Text>("Text", false, objectData.gameObject[0]);
            }

            if (text != null)
            {
                text.text = stringForText;
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strGO        = (text != null) ? text.gameObject.name : "";
                string debugMessage = "Game Object: " + strGO + "\n" +
                                      "Text: " + stringForText;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #18
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            HeroKitObject[] targetObject  = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            string          animationName = AnimationParameterValue.GetValueA(heroKitObject, 2, 3, 4);
            float           floatVal      = FloatFieldValue.GetValueA(heroKitObject, 5);
            bool            runThis       = (animationName != "" && targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                ExecuteOnTarget(targetObject[i], animationName, floatVal);
            }

            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = animationName + ": " + floatVal;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #19
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get field values
            int   smoothing = 5;
            float posY      = 0;
            float posX      = 0;
            float size      = 5;

            // get the object to follow
            HeroKitObject targetObject = HeroObjectFieldValue.GetValueA(heroKitObject, 1)[0];

            // get the camera
            Camera camera = CameraFieldValue.GetValue(heroKitObject, 0, 11);

            // change settings
            if (BoolValue.GetValue(heroKitObject, 2))
            {
                // change smoothing
                if (BoolValue.GetValue(heroKitObject, 3))
                {
                    smoothing = IntegerFieldValue.GetValueA(heroKitObject, 4);
                }

                // change Z pos
                if (BoolValue.GetValue(heroKitObject, 5))
                {
                    posX = FloatFieldValue.GetValueA(heroKitObject, 6);
                }

                // change Y pos
                if (BoolValue.GetValue(heroKitObject, 7))
                {
                    posY = FloatFieldValue.GetValueA(heroKitObject, 8);
                }

                // change size of viewport
                if (BoolValue.GetValue(heroKitObject, 9))
                {
                    size = FloatFieldValue.GetValueA(heroKitObject, 10);
                }
            }

            bool runThis = (camera != null && targetObject != null);

            if (runThis)
            {
                // change perspective to "orthographic"
                camera.orthographic     = true;
                camera.orthographicSize = size;

                // set up the camera
                CameraController cameraController = heroKitObject.GetGameObjectComponent <CameraController>("CameraController", true, camera.gameObject);
                cameraController.targetObject  = targetObject;
                cameraController.smoothing     = smoothing;
                cameraController.defaultPos    = new Vector3(posX, posY, -10);
                cameraController.defaultAngles = new Vector3(0, 0, 0);
                cameraController.firstPerson   = false;
                cameraController.Initialize();
            }

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

            return(-99);
        }
コード例 #20
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            String imageGroupPrefabName = "HeroKit Image Canvas";
            String imagePrefabName      = "HeroKit Image Sprite";
            int    imageID = IntegerFieldValue.GetValueA(heroKitObject, 0);

            // get the game object that contains the images
            GameObject imageGroup = AddImageGroup(imageGroupPrefabName);

            if (imageGroup != null)
            {
                // get the game object that contains the image
                GameObject targetObject = AddImage(imagePrefabName, imageID, imageGroup);
                if (targetObject != null)
                {
                    // get the image component on the game object
                    Image image = heroKitObject.GetGameObjectComponent <Image>("Image", false, targetObject);
                    if (image != null)
                    {
                        bool changeSprite = BoolValue.GetValue(heroKitObject, 1);
                        if (changeSprite)
                        {
                            UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 2);
                            Sprite           sprite      = (unityObject.value != null) ? (Sprite)unityObject.value : null;
                            image.sprite = sprite;
                            RectTransform rectTransform = heroKitObject.GetGameObjectComponent <RectTransform>("RectTransform", false, image.gameObject);
                            rectTransform.sizeDelta     = new Vector2(sprite.rect.width, sprite.rect.height);
                            rectTransform.localPosition = new Vector3();
                        }

                        bool flipSprite = BoolValue.GetValue(heroKitObject, 3);
                        if (flipSprite)
                        {
                            Vector3 eulerAngles = new Vector3();
                            eulerAngles    = image.transform.eulerAngles;
                            eulerAngles.y += 180f;
                            image.transform.eulerAngles = eulerAngles;
                        }

                        bool changeScale = BoolValue.GetValue(heroKitObject, 4);
                        if (changeScale)
                        {
                            float newScale = FloatFieldValue.GetValueA(heroKitObject, 5);
                            image.transform.localScale = new Vector3(newScale, newScale, newScale) * 0.01f;
                        }

                        bool changeXPos = BoolValue.GetValue(heroKitObject, 6);
                        if (changeXPos)
                        {
                            float xPos = FloatFieldValue.GetValueA(heroKitObject, 7);
                            image.transform.localPosition = new Vector3(xPos, image.transform.localPosition.y, image.transform.localPosition.z);
                        }

                        bool changeYPos = BoolValue.GetValue(heroKitObject, 8);
                        if (changeYPos)
                        {
                            float yPos = FloatFieldValue.GetValueA(heroKitObject, 9);
                            image.transform.localPosition = new Vector3(image.transform.localPosition.x, yPos, image.transform.localPosition.z);
                        }
                    }

                    // change the color (alpha = transparent if image is null)
                    Color color = image.color;
                    color.a     = (image.sprite == null) ? color.a = 0 : color.a = 1;
                    image.color = color;

                    // enable the game object
                    targetObject.SetActive(true);
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Image ID: " + imageID;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #21
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            String imageGroupPrefabName = "HeroKit Image Canvas";
            String imagePrefabName      = "HeroKit Image Sprite";
            int    imageID = IntegerFieldValue.GetValueA(heroKitObject, 0);
            int    speed   = IntegerFieldValue.GetValueA(heroKitObject, 1);

            wait = BoolValue.GetValue(heroKitObject, 4);
            HeroKitObject targetObject = null;
            Vector3       position     = new Vector3();

            // get the game object that contains the images
            GameObject imageGroup = GetImageGroup(imageGroupPrefabName);

            if (imageGroup != null)
            {
                // get the game object that contains the image
                GameObject imageObject = GetImage(imagePrefabName, imageID, imageGroup);
                if (imageObject != null)
                {
                    // get the hero kit object
                    targetObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, imageObject);

                    // get the current position
                    position = targetObject.transform.localPosition;

                    // get the image component on the game object
                    Image image = heroKitObject.GetGameObjectComponent <Image>("Image", false, imageObject);
                    if (image != null)
                    {
                        position.x = FloatFieldValue.GetValueA(heroKitObject, 2);
                        position.y = FloatFieldValue.GetValueA(heroKitObject, 3);
                    }
                }
            }

            // pan the camera
            uiPan = targetObject.GetHeroComponent <UIPan>("UIPan", true);
            uiPan.targetPosition = position;
            uiPan.speed          = speed;
            uiPan.Initialize();

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

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Image ID: " + imageID + "\n" +
                                      "Target Position: " + position + "\n" +
                                      "Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
コード例 #22
0
ファイル: MoveCamera.cs プロジェクト: antfitch/HeroKit
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get the camera
            Camera  camera   = CameraFieldValue.GetValue(heroKitObject, 0, 11);
            Vector3 position = new Vector3();
            int     speed    = 0;
            bool    runThis  = (camera != null);

            if (runThis)
            {
                int moveType = DropDownListValue.GetValue(heroKitObject, 1);
                position = new Vector3();

                // move to position
                if (moveType == 1)
                {
                    position.x = BoolValue.GetValue(heroKitObject, 2) ? FloatFieldValue.GetValueA(heroKitObject, 3) : camera.transform.localPosition.x;
                    position.y = BoolValue.GetValue(heroKitObject, 4) ? FloatFieldValue.GetValueA(heroKitObject, 5) : camera.transform.localPosition.y;
                    position.z = BoolValue.GetValue(heroKitObject, 6) ? FloatFieldValue.GetValueA(heroKitObject, 7) : camera.transform.localPosition.z;
                }

                // move to object
                else if (moveType == 2)
                {
                    SceneObjectValueData sceneObjectData = SceneObjectValue.GetValue(heroKitObject, 8, 9, false);
                    if (sceneObjectData.heroKitObject != null)
                    {
                        position.x = BoolValue.GetValue(heroKitObject, 2) ? sceneObjectData.heroKitObject[0].transform.localPosition.x : camera.transform.localPosition.x;
                        position.y = BoolValue.GetValue(heroKitObject, 4) ? sceneObjectData.heroKitObject[0].transform.localPosition.y : camera.transform.localPosition.y;
                        position.z = BoolValue.GetValue(heroKitObject, 6) ? sceneObjectData.heroKitObject[0].transform.localPosition.z : camera.transform.localPosition.z;
                    }
                    else if (sceneObjectData.gameObject != null)
                    {
                        position.x = BoolValue.GetValue(heroKitObject, 2) ? sceneObjectData.gameObject[0].transform.localPosition.x : camera.transform.localPosition.x;
                        position.y = BoolValue.GetValue(heroKitObject, 4) ? sceneObjectData.gameObject[0].transform.localPosition.y : camera.transform.localPosition.y;
                        position.z = BoolValue.GetValue(heroKitObject, 6) ? sceneObjectData.gameObject[0].transform.localPosition.z : camera.transform.localPosition.z;
                    }
                }

                speed = IntegerFieldValue.GetValueA(heroKitObject, 10);

                // pan the camera
                cameraPan = heroKitObject.GetGameObjectComponent <CameraPan>("CameraPan", true, camera.gameObject);
                cameraPan.targetPosition = position;
                cameraPan.speed          = speed;
                cameraPan.Initialize();

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

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Camera: " + camera + "\n" +
                                      "Target Position: " + position + "\n" +
                                      "Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return value
            return(-99);
        }