// Update is called once per frame void Update() { if (Walk()) { cntGoal_++; if (UpdateObstacle()) { return; } //まだ目的地についていないなら if (cntGoal_ < postGoal_.Count) { Object.Destroy(GetComponent <BaseEnemy>().State); EnemyWalkPostState walk = gameObject.AddComponent <EnemyWalkPostState>(); walk.postGoal = postGoal_; walk.CntGoal = cntGoal_; walk.ObstacleObj = obstacleObj_; walk.ObstacleCnt = 0; GetComponent <BaseEnemy>().State = walk; GetComponent <BaseEnemy>().Animation.Walk = true; } else { Object.Destroy(GetComponent <BaseEnemy>().State); GetComponent <BaseEnemy>().State = gameObject.AddComponent <EnemyWaitState>(); GetComponent <BaseEnemy>().Animation.Walk = false; } } }
// Update is called once per frame void Update() { Object.Destroy(GetComponent <BaseEnemy>().State); EnemyWalkPostState walk = gameObject.AddComponent <EnemyWalkPostState>(); walk.postGoal = postGoal_; walk.CntGoal = 0; GetComponent <BaseEnemy>().State = walk; GetComponent <BaseEnemy>().Animation.Walk = true; }
bool UpdateObstacle() { //障害物発見 if (Obstacle()) { BaseEnemy enemy = GetComponent <BaseEnemy>(); int indexStart = enemy.IndexPost; int indexGoal = postGoal_[postGoal.Count - 1].GetComponent <Link>().LinkID - 1; GameObject[] objs = new GameObject[obstacleObj_.Count]; for (int x = 0; x < obstacleObj_.Count; x++) { objs[x] = obstacleObj_[x]; } List <GameObject> objRoot = new List <GameObject>(); List <GameObject> objNewRoot = new List <GameObject>(); float length = 0.0f; float length01 = 0.0f; bool check = false; Link[] link = GameObject.Find("FieldObject/Post").GetComponent <PostManager>().Link; PostManager.PostRootFGoalObstacleReturn(link[enemy.IndexPost], postGoal[postGoal.Count - 1], objs, objRoot, objNewRoot, ref length, ref length01, ref check); Object.Destroy(GetComponent <EnemyWalkPostState>()); EnemyWalkPostState walk = gameObject.AddComponent <EnemyWalkPostState>(); walk.postGoal = objRoot; walk.CntGoal = 0; walk.ObstacleObj = obstacleObj_; walk.ObstacleCnt = obstacleCnt_; GetComponent <BaseEnemy>().State = walk; GetComponent <BaseEnemy>().Animation.Walk = true; return(true); } return(false); }