/// <summary> /// 巡逻 /// </summary> void DoParse() { if (dis > 1.0f && dis < 6.0f) { iTween.Stop(); zombieState = EnemyCommon.CurrentState.Follow; } }
/// <summary> /// 攻击操作 /// </summary> void DoAttack() { transform.LookAt(followpos); anim.SetBool("Attack", true); if (dis > 1.6f && dis < 6.0f) { zombieState = EnemyCommon.CurrentState.Follow; } }
void Start() { thisZombieIndex = 0; onceDropAndAchievement = true; followpos = GameObject.FindWithTag("Player").GetComponentInChildren <FollowPos>().transform; dis = Vector3.Distance(transform.position, followpos.position); zombieState = EnemyCommon.CurrentState.Parse; //iTween参数初始化 args = new Hashtable(); args.Add("path", paths); args.Add("easeType", "Linear"); args.Add("speed", 2); args.Add("movetopath", true); args.Add("orienttopath", true); args.Add("loopType", "Loop"); args.Add("delay", 0.1f); iTween.MoveTo(gameObject, args); }
/// <summary> /// 追踪操作 /// </summary> void DoFollow() { anim.SetBool("Attack", false); transform.LookAt(followpos); transform.position = Vector3.MoveTowards(transform.position, followpos.position, Time.deltaTime); if (life <= 0) { zombieState = EnemyCommon.CurrentState.Die; } if (dis > 10.0f) { //iTween.Resume(); iTween.MoveTo(gameObject, args); zombieState = EnemyCommon.CurrentState.Parse; } else if (dis < 1.6f) { zombieState = EnemyCommon.CurrentState.Attack; } }