コード例 #1
0
    public void MoveObject(int newX, int newY, GameObject obj)
    {
        int x         = newX;
        int y         = newY;
        int newWorldX = DisplayBlocksXCenter;          // Center X
        int newWorldY = DisplayBlocksYCenter;          // Center Y

        if (newX < 0)
        {
            newWorldX -= 1;
            x          = MapRows + newX;
        }
        if (newX >= MapRows)
        {
            newWorldX += 1;
            x          = newX - MapRows;
        }
        if (newY < 0)
        {
            newWorldY -= 1;
            y          = MapCols + newY;
        }
        if (newY >= MapCols)
        {
            newWorldY += 1;
            y          = newY - MapCols;
        }
        GameObject   newWorld     = worlds[newWorldX, newWorldY];
        MapBlockView mapBlockView = newWorld.GetComponent <MapBlockView> ();

        if (mapBlockView != null)
        {
            mapBlockView.AddObject(x, y, obj);
        }
    }
コード例 #2
0
    // checks if a position in the map is open
    public bool isMapPositionOpen(int screenSpaceX, int screenSpaceY)
    {
        bool retval  = false;
        int  worldsx = ((screenSpaceX / MapRows) - (Worldx)) + DisplayBlocksXCenter;
        int  worldsy = ((screenSpaceY / MapCols) - (Worldy)) + DisplayBlocksYCenter;
        int  x       = screenSpaceX % MapRows;
        int  y       = screenSpaceY % MapCols;

        if (worldsx >= 0 && worldsx < DisplayBlocksXSize && worldsy >= 0 && worldsy < DisplayBlocksYSize)
        {
            MapBlockView mapBlockView = this.mapBlocks [worldsx, worldsy];
            if (mapBlockView != null && mapBlockView.mapBlockData != null)
            {
                retval = mapBlockView.mapBlockData.getMainResource(x, y) == "" && mapBlockView.mapBlockData.getFloorResource(x, y) != "Flooring/Water";
            }
        }
        return(retval);
    }
コード例 #3
0
    void InstantiateMap(MapBlockData mapData, int Worldx, int Worldy, int x, int y, YieldDirection yieldDirection)
    {
        GameObject world = GameObject.Find(getWorldName(Worldx, Worldy));

        if (world == null)
        {
            world      = (GameObject)Instantiate(prefabMapBlockView, new Vector3(0, 0, 0), Quaternion.identity, prefabParent.transform);
            world.name = getWorldName(Worldx, Worldy);
            world.transform.position = calculateTransformPosition(Worldx, Worldy);

            MapBlockView mapBlockView = world.GetComponent <MapBlockView> ();
            if (mapBlockView == null)
            {
                throw new MissingComponentException("Expected to find the MapBlockView Component");
            }
            mapBlockView.AutoSave = AutoSave;
            worlds [x, y]         = world;
            this.mapBlocks [x, y] = mapBlockView;
            StartCoroutine(mapBlockView.Initialize(Worldx, Worldy, mapData, getMapPath(Worldx, Worldy, saveMapDataPath), yieldDirection, resourceManager, this));
        }
    }