Exemplo n.º 1
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");
         }
     }
 }
Exemplo n.º 2
0
 private void loopPlayAnim(Nima.Animation.ActorAnimation anim, ref float time, float speed = 1f)
 {
     if (anim == null)
     {
         return;
     }
     time = (time + Time.deltaTime * speed) % anim.Duration;
     anim.Apply(time, m_Actor.ActorInstance, 1.0f);
 }
Exemplo n.º 3
0
 public ActorAnimationInstance(Actor actor, ActorAnimation animation)
 {
     m_Actor     = actor;
     m_Animation = animation;
     m_Time      = 0.0f;
     m_Min       = 0.0f;
     m_Max       = animation.Duration;
     m_Range     = m_Max - m_Min;
     m_Loop      = animation.IsLooping;
 }
Exemplo n.º 4
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");
         }
     }
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
 private bool playUntilEndAnim(Nima.Animation.ActorAnimation anim, ref float time, float speed = 1f)
 {
     if (anim == null)
     {
         return(false);
     }
     time = (time + Time.deltaTime * speed);
     if (time >= anim.Duration)
     {
         time = anim.Duration;
         return(true);
     }
     if (time <= 0)
     {
         time = 0;
     }
     anim.Apply(time, m_Actor.ActorInstance, 1.0f);
     return(false);
 }
Exemplo n.º 7
0
    public void Start()
    {
        m_Actor = gameObject.GetComponent <Nima.Unity.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.
                };
                Nima.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)
                {
                    Nima.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);
                            Nima.Math2D.Mat2D worldTransform = muzzle.WorldTransform;

                            AimSlice slice = m_AimLookup[i];

                            // Extract forward vector and position.
                            slice.dir = new Nima.Math2D.Vec2D();
                            Nima.Math2D.Vec2D.Normalize(slice.dir, new Nima.Math2D.Vec2D(worldTransform[0], worldTransform[1]));
                            slice.point = new Nima.Math2D.Vec2D(worldTransform[4] * Nima.Unity.ActorAsset.NimaToUnityScale,
                                                                worldTransform[5] * Nima.Unity.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);
                            Nima.Math2D.Mat2D worldTransform = muzzle.WorldTransform;

                            AimSlice slice = m_AimWalkingLookup[i];

                            // Extract forward vector and position.
                            slice.dir = new Nima.Math2D.Vec2D();
                            Nima.Math2D.Vec2D.Normalize(slice.dir, new Nima.Math2D.Vec2D(worldTransform[0], worldTransform[1]));
                            slice.point = new Nima.Math2D.Vec2D(worldTransform[4] * Nima.Unity.ActorAsset.NimaToUnityScale,
                                                                worldTransform[5] * Nima.Unity.ActorAsset.NimaToUnityScale);
                            m_AimWalkingLookup[i] = slice;
                        }
                    }
                }
            }
        }
        m_IdleTime = 0.0f;
    }
Exemplo n.º 8
0
        public static ActorAnimation Read(BlockReader reader, ActorComponent[] components)
        {
            ActorAnimation animation = new ActorAnimation();

            animation.m_Name      = Actor.ReadString(reader);
            animation.m_FPS       = (int)reader.ReadByte();
            animation.m_Duration  = reader.ReadSingle();
            animation.m_IsLooping = reader.ReadByte() != 0;

            int numKeyedComponents = reader.ReadUInt16();
            //animation.m_Components = new ComponentAnimation[numKeyedComponents];

            // We distinguish between animated and triggered components as ActorEvents are currently only used to trigger events and don't need
            // the full animation cycle. This lets them optimize them out of the regular animation cycle.
            int animatedComponentCount = 0;
            int triggerComponentCount  = 0;

            ComponentAnimation[] animatedComponents = new ComponentAnimation[numKeyedComponents];
            for (int i = 0; i < numKeyedComponents; i++)
            {
                ComponentAnimation componentAnimation = ComponentAnimation.Read(reader, components);
                animatedComponents[i] = componentAnimation;
                if (componentAnimation != null)
                {
                    ActorComponent actorComponent = components[componentAnimation.ComponentIndex];
                    if (actorComponent != null)
                    {
                        if (actorComponent is ActorEvent)
                        {
                            triggerComponentCount++;
                        }
                        else
                        {
                            animatedComponentCount++;
                        }
                    }
                }
            }

            animation.m_Components        = new ComponentAnimation[animatedComponentCount];
            animation.m_TriggerComponents = new ComponentAnimation[triggerComponentCount];

            // Put them in their respective lists.
            int animatedComponentIndex = 0;
            int triggerComponentIndex  = 0;

            for (int i = 0; i < numKeyedComponents; i++)
            {
                ComponentAnimation componentAnimation = animatedComponents[i];
                if (componentAnimation != null)
                {
                    ActorComponent actorComponent = components[componentAnimation.ComponentIndex];
                    if (actorComponent != null)
                    {
                        if (actorComponent is ActorEvent)
                        {
                            animation.m_TriggerComponents[triggerComponentIndex++] = componentAnimation;
                        }
                        else
                        {
                            animation.m_Components[animatedComponentIndex++] = componentAnimation;
                        }
                    }
                }
            }

            return(animation);
        }