Ejemplo n.º 1
0
        public bool GetStageDataType(int _playerId, Common.MOVE_TYPE pos)
        {
            CharacterModel.Data playerId = GetCharacterData(_playerId);
            switch (pos)
            {
            case Common.MOVE_TYPE.UP:
                if (stageData[(int)playerId.BlockPos.y - 1, (int)playerId.BlockPos.x] == (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                {
                    return(false);
                }
                break;

            case Common.MOVE_TYPE.DOWN:
                if (stageData[(int)playerId.BlockPos.y + 1, (int)playerId.BlockPos.x] == (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                {
                    return(false);
                }
                break;

            case Common.MOVE_TYPE.LEFT:
                if (stageData[(int)playerId.BlockPos.y, (int)playerId.BlockPos.x - 1] == (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                {
                    return(false);
                }
                break;

            case Common.MOVE_TYPE.RIGHT:
                if (stageData[(int)playerId.BlockPos.y, (int)playerId.BlockPos.x + 1] == (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                {
                    return(false);
                }
                break;
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 指定したキャラクターアクターの行動実行
        /// </summary>
        /// <remarks>
        /// キャラクター行動は下記が行える<br>
        /// 遠距離攻撃<br>
        /// 中距離攻撃<br>
        /// 近距離攻撃<br>
        /// 一定時間無敵<br>
        /// なお、1フレーム以内で実行できる行動に制限はないが、同じ行動は一定時間後にしか実行できない
        /// </remarks>
        /// <returns> 行動が実行できる状態であるかどうかの可否 </returns>
        /// <param name="actorId">行動実行させたいキャラクターアクター</param>
        /// <param name="type">実行させたい行動</param>
        public bool Action(int actorId, Define.Battle.ACTION_TYPE type)
        {
            List <CharacterModel.Data> list = GetTeamCharacterDataList(TEAM_TYPE.PLAYER);

            CharacterModel.Data Data = list.Find(obj => obj.ActorId == actorId);

            if (Data == null)
            {
                Debug.LogError("Action Method : not have the right to operate an actor, or the ID is incorrect");
                return(false);
            }

            ActorData?actorData = _actorManager.GetActor(Data.ActorId);

            if (actorData == null)
            {
                return(false);
            }

            Character character = actorData.Value.Actor.GetComponent <Character>();

            if (character == null)
            {
                return(false);
            }

            return(character.ActionManager.StartAction(type));
        }
Ejemplo n.º 3
0
        //---------------------------------------------------
        // CharacterGetItemMoveStateUpdate
        //---------------------------------------------------
        void CharacterGetItemMoveStateUpdate(StateData data)
        {
            CharacterModel.Data character = GetAliveActor(_currentActorId, TEAM_TYPE.PLAYER);

            if (character == null)
            {
                return;
            }

            int            itemActorId = (int)data.table["itemActorId"];
            int            index       = _stageItemDataList.FindIndex(obj => obj.ActorId == itemActorId);
            List <Vector2> moveList    = (List <Vector2>)data.table["moveList"];

            if (index < 0 ||
                moveList.Count <= 0)
            {
                if (_getReservItemList.ContainsKey(itemActorId))
                {
                    _getReservItemList.Remove(itemActorId);
                }

                _characterStateList[_currentActorId].SetNextState(CHARACTER_MOVE_STATE.ATTACK);
            }
            else if (character.IsMoveEnable)
            {
                Move(character.ActorId, GetVecToMoveType(moveList[0] - character.BlockPos));
                moveList.RemoveAt(0);
            }

            data.table["moveList"] = moveList;
        }
Ejemplo n.º 4
0
        // 自分と敵の距離を取得する
        // 戻り値:距離 (float)
        public float Distance(CharacterModel.Data playerId, CharacterModel.Data enemyId)
        {
            float sx = playerId.BlockPos.x - enemyId.BlockPos.x;
            float sy = playerId.BlockPos.y - enemyId.BlockPos.y;

            return(Mathf.Sqrt(sx * sx + sy * sy));
        }
Ejemplo n.º 5
0
        //---------------------------------------------------
        // GetAliveActor
        //---------------------------------------------------
        CharacterModel.Data GetAliveActor(int acctorId, TEAM_TYPE teamType)
        {
            CharacterModel.Data character = GetTeamCharacterDataList(teamType).Find(obj => obj.ActorId == acctorId);

            if (character == null ||
                character.Hp <= 0)
            {
                return(null);
            }

            return(character);
        }
Ejemplo n.º 6
0
        // 自分と敵のIDから同じ行にいるかを確認する
        // 戻り値:ENEMY_POS
        //
        public ENEMY_POS SameRow(CharacterModel.Data playerId, CharacterModel.Data enemyId)
        {
            // 自身と敵は同じ列にいる
            if (enemyId.BlockPos.y == playerId.BlockPos.y)
            {
                return(ENEMY_POS.SAME);
            }

            // 敵は自身より上方向にいる
            if (playerId.BlockPos.y < enemyId.BlockPos.y)
            {
                return(ENEMY_POS.UP);
            }

            // それ以外なので、敵は下方向にいる
            return(ENEMY_POS.DOWN);
        }
Ejemplo n.º 7
0
        // 自分と敵のIDから同じ行にいるかを確認する
        // 戻り値:ENEMY_POS
        //
        public ENEMY_POS SameColumn(CharacterModel.Data playerId, CharacterModel.Data enemyId)
        {
            // 自身と敵は同じ行にいる
            if (enemyId.BlockPos.x == playerId.BlockPos.x)
            {
                return(ENEMY_POS.SAME);
            }

            // 自身と敵は右側にいる
            if (playerId.BlockPos.x < enemyId.BlockPos.x)
            {
                return(ENEMY_POS.RIGHT);
            }

            // それ以外なので、左側にいる
            return(ENEMY_POS.LEFT);
        }
Ejemplo n.º 8
0
        //---------------------------------------------------
        // searchAliveTeam
        //---------------------------------------------------
        CharacterModel.Data searchAliveTeam(TEAM_TYPE type)
        {
            List <CharacterModel.Data> list = GetTeamCharacterDataList(type);

            CharacterModel.Data retData = null;

            foreach (CharacterModel.Data data in list)
            {
                if (data.Hp > 0)
                {
                    retData = data;
                    break;
                }
            }

            return(retData);
        }
Ejemplo n.º 9
0
        //---------------------------------------------------
        // GetLowHpCharacterData
        //---------------------------------------------------
        CharacterModel.Data GetLowHpCharacterData(TEAM_TYPE type)
        {
            List <CharacterModel.Data> list = GetTeamCharacterDataList(type);

            CharacterModel.Data retData = null;
            float hp = 0;

            foreach (CharacterModel.Data data in list)
            {
                if (hp < data.Hp)
                {
                    retData = data;
                }
            }

            return(retData);
        }
Ejemplo n.º 10
0
        //---------------------------------------------------
        // CheckFrontEnemy
        //---------------------------------------------------
        bool CheckFrontEnemy(CharacterModel.Data character, CharacterModel.Data enemy)
        {
            bool flag = ((enemy.BlockPos - character.BlockPos).normalized != character.Forward)? true : false;

            if (character.BlockPos == enemy.BlockPos ||
                flag)
            {
                return(false);
            }

            if (character.BlockPos.x == enemy.BlockPos.x)
            {
                float startBlockPosY = (character.BlockPos.y < enemy.BlockPos.y) ? character.BlockPos.y : enemy.BlockPos.y;
                float endBlockPosY   = (character.BlockPos.y > enemy.BlockPos.y) ? character.BlockPos.y : enemy.BlockPos.y;

                for (int blockPosY = (int)startBlockPosY; blockPosY < endBlockPosY; blockPosY++)
                {
                    if (GetBlockType(new Vector2(character.BlockPos.x, blockPosY)) == Ateam.Define.Stage.BLOCK_TYPE.OBSTACLE)
                    {
                        return(false);
                    }
                }
            }
            else if (character.BlockPos.y == enemy.BlockPos.y)
            {
                float startBlockPosX = (character.BlockPos.x < enemy.BlockPos.x) ? character.BlockPos.x : enemy.BlockPos.x;
                float endBlockPosX   = (character.BlockPos.x > enemy.BlockPos.x) ? character.BlockPos.x : enemy.BlockPos.x;

                for (int blockPosX = (int)startBlockPosX; blockPosX < endBlockPosX; blockPosX++)
                {
                    if (GetBlockType(new Vector2(blockPosX, character.BlockPos.y)) == Ateam.Define.Stage.BLOCK_TYPE.OBSTACLE)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 11
0
        //---------------------------------------------------
        // MoveUpdateGetItemAttackState
        //---------------------------------------------------
        void CharacterGetItemMoveStateEnter(StateData data)
        {
            CharacterModel.Data character = GetAliveActor(_currentActorId, TEAM_TYPE.PLAYER);

            if (character == null)
            {
                return;
            }

            int itemActorId = (int)data.table["itemActorId"];
            int index       = _stageItemDataList.FindIndex(obj => obj.ActorId == itemActorId);

            if (index < 0)
            {
                _characterStateList[_currentActorId].SetNextState(CHARACTER_MOVE_STATE.ATTACK);
            }
            else
            {
                ItemSpawnData  item     = _stageItemDataList[index];
                List <Vector2> moveList = MoveTargetBlock(character.ActorId, item.BlockPos);
                data.table = Common.CreateHashTable("itemActorId", item.ActorId, "moveList", moveList);
            }
        }
Ejemplo n.º 12
0
        //---------------------------------------------------
        // UpdateAI
        //---------------------------------------------------
        override public void UpdateAI()
        {
            //ステージデータ取ってくるときのサンプル
            int[,] stageData = GetStageData();

            for (int y = 0; y < stageData.GetLength(0); y++)
            {
                for (int x = 0; x < stageData.GetLength(1); x++)
                {
                    //Debug.Log("stage" + y + " : " + x );

                    //通常ブロック
                    if (stageData[y, x] == (int)Define.Stage.BLOCK_TYPE.NORMAL)
                    {
                        //Debug.Log("通常ブロック");
                    }
                    else if (stageData[y, x] == (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                    {
                        //Debug.Log("障害物ブロック");
                    }
                    else if (stageData[y, x] == (int)Define.Stage.BLOCK_TYPE.NONE)
                    {
                        //Debug.Log("ブロックなし");
                    }
                }
            }

            //自チームのデータを取得
            List <CharacterModel.Data> playerList = GetTeamCharacterDataList(TEAM_TYPE.PLAYER);

            //敵チームのデータ取得
            List <CharacterModel.Data> enemyList = GetTeamCharacterDataList(TEAM_TYPE.ENEMY);

            //移動のサンプル
            for (int i = 0; i < playerList.Count; i++)
            {
                CharacterModel.Data character = playerList[i];
                int id = character.ActorId;

                //自分がいるステージのブロックタイプを取得
                Define.Stage.BLOCK_TYPE type = GetBlockType(character.BlockPos);

                int move = UnityEngine.Random.Range(0, 4);
                switch (move)
                {
                case 0:
                    //上移動
                    Move(id, Common.MOVE_TYPE.UP);
                    break;

                case 1:
                    //下移動
                    Move(id, Common.MOVE_TYPE.DOWN);
                    break;

                case 2:
                    //左移動
                    Move(id, Common.MOVE_TYPE.LEFT);
                    break;

                case 3:
                    //右移動
                    Move(id, Common.MOVE_TYPE.RIGHT);
                    break;
                }


                //アクションのサンプル
                switch (UnityEngine.Random.Range(0, 4))
                {
                case 0:
                    //近距離攻撃
                    Action(id, Define.Battle.ACTION_TYPE.ATTACK_SHORT);
                    break;

                case 1:
                    //中距離攻撃
                    Action(id, Define.Battle.ACTION_TYPE.ATTACK_MIDDLE);
                    break;

                case 2:
                    //長距離攻撃
                    Action(id, Define.Battle.ACTION_TYPE.ATTACK_LONG);
                    break;

                case 3:
                    //無敵アクション
                    Action(id, Define.Battle.ACTION_TYPE.INVINCIBLE);
                    break;
                }
            }
        }
Ejemplo n.º 13
0
        //---------------------------------------------------
        // UpdateAI
        //---------------------------------------------------
        override public void UpdateAI()
        {
            //互いのチームのデータを取得
            List <CharacterModel.Data> playerList = GetTeamCharacterDataList(TEAM_TYPE.PLAYER);
            List <CharacterModel.Data> enemyList  = GetTeamCharacterDataList(TEAM_TYPE.ENEMY);

            if (playerList[1].Hp != 0)
            {
                CharacterModel.Data getItem = playerList[1];
                float c1 = x - getItem.BlockPos.x;
                float d1 = y - getItem.BlockPos.y;
                if (c1 > 0)
                {
                    Move(getItem.ActorId, Common.MOVE_TYPE.RIGHT);
                }
                if (c1 < 0)
                {
                    Move(getItem.ActorId, Common.MOVE_TYPE.LEFT);
                }
                if (d1 > 0)
                {
                    Move(getItem.ActorId, Common.MOVE_TYPE.UP);
                }
                if (d1 < 0)
                {
                    Move(getItem.ActorId, Common.MOVE_TYPE.DOWN);
                }
            }

            //索敵機から順にロックオン
            //

            foreach (CharacterModel.Data playerData in playerList)
            {
                float minlen = 100;

                foreach (CharacterModel.Data enemyData in enemyList)
                {
                    if (enemyData.Hp <= 0)
                    {
                        continue;
                    }

                    float len = (enemyData.BlockPos - playerData.BlockPos).magnitude;
                    if (minlen > len)
                    {
                        minlen = len;
                    }
                }
                if (minlen < ATTACK_SHORT_LEN)
                {
                    Action(playerData.ActorId, Define.Battle.ACTION_TYPE.ATTACK_SHORT);
                }
                if (minlen < INVINCIBLE_LEN)
                {
                    Action(playerData.ActorId, Define.Battle.ACTION_TYPE.INVINCIBLE);
                }
                if (minlen < ATTACK_MIDDLE_LEN)
                {
                    Action(playerData.ActorId, Define.Battle.ACTION_TYPE.ATTACK_MIDDLE);
                }
                Action(playerData.ActorId, Define.Battle.ACTION_TYPE.ATTACK_LONG);
            }


            if (enemyList[2].Hp != 0)
            {
                foreach (CharacterModel.Data playerData in playerList)
                {
                    CharacterModel.Data enemyData = enemyList[2];


                    float c = enemyData.BlockPos.x - playerData.BlockPos.x;
                    float d = enemyData.BlockPos.y - playerData.BlockPos.y;


                    if (c > 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.RIGHT);
                    }
                    if (c < 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.LEFT);
                    }
                    if (d > 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.UP);
                    }
                    if (d < 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.DOWN);
                    }
                }
            }
            if (enemyList[2].Hp == 0)
            {
                foreach (CharacterModel.Data playerData in playerList)
                {
                    CharacterModel.Data enemyData = enemyList[1];


                    float c = enemyData.BlockPos.x - playerData.BlockPos.x;
                    float d = enemyData.BlockPos.y - playerData.BlockPos.y;

                    if (c > 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.RIGHT);
                    }
                    if (c < 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.LEFT);
                    }
                    if (d > 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.UP);
                    }
                    if (d < 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.DOWN);
                    }
                }
            }
            if (enemyList[2].Hp == 0)
            {
                foreach (CharacterModel.Data playerData in playerList)
                {
                    CharacterModel.Data enemyData = enemyList[0];


                    float c = enemyData.BlockPos.x - playerData.BlockPos.x;
                    float d = enemyData.BlockPos.y - playerData.BlockPos.y;


                    if (c > 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.RIGHT);
                    }
                    if (c < 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.LEFT);
                    }
                    if (d > 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.UP);
                    }
                    if (d < 0)
                    {
                        Move(playerData.ActorId, Common.MOVE_TYPE.DOWN);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        //---------------------------------------------------
        // CharacterAttackMoveStateUpdate
        //---------------------------------------------------
        void CharacterAttackMoveStateUpdate(StateData data)
        {
            CharacterModel.Data character = GetAliveActor(_currentActorId, TEAM_TYPE.PLAYER);

            if (character == null)
            {
                return;
            }

            CharacterModel.Data targetCharacterData = GetLowHpCharacterData(TEAM_TYPE.ENEMY);
            List <Vector2>      moveList            = (List <Vector2>)data.table ["moveList"];
            int frameCount = (int)data.table ["frameCount"];
            List <CharacterModel.Data> enemyList = GetTeamCharacterDataList(TEAM_TYPE.ENEMY);

            //ターゲットの近くになったら更新
            //逃げる
            if (targetCharacterData != null &&
                !_isEscape &&
                (targetCharacterData.BlockPos - character.BlockPos).magnitude < MAIN_MOVE_UPDATE_THRESHOLD)
            {
                moveList  = MoveTargetBlock(character.ActorId, GetRandomPos());
                _isEscape = true;
            }
            //通常思考
            else if (targetCharacterData != null &&
                     (moveList.Count <= 0 || frameCount >= UPDATE_SEARCH_ROUTE_FRAME_THRESHOLD))
            {
                moveList   = MoveTargetBlock(character.ActorId, targetCharacterData.BlockPos);
                frameCount = 0;
                _isEscape  = false;
            }

            //自分の正面に敵がいたら停止
            if (!_isEscape)
            {
                for (int i = 0; i < enemyList.Count; i++)
                {
                    if (enemyList[i].Hp <= 0)
                    {
                        continue;
                    }

                    if (CheckFrontEnemy(character, enemyList[i]))
                    {
                        return;
                    }
                }
            }

            if (character.IsMoveEnable &&
                moveList.Count > 0)
            {
                //経路探索されたもので移動
                Move(character.ActorId, GetVecToMoveType(moveList[0] - character.BlockPos));
                moveList.RemoveAt(0);
            }

            frameCount++;

            data.table["frameCount"] = frameCount;
            data.table["moveList"]   = moveList;
        }
Ejemplo n.º 15
0
Archivo: Echo.cs Proyecto: g1527066/CFM
        //---------------------------------------------------
        // UpdateAI
        //---------------------------------------------------
        override public void UpdateAI()
        {
            //ステージデータ取ってくるときのサンプル
            int[,] stageData = GetStageData();

            for (int y = 0; y < stageData.GetLength(0); y++)
            {
                for (int x = 0; x < stageData.GetLength(1); x++)
                {
                    //Debug.Log("stage" + y + " : " + x );

                    //通常ブロック
                    if (stageData[y, x] == (int)Define.Stage.BLOCK_TYPE.NORMAL)
                    {
                        //Debug.Log("通常ブロック");
                    }
                    else if (stageData[y, x] == (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                    {
                        //Debug.Log("障害物ブロック");
                    }
                    else if (stageData[y, x] == (int)Define.Stage.BLOCK_TYPE.NONE)
                    {
                        //Debug.Log("ブロックなし");
                    }
                }
            }

            //自チームのデータを取得
            List <CharacterModel.Data> playerList = GetTeamCharacterDataList(TEAM_TYPE.PLAYER);

            //敵チームのデータ取得
            List <CharacterModel.Data> enemyList = GetTeamCharacterDataList(TEAM_TYPE.ENEMY);

            //移動のサンプル
            for (int i = 0; i < playerList.Count; i++)
            {
                CharacterModel.Data character = playerList[i];
                int id = character.ActorId;

                //自分がいるステージのブロックタイプを取得
                Define.Stage.BLOCK_TYPE type = GetBlockType(character.BlockPos);

                //敵用
                CharacterModel.Data EnemyCharacter = enemyList[i];
                int nEnemyId = EnemyCharacter.ActorId;
                //敵デバッグ
                //Debug.Log("EnemyID:"+ nEnemyId + "EnemyPos(X):" + EnemyCharacter.BlockPos.x + "EnemyPos(Y):" + EnemyCharacter.BlockPos.y);

                //プレイヤーとエネミーの距離取得
                float fDis = Vector2.Distance(character.BlockPos, EnemyCharacter.BlockPos);
                //Debug.Log("Distance:" + fDis);

                //今現在の体力値
                float fLife = (float)character.Hp / character.MaxHp;

                //itemある時(取られてても行ってしまう)
                if (isItem == true && fLife < 0.8f && i == 0)
                {
                    if (itemPos.x == playerList[0].BlockPos.x && itemPos.y == playerList[0].BlockPos.y)
                    {
                        isItem = false;
                    }

                    Action(id, Define.Battle.ACTION_TYPE.ATTACK_LONG);
                    //x揃える
                    if (itemPos.x != playerList[0].BlockPos.x)
                    {
                        if (playerList[0].BlockPos.x < itemPos.x && stageData[(int)playerList[0].BlockPos.x + 1, (int)playerList[0].BlockPos.y] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                        {
                            Move(id, Common.MOVE_TYPE.RIGHT);
                        }
                        else if (playerList[0].BlockPos.x < itemPos.x && stageData[(int)playerList[0].BlockPos.x + -1, (int)playerList[0].BlockPos.y] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                        {
                            Move(id, Common.MOVE_TYPE.LEFT);
                        }
                        else
                        {
                            int move = UnityEngine.Random.Range(0, 4);
                            switch (move)
                            {
                            case 0:
                                //上移動
                                Move(id, Common.MOVE_TYPE.UP);
                                break;

                            case 1:
                                //下移動
                                Move(id, Common.MOVE_TYPE.DOWN);
                                break;

                            case 2:
                                //左移動
                                Move(id, Common.MOVE_TYPE.LEFT);
                                break;

                            case 3:
                                //右移動
                                Move(id, Common.MOVE_TYPE.RIGHT);
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (playerList[0].BlockPos.y < itemPos.y && stageData[(int)playerList[0].BlockPos.x, (int)playerList[0].BlockPos.y + 1] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                        {
                            Move(id, Common.MOVE_TYPE.UP);
                        }
                        else if (playerList[0].BlockPos.y > itemPos.y && stageData[(int)playerList[0].BlockPos.x, (int)playerList[0].BlockPos.y - 1] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                        {
                            Move(id, Common.MOVE_TYPE.DOWN);
                        }
                        else
                        {
                            int move = UnityEngine.Random.Range(0, 4);
                            switch (move)
                            {
                            case 0:
                                //上移動
                                Move(id, Common.MOVE_TYPE.UP);
                                break;

                            case 1:
                                //下移動
                                Move(id, Common.MOVE_TYPE.DOWN);
                                break;

                            case 2:
                                //左移動
                                Move(id, Common.MOVE_TYPE.LEFT);
                                break;

                            case 3:
                                //右移動
                                Move(id, Common.MOVE_TYPE.RIGHT);
                                break;
                            }
                        }
                    }
                }
                // エノキド担当(10割~8割)
                else if (fLife >= 0.8f)
                {
                    if (character.BlockPos.x < EnemyCharacter.BlockPos.x)
                    {
                        //右移動
                        Move(id, Common.MOVE_TYPE.RIGHT);
                        Debug.Log("right move");
                    }
                    else if (character.BlockPos.x > EnemyCharacter.BlockPos.x)
                    {
                        //左移動
                        Move(id, Common.MOVE_TYPE.LEFT);
                        Debug.Log("left move");
                    }
                    else if (character.BlockPos.y < EnemyCharacter.BlockPos.y)
                    {
                        //上移動
                        Move(id, Common.MOVE_TYPE.UP);
                        Debug.Log("up move");
                    }
                    else if (character.BlockPos.y > EnemyCharacter.BlockPos.y)
                    {
                        //下移動
                        Move(id, Common.MOVE_TYPE.DOWN);
                        Debug.Log("down move");
                    }

                    //アクションのサンプル
                    if (fDis >= 3)
                    {
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_SHORT);
                    }
                    else if (fDis >= 7) //中距離攻撃
                    {
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_MIDDLE);
                    }
                    else if (fDis >= 10)
                    {
                        //長距離攻撃
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_LONG);
                    }
                    else
                    {
                        //無敵アクション
                        Action(id, Define.Battle.ACTION_TYPE.INVINCIBLE);
                        break;
                    }
                }
                //タカハシ担当(8割~3割)
                else if (fLife >= 0.3f)
                {
                    if (fDis <= 5.0f)
                    {
                        Debug.Log("Distance Flag");

                        if (character.BlockPos.x < EnemyCharacter.BlockPos.x)
                        {
                            //右移動
                            Move(id, Common.MOVE_TYPE.RIGHT);
                            Debug.Log("right move");
                        }
                        else if (character.BlockPos.x > EnemyCharacter.BlockPos.x)
                        {
                            //左移動
                            Move(id, Common.MOVE_TYPE.LEFT);
                            Debug.Log("left move");
                        }
                        else if (character.BlockPos.y < EnemyCharacter.BlockPos.y)
                        {
                            //上移動
                            Move(id, Common.MOVE_TYPE.UP);
                            Debug.Log("up move");
                        }
                        else if (character.BlockPos.y > EnemyCharacter.BlockPos.y)
                        {
                            //下移動
                            Move(id, Common.MOVE_TYPE.DOWN);
                            Debug.Log("down move");
                        }
                    }
                    else
                    {
                        int move = UnityEngine.Random.Range(0, 4);
                        switch (move)
                        {
                        case 0:
                            //上移動
                            Move(id, Common.MOVE_TYPE.UP);
                            break;

                        case 1:
                            //下移動
                            Move(id, Common.MOVE_TYPE.DOWN);
                            break;

                        case 2:
                            //左移動
                            Move(id, Common.MOVE_TYPE.LEFT);
                            break;

                        case 3:
                            //右移動
                            Move(id, Common.MOVE_TYPE.RIGHT);
                            break;
                        }
                    }

                    //アクションのサンプル
                    switch (UnityEngine.Random.Range(0, 3))
                    {
                    case 0:
                        //中距離攻撃
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_MIDDLE);
                        break;

                    case 1:
                        //長距離攻撃
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_LONG);
                        break;

                    case 2:
                        //無敵アクション
                        Action(id, Define.Battle.ACTION_TYPE.INVINCIBLE);
                        break;
                    }
                }
                //ミカド担当(3割~0割)
                else
                {
                    //直線に敵がいたら逃げる
                    bool isStraight   = false; //ストレートにいるか
                    bool isHorizontal = false; //方向、trueなら水平上
                    int  enemyId      = 0;
                    int  distance     = 100;   //近さ、近いほど逃げる

                    for (int enemyCount = 0; enemyCount < enemyList.Count; enemyCount++)
                    {
                        if (playerList[i].BlockPos.x == enemyList[enemyCount].BlockPos.x)//縦一列
                        {
                            float temp = playerList[i].BlockPos.y - enemyList[enemyCount].BlockPos.y;
                            //近かったら更新
                            if (distance > Mathf.Abs(temp))
                            {
                                isHorizontal = false;
                                distance     = (int)Mathf.Abs(temp);
                                isStraight   = true;
                                enemyId      = enemyCount;
                                Debug.Log("x軸");
                            }
                        }
                        else if (playerList[i].BlockPos.y == enemyList[enemyCount].BlockPos.y)//横一列
                        {
                            float temp = playerList[i].BlockPos.y - enemyList[enemyCount].BlockPos.y;

                            if (distance > Mathf.Abs(temp))
                            {
                                Debug.Log("y軸");
                                isHorizontal = true;
                                distance     = (int)Mathf.Abs(temp);
                                isStraight   = true;
                                enemyId      = enemyCount;
                            }
                        }
                    }

                    if (isStraight == true)
                    {
                        if (isHorizontal == true)//水平のとき
                        {
                            //上下に逃げ道が無ければ敵と逆に、それも無理なら敵と逆方向
                            if (playerList[i].BlockPos.y < stageData.GetLength(0) - 1 &&
                                stageData[(int)playerList[i].BlockPos.x, (int)playerList[i].BlockPos.y + 1] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                            {
                                Move(id, Common.MOVE_TYPE.UP);
                            }
                            else if (playerList[i].BlockPos.y != 0 && stageData[(int)playerList[i].BlockPos.x, (int)playerList[i].BlockPos.y - 1] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                            {
                                Move(id, Common.MOVE_TYPE.DOWN);
                            }
                            else
                            {
                                if (playerList[i].BlockPos.x < stageData.GetLength(1) - 1 && enemyList[enemyId].BlockPos.x < playerList[i].BlockPos.x &&
                                    stageData[(int)playerList[i].BlockPos.x + 1, (int)playerList[i].BlockPos.y] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                                {
                                    Move(id, Common.MOVE_TYPE.RIGHT);
                                }
                                else
                                {
                                    Move(id, Common.MOVE_TYPE.LEFT);
                                }
                            }
                        }
                        else
                        {
                            //左右に逃げ道が無ければ敵と逆に
                            //→
                            if (playerList[i].BlockPos.x < stageData.GetLength(1) - 1 &&
                                stageData[(int)playerList[i].BlockPos.x + 1, (int)playerList[i].BlockPos.y] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                            {
                                Move(id, Common.MOVE_TYPE.RIGHT);
                            }
                            else if (playerList[i].BlockPos.x != 0 && stageData[(int)playerList[i].BlockPos.x - 1, (int)playerList[i].BlockPos.y] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                            {
                                Move(id, Common.MOVE_TYPE.LEFT);
                            }
                            else
                            {
                                if (playerList[i].BlockPos.y < stageData.GetLength(0) - 1 && enemyList[enemyId].BlockPos.y < playerList[i].BlockPos.y &&
                                    stageData[(int)playerList[i].BlockPos.x, (int)playerList[i].BlockPos.y + 1] != (int)Define.Stage.BLOCK_TYPE.OBSTACLE)
                                {
                                    Move(id, Common.MOVE_TYPE.UP);
                                }
                                else
                                {
                                    Move(id, Common.MOVE_TYPE.DOWN);
                                }
                            }
                        }
                    }
                    else//一旦ランダム //近い奴から逃げるようにする(時間あれば
                    {
                        int move = UnityEngine.Random.Range(0, 4);
                        switch (move)
                        {
                        case 0:
                            //上移動
                            Move(id, Common.MOVE_TYPE.UP);
                            break;

                        case 1:
                            //下移動
                            Move(id, Common.MOVE_TYPE.DOWN);
                            break;

                        case 2:
                            //左移動
                            Move(id, Common.MOVE_TYPE.LEFT);
                            break;

                        case 3:
                            //右移動
                            Move(id, Common.MOVE_TYPE.RIGHT);
                            break;
                        }
                    }

                    //無敵できる状態だったら1%で無敵になる
                    //フレームごとにやってしまってるので1%で十分
                    //今できるかどうか取得できないので、
                    if (Random.Range(0, 100) < 1)
                    {
                        Action(id, Define.Battle.ACTION_TYPE.INVINCIBLE);
                    }
                    //判定できないのでいつも発射
                    //攻撃しながら逃げる
                    ////アクションのサンプル
                    switch (UnityEngine.Random.Range(0, 3))
                    {
                    case 0:
                        //近距離攻撃
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_SHORT);
                        break;

                    case 1:
                        //中距離攻撃
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_MIDDLE);
                        break;

                    case 2:
                        //長距離攻撃
                        Action(id, Define.Battle.ACTION_TYPE.ATTACK_LONG);
                        break;
                    }
                }
            }
        }