Exemplo n.º 1
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            int             angle        = SliderValue.GetValue(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], angle);
            }

            // set up the 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 = "Angle: " + angle;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemplo n.º 2
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;

            // write messages?
            bool print = BoolValue.GetValue(heroKitObject, 0);

            if (print)
            {
                HeroKitCommonRuntime.writeMessage = BoolValue.GetValue(heroKitObject, 1);
                if (HeroKitCommonRuntime.writeMessage)
                {
                    float messageSpeed = SliderValue.GetValue(heroKitObject, 2);
                    if (messageSpeed < 0)
                    {
                        messageSpeed = 0;
                    }
                    if (messageSpeed > 100)
                    {
                        messageSpeed = 100;
                    }

                    // 0=100, 100=0. Then change to 0 to 1.
                    float waitTime = (100 - messageSpeed) * 0.01f;

                    HeroKitCommonRuntime.messageWaitTime = waitTime;
                }
            }

            // change message alignment?
            bool changeAlignment = BoolValue.GetValue(heroKitObject, 3);

            if (changeAlignment)
            {
                int alignID = DropDownListValue.GetValue(heroKitObject, 4);
                switch (alignID)
                {
                case 1:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.UpperLeft;
                    break;

                case 2:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.UpperCenter;
                    break;

                case 3:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.UpperRight;
                    break;

                case 4:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.MiddleLeft;
                    break;

                case 5:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.MiddleCenter;
                    break;

                case 6:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.MiddleRight;
                    break;

                case 7:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.LowerLeft;
                    break;

                case 8:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.LowerCenter;
                    break;

                case 9:
                    HeroKitCommonRuntime.messageAlignment = TextAnchor.LowerRight;
                    break;
                }
            }

            // change background alpha
            bool changeBackgroundAlpha = BoolValue.GetValue(heroKitObject, 5);

            if (changeBackgroundAlpha)
            {
                // get new alpha
                float alpha = SliderValue.GetValue(heroKitObject, 6);

                // keep alpha between 0 - 100
                if (alpha > 100)
                {
                    alpha = 100;
                }
                else if (alpha < 0)
                {
                    alpha = 0;
                }

                // switch to 0 - 1 scale
                alpha *= .01f;

                // change alpha
                HeroKitCommonRuntime.messageBackgroundAlpha = alpha;
                HeroKitCommonRuntime.changeMessageBackgroundTransparency = true;
            }

            // change background alpha
            bool changeButtonAlpha = BoolValue.GetValue(heroKitObject, 19);

            if (changeButtonAlpha)
            {
                // get new alpha
                float alpha = SliderValue.GetValue(heroKitObject, 20);

                // keep alpha between 0 - 100
                if (alpha > 100)
                {
                    alpha = 100;
                }
                else if (alpha < 0)
                {
                    alpha = 0;
                }

                // switch to 0 - 1 scale
                alpha *= .01f;

                // change alpha
                HeroKitCommonRuntime.messageButtonAlpha = alpha;
                HeroKitCommonRuntime.changeMessageButtonTransparency = true;
            }

            // change background image
            bool changeBackgroundImage = BoolValue.GetValue(heroKitObject, 7);

            if (changeBackgroundImage)
            {
                UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 8);
                HeroKitCommonRuntime.messageBackgroundImage  = (unityObject.value != null) ? (Sprite)unityObject.value : null;
                HeroKitCommonRuntime.changeMessageBackground = true;
            }

            // change button image
            bool changeButtonImage = BoolValue.GetValue(heroKitObject, 9);

            if (changeButtonImage)
            {
                UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 10);
                HeroKitCommonRuntime.messageButtonImage  = (unityObject.value != null) ? (Sprite)unityObject.value : null;
                HeroKitCommonRuntime.changeMessageButton = true;
            }

            // change button layout
            bool changeButtonLayout = BoolValue.GetValue(heroKitObject, 11);

            if (changeButtonLayout)
            {
                HeroKitCommonRuntime.messageButtonLayout       = DropDownListValue.GetValue(heroKitObject, 12);
                HeroKitCommonRuntime.changeMessageButtonLayout = true;
            }

            // change text color
            bool changeTextColor = BoolValue.GetValue(heroKitObject, 13);

            if (changeTextColor)
            {
                HeroKitCommonRuntime.messageTextColor       = ColorValue.GetValue(heroKitObject, 14);
                HeroKitCommonRuntime.changeMessageTextColor = true;
            }

            // change heading color
            bool changeHeadingColor = BoolValue.GetValue(heroKitObject, 15);

            if (changeHeadingColor)
            {
                HeroKitCommonRuntime.messageHeadingColor       = ColorValue.GetValue(heroKitObject, 16);
                HeroKitCommonRuntime.changeMessageHeadingColor = true;
            }

            // change button text color
            bool changeButtonTextColor = BoolValue.GetValue(heroKitObject, 17);

            if (changeButtonTextColor)
            {
                HeroKitCommonRuntime.messageButtonTextColor       = ColorValue.GetValue(heroKitObject, 18);
                HeroKitCommonRuntime.changeMessageButtonTextColor = true;
            }

            // change active button color
            bool changeButtonActiveColor = BoolValue.GetValue(heroKitObject, 21);

            if (changeButtonActiveColor)
            {
                HeroKitCommonRuntime.messageButtonActiveColor       = ColorValue.GetValue(heroKitObject, 22);
                HeroKitCommonRuntime.changeMessageButtonActiveColor = true;
            }

            if (heroKitObject.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, ("")));
            }

            return(-99);
        }
Exemplo n.º 3
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

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

            endAlpha = SliderValue.GetValue(heroKitObject, 2) * 0.01f;
            duration = (float)(IntegerFieldValue.GetValueA(heroKitObject, 3) * 0.10);
            wait     = BoolValue.GetValue(heroKitObject, 4);
            Canvas canvas = null;

            // object is hero object
            if (objectData.heroKitObject != null)
            {
                canvas = objectData.heroKitObject[0].GetHeroComponent <Canvas>("Canvas");
                if (canvas != null)
                {
                    canvasGroup = objectData.heroKitObject[0].GetHeroComponent <CanvasGroup>("CanvasGroup", true);
                }
                else
                {
                    Debug.LogError("Can't change alpha because this game object does not have a Canvas component attached to it.");
                    return(-99);
                }
            }

            // object is game object
            else if (objectData.gameObject != null)
            {
                canvas = heroKitObject.GetGameObjectComponent <Canvas>("Canvas", false, objectData.gameObject[0]);
                if (canvas != null)
                {
                    canvasGroup = heroKitObject.GetGameObjectComponent <CanvasGroup>("CanvasGroup", true, objectData.gameObject[0]);
                }
                else
                {
                    Debug.LogError("Can't change alpha because this game object does not have a Canvas component attached to it.");
                    return(-99);
                }
            }

            if (canvasGroup.alpha != endAlpha)
            {
                startAlpha = canvasGroup.alpha;

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

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strCanvas    = (canvas != null) ? canvas.gameObject.name : "";
                string debugMessage = "Canvas: " + strCanvas + "\n" +
                                      "Alpha: " + endAlpha + "\n" +
                                      "Duration: " + duration;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }