예제 #1
0
 public Island(MainForm contextForm, MapWorld world, MapIsland island)
 {
     InitializeComponent();
     _contextForm = contextForm;
     _world       = world;
     _island      = island;
 }
    //<summary>セーブデータからワールドを作成</summary>
    static public MapWorld createFromSave(string aFilePath, MyMap aMap)
    {
        MapSaveFileData tSaveData = new MapSaveFileData(aFilePath);

        //マップデータを記憶
        mData            = tSaveData;
        mWorld           = initWorld(new Vector3Int(mData.mStratums[0].mFeild[0].Count, mData.mStratums.Count, mData.mStratums[0].mFeild.Count));
        mWorld.mMap      = aMap;
        mWorld.mMapName  = mData.mMapName;
        mWorld.mFileData = mData;
        mWorld.mSaveData = tSaveData;

        //マップファイルへのパス
        mWorld.mMapPath = tSaveData.mFilePath;

        //生成
        createFromFileData();

        //生成完了
        foreach (MapBehaviour tBehaviour in mWorld.GetComponentsInChildren <MapBehaviour>())
        {
            tBehaviour.placed();
        }

        MapWorld tCreatedWorld = mWorld;

        mWorld = null;
        mData  = null;
        return(tCreatedWorld);
    }
예제 #3
0
 private void initWorld()
 {
     type = 0;
     dinamincCamera = new DinamicCamera(
         this,
         new Rectangle(0, 0, WORLD_SIZE, WORLD_SIZE),
         new Rectangle(WORLD_LOCATION.X, WORLD_LOCATION.Y, CURRENT_SIZE, CURRENT_SIZE),
         1);
     miniCamera = new Camera(
         mini_map,
         new Rectangle(0, 0, WORLD_SIZE, WORLD_SIZE),
         new Rectangle(0, 0, mini_map.Width, mini_map.Height),
         true);
     normalCamera = new Camera(
         normal_map,
         new Rectangle(0, 0, WORLD_SIZE, WORLD_SIZE),
         new Rectangle(0, 0, normal_map.Width, normal_map.Height),
         true);
     tempCamera = new Camera(
         temp_map,
         new Rectangle(0, 0, WORLD_SIZE / CELL_SIZE, WORLD_SIZE / CELL_SIZE),
         new Rectangle(0, 0, temp_map.Width, temp_map.Height),
         true);
     world = new MapWorld(new Size(WORLD_SIZE / CELL_SIZE, WORLD_SIZE / CELL_SIZE));
     world.Engine.AddPost(
         dinamincCamera,
         //miniCamera,
         //normalCamera,
         tempCamera
         );
 }
예제 #4
0
파일: City.cs 프로젝트: Daubiht/Project-TLJ
 public City(MainForm contextForm, MapWorld world, MapCity City)
 {
     InitializeComponent();
     _contextForm = contextForm;
     _world       = world;
     _city        = City;
 }
예제 #5
0
    /// <summary>
    /// 将一个场景物体转换为信息(string)
    /// </summary>
    /// <param name="root"></param>
    /// <returns></returns>
    public string GetSceneInfo()
    {
        MapWorld mapWorld = new MapWorld();

        List <MapObject> mapobjs = new List <MapObject>();
        int childCount           = mapNameRoot.childCount;

        for (int i = 0; i < childCount; i++)
        {
            Transform item = mapNameRoot.GetChild(i);
            MapObject mop  = new MapObject();
            mop.name     = item.name;
            mop.isStatic = item.gameObject.isStatic;
            mop.transformInfo.position = item.localPosition;
            mop.transformInfo.rotation = item.localRotation.eulerAngles;
            mop.transformInfo.scale    = item.localScale;

            MonoBehaviour[] mos = item.GetComponents <MonoBehaviour>();
            foreach (MonoBehaviour m in mos)
            {
                ClassValue cv = new ClassValue(m);
                mop.behavirComponets.Add(cv);
            }
            mapobjs.Add(mop);
        }
        mapWorld.mapObjects = mapobjs;

        mapWorld.lightPrefab = mapLightRoot.name;
        return(JsonUtils.ClassOrStructToJson(mapWorld));
    }
예제 #6
0
 public World(MapWorld w, MainForm contextForm, bool militia)
 {
     InitializeComponent();
     _w           = w;
     _contextForm = contextForm;
     _militia     = militia;
 }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("E Button Down");

            Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Debug.Log(string.Format("Mouse click at [X: {0} Y: {0}]", pos.x, pos.y));

            float   startTime   = Time.realtimeSinceStartup;
            MapTile clickedTile = MapWorld.GetMapTileAt((int)pos.x, (int)pos.y);
            clickedTile.traversable     = !clickedTile.traversable;
            clickedTile.materialSurface = clickedTile.traversable ? (ushort)1 : (ushort)2;
            Debug.Log("Time(1): " + ((Time.realtimeSinceStartup - startTime) * 1000f));

            UpdateGroundTile(clickedTile);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            Debug.Log("R Button Down");

            Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Debug.Log(string.Format("Mouse click at [X: {0} Y: {0}]", pos.x, pos.y));

            UpdateGrowthTile(new MapGrowth {
                locationX  = (int)pos.x,
                locationY  = (int)pos.y,
                quantity   = 1,
                growthCode = 0
            });
        }
    }
예제 #8
0
파일: MapObj.cs 프로젝트: kylinzlkz/RPGTest
    public virtual void InitB2Edge(MapWorld mapBase, Vector2 start, Vector2 end, short collisionId = 0, bool isActive = true)
    {
        curMap     = mapBase;
        b2Body     = BodyFactory.CreateEdge(mapBase.b2World, start, end, this);
        m_isActive = isActive;

        InitCollisionEvent(b2Body.FixtureList[0]);
        //InitDefaultGroup(b2Body);
    }
예제 #9
0
파일: MapObj.cs 프로젝트: kylinzlkz/RPGTest
    public virtual void InitB2Circle(MapWorld mapBase, float radius, float density = 0, Vector2 position = new Vector2(), BodyType bodyType = BodyType.Static, short collisionId = 0, bool isActive = true)
    {
        curMap     = mapBase;
        b2Body     = BodyFactory.CreateCircle(mapBase.b2World, radius, density, position, bodyType, this);
        m_isActive = isActive;

        InitCollisionEvent(b2Body.FixtureList[0]);
        //InitDefaultGroup(b2Body);
    }
예제 #10
0
    private void UpdateGrowthTile(MapGrowth newGrowth)
    {
        float startTime = Time.realtimeSinceStartup;

        MapWorld.SetGrowth(newGrowth);
        Debug.Log("Time(SetTile): " + ((Time.realtimeSinceStartup - startTime) * 1000f));

        UpdateGrowthTilemap(newGrowth);
        Debug.Log("Time(UpdateGrowthTilemap): " + ((Time.realtimeSinceStartup - startTime) * 1000f));
    }
예제 #11
0
    public void OnChangeMap(MapWorld mapworld, float posX, float posY, float width, float height, short collisionId = 0)
    {
        InitB2Rectangle(mapworld, width, height, 10, new Vector2(posX, posY), 0, BodyType.Dynamic, collisionId);

        m_body.SleepingAllowed = false;
        m_iCollisionCount      = 0;
        ClearCollisionInfo();
        m_forceFieldDic.Clear();
        ClearAction();
    }
예제 #12
0
파일: MapObj.cs 프로젝트: kylinzlkz/RPGTest
    public virtual void InitB2Rectangle(MapWorld mapBase, float width, float height, float density = 0, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, short collisionId = 0, bool isActive = true)
    {
        curMap = mapBase;
        b2Body = BodyFactory.CreateRectangle(mapBase.b2World, width, height, density, position, rotation, bodyType, this);
        b2Body.FixedRotation = true;
        m_isActive           = isActive;

        InitCollisionEvent(b2Body.FixtureList[0]);
        //InitDefaultGroup(b2Body);
    }
예제 #13
0
    static public MapCamera init(MapWorld aWorld)
    {
        MapCamera tCamera = MyBehaviour.create <MapCamera>();

        tCamera.mWorld    = aWorld;
        tCamera.mCamera   = tCamera.createChildCamera(aWorld.mSize.y);
        tCamera.mConfig   = new MapCameraConfig();
        tCamera.positionZ = -10;
        return(tCamera);
    }
예제 #14
0
파일: MapObj.cs 프로젝트: kylinzlkz/RPGTest
 public virtual void Clear()
 {
     userData = null;
     if (null != b2Body && null != curMap && null != curMap.world)
     {
         curMap.world.RemoveBody(b2Body);
         b2Body.UserData = null;
         b2Body          = null;
         curMap          = null;
     }
 }
예제 #15
0
    private void SetWalls()
    {
        for (int i = 0; i < walls.Length; i++)
        {
            MapTile tile = MapWorld.GetMapTileAt(walls[i].x, walls[i].y);
            tile.traversable     = false;
            tile.materialSurface = 2;

            MapWorld.SetTile(tile);
        }
    }
예제 #16
0
    private void UpdateGroundTile(MapTile newTile)
    {
        float startTime = Time.realtimeSinceStartup;

        MapWorld.SetTile(newTile);
        Debug.Log("Time(SetTile): " + ((Time.realtimeSinceStartup - startTime) * 1000f));

        UpdateGroundTilemap(newTile);
        Debug.Log("Time(UpdateTileMap): " + ((Time.realtimeSinceStartup - startTime) * 1000f));
        PathNodesNA.Dispose();
        SetPathNodes();
        Debug.Log("Time(SetPathNodes): " + ((Time.realtimeSinceStartup - startTime) * 1000f));
    }
예제 #17
0
 public void CreateNewWorld()
 {
     if (curMapData == null)
     {
         return;
     }
     if (curMapWorld == null)
     {
         curMapWorld = new MapWorld();
     }
     curMapWorld.Dispose();
     curMapWorld.Init(curMapData);
     curMapWorld.CreateColliders(curMapData.m_colliderDatas);
 }
예제 #18
0
        public Notifications(MapWorld contextWorld, MainForm contextForm)
        {
            InitializeComponent();
            _contextWorld = contextWorld;
            _contextForm  = contextForm;

            List <Notification> listNotifs = contextWorld.Notifs.ListNotif;

            Label[] listLabels = { notif1, notif2, notif3, notif4, notif5, notif6, notif6, notif7, notif8, notif9, notif10 };

            for (int i = 0; i < contextWorld.Notifs.ListNotif.Count; i++)
            {
                listLabels[i].Text = listNotifs[i].Name + " - " + listNotifs[i].Description + " - " + listNotifs[i].Date;
            }
        }
예제 #19
0
 ///<summary>マップ読み込み</summary>
 public void load(string aFilePath)
 {
     if (mEncountSystem == null)
     {
         mEncountSystem = new MapEncoutSystem();
     }
     //ワールドを再生成
     if (mWorld != null)
     {
         mWorld.delete();
     }
     mWorld      = MapWorldFactory.create(aFilePath, this);
     mWorld.mMap = this;
     mWorld.name = "world";
     mWorld.transform.SetParent(this.transform, false);
 }
예제 #20
0
파일: Save.cs 프로젝트: Daubiht/Project-TLJ
        public Save(MapWorld contextWorld, MainForm contextForm)
        {
            InitializeComponent();
            _contextForm = contextForm;
            _contextWorld = contextWorld;

            RadioButton[] radioButtons = { radioButton1, radioButton2, radioButton3, radioButton4, radioButton5 };
            string[] fileName = Directory.GetFiles(@"../../../Saves");

            for (int i = 0; i < fileName.Length; i++)
            {
                fileName[i] = fileName[i].Substring(15);
                radioButtons[(int)Char.GetNumericValue(fileName[i][0]) - 1].Text = fileName[i].Substring(0, fileName[i].Length - 5);
                radioButtons[(int)Char.GetNumericValue(fileName[i][0]) - 1].Enabled = true;
            }
        }
예제 #21
0
파일: MapObj.cs 프로젝트: kylinzlkz/RPGTest
    public virtual void InitB2Polygon(MapWorld mapBase, List <Vector2> points, float density = 0, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, short collisionId = 0, bool isActive = true)
    {
        curMap = mapBase;
        if (points == null)
        {
            return;
        }
        Vertices vertices = new Vertices(points.Count);

        for (int i = 0; i < points.Count; i++)
        {
            vertices.Add(points[i]);
        }
        b2Body     = BodyFactory.CreatePolygon(mapBase.b2World, vertices, density, position, rotation, bodyType, this);
        m_isActive = isActive;

        InitCollisionEvent(b2Body.FixtureList[0]);
    }
예제 #22
0
    ///<summary>セーブデータ読み込み</summary>
    public void loadSaveData(string aFilePath)
    {
        //セーブデータ読み込み
        MapSaveFileData tSaveData = new MapSaveFileData(aFilePath);

        mEncountSystem = new MapEncoutSystem();
        mEncountSystem.setCount(tSaveData.mEncountCount);

        //ワールドを再生成
        if (mWorld != null)
        {
            mWorld.delete();
        }
        mWorld      = MapWorldFactory.createFromSave(aFilePath, this);
        mWorld.mMap = this;
        mWorld.name = "world";
        mWorld.transform.SetParent(this.transform, false);
    }
예제 #23
0
    private void SetGroundTilemap()
    {
        Vector3Int[] locations = new Vector3Int[MapWorld.GetTotalNumMapTiles()];
        TileBase[]   tileArray = new TileBase[MapWorld.GetTotalNumMapTiles()];

        for (int i = 0; i < MapWorld.mapRegions.Length; i++)
        {
            MapTile[] mapTilesInRegion = MapWorld.mapRegions[i].mapTiles;

            for (int j = 0; j < mapTilesInRegion.Length; j++)
            {
                locations[i * mapTilesInRegion.Length + j] = new Vector3Int(mapTilesInRegion[j].locationX, mapTilesInRegion[j].locationY, 0);
                tileArray[i * mapTilesInRegion.Length + j] = tileForGround[mapTilesInRegion[j].materialSurface];
            }
        }

        groundTilemap.GetComponent <Tilemap>().SetTiles(locations, tileArray);
    }
예제 #24
0
        public Instance(MainForm context, MapWorld world, MapInstance instance)
        {
            InitializeComponent();
            _contextForm          = context;
            _world                = world;
            _instance             = instance;
            _world.ActualPosition = _instance.listZones[0];

            ToolTip toolTip = new ToolTip();

            toolTip.ReshowDelay  = 500;
            toolTip.ShowAlways   = true;
            toolTip.AutoPopDelay = 32000;

            string info = "Pour quitter l'instance," + Environment.NewLine + " vous devez retourner à l'entrée ou trouver une sortie.";

            toolTip.SetToolTip(Retour, info);
        }
예제 #25
0
    /// <summary>worldを生成しコンテナを追加</summary>
    static private MapWorld initWorld(Vector3Int aSize)
    {
        MapWorld tWorld = MyBehaviour.create <MapWorld>();

        tWorld.name  = "world";
        tWorld.mSize = aSize;
        //tWorld.gameObject.AddComponent<SortingGroup>();
        //カメラ
        tWorld.mCameraContainer      = MyBehaviour.create <MyBehaviour>();
        tWorld.mCameraContainer.name = "cameraContainer";
        tWorld.mCameraContainer.transform.SetParent(tWorld.transform, false);
        //フィールド
        tWorld.mField      = MyBehaviour.create <MyBehaviour>();
        tWorld.mField.name = "field";
        tWorld.mField.transform.SetParent(tWorld.transform, false);
        //階層
        tWorld.mStratums = new MapStratum[aSize.z];
        //マス
        tWorld.mCells = new MapCell[aSize.x, aSize.y, aSize.z];
        //マップ周りの壁壁
        tWorld.mEndContainer      = MyBehaviour.create <MyBehaviour>();
        tWorld.mEndContainer.name = "endContainer";
        tWorld.mEndContainer.transform.SetParent(tWorld.transform, false);
        //character
        tWorld.mCharacterContainer      = MyBehaviour.create <MyBehaviour>();
        tWorld.mCharacterContainer.name = "characterContainer";
        tWorld.mCharacterContainer.transform.SetParent(tWorld.transform, false);
        //ornament
        tWorld.mOrnamentContainer      = MyBehaviour.create <MyBehaviour>();
        tWorld.mOrnamentContainer.name = "ornamentContainer";
        tWorld.mOrnamentContainer.transform.SetParent(tWorld.transform, false);
        //entityInCell
        tWorld.mEntityInCellContainer      = MyBehaviour.create <MyBehaviour>();
        tWorld.mEntityInCellContainer.name = "entityInCellContainer";
        tWorld.mEntityInCellContainer.transform.SetParent(tWorld.transform, false);
        //trigger
        tWorld.mTriggerContainer      = MyBehaviour.create <MyBehaviour>();
        tWorld.mTriggerContainer.name = "triggerContainer";
        tWorld.mTriggerContainer.transform.SetParent(tWorld.transform, false);
        //event処理システム
        tWorld.mEventSystem = new MapEventSystem(tWorld);
        return(tWorld);
    }
예제 #26
0
    private void CreateWorld()
    {
        MapRegion[] mapRegions = new MapRegion[worldSizeByRegions * worldSizeByRegions];

        for (int i = 0; i < mapRegions.Length; i++)
        {
            mapRegions[i] = new MapRegion {
                mapTiles   = GetDefaultMapTiles(regionSize),
                regionSize = regionSize,
                locationX  = 0,
                locationY  = 0
            };
        }

        MapWorld = new MapWorld {
            mapRegions         = mapRegions,
            regionSize         = regionSize,
            mapHeightByRegions = 1,
            mapWidthByRegions  = 1,
            mapGrowths         = new SpatialHash2D()
        };
    }
예제 #27
0
파일: Optimize.cs 프로젝트: RomaMig/World
 public Optimize(MapWorld world)
 {
     brightnesses = new MapBrightnesses(world.Width * Form1.CELL_SIZE, world.Height * Form1.CELL_SIZE);
     paintables   = new MapPaintables(world.Width * Form1.CELL_SIZE, world.Height * Form1.CELL_SIZE);
     before       = new Rectangle();
     for (int i = 0; i < world.Width; i++)
     {
         for (int j = 0; j < world.Height; j++)
         {
             for (int n = 0; n < world[i, j].Width; n++)
             {
                 for (int m = 0; m < world[i, j].Height; m++)
                 {
                     int cx = i * world[i, j].Width + n;
                     int cy = j * world[i, j].Height + m;
                     brightnesses[cx, cy] = world[i, j][n, m].Height as IBrightness;
                     paintables[cx, cy]   = world[i, j][n, m].Height as IPaintable;
                 }
             }
         }
     }
     Clear();
 }
예제 #28
0
파일: MapObj.cs 프로젝트: kylinzlkz/RPGTest
    public virtual void InitB2Body(MapWorld mapBase, float x, float y, float width, float height, BodyType bodyType = BodyType.Static, short collisionId = 0, bool isActive = true)
    {
        curMap = mapBase;
        //b2Body = BodyFactory.CreateBody(mapBase.world);
        //b2Body.BodyType = bodyType;
        //b2Body.Position = new Vector2(x, y);
        //b2Body.SleepingAllowed = false;
        //b2Body.Mass = 1;
        //b2Body.CollisionPhase = collisionId;
        //b2Body.LinearDamping = 1.0f;
        //b2Body.UserData = this;
        //Vertices vertices = MapFunctions.MakeBoxVertices(width * 0.5f, height * 0.5f);
        //PolygonShape shape = new PolygonShape(vertices, 1f);
        //Fixture fixture = b2Body.CreateFixture(shape);

        Vector2 position = new Vector2(x, y);

        b2Body     = BodyFactory.CreateRectangle(mapBase.b2World, width, height, 0, position, 0, bodyType, this);
        m_isActive = isActive;

        InitCollisionEvent(b2Body.FixtureList[0]);
        //InitCollisionEvent(fixture);
        //InitDefaultGroup(b2Body);
    }
예제 #29
0
    /// <summary>
    /// エンカウントのカウントを進める
    /// </summary>
    /// <returns>エンカウントした場合はtrue</returns>
    /// <param name="aCharacter">Player Character</param>
    /// <param name="aWorld">MapWorld</param>
    static private bool encountCount(MapCharacter aCharacter, MapWorld aWorld)
    {
        Vector3Int tPosition = aCharacter.mFootCellPosition;
        MapCell    tCell     = aWorld.mCells[tPosition.x, tPosition.y, tPosition.z];

        //エンカウントしないマス
        if (tCell.mEncountKey == null || tCell.mEncountKey == "")
        {
            return(false);
        }

        //移動距離
        float tDeltaDistance = (aCharacter.mMovingData.mDeltaPrePosition.vector2 - aCharacter.mMapPosition.vector2).magnitude;

        if (!aWorld.mMap.mEncountSystem.count(tCell.mEncountFrequency * tDeltaDistance, tCell.mEncountKey))
        {
            return(false);
        }

        //エンカウントした
        aCharacter.mMovingData.mRemainingDistance = 0;
        aCharacter.mMovingData.mSpeak             = false;
        return(true);
    }
예제 #30
0
 public Militia(MainForm contextForm, MapWorld contextWorld)
 {
     InitializeComponent();
     _contextWorld = contextWorld;
     _contextForm  = contextForm;
 }