Ejemplo n.º 1
0
    private void SetAniState(AniState state)
    {
        mCurAniState = state;
        string aniName = "";

        switch (state)
        {
        case AniState.Idle:
            aniName = "Stay";
            break;

        case AniState.GetTicket:
            aniName = "Give";
            break;

        case AniState.NotGetTicket:
            aniName = "Take 001";
            break;

        default:
            break;
        }

        mAnimation.Play(aniName);
    }
Ejemplo n.º 2
0
 protected virtual void OnEnable()
 {
     nav.stoppingDistance = act;
     ani.Play(Ani.idle);
     if (Controller.IsPlaying)
     {
         currnetState = AniState.Tour;
     }
     else
     {
         Controller.playAct += () => { currnetState = AniState.Tour; };
     }
 }
Ejemplo n.º 3
0
 protected virtual void ObserveBlood()
 {
     if (bloodVolume <= 0)
     {
         currnetState = AniState.Death;
         if (!ani.IsPlaying(Ani.die))
         {
             ani.CrossFade(Ani.die, 0.2f);
         }
         nav.speed = 0;
     }
     i_blood.fillAmount = bloodVolume / totalBlood;
 }
Ejemplo n.º 4
0
    protected override void InitAnimation()
    {
        m_bIsDancer = true;

        if (!m_bIsDancer)
        {
            OwnerPlayer.IsToShow = false;
            m_LastPlayerPos      = OwnerPlayer.cachedTransform.position;
            OwnerPlayer.cachedTransform.position = CommonDef.RoleHidePos;
        }
        else
        {
            m_fAniScale = 1;// RoomData.PlaySongBPM / (float)DefaultBpm;

            if (AnimationLoader.StageAniExist && OwnerAni != null)
            {
                string   strPreName = getPreNameBySex();
                WrapMode mode       = getWrapModeBySongMode(RoomData.PlaySongMode);

                OwnerAni.AddClip(AnimationLoader.GetAnimationClip(AnimationLoader.StartDance), DanceStart, WrapMode.Loop, 2, 1, m_fAniScale);
                OwnerAni.AddClip(GetAniClipBySex(DanceStart_HB), DanceStart_HB, WrapMode.Loop, 2, 1f, m_fAniScale);
                OwnerAni.AddClip(GetAniClipBySex(Miss), Miss, WrapMode.Once, 3, 1f, m_fAniScale);
                OwnerAni.AddClip(GetAniClipBySex(Lose), Lose, WrapMode.Once, 3, 1f);
                OwnerAni.AddClip(GetAniClipBySex(Win), Win, mode, 3, 1f);

                if (AnimationLoader.s_AniStates.ContainsKey(strPreName))
                {
                    AniState preState = AnimationLoader.s_AniStates[strPreName];
                    if (preState != null)
                    {
                        OwnerAni.AddClip(AnimationLoader.GetAnimationClip(preState.Motion), DancePrepare, WrapMode.Once, 3, 0f, preState.Speed * m_fAniScale);
                    }
                    else
                    {
                        Debug.LogError("Add animation failed. AniState can not be null.Name=" + strPreName);
                    }
                }
                else
                {
                    Debug.LogError("Add animation failed. Animation can not find.Name=" + strPreName);
                }

                OwnerAni.CrossFade(DanceStart);
            }
        }
    }
Ejemplo n.º 5
0
    public void ChangeStatus(EntityBase entity, AniState targetState, params object[] args)
    {
        if (entity.currentAniState == targetState)
        {
            return;
        }

        if (fsm.ContainsKey(targetState))
        {
            if (entity.currentAniState != AniState.None)
            {
                fsm[entity.currentAniState].Exit(entity, args);
            }
            fsm[targetState].Enter(entity, args);
            fsm[targetState].Process(entity, args);
        }
    }
Ejemplo n.º 6
0
    public void SetBlood(int i, GameObject enemy)
    {
        if (target)
        {
            enemys.Add(enemy);
        }
        else
        {
            target = enemy;
        }
        bloodVolume -= i;

        tempState = currnetState;
        if (currnetState != AniState.Death)
        {
            currnetState = AniState.Danmage;
        }
    }
Ejemplo n.º 7
0
    public void ChangeState(EntityBase entity, AniState targetState, params object[] args)
    {
        if (entity.currentAniState == targetState)
        {
            //Debug.Log(GetType() + "/ChangeState()/ Return ");

            return;
        }

        if (fsm.ContainsKey(targetState) == true)
        {
            if (entity.currentAniState != AniState.None)
            {
                fsm[entity.currentAniState].Exit(entity, args);
            }
            fsm[targetState].Enter(entity, args);
            fsm[targetState].Process(entity, args);
        }
    }
Ejemplo n.º 8
0
    public void OnClickReleasSkill_1_Btn()
    {
        AniState curtState = BattleSys.instance.GetPlayerCurrentState();

        if (curtState == AniState.Attack)
        {
            return;
        }
        if (isSk1CD == false)
        {
            BattleSys.instance.ReqReleaseSkill(1);
            isSk1CD = true;
            SetActive(imgSk1CDFill);
            SetActive(txtSk1CD);
            imgSk1CDFill.fillAmount = 1;
            sk1Num = (int)sk1CDTime;
            SetText(txtSk1CD, sk1Num);
        }
    }
Ejemplo n.º 9
0
 public void ChangeStatus(EntityBase entity, AniState targetState)
 {
     //当前状态等于要改变的状态 就直接return
     if (entity.currentAniState == targetState)
     {
         return;
     }
     //我们当前这个实体取出对应的状态
     if (fsm.ContainsKey(targetState))
     {
         if (entity.currentAniState != AniState.None)
         {
             //退出当前状态
             fsm[entity.currentAniState].Exit(entity);
         }
         //进入这个状态
         fsm[targetState].Enter(entity);
         //处理这个状态
         fsm[targetState].Process(entity);
     }
 }
Ejemplo n.º 10
0
    public void ChangeState(EntityBase entity, AniState targetAniState, params object[] args)
    {
        if (entity.currentAniState == targetAniState)
        {
            return;
        }

        //状态切换的处理
        if (fsm.ContainsKey(targetAniState))
        {
            if (entity.currentAniState != AniState.None)
            {
                IState currentState = fsm[entity.currentAniState];
                currentState.Exit(entity, args);
            }
            IState targetState = fsm[targetAniState];
            targetState.Enter(entity, args);
            targetState.Process(entity, args);
            //entity.currentAniState = targetAniState;
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// 巡视逻辑
    /// </summary>
    /// <returns></returns>
    IEnumerator MakeAnInspectionTour()
    {
        while (true)
        {
            foreach (Transform child in transform.tag == "Red" ? Controller.Instance.BlueBornAt.transform : Controller.Instance.redBornAt.transform)
            {
                if (Vector3.Distance(child.position, transform.position) <= view)
                {
                    target       = child.gameObject;
                    currnetState = AniState.Trace;
                    yield break;
                }
            }



            Ray        ray = new Ray(transform.position + (Vector3.up * 0.25f), transform.forward);
            RaycastHit hit, lhit, rhit;

            if (Physics.Raycast(ray, out hit, 1f))
            {
                if (hit.collider.gameObject.tag == "Wall")
                {
                    Ray rray = new Ray(transform.position + (Vector3.up * 0.25f), transform.right);
                    Ray lray = new Ray(transform.position + (Vector3.up * 0.25f), -transform.right);
                    Physics.Raycast(lray, out lhit, Mathf.Infinity);
                    Physics.Raycast(rray, out rhit, Mathf.Infinity);
                    if (Vector3.Distance(lhit.point, transform.position) > Vector3.Distance(rhit.point, transform.position))
                    {
                        transform.localEulerAngles -= Vector3.up * 90 * Time.deltaTime;
                    }
                    else
                    {
                        transform.localEulerAngles += Vector3.up * 90 * Time.deltaTime;
                    }
                }
            }
            yield return(null);
        }
    }
Ejemplo n.º 12
0
        internal void doAnimation1()
        {
            if (state == AniState.anim1) return;
            time = 0.0f;

            switch (lastDirection) {
            case Direction.south:
                mFrame = 4;
                break;
            case Direction.north:
                mFrame = 6;
                break;
            case Direction.east:
                mFrame = 8;
                break;
            case Direction.west:
                mFrame = 10;
                break;
            }
            state = AniState.anim1;
            frame = 0;
        }
Ejemplo n.º 13
0
        private void ChangeAniState(AniState state)
        {
            curAniState = state;
            switch (curAniState)
            {
            case AniState.Foward:
                animator.Play("Foward");
                break;

            case AniState.Left:

                animator.Play("Left");
                break;

            case AniState.Right:

                animator.Play("Right");
                break;

            case AniState.Crash:
                animator.Play("Crash");
                break;
            }
        }
Ejemplo n.º 14
0
    void QueueAddState(float fStartTime, float BPMScale, List <string> danceAniSeq, bool isBoy)
    {
        float startStateTime = fStartTime;
        float startDuration  = 0;
        float fdurtion       = 0;
        float startFrame     = 0;

        for (int i = 0; i < danceAniSeq.Count; i++)
        {
            string stateName = danceAniSeq[i];
            if (!AnimationLoader.s_AniStates.ContainsKey(stateName))
            {
                continue;
            }
            AniState      state    = AnimationLoader.s_AniStates[stateName];
            string        clipName = state.Motion;
            AnimationClip animClip = AnimationLoader.GetAnimationClip(clipName);

            if (animClip == null)
            {
                Debug.LogError("Dance error, animation can not be null." + clipName);
                continue;
            }

            //AddAnimationPlayEvent(startStateTime, stateName, nLayer);
            if (startDuration != 0)
            {
                if (CheckIfAvailableAni(stateName))
                {
                    AddAnimationBlendEvent(startDuration, clipName, fdurtion, startFrame, state.Speed, isBoy);
                }
                if (i > 0)
                {
                    int      tmpIndex = i - 1;
                    AniState revState = AnimationLoader.s_AniStates[AnimationLoader.DanceAniSequence[tmpIndex]];
                    if (CheckIfAvailableAni(revState.Name))
                    {
                        AddAnimationRemoveEvent(startDuration + animClip.length, revState.Motion, isBoy);
                    }
                }
            }
            else
            {
                if (CheckIfAvailableAni(stateName))
                {
                    AddAnimationPlayEvent(startStateTime, clipName, state.Speed, isBoy);
                }
                if (i > 0)
                {
                    int      tmpIndex = i - 1;
                    AniState revState = AnimationLoader.s_AniStates[AnimationLoader.DanceAniSequence[tmpIndex]];
                    if (CheckIfAvailableAni(revState.Name))
                    {
                        AddAnimationRemoveEvent(startDuration + animClip.length, revState.Motion, isBoy);
                    }
                }
            }

            AniState         nextState = null;
            TranState        nextTran  = null;
            List <TranState> trans     = state.Trans;
            foreach (TranState tran in trans)
            {
                if (tran != null && isBoy == tran.IsBoy && AnimationLoader.s_AniStates.ContainsKey(tran.DestState))
                {
                    nextState = AnimationLoader.s_AniStates[tran.DestState];
                    nextTran  = tran;
                    break;
                }
            }

            if (nextState == null)
            {
                foreach (TranState tran in trans)
                {
                    if (tran != null && AnimationLoader.s_AniStates.ContainsKey(tran.DestState))
                    {
                        nextState = AnimationLoader.s_AniStates[tran.DestState];
                        nextTran  = tran;
                        break;
                    }
                }
            }

            if (nextState != null && nextTran != null)
            {
                AnimationClip nextAnimClip = AnimationLoader.GetAnimationClip(nextState.Motion);
                if (nextAnimClip != null)
                {
                    if (state.Speed != 0 && nextTran.ExitTime != 0)
                    {
                        startDuration  = startStateTime + animClip.length / state.Speed * nextTran.ExitTime;
                        startStateTime = startDuration - nextAnimClip.length / AnimationLoader.s_AniStates[nextTran.DestState].Speed * nextTran.TranOffset;
                        fdurtion       = animClip.length * nextTran.TranDuration / state.Speed;

                        startFrame = nextAnimClip.length * nextTran.TranOffset;
                    }
                    else
                    {
                        Debug.LogError("Animation  speed or next ExitTime is zero! Please Check it, aniName is : " + clipName);
                    }
                }
            }
            else
            {
                break;
            }
        }
    }
Ejemplo n.º 15
0
        internal void doAnimation2()
        {
            if (attacks < 2) throw new Exception("one attack");

            time = 0.0f;

            switch (lastDirection) {
            case Direction.south:
                mFrame = 12;
                break;
            case Direction.north:
                mFrame = 14;
                break;
            case Direction.east:
                mFrame = 16;
                break;
            case Direction.west:
                mFrame = 18;
                break;
            }
            state = AniState.anim2;
            frame = 0;
        }
Ejemplo n.º 16
0
        internal void draw(RenderWindow window, double gameTime, Vector2f midBotPos,Direction direction)
        {
            Vector2f drawPos = new Vector2f(midBotPos.X - 50*scale,midBotPos.Y - 50*scale);

            sourceRect = GeoLib.getRectOfFrame(mFrame, 4, new Vector2f(164,184));
            sprite.TextureRect = sourceRect;
            sprite.Position = drawPos;
            sprite.Scale = new Vector2f(scale, scale);
            window.Draw(sprite);

            if (state == AniState.idle) {
                if (lastDirection != direction || mFrame > 3) {
                    switch (direction) {
                    case Direction.south:
                        mFrame = 0;
                        break;
                    case Direction.north:
                        mFrame = 1;
                        break;
                    case Direction.east:
                        mFrame = 2;
                        break;
                    case Direction.west:
                        mFrame = 3;
                        break;
                    }
                    lastDirection = direction;
                }
                return;
            }

            float cFrameTime = frameTime[(int)state];//current frameTime
            time += (float)(gameTime - GameBox.getInstance().getLastUpdateTime()) / 1000;//getting seconds
            if (time > cFrameTime && time < cFrameTime + cFrameTime) {
                if (frame == 0) {
                    time -= cFrameTime;
                    mFrame++;
                    frame++;
                }else
                    state = AniState.idle;

            }
        }
Ejemplo n.º 17
0
 public void PlayAni(AniState aniState)
 {
     Animator.speed = TimeManager.GetTimeScale;
     Animator.SetInteger("State", (int)aniState);
 }
Ejemplo n.º 18
0
    protected virtual void Update()
    {
        ObserveBlood();
        if (ani.IsPlaying(Ani.die))
        {
            if (ani[Ani.die].normalizedTime >= 0.9f)
            {
                Destroy(gameObject);
            }
            return;
        }

        if (target == null)
        {
            foreach (var enemy in enemys)
            {
                if (enemy)
                {
                    target = enemy;
                    break;
                }
            }
            if (Controller.IsPlaying && !target)
            {
                currnetState = AniState.Tour;
            }
        }
        if (target != null)
        {
            if (Vector3.Distance(target.transform.position, transform.position) <= act)
            {
                Ray        ray = new Ray(transform.position + Vector3.up * 0.25f, target.transform.position - transform.position);
                RaycastHit hit;
                Vector3    dir = target.transform.position - transform.position;
                if (Vector3.Angle(transform.forward, dir) > m_angle)
                {
                    if (Vector3.Cross(transform.forward, dir).y < 0)
                    {
                        transform.localEulerAngles = transform.localEulerAngles -= Vector3.up * Time.deltaTime * rot_speed;
                    }
                    else
                    {
                        transform.localEulerAngles = transform.localEulerAngles += Vector3.up * Time.deltaTime * rot_speed;
                    }
                }
                else if (Physics.Raycast(ray, out hit) && hit.collider.tag != target.tag)
                {
                    currnetState = AniState.Trace;
                }
                else
                {
                    currnetState = AniState.Attack;
                }
            }
            if (Vector3.Distance(target.transform.position, transform.position) > view)
            {
                currnetState = AniState.Trace;
            }
        }

        switch (currnetState)
        {
        case AniState.None:
            if (!Controller.IsPlaying)
            {
                ani.CrossFade(Ani.idle, 0.2f);
            }
            break;

        case AniState.Tour:
            if (!ani.IsPlaying(Ani.walk))
            {
                tempPos = Controller.floors[Random.Range(0, Controller.floors.Length)].transform.position;
                ani.CrossFade(Ani.walk, 0.2f);
                if (current != null)
                {
                    StopCoroutine(current);
                    current = null;
                }
                StartCoroutine(MakeAnInspectionTour());
            }
            if (Vector3.Distance(transform.position, tempPos) < act)
            {
                tempPos = Controller.floors[Random.Range(0, Controller.floors.Length)].transform.position;
            }

            nav.destination = tempPos /*transform.position + transform.forward*/;

            nav.speed = 0.5f * speed;
            break;

        case AniState.Trace:
            if (!(ani.IsPlaying(Ani.run) || ani.IsPlaying(Ani.idle)))
            {
                ani.CrossFade(Ani.run, 0.2f);
            }
            nav.destination = target.transform.position;
            nav.speed       = 1 * speed;
            break;

        case AniState.Attack:
            if (!(ani.IsPlaying(Ani.attack1) || ani.IsPlaying(Ani.idle)))
            {
                att = false;
                ani.CrossFade(Ani.attack1, 0.2f);
            }
            if (ani.IsPlaying(Ani.attack1))
            {
                if (ani[Ani.attack1].normalizedTime >= 0.5f && !att)
                {
                    Attack();
                    att = true;
                }
                if (ani[Ani.attack1].normalizedTime >= 0.8f)
                {
                    ani.CrossFade(Ani.idle, 0.2f);
                    timer = 0;
                }
            }
            if (ani.IsPlaying(Ani.idle))
            {
                Debug.Log("CD中......");
                timer += Time.deltaTime;
                if (timer >= CD)
                {
                    timer = 0;
                    ani.CrossFade(Ani.attack1, 0.2f);
                    att = false;
                }
            }
            break;

        case AniState.Death:
            if (!ani.IsPlaying(Ani.die))
            {
                ani.CrossFade(Ani.die, 0.2f);
            }
            nav.speed = 0;
            break;

        case AniState.Danmage:
            if (!ani.IsPlaying(Ani.danmage))
            {
                ani.CrossFade(Ani.danmage, 0.2f);
            }
            if (ani.IsPlaying(Ani.danmage) && ani[Ani.danmage].normalizedTime >= 0.9f)
            {
                currnetState = tempState;
            }
            break;

        default:
            break;
        }
    }