Example #1
0
    /// <summary>
    /// エリア生成(実体化)/(データ化)
    /// </summary>
    /// <param name="go">生成するエリアのprefab</param>
    /// <param name="position">生成座標</param>
    /// <param name="angle">エリアの回る角度</param>
    void CreateArea(GameObject go, AreaPrefabManager areaManager, Vector2 position, AngleFix angle)
    {
        if (mode == MakeMode.MakeSceneMode)
        {
            if (areaContainer == null)
            {
                areaContainer = new GameObject("Environment");
            }
            GameObject gameObject = Instantiate(Resources.Load(go.name), new Vector3(position.x, 0, position.y), Quaternion.Euler(0, (int)angle, 0)) as GameObject;
            gameObject.transform.parent = areaContainer.transform;
        }
        else
        {
            areaDataList.Add(
                new AreaData(
                    GameController._instance.GetGoingToFloor(),
                    go.name,
                    position.x,
                    0,
                    position.y,
                    angle,
                    areaManager.GetAreaPrefabInfo(angle).width,
                    areaManager.GetAreaPrefabInfo(angle).height));


            bool isCreateEnemy = false;

            switch (areaManager.type)
            {
                case UnitType.Road:
                    isCreateEnemy = Random.value > 0.75;
                    break;
                case UnitType.Room:
                    isCreateEnemy = Random.value > 0.25;
                    break;
                case UnitType.End:
                    isCreateEnemy = Random.value > 0.5;
                    break;
                case UnitType.Corner:
                    isCreateEnemy = Random.value > 0.75;
                    break;
            }


            if (isCreateEnemy)
            {
                int enemyCount = Random.Range(1, areaManager.GetAreaPrefabInfo(angle).width * areaManager.GetAreaPrefabInfo(angle).height / 25);
                int enemyID = GameController._instance.GetRandomEnemyInfo().ID;
                enemyDataList.Add(
                    new EnemyPositionData(
                        GameController._instance.GetGoingToFloor(),
                        enemyID,
                        enemyCount,
                        GameController._instance.GetGoingToFloor() + 11,
                        position.x,
                        0.25f,
                        position.y,
                        areaManager.GetAreaPrefabInfo(angle).width,
                        areaManager.GetAreaPrefabInfo(angle).height
                    ));
            }
        }
    }
Example #2
0
    /// <summary>
    /// Simple AABB check
    /// </summary>
    /// <param name="position">エリアの中心座標 区域地点</param>
    /// <param name="areaManager">エリアの情報クラス 区域信息</param>
    /// <param name="angle">エリア回る角度 是否旋转</param>
    /// <returns>この検証を通過できるかどうか TRUE=通過 返回是否通过检测 TRUE=通过</returns>
    bool CheckAreaOverlay(Vector3 position, AreaPrefabManager areaManager, AngleFix angle)
    {
        AreaPrefabInfo info = areaManager.GetAreaPrefabInfo(angle);
        bool OverlayCheck = true;

        Vector3 relativePosition;

        for (int i = 0; i < areaDataList.Count; i++)
        {
            relativePosition = areaDataList[i].areaPosition - position;
            if (Mathf.Abs(relativePosition.x) < areaDataList[i].heightHalf + info.centerPointUp.magnitude &&
                Mathf.Abs(relativePosition.z) < areaDataList[i].widthHalf + info.centerPointLeft.magnitude
                )
            {
                OverlayCheck = false;
                break;
            }
        }
        return OverlayCheck;
    }
Example #3
0
    /// <summary>
    /// 検証:このエリアの生成場所は指定されたマップサイズに超えたか 验证该地区是否超过地图尺寸
    /// </summary>
    /// <param name="position">エリアの中心座標 区域地点</param>
    /// <param name="areaManager">エリアの情報クラス 区域信息</param>
    /// <param name="angle">エリア回る角度 是否旋转</param>
    /// <returns>この検証を通過できるかどうか TRUE=通過 返回是否通过检测 TRUE=通过</returns>
    bool checkInMap(Vector3 position, AreaPrefabManager areaManager, AngleFix angle)
    {
        AreaPrefabInfo info = areaManager.GetAreaPrefabInfo(angle);
        bool sizeCheck = checkSize(new Vector2(position.x, position.z), info.width, info.height);

        return sizeCheck;
    }
Example #4
0
    /// <summary>
    /// 検証:CapsuleCastを使用し、他のエリアと被るかどうか    用投影的方式确认该地区是否与其他地区重合
    /// </summary>
    /// <param name="position">エリアの中心座標 区域地点</param>
    /// <param name="areaManager">エリアの情報クラス 区域信息</param>
    /// <param name="angle">エリア回る角度 是否旋转</param>
    /// <returns>この検証を通過できるかどうか TRUE=通過 返回是否通过检测 TRUE=通过</returns>
    bool CheckAreaPhysics(Vector3 position, AreaPrefabManager areaManager, AngleFix angle)
    {
        AreaPrefabInfo info = areaManager.GetAreaPrefabInfo(angle);
        bool physicsCheck = false;
        //left to right
        if (info.width > info.height)
        {
            //width>height:左から右までのCapsuleCast検証 宽大于长,从左到右
            physicsCheck = Physics.CapsuleCast(
          position + new Vector3(0, 100, info.centerPointLeft.z + 1 + info.centerPointUp.magnitude > 0 ? 0 : info.centerPointLeft.z + 1 + info.centerPointUp.magnitude),
          position + new Vector3(0, 100, info.centerPointRight.z - 1 - info.centerPointUp.magnitude < 0 ? 0 : info.centerPointRight.z - 1 - info.centerPointUp.magnitude),
            info.centerPointUp.magnitude - 1f,
            Vector3.down);
        }
        else
        {
            //height>width:上から下までのCapsuleCast検証 长大于宽,从上到下
            physicsCheck = Physics.CapsuleCast(
          position + new Vector3(info.centerPointUp.x + 1 + info.centerPointLeft.magnitude > 0 ? 0 : info.centerPointUp.x + 1 + info.centerPointLeft.magnitude, 100, 0),
          position + new Vector3(info.centerPointDown.x - 1 - info.centerPointLeft.magnitude < 0 ? 0 : info.centerPointDown.x - 1 - info.centerPointLeft.magnitude, 100, 0),
            info.centerPointLeft.magnitude - 1f,
            Vector3.down);
        }

        //Debug.Log(physicsCheck);
        return !physicsCheck;
    }