예제 #1
0
 // Use this for initialization
 void Start()
 {
     instance = this;
     EquipacionManager.instance.PintarEquipacionesIngame(true, Goalkeeper.instance.gameObject);
     m_bip01 = transform.Find("Bip01");
     m_ball  = m_bip01.Find("Balon");
     m_animationDescriptorsResource = Resources.Load("AnimationDescriptorsResource") as AnimationDescriptorsResource;
     ServiceLocator.Request <IDefenseService>().RegisterListener(CalcDefenseResult);
     ServiceLocator.Request <IShotResultService>().RegisterListener(Celebrate);
 }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        ServiceLocator.Request <IShotResultService>().RegisterListener(resultAnimations);
        m_bip01 = transform.Find("Bip01");
        m_ball  = m_bip01.Find("Balon");
        m_feet  = m_bip01.Find("Bip01 Footsteps");

        if (m_animationDescriptorsResource == null)
        {
            m_animationDescriptorsResource = Resources.Load("AnimationDescriptorsResource") as AnimationDescriptorsResource;
        }
    }
예제 #3
0
    public AnimationDescriptors(Animation _animation, Animation _source)
    {
        AnimationDescriptorsResource adr = Resources.Load("AnimationDescriptorsResource", typeof(AnimationDescriptorsResource)) as AnimationDescriptorsResource;

        if (adr != null)
        {
            m_animations = new AnimationDescriptor[adr.m_descriptors.Length];
            _source      = (GameObject.Instantiate(_source.gameObject) as GameObject).GetComponent <Animation>();
            for (int i = 0; i < adr.m_descriptors.Length; ++i)
            {
                AnimationClip clip = _source.GetClip(adr.m_descriptors[i].m_name);
                if (clip == null)
                {
                    Debug.LogError("No se encuentra la animacion " + adr.m_descriptors[i].m_name + " " + _source.GetClipCount());
                }
                else
                {
                    _animation.AddClip(clip, adr.m_descriptors[i].m_name);
                    m_animations[i] = new AnimationDescriptor(_animation[adr.m_descriptors[i].m_name], adr.m_descriptors[i].m_velocity);
                }
            }
            GameObject.Destroy(_source.gameObject);
        }
    }
예제 #4
0
    void OnPostprocessModel(GameObject go)
    {
        if (assetPath.Contains("Animaciones") && go.GetComponent <Animation>() != null)
        {
            if (m_adr == null)
            {
                m_adr = AssetDatabase.LoadAssetAtPath("Assets/Resources/AnimationDescriptorsResource.asset", typeof(AnimationDescriptorsResource)) as AnimationDescriptorsResource;
            }
            if (m_adr == null)
            {
                m_adr = ScriptableObject.CreateInstance <AnimationDescriptorsResource>();
                AssetDatabase.CreateAsset(m_adr, "Assets/Resources/AnimationDescriptorsResource.asset");
            }

            EditorUtility.SetDirty(m_adr);

            AnimationClip[] clips = AnimationUtility.GetAnimationClips(go);
            if (clips.Length != 0)
            {
                m_grabEventTime /= clips[0].frameRate;
                m_grabEventDiff  = Vector3.zero;
                foreach (AnimationClip clip in clips)
                {
                    AnimationState anmsts = go.GetComponent <Animation>()[clip.name];
                    anmsts.enabled = true;
                    anmsts.time    = m_grabEventTime;
                    go.GetComponent <Animation>().Sample();

                    Transform balon = go.transform.Find("Bip01/Balon");
                    if (balon != null)
                    {
                        m_grabEventDiff = balon.position;
                    }
                    else
                    {
                        m_grabEventDiff = Vector3.zero;
                    }


                    AnimationClipCurveData[] curves = AnimationUtility.GetAllCurves(clip, true);
                    clip.ClearCurves();
                    clip.name = go.name.Substring(4);
                    Vector3 vel = Vector3.zero;
                    foreach (AnimationClipCurveData data in curves)
                    {
                        Keyframe[] keys = data.curve.keys;
                        if (data.path == "Bip01")
                        {
                            if (data.propertyName.Contains("m_LocalPosition.x"))
                            {
                                vel.x = keys[keys.Length - 1].value - keys[0].value;
                            }
                            if (data.propertyName.Contains("m_LocalPosition.z"))
                            {
                                vel.z = keys[keys.Length - 1].value - keys[0].value;
                            }


                            if (vel.magnitude > 0.1f)
                            {
                                // Recorre las keys y las pone a cero.
                                for (int i = 0; i < keys.Length; ++i)
                                {
                                    //                if (data.propertyName.Contains("m_LocalPosition.x")) keys[i].value = 0.0f;
                                    //                if (data.propertyName.Contains("m_LocalPosition.z")) keys[i].value = 0.0f;
                                }
                            }
                        }
                        AnimationCurve curve = new AnimationCurve(keys);
                        clip.SetCurve(data.path, data.type, data.propertyName, curve);
                    }
                    m_adr.Add(clip.name, vel / clip.length, m_grabEventTime, m_grabEventDiff);

                    if (m_events.Count != 0)
                    {
                        for (int i = 0; i < m_events.Count; ++i)
                        {
                            m_events[i].time /= clips[0].frameRate;
                        }
                        AnimationUtility.SetAnimationEvents(clips[0], m_events.ToArray());
                        AnimationUtility.SetAnimationClips(go.GetComponent <Animation>(), clips);
                        m_events.Clear();
                    }
                }
            }
        }
    }