예제 #1
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get field values
            int   smoothing = 5;
            float posY      = 2;
            float posZ      = -2;
            float angle     = 30;

            // 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))
                {
                    posZ = FloatFieldValue.GetValueA(heroKitObject, 6);
                }

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

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

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

            if (runThis)
            {
                // change perspective to "perspective"
                camera.orthographic = false;

                // set up the camera
                CameraController cameraController = heroKitObject.GetGameObjectComponent <CameraController>("CameraController", true, camera.gameObject);
                cameraController.targetObject  = targetObject;
                cameraController.smoothing     = smoothing;
                cameraController.defaultPos    = new Vector3(0, posY, posZ);
                cameraController.defaultAngles = new Vector3(angle, 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);
        }
예제 #2
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);
            Color  targetColor = ColorValue.GetValue(heroKitObject, 2);

            wait = BoolValue.GetValue(heroKitObject, 3);

            HeroKitObject targetObject = null;
            Image         targetImage  = null;
            Color         currentColor = new Color();

            // 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 image component on the game object
                    targetImage = heroKitObject.GetGameObjectComponent <Image>("Image", false, imageObject);
                    if (targetImage != null)
                    {
                        currentColor = targetImage.color;
                    }
                }
            }

            // pan the camera
            uiColor             = targetObject.GetHeroComponent <UIColor>("UIColor", true);
            uiColor.targetImage = targetImage;
            uiColor.targetColor = targetColor;
            uiColor.startColor  = targetImage.color;
            uiColor.speed       = speed;
            uiColor.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 Image: " + targetImage + "\n" +
                                      "Target Color: " + targetColor + "\n" +
                                      "Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
예제 #3
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            String imageGroupPrefabName = "HeroKit Image Canvas";
            String imagePrefabName      = "HeroKit Image Sprite";
            int    degrees  = 0;
            int    duration = 0;

            int imageID      = IntegerFieldValue.GetValueA(heroKitObject, 0);
            int speed        = IntegerFieldValue.GetValueA(heroKitObject, 1);
            int rotationType = DropDownListValue.GetValue(heroKitObject, 2);

            if (rotationType == 1)
            {
                degrees = IntegerFieldValue.GetValueA(heroKitObject, 3);
            }
            else if (rotationType == 2 || rotationType == 3)
            {
                duration = IntegerFieldValue.GetValueA(heroKitObject, 4);
            }
            wait = BoolValue.GetValue(heroKitObject, 5);
            HeroKitObject targetObject = null;

            // 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);
                }
            }

            // rotate the image
            uiRotate = targetObject.GetHeroComponent <UIRotate>("UIRotate", true);
            uiRotate.rotationType = rotationType;
            uiRotate.speed        = speed;
            uiRotate.degrees      = degrees;
            uiRotate.duration     = duration;
            uiRotate.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" +
                                      "Degrees: " + degrees + "\n" +
                                      "Duration: " + duration + "\n" +
                                      "Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
예제 #4
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            string   saveGameName = StringFieldValue.GetValueA(heroKitObject, 12, true);
            string   path         = Application.persistentDataPath + "/HeroSaves/" + saveGameName + ".json";
            DateTime date         = new DateTime();
            bool     runThis      = (File.Exists(path));

            // get the json data in the file
            if (runThis)
            {
                date = File.GetLastWriteTime(path);

                // set year
                if (BoolValue.GetValue(heroKitObject, 0))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 1, date.Year);
                }

                // set month
                if (BoolValue.GetValue(heroKitObject, 2))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 3, date.Month);
                }

                // set day
                if (BoolValue.GetValue(heroKitObject, 4))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 5, date.Day);
                }

                // set hour
                if (BoolValue.GetValue(heroKitObject, 6))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 7, date.Hour);
                }

                // set minute
                if (BoolValue.GetValue(heroKitObject, 8))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 9, date.Minute);
                }

                // set second
                if (BoolValue.GetValue(heroKitObject, 10))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 11, date.Second);
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Save Game Name: " + saveGameName + "\n" +
                                      "Save Date: " + date;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }