Ejemplo n.º 1
0
        public Vector3 ToWorldPos(Transform ccroot)
        {
            Vector3   finalPos;
            Transform relTr = null;

            if (m_RelTr != null)
            {
                relTr = m_RelTr.GetTransform(ccroot);
            }

            if (relTr != null)
            {
                if (m_Space == Space.Self)
                {
                    finalPos = relTr.TransformPoint(m_RelPos);
                }
                else
                {
                    finalPos = relTr.position + m_RelPos;
                }
            }
            else
            {
                finalPos = m_RelPos;
            }

            return(finalPos);
        }
Ejemplo n.º 2
0
        // data

        //private bool m_bEventReached = false;

        #endregion "data"

        #region "unity event handlers"
        // unity event handlers

        #endregion "unity event handlers"

        #region "public method"
        // public method

        public override void OnAnimEvent()
        {
            //m_bEventReached = true;

            Transform cctr = m_CC.transform;

            if (!m_Target.Valid)
            {
                Dbg.LogWarn("CC_SetTransform.OnAnimEvent: Target not specified");
                return;
            }

            Transform targetTr = m_Target.GetTransform(cctr);

            if (m_NewParent.Valid)
            {
                Transform newPrTr = m_NewParent.GetTransform(cctr);
                targetTr.parent = newPrTr;
            }

            if (m_Pos.Valid)
            {
                targetTr.position = m_Pos.ToWorldPos(cctr);
            }
            if (m_Rot.Valid)
            {
                targetTr.rotation = m_Rot.ToWorldRotation(cctr);
            }
            if (m_Scale.Valid)
            {
                targetTr.localScale = m_Scale.ToLocalScale(cctr);
            }
        }
Ejemplo n.º 3
0
        // public method

        public override void OnAnimEvent()
        {
            Transform tr = m_TargetGO.GetTransform(m_CC.transform);

            if (tr == null)
            {
                Dbg.LogWarn("CC_SendMsg.OnAnimEvent: failed to find GO on path: {0}: {1}", m_TargetGO.m_trPath, name);
                return;
            }

            tr.SendMessage(m_Function, m_Param, m_Param.m_RequireReceiver);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// static version
        /// get the position of the transform specified by trPath
        /// </summary>
        public static Vector3 ToWorldPos(Transform ccroot, CCTrPath targetTrPath)
        {
            Transform relTr = null;

            if (targetTrPath != null)
            {
                relTr = targetTrPath.GetTransform(ccroot);
            }

            if (relTr != null)
            {
                return(relTr.position);
            }
            else
            {
                return(Vector3.zero);
            }
        }
Ejemplo n.º 5
0
        public CCTrPath m_Parent; //if not specified, new object will be added under CC_Spawn.transform

        public GameObject Spawn(Transform ccroot)
        {
            if (!m_SrcObj.Valid)
            {
                Dbg.LogWarn("CCSpawnData.Spawn: didn't specify SrcObj!");
                return(null);
            }

            Object o = m_SrcObj.GetObj();

            if (o == null)
            {
                Dbg.LogWarn("CCSpawnData.Spawn: m_SrcObj.GetObj returned null");
                return(null);
            }

            GameObject newObj = Object.Instantiate(o) as GameObject;
            Transform  tr     = newObj.transform;

            Dbg.Assert(m_Pos != null, "CCSpawnData.Spawn: m_Pos is null");

            tr.position = m_Pos.ToWorldPos(ccroot);

            if (m_Rot.Valid)
            {
                tr.rotation = m_Rot.ToWorldRotation(ccroot);
            }

            if (m_Scale.Valid)
            {
                tr.localScale = m_Scale.ToLocalScale(ccroot);
            }

            if (m_Parent.Valid)
            {
                Transform newParent = m_Parent.GetTransform(ccroot);
                tr.parent = newParent;
            }

            return(newObj);
        }
Ejemplo n.º 6
0
        public Vector3 ToLocalScale(Transform ccroot)
        {
            Vector3   finalScale;
            Transform relTr = null;

            if (m_TrPath.Valid)
            {
                relTr = m_TrPath.GetTransform(ccroot);
            }

            if (relTr != null)
            {
                finalScale = Vector3.Scale(relTr.lossyScale, m_RelScale);
            }
            else
            {
                finalScale = m_RelScale;
            }

            return(finalScale);
        }
Ejemplo n.º 7
0
        public Vector3 ToWorldDir(Transform ccroot)
        {
            Vector3   finalDir;
            Transform relTr = null;

            if (m_TrPath != null)
            {
                relTr = m_TrPath.GetTransform(ccroot);
            }

            if (relTr != null)
            {
                finalDir = relTr.TransformDirection(m_RelDirection);
            }
            else
            {
                finalDir = m_RelDirection;
            }

            return(finalDir);
        }
Ejemplo n.º 8
0
        // public method
        public override void OnAnimEvent()
        {
            Transform   audioTr  = m_AudioSourcePath.GetTransform(m_CC.transform);
            AudioSource audioSrc = audioTr.GetComponent <AudioSource>();

            if (audioSrc == null)
            {
                Dbg.LogWarn("CC_Sound.OnAnimEvent: no AudioSource found on path {0}, do nothing...: {1}", m_AudioSourcePath.m_trPath, name);
                return;
            }

            switch (m_ExecAction)
            {
            case Action.Start:
            {
                if (m_Clip != null)
                {
                    //Dbg.Log("Sound Played: {0}", m_Clip);
                    audioSrc.clip = m_Clip;
                    audioSrc.Play();
                }
                else
                {
                    audioSrc.Play();
                }
            }
            break;

            case Action.Stop:
            {
                audioSrc.Stop();
            }
            break;

            default:
                Dbg.LogErr("CC_Sound.OnAnimEvent: unexpected exec action: {0}", m_ExecAction);
                break;
            }
        }