Пример #1
0
        internal override void OnTrigger()
        {
            base.OnTrigger();

            Vector3 ori;

            if (this.EntityAct.TargetList.Count != 0 && this.EntityAct.TargetList[0] != null)
            {
                Entity target = this.EntityAct.TargetList[0];
                ori = target.Position - this.Entity.Position;
            }
            else if (this.EntityAct.TargetPos != Vector3.zero)
            {
                ori = this.EntityAct.TargetPos - this.Entity.Position;
            }
            else
            {
                return;
            }

            ori.y = 0;
            if (ori.magnitude <= 0.01)
            {
                return;
            }

            GOEActorEntity actorEntity = this.Entity as GOEActorEntity;

            if (actorEntity != null && actorEntity.RotateSmooth)
            {
                actorEntity.StartSmoothRotation(Quaternion.LookRotation(ori.normalized), TotalTime);
                return;
            }
            this.Entity.Orientation = ori.normalized;
        }
Пример #2
0
        protected override void onLoadPost()
        {
            _animator = GameObject.GetComponent <Animator>();
            animation = GameObject.GetComponent <Animation>();
            if (AutoPlaySubAnimation)
            {
                Transform[] trans = GameObject.GetComponentsInChildren <Transform>();
                foreach (Transform tran in trans)
                {
                    if (tran.gameObject == GameObject)
                    {
                        continue;
                    }
                    if (tran.gameObject.GetComponent <Animation>() != null && tran.gameObject.GetComponent <Animation>().GetClipCount() > 1)
                    {
                        GOEActorEntity part = this.AddActorAttach(tran.gameObject.name, tran.parent) as GOEActorEntity;
                        part.IsVirtual  = true;
                        part.Rotation   = tran.localRotation;
                        part.GameObject = tran.gameObject;
                    }
                }
            }
            string sname = GetAniName(_standAni);

            if (animation != null && animation[sname] != null && !animation[sname].enabled)
            {
                CrossFade(_standAni);
            }
            base.onLoadPost();
        }
Пример #3
0
        public void getNearestPoint(Vector3 end, out Vector3 pos, IDetourSender actor)
        {
            GOEActorEntity Actor = actor as GOEActorEntity;

            if (dirs.Count == 0)
            {
                for (int i = 0; i < 24; i++)
                {
                    double  an  = Math.PI * 15 * i / 180;
                    Vector3 dir = Vector3.zero;
                    dir.x = (float)Math.Cos(an) * 5;
                    dir.z = (float)Math.Sin(an) * 5;
                    dirs.Add(dir);
                }
            }
            pos = Vector3.zero;

            for (int i = 0; i < 24; i++)
            {
                Vector3 dir = dirs[i];
                //Vector3 start = new Vector3(end.x - dir.x, end.y, end.z - dir.z);
                Vector3 tem;
                GetRaycast(Actor, end - dir, end, out tem);
                if (Vector3.Distance(end, tem) < Vector3.Distance(pos, end))
                {
                    pos = tem;
                }
                if (Vector3.Distance(end, tem) <= 2)
                {
                    break;
                }
            }
        }
Пример #4
0
        internal override void OnTrigger()
        {
            base.OnTrigger();
            GOEActorEntity act  = this.Entity as GOEActorEntity;
            bool           has1 = !string.IsNullOrEmpty(Animation1);
            bool           has2 = !string.IsNullOrEmpty(Animation2);
            bool           has3 = !string.IsNullOrEmpty(Animation3);

            if (EntityAct.ActSpeed != 1)
            {
                act.AnimationSpeed = EntityAct.ActSpeed;
            }
            if (has1)
            {
                //只与部分动作融合(跑步)
                if (IsAnimationBlend && act.CheckBlendAnim())
                {
                    if (act.PlayBlend(Animation1, BlendWeight, act.BlendPoint))
                    {
                        bBlend = true;
                    }
                }
                else
                {
                    act.Stop();
                    if (!has2)
                    {
                        act.CrossFade(Animation1, crossfadeTime, PlayMode.StopSameLayer, !DoNotReturnToStand);
                    }
                    else
                    {
                        act.CrossFade(Animation1, crossfadeTime, PlayMode.StopSameLayer, false);
                    }
                }
            }
            if (has2)
            {
                if (!has3)
                {
                    act.PlayQueued(Animation2, QueueMode.CompleteOthers, PlayMode.StopSameLayer, !DoNotReturnToStand);
                }
                else
                {
                    act.PlayQueued(Animation2);
                }
            }
            if (has3)
            {
                act.PlayQueued(Animation3, QueueMode.CompleteOthers, PlayMode.StopSameLayer, !DoNotReturnToStand);
            }
            if (IsNextAnimationNoCrossfade)
            {
                act.NextAnimationNoCrossfade = true;
            }
            this.Enable = false;
        }
Пример #5
0
        internal override void OnDestroy()
        {
            base.OnDestroy();
            GOEActorEntity act = this.Entity as GOEActorEntity;

            if (bBlend)
            {
                act.ClearBlend(Animation1, act.BlendPoint);
            }
            if (EntityAct.ActSpeed != 1)
            {
                act.AnimationSpeed = 1;
            }
        }
Пример #6
0
        public bool CrossFade(string name, float fadeLength = 0.3F, PlayMode mode = PlayMode.StopSameLayer, bool backToStand = true)
        {
            if (nextAnimNoCrossFade)
            {
                nextAnimNoCrossFade = false;
                PlayAnimation(name, mode, backToStand);
                return(true);
            }
            if (this.GameObject == null || animation == null || string.IsNullOrEmpty(name))
            {
                return(false);
            }
            name = GetAniName(name);
            AnimationClip animClip = animation.GetClip(name);

            if (animClip == null)
            {
                _waitAni = name;
                string animName = name + ANIM_SUFFIX;
                GOERoot.ResMgrImp.GetAsset(animName, (string cbName, UnityEngine.Object cbObject) =>
                {
                    OnLoadAnim(name, cbObject);
                    if (_waitAni == name)
                    {
                        _CrossFade(name, fadeLength, mode, backToStand);
                    }
                });
            }
            else
            {
                _CrossFade(name, fadeLength, mode, backToStand);
            }

            foreach (Entity ent in mAttaches)
            {
                if (ent is GOEActorEntity)
                {
                    GOEActorEntity ae = ent as GOEActorEntity;
                    if (!ae.IsVirtual)
                    {
                        continue;
                    }
                    ae.CrossFade(name, fadeLength, mode, backToStand);
                }
            }
            return(true);
        }
Пример #7
0
        public void PlayAnimation(string name, PlayMode mode = PlayMode.StopSameLayer, bool backToStand = false, float time = 0f)
        {
            if (this.GameObject == null || animation == null || string.IsNullOrEmpty(name))
            {
                return;
            }
            name = GetAniName(name);
            if (this.ResStatus != ResStatus.OK)
            {
                return;
            }
            AnimationClip animClip = animation.GetClip(name);

            if (animClip == null)
            {
                _waitAni = name;
                string animName = name + ANIM_SUFFIX;
                GOERoot.ResMgrImp.GetAsset(animName, (string cbName, UnityEngine.Object cbObject) =>
                {
                    OnLoadAnim(name, cbObject);
                    if (_waitAni == name)
                    {
                        _PlayAnimation(name, mode, backToStand, time);
                    }
                });
            }
            else
            {
                _PlayAnimation(name, mode, backToStand, time);
            }
            foreach (Entity ent in mAttaches)
            {
                if (ent is GOEActorEntity)
                {
                    GOEActorEntity ae = ent as GOEActorEntity;
                    if (!ae.IsVirtual)
                    {
                        continue;
                    }
                    ae.PlayAnimation(name, mode, backToStand, time);
                }
            }
        }
Пример #8
0
        public void CrossFadeQueued(string name, float fadeLength = 0.3F, UnityEngine.QueueMode queue = QueueMode.CompleteOthers, UnityEngine.PlayMode mode = PlayMode.StopSameLayer, bool backToStand = false)
        {
            if (this.GameObject == null || animation == null || string.IsNullOrEmpty(name))
            {
                return;
            }
            name = GetAniName(name);
            if (nextAnimNoCrossFade)
            {
                nextAnimNoCrossFade = false;
                PlayQueued(name, queue, mode, backToStand);
                return;
            }
            foreach (Entity ent in mAttaches)
            {
                if (ent is GOEActorEntity)
                {
                    GOEActorEntity ae = ent as GOEActorEntity;
                    if (!ae.IsVirtual)
                    {
                        continue;
                    }
                    ae.CrossFadeQueued(name, fadeLength, queue, mode);
                }
            }
            AnimationClip animClip = animation.GetClip(name);

            if (animClip == null)
            {
                string animName = name + ANIM_SUFFIX;
                GOERoot.ResMgrImp.GetAsset(animName, (string cbName, UnityEngine.Object cbObject) =>
                {
                    OnLoadAnim(name, cbObject);
                });
                return;
                //Debug.LogError("CrossFadeQueued must make sure that the animation clip is on the character, animation is -> " + name);
            }

            animation.CrossFadeQueued(name, fadeLength, queue, mode);
            setAniSpeed(name);
            appendStand(backToStand);
        }