예제 #1
0
    // MDAxMTAwMDAxMDEwMDExMDExMDAwMDAwMTAxMDAwMDAxMDAwMDEwMDAwMTAwMDEwMTAwMDAxMTExMTAwMDEwMDAxMDEwMDAxMDAwMTEwMDEwMTAwMDExMDExMTAwMTExMDAxMDAwMTAwMTEwMDAxMTAxMDAwMDEwMTAwMDEwMDAwMDEwMDAwMTAwMDEwMDAwMDAwMDAxMDAwMDAxMDAwMTEwMDAwMDAwMDExMDAwMDEwMDAxMTAwMDAwMDAwMTEwMDAwMTAwMDExMDAwMDAwMDAxMDAwMDAxMDAwMTEwMDAwMDAwMDAxMDAwMDEwMDAxMDAwMDAwMDAwMTEwMDAxMDAwMDEwMDAwMDA=
    void SetCloseToKingEvent(MapBoard _mcBoard)
    {
        Unit myKing = GetKing(this.team, _mcBoard, "KING");

        // Unit myKing = GetKing(this.team);
        // Debug.Log(myKing.xz_position[0]+","+myKing.xz_position[1]+":"+myKing.team);
        int[,] marea = _mcBoard.GetMoveArea(myKing.xz_position[0], myKing.xz_position[1], 4, myKing.team);
        for (int i = 0; i < marea.GetLength(0); i++)
        {
            for (int j = 0; j < marea.GetLength(1); j++)
            {
                if (marea[i, j] < 0 || marea[i, j] == 4)
                {
                    continue;
                }

                // 移動範囲+攻撃範囲に敵 or 味方がいるか
                for (int k = 0; k < myKing.attackRange.GetLength(0); k++)
                {
                    int tmp_i = i + myKing.attackRange[k, 0];
                    int tmp_j = j + myKing.attackRange[k, 1];
                    // 敵との距離でフラグ設定
                    Unit tmp_enemy = _mcBoard.GetMapBoardUnit(tmp_i, tmp_j);
                    if (IsTeamMate(tmp_enemy) == myKing.enemy_team)
                    {
                        SetFlag(Constants.F_CLOSE_TO_F_KING_ENEMY);
                    }
                    else if (IsTeamMate(tmp_enemy) == myKing.team)
                    {
                        SetFlag(Constants.F_CLOSE_TO_F_KING_FRIEND);
                    }
                }
            }
        }
    }
예제 #2
0
    List <Unit> GetTargetEnemys(MapBoard _mcBoard)
    {
        List <Unit> tmp_taeget_enemy = new List <Unit>();

        // attackRange;
        for (int i = 0; i < attackRange.GetLength(0); i++)
        {
            // 攻撃範囲に敵がいるか調べる
            int  tmp_x     = xz_position[0] + attackRange[i, 0];
            int  tmp_z     = xz_position[1] + attackRange[i, 1];
            Unit tmp_mCube = _mcBoard.GetMapBoardUnit(tmp_x, tmp_z);
            // ターゲットならターゲットを攻撃!!
            if (target_position[0] == tmp_x && target_position[1] == tmp_z && IsTeamMate(tmp_mCube) == this.enemy_team)
            {
                tmp_taeget_enemy.Clear();
                tmp_taeget_enemy.Add(tmp_mCube);
                break;
            }
            if (IsTeamMate(tmp_mCube) == this.enemy_team)
            {
                tmp_taeget_enemy.Add(tmp_mCube);
            }
        }
        return(tmp_taeget_enemy);
    }
예제 #3
0
    public void ViewArea(MapBoard _mcBoard)
    {
        int top_value = SetTopValue(this.state);

        int[] next_position = new int[2] {
            xz_position[0], xz_position[1]
        };

        int[,] marea = _mcBoard.GetMoveArea(xz_position[0], xz_position[1], locomotion, this.team);
        old_marea    = (int[, ])marea.Clone();
        for (int i = 0; i < marea.GetLength(0); i++)
        {
            for (int j = 0; j < marea.GetLength(1); j++)
            {
                if (marea[i, j] >= 0)
                {
                    // 仲間なら飛ばす 自分なら飛ばさない
                    if (IsTeamMate(_mcBoard.GetMapBoardUnit(i, j)) == this.team)
                    {
                        continue;
                    }
                    _mcBoard.DrawBlock(i, j, marea[i, j]);
                    int tmp_dist1 = GetManhattanDistance(new int[2] {
                        i, j
                    }, target_position);
                    int tmp_dist2 = GetManhattanDistance(xz_position, new int[2] {
                        i, j
                    });
                    int tmp_dist = tmp_dist1 * 6 + tmp_dist2;
                    if (IsGoodValue(this.state, top_value, tmp_dist) == 0 && Random.value < 0.5f)
                    {
                        top_value     = tmp_dist;
                        next_position = new int[2] {
                            i, j
                        };
                    }
                    else if (IsGoodValue(this.state, top_value, tmp_dist) == 1)
                    {
                        top_value     = tmp_dist;
                        next_position = new int[2] {
                            i, j
                        };
                    }
                }
            }
        }
        // もしどれも良くないなら
        if (top_value == SetTopValue(this.state))
        {
            next_position[0] = xz_position[0];
            next_position[1] = xz_position[1];
        }

        _mcBoard.SetMapBoard(xz_position[0], xz_position[1], null);
        _mcBoard.DrawBlock(next_position[0], next_position[1], 4);       // min_position = 目的地
        List <string> path = GetPath(marea, next_position[0], next_position[1]);

        if (path.Count > 0)
        {
            float     sum_time     = 0.3f;
            float     play_time    = 0.5f;
            Vector3   now_position = this.gameObject.transform.position;
            Vector3[] path_array   = new Vector3[path.Count];
            for (int i = 0; i < path.Count; i++)
            {
                path_array[i] = now_position;
            }
            for (int i = 0; i < path.Count; i++)
            {
                if (i == 0)
                {
                    path_array[i] += GetRoot(path[i]);
                }
                else
                {
                    path_array[i] = path_array[i - 1] + GetRoot(path[i]);
                }
                play_time += 0.2f;
            }
            _mcBoard.SetMapBoard(xz_position[0], xz_position[1], this);
            animator.SetInteger("animation", 14);
            if (path_array.Length == 1)
            {
                TemplateMove(path_array[0], play_time, sum_time, "Animated", _mcBoard, this.gameObject);
            }
            else
            {
                TemplateMoveArray(path_array, play_time, sum_time, "Animated", _mcBoard, this.gameObject);
            }
        }
        else
        {
            _mcBoard.SetMapBoard(xz_position[0], xz_position[1], this);
            Animated(_mcBoard);
        }
    }
예제 #4
0
    void SetDistanceEvent(MapBoard _mcBoard)
    {
        if (sub_enemy_targets == null)
        {
            sub_enemy_targets = new List <Unit>();
        }
        else
        {
            sub_enemy_targets.Clear();
        }
        if (sub_friend_targets == null)
        {
            sub_friend_targets = new List <Unit>();
        }
        else
        {
            sub_friend_targets.Clear();
        }

        int[,] marea = _mcBoard.GetMoveArea(xz_position[0], xz_position[1], this.locomotion, this.team);
        for (int i = 0; i < marea.GetLength(0); i++)
        {
            for (int j = 0; j < marea.GetLength(1); j++)
            {
                if (marea[i, j] < 0 || marea[i, j] == this.locomotion)
                {
                    continue;
                }

                // 移動範囲+攻撃範囲に敵 or 味方がいるか
                for (int k = 0; k < attackRange.GetLength(0); k++)
                {
                    int tmp_i = i + attackRange[k, 0];
                    int tmp_j = j + attackRange[k, 1];
                    // 敵との距離でフラグ設定
                    Unit tmp_enemy = _mcBoard.GetMapBoardUnit(tmp_i, tmp_j);
                    if (IsTeamMate(tmp_enemy) == this.enemy_team)
                    {
                        // Debug.Log(marea[i,j]+":"+tmp_i+","+tmp_j);
                        if (this.state == Constants.S_ATK_KING && tmp_enemy.type == "KING")
                        {
                        }
                        else
                        {
                            SetFlag(Constants.F_E_APPRECIABLE);
                            // 攻撃候補を取得
                            if (!sub_enemy_targets.Contains(tmp_enemy))
                            {
                                sub_enemy_targets.Add(tmp_enemy);
                            }
                        }
                    }
                    else if (IsTeamMate(tmp_enemy) == this.team)
                    {
                        SetFlag(Constants.F_F_APPRECIABLE);
                        // 攻撃候補を取得
                        if (!sub_friend_targets.Contains(tmp_enemy))
                        {
                            sub_friend_targets.Add(tmp_enemy);
                        }
                    }
                }
            }
        }
    }