Ejemplo n.º 1
0
        public override void Initialize(ActorBaseComponent actorBaseComponent)
        {
            base.Initialize(actorBaseComponent);

            ActorComponent actorComponent = actorBaseComponent as ActorComponent;

            m_SortingOrderOffset = actorComponent.SortingOrder;

            ActorImage imageNode = m_ActorNode as ActorImage;

            // Attach the skinned bone nodes to the bones of the skinned renderer.
            if (imageNode.IsSkinned)
            {
                SkinnedMeshRenderer skinnedRenderer = gameObject.GetComponent <SkinnedMeshRenderer>();

                Transform[] transforms = new Transform[imageNode.ConnectedBoneCount + 1];
                transforms[0] = actorComponent.DefaultBone.transform;
                int idx = 1;
                foreach (ActorImage.BoneConnection bc in imageNode.BoneConnections)
                {
                    ActorNodeComponent boneComponent = actorComponent.Nodes[bc.m_BoneIdx];
                    transforms[idx] = boneComponent.gameObject.transform;
                    idx++;
                }
                skinnedRenderer.bones = transforms;
            }
        }
Ejemplo n.º 2
0
 public void Start()
 {
     m_Actor = gameObject.GetComponent <Nima.Unity.ActorBaseComponent>();
     if (m_Actor != null)
     {
         if (m_Actor.ActorInstance != null)
         {
             fade            = m_Actor.ActorInstance.GetAnimation("fade");
             claws_contract  = m_Actor.ActorInstance.GetAnimation("claws_contract");
             show_z          = m_Actor.ActorInstance.GetAnimation("show_z");
             show_x          = m_Actor.ActorInstance.GetAnimation("show_x");
             z_idle          = m_Actor.ActorInstance.GetAnimation("z_idle");
             x_idle          = m_Actor.ActorInstance.GetAnimation("x_idle");
             claws_idle      = m_Actor.ActorInstance.GetAnimation("claws_idle");
             claws_spark     = m_Actor.ActorInstance.GetAnimation("claws_spark");
             arms_contract   = m_Actor.ActorInstance.GetAnimation("arms_contract");
             arms_idle       = m_Actor.ActorInstance.GetAnimation("arms_idle");
             arms_fire       = m_Actor.ActorInstance.GetAnimation("arms_fire");
             smoke_flicker   = m_Actor.ActorInstance.GetAnimation("smoke_flicker");
             flame_flicker2  = m_Actor.ActorInstance.GetAnimation("flame_flicker2");
             flame_size      = m_Actor.ActorInstance.GetAnimation("flame_size");
             flame_opacity   = m_Actor.ActorInstance.GetAnimation("flame_opacity");
             smoke_opacity   = m_Actor.ActorInstance.GetAnimation("smoke_opacity");
             smoke_stability = m_Actor.ActorInstance.GetAnimation("smoke_stability");
         }
     }
 }
Ejemplo n.º 3
0
 public void OnDisable()
 {
     if (m_ActorBase != null)
     {
         m_ActorBase.RemoveFinalFormDependent(this);
         m_ActorBase = null;
         m_MountNode = null;
     }
 }
Ejemplo n.º 4
0
 public void Start()
 {
     m_Animator           = GetComponent <Animator>();
     m_ActorBaseComponent = GetComponent <ActorBaseComponent>();
     m_AnimationLookup    = new Dictionary <int, Nima.Animation.ActorAnimation>();
     if (m_ActorBaseComponent != null)
     {
         m_Actor = m_ActorBaseComponent.ActorInstance;
     }
 }
Ejemplo n.º 5
0
 public void Start()
 {
     m_Actor = gameObject.GetComponent <Nima.Unity.ActorBaseComponent>();
     if (m_Actor != null)
     {
         if (m_Actor.ActorInstance != null)
         {
             outro = m_Actor.ActorInstance.GetAnimation("outro");
         }
     }
 }
Ejemplo n.º 6
0
 public void Start()
 {
     m_Actor = gameObject.GetComponent <Nima.Unity.ActorBaseComponent>();
     if (m_Actor != null)
     {
         if (m_Actor.ActorInstance != null)
         {
             start = m_Actor.ActorInstance.GetAnimation("start");
             title = m_Actor.ActorInstance.GetAnimation("title");
         }
     }
     FireStorySystem.storyReset = false;
     FireStorySystem.steamReset = false;
 }
Ejemplo n.º 7
0
        public void Start()
        {
            ActorBaseComponent actor = gameObject.GetComponent <ActorBaseComponent>();

            if (actor != null)
            {
                m_ActorInstance = actor.ActorInstance;
                if (m_ActorInstance != null)
                {
                    m_Animation = m_ActorInstance.GetAnimation(m_AnimationName);
                }
            }
            m_AnimationTime = m_Offset * m_Animation.Duration;
        }
Ejemplo n.º 8
0
        public virtual void Initialize(ActorBaseComponent actorComponent)
        {
            m_ActorComponent = actorComponent;

            ActorNodeComponent parentComponent = actorComponent.Nodes[m_ActorNode.ParentIdx];

            if (parentComponent == this)
            {
                // This is the root.
                // If the parent is self, we've reached root.
                gameObject.transform.parent = actorComponent.gameObject.transform;
            }
            else
            {
                gameObject.transform.parent = parentComponent.gameObject.transform;
            }
            UpdateTransform();
        }
Ejemplo n.º 9
0
 public void Start()
 {
     if (m_ActorGameObject != null)
     {
         m_ActorBase = m_ActorGameObject.GetComponent <ActorBaseComponent>();
         if (m_ActorBase != null)
         {
             m_MountNode = m_ActorBase.GetActorNode(m_NodeName);
             if (m_MountNode != null)
             {
                 m_ActorBase.AddFinalFormDependent(this);
             }
             //if(go != null)
             //{
             //gameObject.transform.SetParent(go.transform, false);
             //}
         }
     }
 }
Ejemplo n.º 10
0
        public virtual void Initialize(ActorBaseComponent actorComponent)
        {
            m_ActorComponent            = actorComponent;
            gameObject.transform.parent = actorComponent.gameObject.transform;

            /*
             * ActorNodeComponent parentComponent = actorComponent.Nodes[m_ActorNode.ParentIdx];
             * if(parentComponent == this)
             * {
             *      // This is the root.
             *      // If the parent is self, we've reached root.
             *      gameObject.transform.parent = actorComponent.gameObject.transform;
             * }
             * else
             * {
             *      gameObject.transform.parent = parentComponent.gameObject.transform;
             * }
             * //UpdateTransform();
             */
        }
Ejemplo n.º 11
0
        public override void Initialize(ActorBaseComponent actorComponent)
        {
            base.Initialize(actorComponent);
            m_ActorCollider = m_ActorNode as ActorCollider;

            if (m_ActorCollider is ActorColliderCircle)
            {
                gameObject.AddComponent(typeof(CircleCollider2D));
                CircleCollider2D circleCollider = gameObject.GetComponent <CircleCollider2D>();

                ActorColliderCircle actorCircleCollider = m_ActorCollider as ActorColliderCircle;
                circleCollider.radius = actorCircleCollider.Radius;

                m_Collider = circleCollider;
            }
            else if (m_ActorCollider is ActorColliderRectangle)
            {
                gameObject.AddComponent(typeof(BoxCollider2D));
                BoxCollider2D boxCollider = gameObject.GetComponent <BoxCollider2D>();

                ActorColliderRectangle actorRectangleCollider = m_ActorCollider as ActorColliderRectangle;
                boxCollider.size = new Vector2(actorRectangleCollider.Width, actorRectangleCollider.Height);

                m_Collider = boxCollider;
            }
            else if (m_ActorCollider is ActorColliderPolygon)
            {
                gameObject.AddComponent(typeof(PolygonCollider2D));
                PolygonCollider2D polygonCollider = gameObject.GetComponent <PolygonCollider2D>();

                ActorColliderPolygon actorPolygonCollider = m_ActorCollider as ActorColliderPolygon;
                polygonCollider.pathCount = 1;
                float[]   contourBuffer = actorPolygonCollider.ContourVertices;
                Vector2[] points        = new Vector2[contourBuffer.Length / 2];
                int       readIdx       = 0;
                for (int i = 0; i < points.Length; i++)
                {
                    points[i] = new Vector2(contourBuffer[readIdx], contourBuffer[readIdx + 1]);
                    readIdx  += 2;
                }
                polygonCollider.SetPath(0, points);

                m_Collider = polygonCollider;
            }
            else if (m_ActorCollider is ActorColliderTriangle)
            {
                gameObject.AddComponent(typeof(PolygonCollider2D));
                PolygonCollider2D polygonCollider = gameObject.GetComponent <PolygonCollider2D>();

                ActorColliderTriangle actorTriangleCollider = m_ActorCollider as ActorColliderTriangle;
                polygonCollider.pathCount = 1;

                float     hwidth  = actorTriangleCollider.Width / 2.0f;
                float     hheight = actorTriangleCollider.Height / 2.0f;
                Vector2[] points  = new Vector2[3];
                points[0] = new Vector2(-hwidth, -hheight);
                points[1] = new Vector2(0.0f, hheight);
                points[2] = new Vector2(hwidth, -hheight);
                polygonCollider.SetPath(0, points);

                m_Collider = polygonCollider;
            }
        }
Ejemplo n.º 12
0
        public void Start()
        {
            m_Actor = gameObject.GetComponent <ActorBaseComponent>();
            if (m_Actor != null)
            {
                // Get a game object from the actor, use this to mount items or query for other components.
                // GameObject headColliderGameObject = m_Actor.GetActorGameObject("HeadCollider");
                // if(headColliderGameObject != null)
                // {
                //  Collider2D collider = headColliderGameObject.GetComponent<Collider2D>();
                //  if(collider != null)
                //  {
                //      // Set it to a trigger, or do something else with it...
                //      // collider.isTrigger = true;
                //  }
                // }
                if (m_Actor.ActorInstance != null)
                {
                    m_Idle       = m_Actor.ActorInstance.GetAnimation("Idle");
                    m_Aim        = m_Actor.ActorInstance.GetAnimation("Aim2");
                    m_Walk       = m_Actor.ActorInstance.GetAnimationInstance("Walk");
                    m_Run        = m_Actor.ActorInstance.GetAnimation("Run");
                    m_WalkToIdle = m_Actor.ActorInstance.GetAnimation("WalkToIdle");

                    // We made walk an animation instance so it has it's own sense of time which lets it do things like track events.
                    m_Walk.AnimationEvent += delegate(object animationInstance, Nima.Animation.AnimationEventArgs args)
                    {
                        // Event triggered from animation.
                    };
                    ActorNode characterNode = m_Actor.ActorInstance.GetNode("Character");
                    if (characterNode != null)
                    {
                        m_GroundSpeedProperty = characterNode.GetCustomFloatProperty("GroundSpeed");
                        m_IsRunningProperty   = characterNode.GetCustomBooleanProperty("IsRunning");
                    }
                    // Calculate aim slices.
                    if (m_Aim != null)
                    {
                        ActorNode muzzle = m_Actor.ActorInstance.GetNode("Muzzle");
                        if (muzzle != null)
                        {
                            for (int i = 0; i < AimSliceCount; i++)
                            {
                                float position = i / (float)(AimSliceCount - 1) * m_Aim.Duration;
                                m_Aim.Apply(position, m_Actor.ActorInstance, 1.0f);
                                m_Actor.ActorInstance.Advance(0.0f);
                                Mat2D worldTransform = muzzle.WorldTransform;

                                AimSlice slice = m_AimLookup[i];

                                // Extract forward vector and position.
                                slice.dir = new Vec2D();
                                Vec2D.Normalize(slice.dir, new Vec2D(worldTransform[0], worldTransform[1]));
                                slice.point    = new Vec2D(worldTransform[4] * ActorAsset.NimaToUnityScale, worldTransform[5] * ActorAsset.NimaToUnityScale);
                                m_AimLookup[i] = slice;
                            }
                        }
                        if (m_Walk != null)
                        {
                            m_Walk.Time = 0.0f;
                            m_Walk.Apply(1.0f);

                            for (int i = 0; i < AimSliceCount; i++)
                            {
                                float position = i / (float)(AimSliceCount - 1) * m_Aim.Duration;
                                m_Aim.Apply(position, m_Actor.ActorInstance, 1.0f);
                                m_Actor.ActorInstance.Advance(0.0f);
                                Mat2D worldTransform = muzzle.WorldTransform;

                                AimSlice slice = m_AimWalkingLookup[i];

                                // Extract forward vector and position.
                                slice.dir = new Vec2D();
                                Vec2D.Normalize(slice.dir, new Vec2D(worldTransform[0], worldTransform[1]));
                                slice.point           = new Vec2D(worldTransform[4] * ActorAsset.NimaToUnityScale, worldTransform[5] * ActorAsset.NimaToUnityScale);
                                m_AimWalkingLookup[i] = slice;
                            }
                        }
                    }
                }
            }
            m_IdleTime = 0.0f;
        }
Ejemplo n.º 13
0
        public static void ReloadMecanimController(ActorBaseComponent actorComponent, UnityEditor.Animations.AnimatorController animatorController)
        {
            Nima.Actor actor = actorComponent.Asset.Actor;

            string path = AssetDatabase.GetAssetPath(animatorController);

            UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(path);

            List <Nima.Animation.ActorAnimation> alreadyUsedAnimations = new List <Nima.Animation.ActorAnimation>();

            foreach (UnityEngine.Object asset in assets)
            {
                AnimationClip clip = asset as AnimationClip;
                if (clip == null)
                {
                    continue;
                }

                bool exists = false;
                foreach (Nima.Animation.ActorAnimation actorAnimation in actor.Animations)
                {
                    if (actorAnimation.Name == clip.name)
                    {
                        exists = true;
                        alreadyUsedAnimations.Add(actorAnimation);
                        clip.SetCurve("", typeof(GameObject), "null", AnimationCurve.Linear(0, 0, actorAnimation.Duration, 0));
                        AnimationClipSettings clipSettings = AnimationUtility.GetAnimationClipSettings(clip);
                        clipSettings.stopTime = actorAnimation.Duration;
                        clipSettings.loopTime = actorAnimation.IsLooping;
                        AnimationUtility.SetAnimationClipSettings(clip, clipSettings);

                        EditorUtility.SetDirty(clip);
                        break;
                    }
                }
                if (!exists)
                {
                    AnimationClip.DestroyImmediate(clip, true);
                }
            }

            foreach (Nima.Animation.ActorAnimation actorAnimation in actor.Animations)
            {
                int idx = alreadyUsedAnimations.IndexOf(actorAnimation);
                if (idx == -1)
                {
                    AnimationClip animationClip = new AnimationClip();
                    animationClip.name = actorAnimation.Name;
                    animationClip.SetCurve("", typeof(GameObject), "null", AnimationCurve.Linear(0, 0, actorAnimation.Duration, 0));
                    AnimationClipSettings clipSettings = AnimationUtility.GetAnimationClipSettings(animationClip);
                    clipSettings.stopTime = actorAnimation.Duration;
                    clipSettings.loopTime = actorAnimation.IsLooping;
                    AnimationUtility.SetAnimationClipSettings(animationClip, clipSettings);

                    AssetDatabase.AddObjectToAsset(animationClip, animatorController);

                    EditorUtility.SetDirty(animationClip);
                }
            }

            EditorUtility.SetDirty(animatorController);
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();
        }
Ejemplo n.º 14
0
 public void OnFinalForm(ActorBaseComponent actorBase)
 {
     UpdateMount();
 }
Ejemplo n.º 15
0
        void Start()
        {
            m_Animator = GetComponent <Animator>();
            m_Actor    = gameObject.GetComponent <ActorBaseComponent>();
            if (m_Actor != null)
            {
                if (m_Actor.ActorInstance != null)
                {
                    m_Aim = m_Actor.ActorInstance.GetAnimation("Aim2");
                    Nima.Animation.ActorAnimation walk       = m_Actor.ActorInstance.GetAnimation("Walk");
                    Nima.Animation.ActorAnimation walkToIdle = m_Actor.ActorInstance.GetAnimation("WalkToIdle");


                    // Calculate aim slices.
                    if (m_Aim != null)
                    {
                        ActorNode muzzle = m_Actor.ActorInstance.GetNode("Muzzle");
                        if (muzzle != null)
                        {
                            for (int i = 0; i < AimSliceCount; i++)
                            {
                                float position = i / (float)(AimSliceCount - 1) * m_Aim.Duration;
                                m_Aim.Apply(position, m_Actor.ActorInstance, 1.0f);
                                Mat2D worldTransform = muzzle.WorldTransform;

                                AimSlice slice = m_AimLookup[i];

                                // Extract forward vector and position.
                                slice.dir = new Vec2D();
                                Vec2D.Normalize(slice.dir, new Vec2D(worldTransform[0], worldTransform[1]));
                                slice.point    = new Vec2D(worldTransform[4], worldTransform[5]);
                                m_AimLookup[i] = slice;
                            }
                        }
                        if (walk != null)
                        {
                            walk.Apply(0.0f, m_Actor.ActorInstance, 1.0f);

                            for (int i = 0; i < AimSliceCount; i++)
                            {
                                float position = i / (float)(AimSliceCount - 1) * m_Aim.Duration;
                                m_Aim.Apply(position, m_Actor.ActorInstance, 1.0f);
                                Mat2D worldTransform = muzzle.WorldTransform;

                                AimSlice slice = m_AimWalkingLookup[i];

                                // Extract forward vector and position.
                                slice.dir = new Vec2D();
                                Vec2D.Normalize(slice.dir, new Vec2D(worldTransform[0], worldTransform[1]));
                                slice.point           = new Vec2D(worldTransform[4], worldTransform[5]);
                                m_AimWalkingLookup[i] = slice;
                            }
                        }

                        if (walkToIdle != null)
                        {
                            walkToIdle.Apply(walkToIdle.Duration, m_Actor.ActorInstance, 1.0f);
                        }
                    }
                }
            }
        }