Exemplo n.º 1
0
    protected void DrawSharedElements()
    {
        if (AdvGame.GetReferences() == null)
        {
            Debug.LogError("A References file is required - please use the Adventure Creator window to create one.");
            EditorGUILayout.LabelField("No References file found!");
        }
        else
        {
            actionsManager = AdvGame.GetReferences().actionsManager;

            ActionList _target = (ActionList)target;

            if (actionsManager)
            {
                int numActions = _target.actions.Count;
                if (numActions < 1)
                {
                    numActions = 1;

                    string defaultAction = actionsManager.GetDefaultAction();

                    _target.actions.Add((Action)CreateInstance(defaultAction));
                }

                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("Expand all"))
                {
                    Undo.RegisterUndo(_target, "Expand actions");

                    foreach (Action action in _target.actions)
                    {
                        action.isDisplayed = true;
                    }
                }

                if (GUILayout.Button("Collapse all"))
                {
                    Undo.RegisterUndo(_target, "Collapse actions");

                    foreach (Action action in _target.actions)
                    {
                        action.isDisplayed = false;
                    }
                }

                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < _target.actions.Count; i++)
                {
                    EditorGUILayout.BeginVertical("Button");
                    typeNumber = GetTypeNumber(i);

                    string actionLabel = " " + (i).ToString() + ": " + _target.actions[i].title + _target.actions[i].SetLabel();

                    _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel);

                    if (_target.actions[i].isDisplayed)
                    {
                        typeNumber = EditorGUILayout.Popup("Action type:", typeNumber, actionsManager.GetActionTitles());
                        EditorGUILayout.Space();

                        // Rebuild constructor if Subclass and type string do not match
                        if (_target.actions[i].GetType().ToString() != actionsManager.GetActionName(typeNumber))
                        {
                            _target.actions[i] = RebuildAction(_target.actions[i], typeNumber);
                        }

                        ShowActionGUI(_target.actions[i], _target.gameObject, i, _target.actions.Count);

                        EditorGUILayout.BeginHorizontal();

                        if (i > 0)
                        {
                            if (GUILayout.Button("Move up"))
                            {
                                Undo.RegisterUndo(_target, "Move action up");
                                _target.actions = AdvGame.SwapActions(_target.actions, i, i - 1);
                            }
                        }

                        if (i < _target.actions.Count - 1)
                        {
                            if (GUILayout.Button("Insert new"))
                            {
                                Undo.RegisterUndo(_target, "Create action");

                                numActions += 1;

                                _target.actions = ResizeList(_target.actions, numActions);
                                // Swap all elements up one
                                for (int k = numActions - 1; k > i + 1; k--)
                                {
                                    _target.actions = AdvGame.SwapActions(_target.actions, k, k - 1);
                                }
                            }
                        }

                        if (_target.actions.Count > 1)
                        {
                            if (GUILayout.Button("Delete"))
                            {
                                Undo.RegisterUndo(_target, "Delete action");

                                _target.actions.RemoveAt(i);
                                numActions -= 1;
                            }
                        }

                        if (i < _target.actions.Count - 1)
                        {
                            if (GUILayout.Button("Move down"))
                            {
                                Undo.RegisterUndo(_target, "Move action down");
                                _target.actions = AdvGame.SwapActions(_target.actions, i, i + 1);
                            }
                        }

                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.EndVertical();
                    EditorGUILayout.Space();
                }

                if (GUILayout.Button("Add new action"))
                {
                    Undo.RegisterUndo(_target, "Create action");
                    numActions += 1;
                }

                _target.actions = ResizeList(_target.actions, numActions);
            }
        }
    }
Exemplo n.º 2
0
    public override void TurnHead(Vector2 angles)
    {
        if (character == null)
        {
            return;
        }

        Animation animation = null;

        if (character.spriteChild && character.spriteChild.GetComponent <Animation>())
        {
            animation = character.spriteChild.GetComponent <Animation>();
        }
        if (character.GetComponent <Animation>())
        {
            animation = character.GetComponent <Animation>();
        }

        if (animation == null)
        {
            return;
        }

        // Horizontal
        if (character.headLookLeftAnim && character.headLookRightAnim)
        {
            if (angles.x < 0f)
            {
                animation.Stop(character.headLookRightAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck), character.headLookLeftAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookLeftAnim.name].weight = -angles.x;
                animation [character.headLookLeftAnim.name].speed  = 0f;
            }
            else if (angles.x > 0f)
            {
                animation.Stop(character.headLookLeftAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck), character.headLookRightAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookRightAnim.name].weight = angles.x;
                animation [character.headLookRightAnim.name].speed  = 0f;
            }
            else
            {
                animation.Stop(character.headLookLeftAnim.name);
                animation.Stop(character.headLookRightAnim.name);
            }
        }

        // Vertical
        if (character.headLookUpAnim && character.headLookDownAnim)
        {
            if (angles.y < 0f)
            {
                animation.Stop(character.headLookUpAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck) + 1, character.headLookDownAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookDownAnim.name].weight = -angles.y;
                animation [character.headLookDownAnim.name].speed  = 0f;
            }
            else if (angles.y > 0f)
            {
                animation.Stop(character.headLookDownAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck) + 1, character.headLookUpAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookUpAnim.name].weight = angles.y;
                animation [character.headLookUpAnim.name].speed  = 0f;
            }
            else
            {
                animation.Stop(character.headLookDownAnim.name);
                animation.Stop(character.headLookUpAnim.name);
            }
        }
    }
Exemplo n.º 3
0
    public override void CharSettingsGUI()
    {
                #if UNITY_EDITOR
        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Mecanim parameters:", EditorStyles.boldLabel);

        if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsTopDown())
        {
            character.spriteChild = (Transform)EditorGUILayout.ObjectField("Animator child:", character.spriteChild, typeof(Transform), true);
        }
        else
        {
            character.spriteChild = null;
        }

        character.moveSpeedParameter = EditorGUILayout.TextField("Move speed float:", character.moveSpeedParameter);
        character.turnParameter      = EditorGUILayout.TextField("Turn float:", character.turnParameter);
        character.talkParameter      = EditorGUILayout.TextField("Talk bool:", character.talkParameter);

        if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
            AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
        {
            if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
            {
                if (character.GetShapeable())
                {
                    character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                }
                else
                {
                    EditorGUILayout.HelpBox("Attach a Shapeable script to show phoneme options", MessageType.Info);
                }
            }
            else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
            {
                if (character.GetComponent <LipSyncTexture>() == null)
                {
                    EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                }
            }
        }

        if (!character.ikHeadTurning)
        {
            character.headYawParameter   = EditorGUILayout.TextField("Head yaw float:", character.headYawParameter);
            character.headPitchParameter = EditorGUILayout.TextField("Head pitch float:", character.headPitchParameter);
        }

        character.verticalMovementParameter = EditorGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter);
        if (character is Player)
        {
            Player player = (Player)character;
            player.jumpParameter = EditorGUILayout.TextField("Jump bool:", player.jumpParameter);
        }
        character.talkingAnimation = TalkingAnimation.Standard;

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Mecanim settings:", EditorStyles.boldLabel);

        character.headLayer  = EditorGUILayout.IntField("Head layer #:", character.headLayer);
        character.mouthLayer = EditorGUILayout.IntField("Mouth layer #:", character.mouthLayer);

        character.ikHeadTurning = EditorGUILayout.Toggle("IK head-turning?", character.ikHeadTurning);
        if (character.ikHeadTurning)
        {
                        #if UNITY_5 || UNITY_PRO
            EditorGUILayout.HelpBox("'IK Pass' must be enabled for this character's Base layer.", MessageType.Info);
                        #else
            EditorGUILayout.HelpBox("This features is only available with Unity 5 or Unity Pro.", MessageType.Info);
                        #endif
        }

        character.relyOnRootMotion  = EditorGUILayout.BeginToggleGroup("Rely on Root Motion?", character.relyOnRootMotion);
        character.rootTurningFactor = EditorGUILayout.Slider("Root Motion turning:", character.rootTurningFactor, 0f, 1f);
        EditorGUILayout.EndToggleGroup();
        character.doWallReduction = EditorGUILayout.BeginToggleGroup("Slow movement near wall colliders?", character.doWallReduction);
        character.wallLayer       = EditorGUILayout.TextField("Wall collider layer:", character.wallLayer);
        character.wallDistance    = EditorGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f);
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Bone transforms:", EditorStyles.boldLabel);

        character.neckBone      = (Transform)EditorGUILayout.ObjectField("Neck bone:", character.neckBone, typeof(Transform), true);
        character.leftHandBone  = (Transform)EditorGUILayout.ObjectField("Left hand:", character.leftHandBone, typeof(Transform), true);
        character.rightHandBone = (Transform)EditorGUILayout.ObjectField("Right hand:", character.rightHandBone, typeof(Transform), true);
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(character);
        }
                #endif
    }
Exemplo n.º 4
0
    public override void ActionCharAnimSkip(ActionCharAnim action)
    {
        if (action.animChar == null)
        {
            return;
        }

        Animation animation = null;

        if (action.animChar.spriteChild && action.animChar.spriteChild.GetComponent <Animation>())
        {
            animation = action.animChar.spriteChild.GetComponent <Animation>();
        }
        if (character._animation)
        {
            animation = action.animChar._animation;
        }

        if (action.method == ActionCharAnim.AnimMethodChar.PlayCustom && action.clip)
        {
            if (action.layer == AnimLayer.Base)
            {
                action.animChar.charState = CharState.Custom;
                action.blendMode          = AnimationBlendMode.Blend;
                action.playMode           = (AnimPlayMode)action.playModeBase;
            }

            if (action.playMode == AnimPlayMode.PlayOnce)
            {
                if (action.layer == AnimLayer.Base && action.method == ActionCharAnim.AnimMethodChar.PlayCustom)
                {
                    action.animChar.charState = CharState.Idle;
                    action.animChar.ResetBaseClips();
                }
            }
            else
            {
                AdvGame.CleanUnusedClips(animation);

                WrapMode  wrap            = WrapMode.Once;
                Transform mixingTransform = null;

                if (action.layer == AnimLayer.UpperBody)
                {
                    mixingTransform = action.animChar.upperBodyBone;
                }
                else if (action.layer == AnimLayer.LeftArm)
                {
                    mixingTransform = action.animChar.leftArmBone;
                }
                else if (action.layer == AnimLayer.RightArm)
                {
                    mixingTransform = action.animChar.rightArmBone;
                }
                else if (action.layer == AnimLayer.Neck || action.layer == AnimLayer.Head || action.layer == AnimLayer.Face || action.layer == AnimLayer.Mouth)
                {
                    mixingTransform = action.animChar.neckBone;
                }

                if (action.playMode == AnimPlayMode.PlayOnceAndClamp)
                {
                    wrap = WrapMode.ClampForever;
                }
                else if (action.playMode == AnimPlayMode.Loop)
                {
                    wrap = WrapMode.Loop;
                }

                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(action.layer), action.clip, action.blendMode, wrap, action.fadeTime, mixingTransform, 1f);
            }

            AdvGame.CleanUnusedClips(animation);
        }

        else if (action.method == ActionCharAnim.AnimMethodChar.StopCustom && action.clip)
        {
            if (action.clip != action.animChar.idleAnim && action.clip != action.animChar.walkAnim)
            {
                animation.Blend(action.clip.name, 0f, 0f);
            }
        }

        else if (action.method == ActionCharAnim.AnimMethodChar.ResetToIdle)
        {
            action.animChar.ResetBaseClips();

            action.animChar.charState = CharState.Idle;
            AdvGame.CleanUnusedClips(animation);
        }

        else if (action.method == ActionCharAnim.AnimMethodChar.SetStandard)
        {
            if (action.clip != null)
            {
                if (action.standard == AnimStandard.Idle)
                {
                    action.animChar.idleAnim = action.clip;
                }
                else if (action.standard == AnimStandard.Walk)
                {
                    action.animChar.walkAnim = action.clip;
                }
                else if (action.standard == AnimStandard.Run)
                {
                    action.animChar.runAnim = action.clip;
                }
                else if (action.standard == AnimStandard.Talk)
                {
                    action.animChar.talkAnim = action.clip;
                }
            }

            if (action.changeSpeed)
            {
                if (action.standard == AnimStandard.Walk)
                {
                    action.animChar.walkSpeedScale = action.newSpeed;
                }
                else if (action.standard == AnimStandard.Run)
                {
                    action.animChar.runSpeedScale = action.newSpeed;
                }
            }

            if (action.changeSound)
            {
                if (action.standard == AnimStandard.Walk)
                {
                    if (action.newSound != null)
                    {
                        action.animChar.walkSound = action.newSound;
                    }
                    else
                    {
                        action.animChar.walkSound = null;
                    }
                }
                else if (action.standard == AnimStandard.Run)
                {
                    if (action.newSound != null)
                    {
                        action.animChar.runSound = action.newSound;
                    }
                    else
                    {
                        action.animChar.runSound = null;
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
    public override float ActionAnimRun(ActionAnim action)
    {
        if (!action.isRunning)
        {
            action.isRunning = true;

            if (action.method == AnimMethod.PlayCustom && action._anim && action.clip)
            {
                AdvGame.CleanUnusedClips(action._anim);

                WrapMode wrap = WrapMode.Once;
                if (action.playMode == AnimPlayMode.PlayOnceAndClamp)
                {
                    wrap = WrapMode.ClampForever;
                }
                else if (action.playMode == AnimPlayMode.Loop)
                {
                    wrap = WrapMode.Loop;
                }

                AdvGame.PlayAnimClip(action._anim, 0, action.clip, action.blendMode, wrap, action.fadeTime, null, false);
            }

            else if (action.method == AnimMethod.StopCustom && action._anim && action.clip)
            {
                AdvGame.CleanUnusedClips(action._anim);
                action._anim.Blend(action.clip.name, 0f, action.fadeTime);
            }

            else if (action.method == AnimMethod.BlendShape && action.shapeKey > -1)
            {
                if (action.shapeObject)
                {
                    action.shapeObject.Change(action.shapeKey, action.shapeValue, action.fadeTime);

                    if (action.willWait)
                    {
                        return(action.fadeTime);
                    }
                }
            }

            if (action.willWait)
            {
                return(action.defaultPauseTime);
            }
        }
        else
        {
            if (action.method == AnimMethod.PlayCustom && action._anim && action.clip)
            {
                if (!action._anim.IsPlaying(action.clip.name))
                {
                    action.isRunning = false;
                    return(0f);
                }
                else
                {
                    return(action.defaultPauseTime);
                }
            }
            else if (action.method == AnimMethod.BlendShape && action.shapeObject)
            {
                action.isRunning = false;
                return(0f);
            }
        }

        return(0f);
    }
Exemplo n.º 6
0
    override public float Run()
    {
        if (isPlayer)
        {
            animChar = GameObject.FindWithTag(Tags.player).GetComponent <Char>();
        }

        if (!isRunning)
        {
            isRunning = true;


            if (animChar)
            {
                if (method == AnimMethodChar.PlayCustom && clip)
                {
                    AdvGame.CleanUnusedClips(animChar.animation);

                    WrapMode  wrap            = WrapMode.Once;
                    Transform mixingTransform = null;

                    if (layer == AnimLayer.Base)
                    {
                        animChar.charState = CharState.Custom;
                        blendMode          = AnimationBlendMode.Blend;
                        playMode           = (AnimPlayMode)playModeBase;
                    }
                    else if (layer == AnimLayer.UpperBody)
                    {
                        mixingTransform = animChar.upperBodyBone;
                    }
                    else if (layer == AnimLayer.LeftArm)
                    {
                        mixingTransform = animChar.leftArmBone;
                    }
                    else if (layer == AnimLayer.RightArm)
                    {
                        mixingTransform = animChar.rightArmBone;
                    }
                    else if (layer == AnimLayer.Neck || layer == AnimLayer.Head || layer == AnimLayer.Face || layer == AnimLayer.Mouth)
                    {
                        mixingTransform = animChar.neckBone;
                    }

                    if (playMode == AnimPlayMode.PlayOnceAndClamp)
                    {
                        wrap = WrapMode.ClampForever;
                    }
                    else if (playMode == AnimPlayMode.Loop)
                    {
                        wrap = WrapMode.Loop;
                    }

                    AdvGame.PlayAnimClip(animChar.GetComponent <Animation>(), (int)layer, clip, blendMode, wrap, fadeTime, mixingTransform);
                }

                else if (method == AnimMethodChar.StopCustom && clip)
                {
                    if (clip != animChar.idleAnim && clip != animChar.walkAnim)
                    {
                        animChar.animation.Blend(clip.name, 0f, fadeTime);
                    }
                }

                else if (method == AnimMethodChar.ResetToIdle)
                {
                    animChar.ResetBaseClips();
                    animChar.charState = CharState.Idle;
                    AdvGame.CleanUnusedClips(animChar.animation);
                }

                else if (method == AnimMethodChar.SetStandard && clip)
                {
                    if (standard == AnimStandard.Idle)
                    {
                        animChar.idleAnim = clip;
                    }

                    else if (standard == AnimStandard.Walk)
                    {
                        animChar.walkAnim = clip;
                    }

                    else if (standard == AnimStandard.Run)
                    {
                        animChar.runAnim = clip;
                    }
                }


                if (willWait && clip)
                {
                    if (method == AnimMethodChar.PlayCustom)
                    {
                        return(defaultPauseTime);
                    }
                    else if (method == AnimMethodChar.StopCustom)
                    {
                        return(fadeTime);
                    }
                }
            }

            return(0f);
        }
        else
        {
            if (animChar.animation[clip.name] && animChar.animation[clip.name].normalizedTime < 1f && animChar.animation.IsPlaying(clip.name))
            {
                return(defaultPauseTime);
            }
            else
            {
                isRunning = false;

                if (playMode == AnimPlayMode.PlayOnce)
                {
                    animChar.animation.Blend(clip.name, 0f, fadeTime);

                    if (layer == AnimLayer.Base && method == AnimMethodChar.PlayCustom)
                    {
                        animChar.charState = CharState.Idle;
                        animChar.ResetBaseClips();
                    }
                }

                AdvGame.CleanUnusedClips(animChar.animation);

                return(0f);
            }
        }
    }
Exemplo n.º 7
0
    public override void CharSettingsGUI()
    {
                #if UNITY_EDITOR
        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Standard 3D animations:", EditorStyles.boldLabel);

        if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsTopDown())
        {
            character.spriteChild = (Transform)EditorGUILayout.ObjectField("Animation child:", character.spriteChild, typeof(Transform), true);
        }
        else
        {
            character.spriteChild = null;
        }

        character.talkingAnimation = (TalkingAnimation)EditorGUILayout.EnumPopup("Talk animation style:", character.talkingAnimation);
        character.idleAnim         = (AnimationClip)EditorGUILayout.ObjectField("Idle:", character.idleAnim, typeof(AnimationClip), false);
        character.walkAnim         = (AnimationClip)EditorGUILayout.ObjectField("Walk:", character.walkAnim, typeof(AnimationClip), false);
        character.runAnim          = (AnimationClip)EditorGUILayout.ObjectField("Run:", character.runAnim, typeof(AnimationClip), false);
        if (character.talkingAnimation == TalkingAnimation.Standard)
        {
            character.talkAnim = (AnimationClip)EditorGUILayout.ObjectField("Talk:", character.talkAnim, typeof(AnimationClip), false);
        }

        if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager)
        {
            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    if (character.GetShapeable())
                    {
                        character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Attach a Shapeable script to show phoneme options", MessageType.Info);
                    }
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }
        }

        character.turnLeftAnim      = (AnimationClip)EditorGUILayout.ObjectField("Turn left:", character.turnLeftAnim, typeof(AnimationClip), false);
        character.turnRightAnim     = (AnimationClip)EditorGUILayout.ObjectField("Turn right:", character.turnRightAnim, typeof(AnimationClip), false);
        character.headLookLeftAnim  = (AnimationClip)EditorGUILayout.ObjectField("Head look left:", character.headLookLeftAnim, typeof(AnimationClip), false);
        character.headLookRightAnim = (AnimationClip)EditorGUILayout.ObjectField("Head look right:", character.headLookRightAnim, typeof(AnimationClip), false);
        character.headLookUpAnim    = (AnimationClip)EditorGUILayout.ObjectField("Head look up:", character.headLookUpAnim, typeof(AnimationClip), false);
        character.headLookDownAnim  = (AnimationClip)EditorGUILayout.ObjectField("Head look down:", character.headLookDownAnim, typeof(AnimationClip), false);
        if (character is Player)
        {
            Player player = (Player)character;
            player.jumpAnim = (AnimationClip)EditorGUILayout.ObjectField("Jump:", player.jumpAnim, typeof(AnimationClip), false);
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Bone transforms:", EditorStyles.boldLabel);

        character.upperBodyBone = (Transform)EditorGUILayout.ObjectField("Upper body:", character.upperBodyBone, typeof(Transform), true);
        character.neckBone      = (Transform)EditorGUILayout.ObjectField("Neck bone:", character.neckBone, typeof(Transform), true);
        character.leftArmBone   = (Transform)EditorGUILayout.ObjectField("Left arm:", character.leftArmBone, typeof(Transform), true);
        character.rightArmBone  = (Transform)EditorGUILayout.ObjectField("Right arm:", character.rightArmBone, typeof(Transform), true);
        character.leftHandBone  = (Transform)EditorGUILayout.ObjectField("Left hand:", character.leftHandBone, typeof(Transform), true);
        character.rightHandBone = (Transform)EditorGUILayout.ObjectField("Right hand:", character.rightHandBone, typeof(Transform), true);
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(character);
        }
                #endif
    }
 /**
  * <summary>Converts the replacementText into a temporary one that has no colon or pipe characters, so that it is safe for saving.</summary>
  * <returns>The converted replacementText that is safe for saving.</returns>
  */
 public string GetSafeReplacementText()
 {
     return(AdvGame.PrepareStringForSaving(replacementText));
 }
 /**
  * <summary>Assigns the replacementText from a safe-to-store string that was stored in save data.</summary>
  * <param name = "safeText">The safe-to-store variant of replacementText that was stored in save data</param>
  */
 public void SetSafeReplacementText(string safeText)
 {
     replacementText = AdvGame.PrepareStringForLoading(safeText);
 }
Exemplo n.º 10
0
    private void Awake()
    {
        // Test for key imports
        References references = (References)Resources.Load(Resource.references);

        if (references)
        {
            SceneManager     sceneManager     = AdvGame.GetReferences().sceneManager;
            SettingsManager  settingsManager  = AdvGame.GetReferences().settingsManager;
            ActionsManager   actionsManager   = AdvGame.GetReferences().actionsManager;
            InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager;
            VariablesManager variablesManager = AdvGame.GetReferences().variablesManager;
            SpeechManager    speechManager    = AdvGame.GetReferences().speechManager;

            if (sceneManager == null)
            {
                Debug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (settingsManager == null)
            {
                Debug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard");
            }
            else
            {
                if (!GameObject.FindGameObjectWithTag(Tags.player))
                {
                    try
                    {
                        Player ref_player = AdvGame.GetReferences().settingsManager.player;
                        Player player     = (Player)Instantiate(ref_player);
                        player.name = ref_player.name;
                    }
                    catch {}
                }
            }

            if (actionsManager == null)
            {
                Debug.LogError("No Actions Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (inventoryManager == null)
            {
                Debug.LogError("No Inventory Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (variablesManager == null)
            {
                Debug.LogError("No Variables Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (speechManager == null)
            {
                Debug.LogError("No Speech Manager found - please set one using the Adventure Creator Kit wizard");
            }

            if (GameObject.FindWithTag(Tags.player) == null)
            {
                Debug.LogError("No Player found - please set one using the Settings Manager, tagging it as Player");
            }
        }
        else
        {
            Debug.LogError("No References object found. Please set one using the Adventure Creator Kit wizard.");
        }

        if (!GameObject.FindGameObjectWithTag(Tags.persistentEngine))
        {
            try
            {
                GameObject persistentEngine = (GameObject)Instantiate(Resources.Load(Resource.persistentEngine));
                persistentEngine.name = AdvGame.GetName(Resource.persistentEngine);
            }
            catch {}
        }

        if (GameObject.FindWithTag(Tags.persistentEngine) == null)
        {
            Debug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine");
        }
        else
        {
            GameObject persistentEngine = GameObject.FindWithTag(Tags.persistentEngine);

            if (persistentEngine.GetComponent <Options>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no Options component attached.");
            }
            if (persistentEngine.GetComponent <RuntimeInventory>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no RuntimeInventory component attached.");
            }
            if (persistentEngine.GetComponent <RuntimeVariables>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no RuntimeVariables component attached.");
            }
            if (persistentEngine.GetComponent <StateHandler>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no StateHandler component attached.");
            }
            if (persistentEngine.GetComponent <SceneChanger>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no SceneChanger component attached.");
            }
            if (persistentEngine.GetComponent <SaveSystem>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no SaveSystem component attached.");
            }
            if (persistentEngine.GetComponent <LevelStorage>() == null)
            {
                Debug.LogError(persistentEngine.name + " has no LevelStorage component attached.");
            }
        }

        if (GameObject.FindWithTag(Tags.mainCamera) == null)
        {
            Debug.LogError("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one.");
        }
        else
        {
            if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null)
            {
                Debug.LogError("MainCamera has no MainCamera component.");
            }
        }

        if (this.tag == Tags.gameEngine)
        {
            if (this.GetComponent <MenuSystem>() == null)
            {
                Debug.LogError(this.name + " has no MenuSystem component attached.");
            }

            if (this.GetComponent <Dialog>() == null)
            {
                Debug.LogError(this.name + " has no Dialog component attached.");
            }

            if (this.GetComponent <PlayerInput>() == null)
            {
                Debug.LogError(this.name + " has no PlayerInput component attached.");
            }

            if (this.GetComponent <PlayerInteraction>() == null)
            {
                Debug.LogError(this.name + " has no PlayerInteraction component attached.");
            }

            if (this.GetComponent <PlayerMenus>() == null)
            {
                Debug.LogError(this.name + " has no PlayerMenus component attached.");
            }

            if (this.GetComponent <PlayerMovement>() == null)
            {
                Debug.LogError(this.name + " has no PlayerMovement component attached.");
            }
            if
            (this.GetComponent <PlayerCursor>() == null)
            {
                Debug.LogError(this.name + " has no PlayerCursor component attached.");
            }

            if (this.GetComponent <SceneSettings>() == null)
            {
                Debug.LogError(this.name + " has no SceneSettings component attached.");
            }
            else
            {
                if (this.GetComponent <SceneSettings>().navMesh == null)
                {
                    Debug.LogWarning("No NavMesh set.  Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager.");
                }

                if (this.GetComponent <SceneSettings>().defaultPlayerStart == null)
                {
                    Debug.LogWarning("No default PlayerStart set.  The game may not be able to begin if one is not defined - please choose one using the Scene Manager.");
                }
            }

            if (this.GetComponent <RuntimeActionList>() == null)
            {
                Debug.LogError(this.name + " has no RuntimeActionList component attached.");
            }
        }
    }
Exemplo n.º 11
0
        public override void OnGUI(int WindowID)
        {
            if (inventoryManager == null && AdvGame.GetReferences().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }
            if (settingsManager == null && AdvGame.GetReferences().settingsManager)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            if (inventoryManager)
            {
                // Create a string List of the field's names (for the PopUp box)
                List <string> labelList = new List <string>();

                int i = 0;
                if (parameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add(_item.label);

                        // If an item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        // Wasn't found (item was possibly deleted), so revert to zero
                        ACDebug.LogWarning("Previously chosen item no longer exists!");

                        invNumber = 0;
                        invID     = 0;
                    }


                    parameterID = AC.Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                    if (parameterID >= 0)
                    {
                        invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                        invID     = -1;
                    }
                    else
                    {
                        invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                        invID     = inventoryManager.items[invNumber].id;
                    }
                    //

                    if (inventoryManager.items[invNumber].canCarryMultiple)
                    {
                        doCount = EditorGUILayout.Toggle("Query count?", doCount);

                        if (doCount)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("Count is:", GUILayout.MaxWidth(70));
                            intCondition = (IntCondition)EditorGUILayout.EnumPopup(intCondition);
                            intValue     = EditorGUILayout.IntField(intValue);

                            if (intValue < 1)
                            {
                                intValue = 1;
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        doCount = false;
                    }

                    if (settingsManager != null && settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory)
                    {
                        EditorGUILayout.Space();

                        setPlayer = EditorGUILayout.Toggle("Check specific player?", setPlayer);
                        if (setPlayer)
                        {
                            ChoosePlayerGUI();
                        }
                    }
                    else
                    {
                        setPlayer = false;
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("No inventory items exist!");
                    invID     = -1;
                    invNumber = -1;
                }
            }
            else
            {
                EditorGUILayout.HelpBox("An Inventory Manager must be assigned for this Action to work", MessageType.Warning);
            }
        }
Exemplo n.º 12
0
    public void ShowGUI(int lowerValue, int upperValue)
    {
        if (!variablesManager)
        {
            variablesManager = AdvGame.GetReferences().variablesManager;
        }

        if (variablesManager)
        {
            // Create a string List of the field's names (for the PopUp box)
            List <string> labelList = new List <string>();

            int i = 0;
            variableNumber = -1;

            if (variablesManager.vars.Count > 0)
            {
                foreach (GVar _var in variablesManager.vars)
                {
                    labelList.Add(_var.label);

                    // If a GlobalVar variable has been removed, make sure selected variable is still valid
                    if (_var.id == variableID)
                    {
                        variableNumber = i;
                    }

                    i++;
                }

                if (variableNumber == -1)
                {
                    // Wasn't found (variable was deleted?), so revert to zero
                    Debug.LogWarning("Previously chosen variable no longer exists!");
                    variableNumber = 0;
                    variableID     = 0;
                }

                EditorGUILayout.BeginHorizontal();

                variableNumber = EditorGUILayout.Popup(variableNumber, labelList.ToArray());
                variableID     = variablesManager.vars[variableNumber].id;

                if (variablesManager.vars[variableNumber].type == VariableType.Boolean)
                {
                    boolCondition = (BoolCondition)EditorGUILayout.EnumPopup(boolCondition);
                    boolValue     = (BoolValue)EditorGUILayout.EnumPopup(boolValue);
                }
                else
                {
                    intCondition = (IntCondition)EditorGUILayout.EnumPopup(intCondition);
                    intValue     = EditorGUILayout.IntField(intValue);
                }

                EditorGUILayout.EndHorizontal();

                if (lowerValue > upperValue || lowerValue == upperValue)
                {
                    lowerValue = upperValue;
                }

                resultActionTrue = (Action.ResultAction)EditorGUILayout.EnumPopup("If condition is met:", (Action.ResultAction)resultActionTrue);
                if (resultActionTrue == Action.ResultAction.RunCutscene)
                {
                    linkedCutsceneTrue = (Cutscene)EditorGUILayout.ObjectField("Cutscene to run:", linkedCutsceneTrue, typeof(Cutscene), true);
                }
                else if (resultActionTrue == Action.ResultAction.Skip)
                {
                    skipActionTrue = EditorGUILayout.IntSlider("Action # to skip to:", skipActionTrue, lowerValue, upperValue);
                }

                resultActionFail = (Action.ResultAction)EditorGUILayout.EnumPopup("If condition is not met:", (Action.ResultAction)resultActionFail);
                if (resultActionFail == Action.ResultAction.RunCutscene)
                {
                    linkedCutsceneFail = (Cutscene)EditorGUILayout.ObjectField("Cutscene to run:", linkedCutsceneFail, typeof(Cutscene), true);
                }
                else if (resultActionFail == Action.ResultAction.Skip)
                {
                    skipActionFail = EditorGUILayout.IntSlider("Action # to skip to:", skipActionFail, lowerValue, upperValue);
                }
            }
            else
            {
                EditorGUILayout.LabelField("No global variables exist!");
                variableID     = -1;
                variableNumber = -1;
            }
        }
    }
Exemplo n.º 13
0
 private void RenameObject(GameObject ob, string resourceName)
 {
     ob.name = AdvGame.GetName(resourceName);
 }
Exemplo n.º 14
0
    public void ShowGUI(int lowerValue, int upperValue)
    {
        if (!inventoryManager)
        {
            inventoryManager = AdvGame.GetReferences().inventoryManager;
        }

        if (inventoryManager)
        {
            // Create a string List of the field's names (for the PopUp box)
            List <string> labelList = new List <string>();

            int i = 0;
            invNumber = -1;

            if (inventoryManager.items.Count > 0)
            {
                foreach (InvItem _item in inventoryManager.items)
                {
                    labelList.Add(_item.label);

                    // If an item has been removed, make sure selected variable is still valid
                    if (_item.id == invID)
                    {
                        invNumber = i;
                    }

                    i++;
                }

                if (invNumber == -1)
                {
                    // Wasn't found (item was possibly deleted), so revert to zero
                    Debug.LogWarning("Previously chosen item no longer exists!");

                    invNumber = 0;
                    invID     = 0;
                }

                EditorGUILayout.BeginHorizontal();
                invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                invID     = inventoryManager.items[invNumber].id;
                EditorGUILayout.EndHorizontal();

                if (lowerValue > upperValue)
                {
                    lowerValue = upperValue;
                }
                else if (upperValue < lowerValue)
                {
                    upperValue = lowerValue;
                }

                if (inventoryManager.items[invNumber].canCarryMultiple)
                {
                    doCount = EditorGUILayout.Toggle("Query count?", doCount);

                    if (doCount)
                    {
                        EditorGUILayout.BeginHorizontal("");
                        EditorGUILayout.LabelField("Count is:", GUILayout.MaxWidth(70));
                        intCondition = (IntCondition)EditorGUILayout.EnumPopup(intCondition);
                        intValue     = EditorGUILayout.IntField(intValue);

                        if (intValue < 1)
                        {
                            intValue = 1;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                else
                {
                    doCount = false;
                }

                if (doCount)
                {
                    resultActionTrue = (Action.ResultAction)EditorGUILayout.EnumPopup("If condition is met:", (Action.ResultAction)resultActionTrue);
                }
                else
                {
                    resultActionTrue = (Action.ResultAction)EditorGUILayout.EnumPopup("If player is carrying:", (Action.ResultAction)resultActionTrue);
                }

                if (resultActionTrue == Action.ResultAction.RunCutscene)
                {
                    linkedCutsceneTrue = (Cutscene)EditorGUILayout.ObjectField("Cutscene to trigger:", linkedCutsceneTrue, typeof(Cutscene), true);
                }
                else if (resultActionTrue == Action.ResultAction.Skip)
                {
                    skipActionTrue = EditorGUILayout.IntSlider("Action # to skip to:", skipActionTrue, lowerValue, upperValue);
                }

                if (doCount)
                {
                    resultActionFail = (Action.ResultAction)EditorGUILayout.EnumPopup("If condition is not met:", (Action.ResultAction)resultActionFail);
                }
                else
                {
                    resultActionFail = (Action.ResultAction)EditorGUILayout.EnumPopup("If player is not carrying:", (Action.ResultAction)resultActionFail);
                }

                if (resultActionFail == Action.ResultAction.RunCutscene)
                {
                    linkedCutsceneFail = (Cutscene)EditorGUILayout.ObjectField("Cutscene to trigger:", linkedCutsceneFail, typeof(Cutscene), true);
                }
                else if (resultActionFail == Action.ResultAction.Skip)
                {
                    skipActionFail = EditorGUILayout.IntSlider("Action # to skip to:", skipActionFail, lowerValue, upperValue);
                }
            }

            else
            {
                EditorGUILayout.LabelField("No inventory items exist!");
                invID     = -1;
                invNumber = -1;
            }
        }
    }
Exemplo n.º 15
0
    public override void OnInspectorGUI()
    {
        Moveable_Drag _target = (Moveable_Drag)target;

        GetReferences();

        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Movment settings:", EditorStyles.boldLabel);
        _target.maxSpeed    = EditorGUILayout.FloatField("Max speed:", _target.maxSpeed);
        _target.invertInput = EditorGUILayout.Toggle("Invert input?", _target.invertInput);
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("Button");

        EditorGUILayout.LabelField("Drag settings:", EditorStyles.boldLabel);
        _target.dragMode = (DragMode)EditorGUILayout.EnumPopup("Drag mode:", _target.dragMode);
        if (_target.dragMode == DragMode.LockToTrack)
        {
            _target.track      = (DragTrack)EditorGUILayout.ObjectField("Track to stick to:", _target.track, typeof(DragTrack), true);
            _target.setOnStart = EditorGUILayout.Toggle("Set starting position?", _target.setOnStart);
            if (_target.setOnStart)
            {
                _target.trackValueOnStart = EditorGUILayout.Slider("Initial distance along:", _target.trackValueOnStart, 0f, 1f);
            }

            EditorGUILayout.BeginHorizontal();
            _target.interactionOnMove = (Interaction)EditorGUILayout.ObjectField("Interaction on move:", _target.interactionOnMove, typeof(Interaction), true);

            if (_target.interactionOnMove == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Undo.RecordObject(_target, "Create Interaction");
                    Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();
                    newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name);
                    _target.interactionOnMove      = newInteraction;
                }
            }
            EditorGUILayout.EndVertical();
        }
        else if (_target.dragMode == DragMode.MoveAlongPlane)
        {
            _target.alignMovement = (AlignDragMovement)EditorGUILayout.EnumPopup("Align movement:", _target.alignMovement);
            if (_target.alignMovement == AlignDragMovement.AlignToPlane)
            {
                _target.plane = (Transform)EditorGUILayout.ObjectField("Movement plane:", _target.plane, typeof(Transform), true);
            }
        }
        else if (_target.dragMode == DragMode.RotateOnly)
        {
            _target.rotationFactor = EditorGUILayout.FloatField("Rotation factor:", _target.rotationFactor);
            _target.allowZooming   = EditorGUILayout.Toggle("Allow zooming?", _target.allowZooming);
            if (_target.allowZooming)
            {
                _target.zoomSpeed = EditorGUILayout.FloatField("Zoom speed:", _target.zoomSpeed);
                _target.minZoom   = EditorGUILayout.FloatField("Closest distance:", _target.minZoom);
                _target.maxZoom   = EditorGUILayout.FloatField("Farthest distance:", _target.maxZoom);
            }
        }

        if (_target.dragMode != DragMode.LockToTrack)
        {
            _target.noGravityWhenHeld = EditorGUILayout.Toggle("Disable gravity when held?", _target.noGravityWhenHeld);
        }

        if (Application.isPlaying && _target.dragMode == DragMode.LockToTrack && _target.track)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Distance along: " + _target.GetPositionAlong().ToString(), EditorStyles.miniLabel);
        }

        EditorGUILayout.EndVertical();

        if (_target.dragMode == DragMode.LockToTrack && _target.track is DragTrack_Hinge)
        {
            SharedGUI(_target, true);
        }
        else
        {
            SharedGUI(_target, false);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_target);
        }
    }
Exemplo n.º 16
0
    private void Start()
    {
        if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager)
        {
            speechManager = AdvGame.GetReferences().speechManager;
        }

        SetFontSize();

        menus.Add(pauseMenu);
        menus.Add(optionsMenu);
        menus.Add(saveMenu);
        menus.Add(loadMenu);
        menus.Add(inventoryMenu);
        menus.Add(inGameMenu);
        menus.Add(conversationMenu);
        menus.Add(hotspotMenu);
        menus.Add(subsMenu);

        pauseMenu.Add(pause_ResumeButton);
        pauseMenu.Add(pause_OptionsButton);

        if (Application.platform != RuntimePlatform.OSXWebPlayer && Application.platform != RuntimePlatform.WindowsWebPlayer)
        {
            pauseMenu.Add(pause_SaveButton);
            pauseMenu.Add(pause_LoadButton);
        }
        pauseMenu.Add(pause_QuitButton);
        pauseMenu.SetBackground(backgroundTexture);
        pauseMenu.Centre();

        optionsMenu.Add(options_Title);
        options_Speech.SetSliderTexture(sliderTexture);
        options_Music.SetSliderTexture(sliderTexture);
        options_Sfx.SetSliderTexture(sliderTexture);
        optionsMenu.Add(options_Speech);
        optionsMenu.Add(options_Music);
        optionsMenu.Add(options_Sfx);

        if (speechManager)
        {
            options_Language = new MenuCycle("Language", speechManager.languages.ToArray());
            optionsMenu.Add(options_Language);
            if (speechManager.languages.Count == 1)
            {
                options_Language.isVisible = false;
            }
        }

        optionsMenu.Add(options_Subs);
        optionsMenu.Add(options_BackButton);
        optionsMenu.SetBackground(backgroundTexture);
        optionsMenu.Centre();

        saveMenu.Add(save_Title);
        saveMenu.Add(save_SavesList);
        saveMenu.Add(save_NewButton);
        saveMenu.Add(save_BackButton);
        saveMenu.SetBackground(backgroundTexture);
        saveMenu.Centre();

        loadMenu.Add(load_Title);
        loadMenu.Add(load_SavesList);
        loadMenu.Add(load_BackButton);
        loadMenu.SetBackground(backgroundTexture);
        loadMenu.Centre();

        inventoryMenu.Add(inventory_Box);
        inventoryMenu.SetSize(new Vector2(1f, 0.12f));
        inventoryMenu.Align(TextAnchor.UpperCenter);
        inventoryMenu.SetBackground(backgroundTexture);

        inGameMenu.Add(inGame_MenuButton);
        inGameMenu.Align(TextAnchor.LowerLeft);
        inGameMenu.SetBackground(backgroundTexture);

        conversationMenu.Add(dialog_Box);
        conversationMenu.Add(dialog_Timer);
        conversationMenu.SetCentre(new Vector2(0.25f, 0.72f));
        dialog_Timer.SetSize(new Vector2(0.2f, 0.01f));
        dialog_Timer.SetTimerTexture(sliderTexture);
        conversationMenu.SetBackground(backgroundTexture);

        subsMenu.Add(subs_Speaker);
        subsMenu.Add(subs_Line);
        subsMenu.SetBackground(backgroundTexture);
        subs_Line.SetAlignment(TextAnchor.UpperLeft);
        subsMenu.SetCentre(new Vector2(0.5f, 0.85f));

        hotspotMenu.Add(hotspot_Label);

        if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsWebPlayer)
        {
            pause_QuitButton.isVisible = false;
            pauseMenu.AutoResize();
        }

        SetStyles();

        if (GameObject.FindWithTag(Tags.persistentEngine))
        {
            if (GameObject.FindWithTag(Tags.persistentEngine).GetComponent <Options>())
            {
                options = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <Options>();
            }

            if (GameObject.FindWithTag(Tags.persistentEngine).GetComponent <SaveSystem>())
            {
                saveSystem = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <SaveSystem>();
            }
        }
    }
Exemplo n.º 17
0
    override public void ShowGUI()
    {
        if (!inventoryManager)
        {
            inventoryManager = AdvGame.GetReferences().inventoryManager;
        }

        if (inventoryManager)
        {
            // Create a string List of the field's names (for the PopUp box)
            List <string> labelList = new List <string>();

            int i = 0;
            invNumber = -1;

            if (inventoryManager.items.Count > 0)
            {
                foreach (InvItem _item in inventoryManager.items)
                {
                    labelList.Add(_item.label);

                    // If a item has been removed, make sure selected variable is still valid
                    if (_item.id == invID)
                    {
                        invNumber = i;
                    }

                    i++;
                }

                if (invNumber == -1)
                {
                    Debug.Log("Previously chosen item no longer exists!");
                    invNumber = 0;
                    invID     = 0;
                }

                EditorGUILayout.BeginHorizontal();
                invAction = (InvAction)EditorGUILayout.EnumPopup("Inventory item:", invAction);

                invNumber = EditorGUILayout.Popup(invNumber, labelList.ToArray());
                invID     = inventoryManager.items[invNumber].id;
                EditorGUILayout.EndHorizontal();

                if (inventoryManager.items[invNumber].canCarryMultiple)
                {
                    setAmount = EditorGUILayout.Toggle("Set amount?", setAmount);

                    if (setAmount)
                    {
                        if (invAction == InvAction.Add)
                        {
                            amount = EditorGUILayout.IntField("Increase count by:", amount);
                        }
                        else
                        {
                            amount = EditorGUILayout.IntField("Reduce count by:", amount);
                        }
                    }
                    else
                    {
                        amount = 1;
                    }
                }
                else
                {
                    amount = 1;
                }

                AfterRunningOption();
            }

            else
            {
                EditorGUILayout.LabelField("No inventory items exist!");
                invID     = -1;
                invNumber = -1;
            }
        }
    }
Exemplo n.º 18
0
    private void FixedUpdate()
    {
        if (isMoving)
        {
            if (Time.time < moveStartTime + moveChangeTime)
            {
                if (transformType == TransformType.Translate)
                {
                    if (moveMethod == MoveMethod.Linear)
                    {
                        transform.localPosition = Vector3.Lerp(startVector, targetVector, AdvGame.LinearTimeFactor(moveStartTime, moveChangeTime));
                    }
                    else if (moveMethod == MoveMethod.Smooth)
                    {
                        transform.localPosition = Vector3.Lerp(startVector, targetVector, AdvGame.SmoothTimeFactor(moveStartTime, moveChangeTime));
                    }
                    else
                    {
                        transform.localPosition = Vector3.Slerp(startVector, targetVector, AdvGame.SmoothTimeFactor(moveStartTime, moveChangeTime));
                    }
                }

                else if (transformType == TransformType.Rotate)
                {
                    if (moveMethod == MoveMethod.Linear)
                    {
                        transform.localEulerAngles = Vector3.Lerp(startVector, targetVector, AdvGame.LinearTimeFactor(moveStartTime, moveChangeTime));
                    }
                    else if (moveMethod == MoveMethod.Smooth)
                    {
                        transform.localEulerAngles = Vector3.Lerp(startVector, targetVector, AdvGame.SmoothTimeFactor(moveStartTime, moveChangeTime));
                    }
                    else
                    {
                        transform.localEulerAngles = Vector3.Slerp(startVector, targetVector, AdvGame.SmoothTimeFactor(moveStartTime, moveChangeTime));
                    }
                }

                else
                {
                    if (moveMethod == MoveMethod.Linear)
                    {
                        transform.localScale = Vector3.Lerp(startVector, targetVector, AdvGame.LinearTimeFactor(moveStartTime, moveChangeTime));
                    }
                    else if (moveMethod == MoveMethod.Smooth)
                    {
                        transform.localScale = Vector3.Lerp(startVector, targetVector, AdvGame.SmoothTimeFactor(moveStartTime, moveChangeTime));
                    }
                    else
                    {
                        transform.localScale = Vector3.Slerp(startVector, targetVector, AdvGame.SmoothTimeFactor(moveStartTime, moveChangeTime));
                    }
                }
            }
            else
            {
                isMoving = false;
            }
        }
    }