/// <summary>
 /// 状態の設定
 /// </summary>
 void StateDetermination()
 {
     if (searchArea < targetDistance)
     {
         enemyStatus_p = enemyStatus.Serch_Run;
     }
     else
     {
         if (targetZ + 0.5f > this.gameObject.transform.position.z &&
             targetZ - 0.5f < this.gameObject.transform.position.z)
         {
             if (targetX < this.gameObject.transform.position.x + 2.0f &&
                 targetX > this.gameObject.transform.position.x - 2.0f)                     //プレイヤーが左
             {
                 enemyStatus_p = enemyStatus.Attack;
             }
             else
             {
                 enemyStatus_p = enemyStatus.Escape;
             }
         }
         else
         {
             enemyStatus_p = enemyStatus.Escape;
         }
     }
 }
    void Update()
    {
        //Console ();
        switch (enemyStatus_p)
        {
        case enemyStatus.Create:
            enemyStatus_p = enemyStatus.Stand;
            break;

        case enemyStatus.Stand:
            enemyStatus_p = enemyStatus.Serch_Run;
            break;

        case enemyStatus.Attack:        //攻撃範囲内:X軸同一線上
            SetTarget();
            Attack();
            StateDetermination();
            break;

        case enemyStatus.Escape:        //逃避範囲内:X軸同一線上外
            SetTarget();
            Escape();
            StateDetermination();
            break;

        case enemyStatus.Serch_Run:        //範囲外:X・Z非同一線上
            SetTarget();
            SearchRun();
            StateDetermination();
            break;

        case enemyStatus.Hit:
            break;

        case enemyStatus.Destroy:
            break;
        }
    }
    void Update()
    {
        switch (enemyStatus_p)
        {
        case enemyStatus.Create:
            enemyStatus_p = enemyStatus.Stand;
            break;

        case enemyStatus.Stand:
            enemyStatus_p = enemyStatus.Serch_Run;
            break;

        case enemyStatus.Attack:        //攻撃範囲内:X軸同一線上
            SetTarget();
            if (targetDistance > changeDistance)
            {
                enemyStatus_p = enemyStatus.Serch_Run;
            }
            else
            {
                if (this.gameObject.transform.position.z + 4.0f >= targetZ &&
                    this.gameObject.transform.position.z - 4.0f <= targetZ &&
                    this.gameObject.transform.position.x + 4.0f >= targetX &&
                    this.gameObject.transform.position.x - 4.0f <= targetX)
                {
                    if (canAttack == true)
                    {
                        GameObject obj = Instantiate(TestAttack);
                        obj.transform.parent = transform;
                        obj.name             = ("Effect");
                        canAttack            = false;
                    }
                }
                else
                {
                    enemyStatus_p = enemyStatus.Escape;
                }

                /*if ((this.gameObject.transform.position.x +2.0f > targetX &&
                 *      this.gameObject.transform.position.x - 2.0f < targetX)&&
                 *      (this.gameObject.transform.position.z+2.0<targetZ&&
                 *      this.gameObject.transform.position.z-2.0>targetZ)) {
                 *      enemyStatus_p = enemyStatus.Escape;
                 * } else {
                 *      if (canAttack == true) {
                 *              GameObject obj = Instantiate (TestAttack);
                 *              obj.transform.parent = transform;
                 *              obj.name = ("Effect");
                 *              canAttack = false;
                 *      }
                 * }*/
            }
            break;

        case enemyStatus.Escape:        //逃避範囲内:X軸同一線上外
            SetTarget();

            /*if (targetDistance > changeDistance) {
             *      enemyStatus_p = enemyStatus.Serch_Run;
             * } else {*/
            if (targetDistance < changeDistance ||
                this.gameObject.transform.position.z + 4.0f >= targetZ &&
                this.gameObject.transform.position.z - 4.0f <= targetZ &&
                this.gameObject.transform.position.x + 4.0f >= targetX &&
                this.gameObject.transform.position.x - 4.0f <= targetX)
            {
                enemyStatus_p = enemyStatus.Serch_Run;
            }
            else
            {
                if (this.gameObject.transform.position.z < targetZ)
                {
                    speedZ = speed / 2;
                }
                else
                {
                    speedZ = -speed / 2;
                }
                this.transform.position += new Vector3(speed * Time.deltaTime, 0, speedZ * Time.deltaTime);
            }

            break;

        case enemyStatus.Serch_Run:        //範囲外:X・Z非同一線上
            SetTarget();
            if (targetDistance > changeDistance)
            {
                ToTargetMove();
            }
            else
            {
                enemyStatus_p = enemyStatus.Attack;
            }
            break;

        case enemyStatus.Hit:
            break;

        case enemyStatus.Destroy:
            break;
        }
    }