Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (curState == State.depth)
        {
            return;
        }

        //StartCoroutine (attackPer2second ());
        if (curState != State.attacking && curState != State.hitted && Vector3.Distance(transform.position, player.position) < 0.3)
        {
            _animator.SetBool("idle2attack", true);
            _animator.SetBool("idle2walk", false);
            curState = State.attacking;

            player.animation["hit"].speed = (float)0.5;
            player.animation.CrossFade("hit");
            playerstate.xueDownRandom();
        }

        _animatorinfo = _animator.GetCurrentAnimatorStateInfo(0);
        if (!_animator.GetBool("idle2attack") && !_animator.GetBool("idle2gethit") && _animatorinfo.IsName("Base Layer.idle"))
        {
            curState = State.idle;
        }
        if (curState != State.hitted && playerstate.ani_stat == playerStateLinster.enum_ani_state.Attacking1)
        {
            if (Vector3.Distance(player.position, transform.position) < (float)0.3 || Vector3.Distance(player.position, transform.position) < 1 && Vector3.Angle(player.transform.forward, transform.position - player.transform.position) < 30)
            {
                _animator.SetBool("idle2gethit", true);
                _animator.SetBool("walk2gethit", true);
                curState = State.hitted;
                Debug.Log("getigt");
                rolePropertyItem.subXue();
            }
        }
        //if ( curState!=State.attacking&&playerstate.ani_stat == playerStateLinster.enum_ani_state.Idle||playerstate.ani_stat == playerStateLinster.enum_ani_state.NoAni) {
        //	curState =State.idle;
        //	Debug.Log("..........");
        //}

        if (rolePropertyItem.getCurXue() <= 0)
        {
            curState = State.depth;
            BossAnimation.smallMonsterdie++;
            StartCoroutine(WaitFordepthPlayOver());
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        xuekuang.SetRect(25, -8, curXue, 15);
        xuelable.text = curXue.ToString();
        if (curXue <= 0)
        {
            GameObject.FindWithTag("scriptObj").GetComponent <otherInput>().togameover(0);
            Time.timeScale = 0;
        }
        //	Debug.Log ("boss " + bossstate);
        if (playerstate.ani_stat == playerStateLinster.enum_ani_state.Attacking1 && bossstate != BossState.gethit)
        {
            if (smallMonsterdie == 2 && Vector3.Distance(player.position, transform.position) < (float)0.5 && Vector3.Angle(player.transform.forward, transform.position - player.transform.position) < 60)
            {
                curXue -= Random.Range(20, 25);
                curXue -= (int)playerstate.tool_stat * 5;
                StartCoroutine(WaitForAnimationPlayOver((int)BossState.gethit));
                //Debug.Log ("boss xue down");
            }
        }

        if (bossstate == BossState.noani)
        {
            //if(playerstate.ani_stat==playerStateLinster.enum_ani_state.Attacking1)
            //{
            //	if(Vector3.Distance(player.position,transform.position)<(float)0.5&& Vector3.Angle(player.transform.forward,transform.position-player.transform.position)<60)
            //	{
            //		StartCoroutine( WaitForAnimationPlayOver((int)BossState.gethit));
            //		Debug.Log ("boss xue down");
            //	}
            //}
            int temp = Random.Range(0, 100);
            if (temp < 10 && Vector3.Distance(player.position, transform.position) > 3)
            {
                StartCoroutine(WaitForAnimationPlayOver((int)BossState.idle));
            }
            else if (temp <= 40 && Vector3.Distance(player.position, transform.position) > 1)
            {
                StartCoroutine(WaitForAnimationPlayOver((int)BossState.walk));
            }
            else if (Vector3.Distance(player.position, transform.position) < 1)
            {
                StartCoroutine(WaitForAnimationPlayOver((int)BossState.attack));
            }
            else
            {
                //StartCoroutine( WaitForAnimationPlayOver((int)BossState.idle));
                //	bossstate =BossState.noani;
            }
        }
        if (bossstate == BossState.walk)
        {
            if (!haswalkredirect)
            {
                //transform.LookAt(player.position);
                //haswalkredirect =true;
                float temp = Vector3.Angle(transform.forward, player.position - transform.position);
                if (Vector3.Cross(transform.forward, player.position - transform.position).y > 0)
                {
                    transform.Rotate(0, temp, 0);
                }
                else
                {
                    transform.Rotate(0, -temp, 0);
                }
                haswalkredirect = true;
            }
            Vector3 tempv = transform.forward;
            tempv.y             = 0;
            transform.position += tempv * Time.deltaTime;
            //transform.position =Vector3.MoveTowards(transform.position, player.position,   Time.deltaTime);
        }
        if (bossstate == BossState.attack)
        {
            if (!hasattacked && Vector3.Distance(player.position, transform.position) < (float)0.5)
            {
                transform.LookAt(player.position);
                player.animation.CrossFade("hit");
                playerstate.xueDownRandom();
                hasattacked = true;
            }
        }
    }