Ejemplo n.º 1
0
    public static Mesh GenerateGridMesh(MapSettings settings, MeshSettings meshSettings)
    {
        Mesh mesh = new Mesh();

        Vector2 bottomLeft;

        if (meshSettings.isCentered)
        {
            bottomLeft = new Vector2(-settings.width, -settings.height) * meshSettings.cellScale * 0.5f + new Vector2(meshSettings.mapOffsetX, -meshSettings.mapOffsetZ);
        }
        else
        {
            bottomLeft = new Vector2(meshSettings.mapOffsetX, -meshSettings.mapOffsetZ);
        }

        Vector3[] vertices  = new Vector3[settings.width * settings.height * 4];
        Vector2[] uv        = new Vector2[vertices.Length];
        int[]     triangles = new int[settings.width * settings.height * 6]; //6 = 2 triangles * 3 vertices
        Color[]   colors    = new Color[vertices.Length];

        float vertexOffset = meshSettings.cellScale;

        int vert = 0;
        int tri  = 0;

        for (int y = 0; y < settings.height; y++)
        {
            for (int x = 0; x < settings.width; x++)
            {
                Vector3 cellOffset = new Vector3(x * meshSettings.cellScale, 0.0f, y * meshSettings.cellScale) + new Vector3(bottomLeft.x, 0.0f, bottomLeft.y);

                vertices[vert]     = cellOffset;                                                    //bottom left
                vertices[vert + 1] = new Vector3(vertexOffset, 0.0f, 0.0f) + cellOffset;            //bottom right
                vertices[vert + 2] = new Vector3(0.0f, 0.0f, vertexOffset) + cellOffset;            //top left
                vertices[vert + 3] = new Vector3(vertexOffset, 0.0f, vertexOffset) + cellOffset;    //top right

                uv[vert]     = new Vector2((float)x / settings.width, (float)y / settings.height);
                uv[vert + 1] = new Vector2((float)(x + 1) / settings.width, (float)y / settings.height);
                uv[vert + 2] = new Vector2((float)x / settings.width, (float)(y + 1) / settings.height);
                uv[vert + 3] = new Vector2((float)(x + 1) / settings.width, (float)(y + 1) / settings.height);

                colors[vert] = colors[vert + 1] = colors[vert + 2] = colors[vert + 3] = settings.tilesColors[Random.Range(0, settings.tilesColors.Length)];

                triangles[tri + 2] = vert++;                        //_ _ 1 | _ _ _
                triangles[tri + 1] = triangles[tri + 3] = vert++;   //_ 2 1 | 2 _ _
                triangles[tri]     = triangles[tri + 4] = vert++;   //3 2 1 | 2 3 _
                triangles[tri + 5] = vert++;                        //3 2 1 | 2 3 4
                tri += 6;
            }
        }

        mesh.name      = "Discrete Mesh";
        mesh.vertices  = vertices;
        mesh.uv        = uv;
        mesh.triangles = triangles;
        mesh.colors    = colors;
        mesh.RecalculateNormals();

        return(mesh);
    }
Ejemplo n.º 2
0
    public PlayerController(MapSettings mapSetting)
    {
        this.mapSetting = mapSetting;
        players         = new Player[mapSetting.numberOfPlayer];

        CreatePlayers();
    }
Ejemplo n.º 3
0
    public void GenerateTilesWorldMap(int[,] worldMap, int[,] wallTilesMap)
    {
        MapSettings middleMapSettings = Instantiate((MapSettings)Resources.Load("Scriptables/MapSettings/MiddleLayer"));
        MapSettings bottomMapSettings = Instantiate((MapSettings)Resources.Load("Scriptables/MapSettings/BottomLayer"));

        float seed = Time.time.GetHashCode();

        worldMap = MapFunctions.RandomWalkTop(worldMap, wallTilesMap, seed);
        worldMap = MapFunctions.PerlinNoiseCave(worldMap, bottomMapSettings.modifier);

        // Création des 3 tunnels
        var startPosX = worldMap.GetUpperBound(0) / 6;

        worldMap = MapFunctions.DirectionalTunnel(worldMap, middleMapSettings.minPathWidth, middleMapSettings.maxPathWidth,
                                                  middleMapSettings.maxPathChange, middleMapSettings.roughness, middleMapSettings.windyness, startPosX);
        var startPosX2 = worldMap.GetUpperBound(0) / 2;

        worldMap = MapFunctions.DirectionalTunnel(worldMap, middleMapSettings.minPathWidth, middleMapSettings.maxPathWidth,
                                                  middleMapSettings.maxPathChange, middleMapSettings.roughness, middleMapSettings.windyness, startPosX2);
        var startPosX3 = worldMap.GetUpperBound(0) * 0.80f;

        worldMap = MapFunctions.DirectionalTunnel(worldMap, middleMapSettings.minPathWidth, middleMapSettings.maxPathWidth,
                                                  middleMapSettings.maxPathChange, middleMapSettings.roughness, middleMapSettings.windyness, (int)startPosX3);
        // generate irons
        // MapFunctions.GenerateIrons(worldMap);
        // add grass
        // worldMap = MapFunctions.AddGrassOntop(worldMap);
    }
Ejemplo n.º 4
0
    void Start()
    {
        Event.SetActive(true);

        for (int i = 0; i < 64; i++)
        {
            ScoreboardUIS.Add(ScoresObject.transform.GetChild(i).GetComponent <ScoreUI>());
        }

        RaceData             = new MapSettings();
        RaceData.PlayerCount = 1;

        SceneManager.sceneLoaded += OnSceneLoaded;

        Application.targetFrameRate = 60;

        for (int i = 0; i < 4; i++)
        {
            BodyIndex[i]  = Previews[i].BodyIndex;
            WheelIndex[i] = Previews[i].WheelIndex;

            BodyTexts[i].text  = KartBodies[BodyIndex[i]].Name;
            WheelTexts[i].text = KartWheels[WheelIndex[i]].Name;
        }

        MapName.text        = AllTracks[MapIndex].TrackName;
        MapDescription.text = AllTracks[MapIndex].TrackDescription;
        MapIcon.texture     = AllTracks[MapIndex].Icon;

        ToggleKarts();
    }
Ejemplo n.º 5
0
    /*
     * All the players get added here
     **/
    public void InstantiatePlayers(bool inEditor)
    {
        MapSettings settings = GetComponentInParent <MapSettings>();

        Hexagon[] getSpawnPositions = GetSpawnPositions(numberOfPlayers);

        childCount = transform.childCount;
        for (int i = 0; i < numberOfPlayers; i++)
        {
            if (childCount - 1 >= i)
            {
                CheckForCompatibilityWithCurrentVersion(i, inEditor);
            }

            if (childCount - 1 < i)
            {
                GameObject playerBall = Instantiate(ball);
                playerBall.name             = "Player" + (i + 1);
                playerBall.transform.parent = this.transform;
            }

            Ball player = transform.GetChild(i).GetComponent <Ball>();
            players.Add(player);
            player.GoToSpawnPosition(getSpawnPositions[i], settings.GetSpawnPositionOffset(), true);

            CameraFollow camera = GetCameraScript();
            camera.GetReady(player.transform);

            player.GetStarted(i);
        }
    }
Ejemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        instance   = this;
        playerName = PlayerPrefs.GetString("Player Name");                     //get saved player settings for their name

        DirectoryInfo levelDir = new DirectoryInfo("Assets/Resources/Levels"); //load all the levels

        FileInfo[] levelInfo = levelDir.GetFiles("*.*");

        foreach (FileInfo level in levelInfo)
        {
            if (level.Name.EndsWith(".xml"))
            {
                MapSettings newLevelDisplay = new MapSettings();
                newLevelDisplay.mapName     = level.Name.Remove(level.Name.Length - 4);
                newLevelDisplay.mapLoadName = level.Name.Remove(level.Name.Length - 4);
                MapList.Add(newLevelDisplay);
            }
        }

        if (MapList.Count > 0)
        {
            currentMap = MapList[0];
        }

        skins = Resources.LoadAll("Skins");
    }
Ejemplo n.º 7
0
    public static GameSettings Make(GameConfigs configs)
    {
        eGame gameType = configs._gameType;

        if (gameType == eGame.Sandbox)
        {
            return(new GameSettings(configs));
        }
        else if (gameType == eGame.Exodus)
        {
            return(new GameSettings(eGame.Exodus,
                                    eEndCondition.Survival,
                                    new MapSettings(configs._mapConfigs),
                                    PlayerSettings.ExodusSettings(),
                                    TickSettings.ExodusSettings()));
        }
        else if (gameType == eGame.HotSeat)
        {
            return(new GameSettings(eGame.HotSeat,
                                    eEndCondition.LastOneStanding,
                                    MapSettings.HotseatSettings(),
                                    new PlayerSettings(configs._playerConfigs),
                                    TickSettings.HotseatSettings()));
        }
        else
        {
            throw new System.NotImplementedException();
        }
    }
Ejemplo n.º 8
0
 public Settings()
 {
     basicSettings  = new BasicSettings();
     mapSettings    = new MapSettings();
     lightSettings  = new LightSettings();
     effectSettings = new EffectSettings();
 }
Ejemplo n.º 9
0
    public void GetStarted(int playerNumber)
    {
        Game.hasStarted = false;
        Game.isPaused = false;
        
        firstSpawnPosition = transform.position;
        this.playerNumber = playerNumber;        
        rb = GetComponent<Rigidbody>();
        timer = GetComponentInChildren<Timer>();
        tiles = GameObject.Find("Map/Tiles").GetComponent<Tiles>();
        tileColorsIntroduction = tiles.GetComponent<TileColorsIntroduction>(); // Get the script for the colour introduction
        settings = GameObject.Find("Map").GetComponent<MapSettings>();
        lastSpawnOffset = settings.GetSpawnPositionOffset();        
        cameraFollow = GetPlayerCamera().GetComponent<CameraFollow>();
        skipButton = GetComponentInChildren<SkipButton>();
        tutorialManager = GetComponentInChildren<TutorialManager>(true);
        accelerometerInformation = GetComponentInChildren<AccelorometerReading>(true).transform.parent.gameObject;

        GameObject loseTile = GameObject.Find("Map/UntaggedGameObjects/LoseHeight");
        loseHeight = loseTile.transform.position.y;
        rb.constraints = RigidbodyConstraints.FreezeAll;
        timer.GetReady();
        SceneTransitionValues.record = timer.GetBestTime();
        SceneTransitionValues.alreadyEnteredEndScreen = false;

        if(SceneTransitionAudio.Instance != null)
        {
            SceneTransitionAudio.Instance.gameObject.GetComponent<AudioSource>().Stop();
        }
 
        StartCoroutine(Introduction(cameraFollow, skipButton));
    }
Ejemplo n.º 10
0
    public void Confirm()
    {
        MapSettings save = new MapSettings();

        //Map setting
        save.Ncicles          = int.Parse(Nclicles.text);
        save.MapWidth         = int.Parse(MapWidth.text);
        save.MapHeight        = int.Parse(MapHeight.text);
        save.AmountCells      = int.Parse(amountCells.text);
        save.AmountCleanWalls = int.Parse(amountCleanWalls.text);

        //OBJ's Settings 1
        save.XmoduleChest  = int.Parse(XModuleChest.text);
        save.YmoduleChest  = int.Parse(YModuleChest.text);
        save.XmodulePlayer = int.Parse(XModulePlayer.text);
        save.YmodulePlayer = int.Parse(YModulePlayer.text);

        //OBJ's Settings 2
        save.AmountFlower  = int.Parse(AmountFlower.text);
        save.XmoduleFlower = int.Parse(XModuleFlower.text);
        save.AmountEnemy   = int.Parse(AmountEnemy.text);
        save.XmoduleEnemy  = int.Parse(XModuleEnemy.text);
        save.YmoduleEnemy  = int.Parse(YModuleEnemy.text);


        JsonConfig = JsonUtility.ToJson(save);

        Debug.Log("Saving as JSON: " + JsonConfig);
    }
Ejemplo n.º 11
0
        public void Init()
        {
            Settings = _session.GetMapSettings();

            // todo: remove the requirement to manually subscribe with IHandleCommand<...> ?
            _messageHub.Subscribe(this, CommandType.PlaceTile);

            var tiles    = _session.GetTiles();
            var terrains = _session.GetTerrains();

            for (var x = 0; x < Settings.Width; x++)
            {
                for (var y = 0; y < Settings.Height; y++)
                {
                    var worldX  = x * CellSize;
                    var worldY  = y * CellSize;
                    var terrain = new Terrain(TerrainType.Empty, null, Settings.Width, Settings.Height);
                    if (!terrains.ContainsKey(terrain.Key))
                    {
                        terrains.Add(terrain.Key, terrain);
                    }

                    tiles[x, y] = new Tile(worldX, worldY, terrain.Key);
                }
            }
        }
Ejemplo n.º 12
0
        private static MapSettings GetMapSettings(Map map,
                                                  IEnumerable <Wall> walls,
                                                  IEnumerable <Bonus> bonuses,
                                                  IEnumerable <Trap> traps,
                                                  IEnumerable <StartPoint> startPoints,
                                                  IEnumerable <MapBot> mapBots)
        {
            var mapSettings = new MapSettings(
                map.Id,
                map.Width,
                map.Height,
                map.InitialPower,
                map.StrengthWeight,
                map.StaminaWeight,
                map.RangedWeight,
                map.MaxStepCount ?? int.MaxValue,
                map.BonusSpawnInterval,
                map.BulletSpeed,
                map.ActionTimeout,
                map.MemoryLimit,
                walls.Select(w => new BotWorld.Wall(w.Id, w.X, w.Y)).ToList(),
                bonuses.Select(b => new BotWorld.Bonus(b.Id, b.X, b.Y, b.Power)).ToList(),
                traps.Select(t => new BotWorld.Trap(t.Id, t.X, t.Y, t.Damage)).ToList(),
                startPoints.Select(p => new Core.StartPoint(p.X, p.Y, mapBots.FirstOrDefault(mb => mb.StartPointId == p.Id)?.BotId)).ToList());

            return(mapSettings);
        }
Ejemplo n.º 13
0
    // Start is called before the first frame update
    void Start()
    {
        DontDestroyOnLoad(gameObject);
        GameObject mapSelectionData = GameObject.Find("MapSelectionObject");

        if (mapSelectionData != null)
        {
            this.hardModeEnabled = mapSelectionData.GetComponent <MapSelectionObject>().hardmodeEnabled;
        }

        if (!hardModeEnabled)
        {
            currentMap = map1.GetComponent <MapSettings>();
            map1.SetActive(true);
            map2.SetActive(false);
        }
        else
        {
            currentMap = map2.GetComponent <MapSettings>();
            map1.SetActive(false);
            map2.SetActive(true);
        }

        GameObject selData = GameObject.Find("PlayerSelectionData");

        if (selData != null)
        {
            playerColors = selData.GetComponent <PlayerSelectionData>().playerColors;
        }
        tutorialImage.enabled = true;
        ChangeState(GameState.PREP);
    }
Ejemplo n.º 14
0
    void OnMenuStart()
    {
        GameNameInputField.text = "Room:" + Random.Range(0, 9999);
        PhotonNetwork.AutomaticallySyncScene = true;
        Dropdown.OptionData[]      m_NewData;
        List <Dropdown.OptionData> m_Messages = new List <Dropdown.OptionData>();

        DropdownMaps.ClearOptions();
        PlayerNameInputfield.text = "Player:" + Random.Range(0, 9999);
        SetPlayername(PlayerNameInputfield.text);
        //Debug.Log(GameManager.instance.CurrentMap.MapName);
        MapSettings[] mapnames = new MapSettings[GameManager.instance.GetAllMap().Length];
        mapnames  = GameManager.instance.GetAllMap();
        m_NewData = new Dropdown.OptionData[mapnames.Length];

        for (int i = 0; i < mapnames.Length; i++)
        {
            m_NewData[i]      = new Dropdown.OptionData();
            m_NewData[i].text = mapnames[i].MapName;
            m_Messages.Add(m_NewData[i]);
        }
        DropdownMaps.AddOptions(m_Messages);
        SelectedMapPreview.sprite = GameManager.instance.MapList[0].MapLoadImage;
        SelectedGameTypeText.text = GameManager.instance.CurrentGameType.GameTypeLoadName;
    }
Ejemplo n.º 15
0
        public void SaveMapSettings(MapSettings settings)
        {
            if (!Directory.Exists(propsPath))
            {
                Directory.CreateDirectory(propsPath);
            }

            File.Create(propsPath + settings.name + ".properties").Dispose();
            using (StreamWriter SW = File.CreateText(propsPath + settings.name + ".properties"))
            {
                SW.WriteLine("#Lava Survival properties for " + settings.name);
                SW.WriteLine("fast-chance = " + settings.fast);
                SW.WriteLine("killer-chance = " + settings.killer);
                SW.WriteLine("destroy-chance = " + settings.destroy);
                SW.WriteLine("water-chance = " + settings.water);
                SW.WriteLine("layer-chance = " + settings.layer);
                SW.WriteLine("layer-height = " + settings.layerHeight);
                SW.WriteLine("layer-count = " + settings.layerCount);
                SW.WriteLine("layer-interval = " + settings.layerInterval);
                SW.WriteLine("round-time = " + settings.roundTime);
                SW.WriteLine("flood-time = " + settings.floodTime);
                SW.WriteLine("block-flood = " + settings.blockFlood.ToString());
                SW.WriteLine("block-layer = " + settings.blockLayer.ToString());
                SW.WriteLine(String.Format("safe-zone = {0}-{1}", settings.safeZone[0].ToString(), settings.safeZone[1].ToString()));
            }
        }
Ejemplo n.º 16
0
    public static MapSettings HotseatSettings()
    {
        eMap              mapType         = eMap.Basic;
        eTileShape        tileShape       = eTileShape.Square;
        int               xDim            = 19;
        int               yDim            = 19;
        bool              wrapEastWest    = false;
        bool              wrapNorthSouth  = false;
        float             percentOcean    = 0.3f;
        float             percentRiver    = 0.01f;
        int               expansionFactor = 0;
        WaterBodyPrefence wbp             = WaterBodyPrefence.Continent;

        MapSettings settings = new MapSettings(mapType,
                                               tileShape,
                                               xDim,
                                               yDim,
                                               wrapEastWest,
                                               wrapNorthSouth,
                                               percentOcean,
                                               percentRiver,
                                               expansionFactor,
                                               wbp);

        return(settings);
    }
Ejemplo n.º 17
0
    public static Map Generate(MapSettings settings)
    {
        var board = new Map();

        Generate(board, settings);
        return(board);
    }
Ejemplo n.º 18
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Debug.LogError("OOPSALA we have an ERROR! More than one instance bein created");
            Destroy(gameObject);
        }

        _mapSettings = transform.parent.GetComponent <MapSettings>();
        if (_mapSettings == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _nodeBuilder = transform.parent.GetComponentInChildren <NodeBuilder>();
        if (_nodeBuilder == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _GridLocToScriptLookup = new Dictionary <Vector3, CubeLocationScript>();
    }
            public void SetUp()
            {
                var settings = new MapSettings();

                playerRepository = new Mock <IPlayerRepository>();
                players          = new List <Player> {
                    new Player {
                        Name = "Gimli", X = 0, Y = 0, IsIt = false
                    },
                    new Player {
                        Name = "Darth Vader", X = 10, Y = 10, IsIt = true
                    },
                    new Player {
                        Name = "Gandalf", X = 25, Y = 29, IsIt = false
                    },
                    new Player {
                        Name = "Frodo", X = 25, Y = 0, IsIt = false
                    }
                };
                playerRepository.Setup(x => x.GetAllPlayers()).Returns(players);
                ClassUnderTest = new MapImageBuilder(playerRepository.Object, settings);
                var imageBytes = ClassUnderTest.BuildImage();

                image = new MagickImage(imageBytes, MagickFormat.Png);
            }
Ejemplo n.º 20
0
        public Map(MapSettings settings)
        {
            _settings = settings;

            Create();
            _availableTiles = TotalTiles;
        }
Ejemplo n.º 21
0
    public IEnumerator ChangeSceneRoutine(string newMapName, LoadSceneMode mode, bool doUnloadPrevScene)
    {
        MapSettings map = Resources.Load <MapSettings>("MapSettings/" + newMapName);

        if (map.BackgroundMusic != null)
        {
            eventCtrl.BroadcastEvent(typeof(FadeAudioEvent), new FadeAudioEvent(null, 0, 2, 0.05f));
        }

        if (doUnloadPrevScene && mode == LoadSceneMode.Additive)
        {
            Scene          originalScene = SceneManager.GetSceneByName(CurrentMap.SceneName);
            AsyncOperation op2           = SceneManager.UnloadSceneAsync(originalScene);
            yield return(new WaitUntil(() => op2.isDone));
        }

        AsyncOperation op = SceneManager.LoadSceneAsync(map.SceneName, mode);

        op.completed           += (AsyncOperation o) => { SceneManager.SetActiveScene(SceneManager.GetSceneByName(map.SceneName)); };
        op.allowSceneActivation = true;
        yield return(new WaitUntil(() => op.isDone));

        CurrentMap = map;

        IsChangingScene = false;

        eventCtrl.BroadcastEvent(typeof(ChangeUnitySceneCompleteEvent), new ChangeUnitySceneCompleteEvent());
        eventCtrl.BroadcastEvent(typeof(HideBlackOverlayEvent), new HideBlackOverlayEvent());

        if (map.BackgroundMusic != null)
        {
            eventCtrl.BroadcastEvent(typeof(PlayBackgroundClip), new PlayBackgroundClip(CurrentMap.BackgroundMusic));
        }
    }
Ejemplo n.º 22
0
    private static void GenerateRoomsAndCorridors(Map map, MapSettings settings, Random rng)
    {
        map.rooms = new Room[settings.numRooms.Random(rng)];

        map.corridors = new Corridor[map.rooms.Length - 1];

        map.rooms[0]     = new Room();
        map.corridors[0] = new Corridor();

        GenerateFirstRoom(map.rooms[0], settings, rng);

        GenerateCorridor(map.corridors[0], map.rooms[0], settings, true, rng);

        for (var i = 1; i < map.rooms.Length; i++)
        {
            map.rooms[i] = new Room();

            GenerateRoom(map.rooms[i], settings, map.corridors[i - 1], rng);

            if (i >= map.corridors.Length)
            {
                continue;
            }
            map.corridors[i] = new Corridor();

            GenerateCorridor(map.corridors[i], map.rooms[i], settings, false, rng);
        }
    }
Ejemplo n.º 23
0
        public void LoadMap(string name)
        {
            if (String.IsNullOrEmpty(name) || !HasMap(name))
            {
                return;
            }

            name = name.ToLower();
            Level oldMap = null;

            if (active && map != null)
            {
                oldMap = map;
            }
            CmdLoad.LoadLevel(null, name);
            map = LevelInfo.FindExact(name);

            if (map != null)
            {
                mapSettings = LoadMapSettings(name);
                mapData     = GenerateMapData(mapSettings);

                map.setPhysics(mapData.destroy ? 2 : 1);
                map.Config.PhysicsOverload = 1000000;
                map.Config.AutoUnload      = false;
                map.Config.LoadOnGoto      = false;
                Level.SaveSettings(map);
            }

            if (active && map != null)
            {
                sendingPlayers = true;
                try
                {
                    Player[] online = PlayerInfo.Online.Items;
                    foreach (Player pl in online)
                    {
                        pl.Game.RatedMap      = false;
                        pl.Game.PledgeSurvive = false;
                        if (pl.level == oldMap)
                        {
                            if (sendAfkMain && pl.IsAfk)
                            {
                                PlayerActions.ChangeMap(pl, Server.mainLevel);
                            }
                            else
                            {
                                PlayerActions.ChangeMap(pl, map);
                            }
                        }
                    }
                    oldMap.Unload(true, false);
                }
                catch { }
                sendingPlayers = false;

                StartRound();
            }
        }
Ejemplo n.º 24
0
    void Awake()
    {
        _gameManager = FindObjectOfType <GameManager>();
        if (_gameManager == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _locationManager = _gameManager._locationManager;
        if (_locationManager == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }


        _worldBuilder = GetComponentInChildren <WorldBuilder>();
        if (_worldBuilder == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _gridBuilder = GetComponentInChildren <GridBuilder>();
        if (_gridBuilder == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _cubeBuilder = GetComponentInChildren <CubeBuilder>();
        if (_cubeBuilder == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _mapPieceBuilder = GetComponentInChildren <MapPieceBuilder>();
        if (_mapPieceBuilder == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _outerZoneBuilder = GetComponentInChildren <OuterZoneBuilder>();
        if (_outerZoneBuilder == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }

        _nodeBuilder = GetComponentInChildren <NodeBuilder>();
        if (_nodeBuilder == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }



        _mapSettings = GetComponent <MapSettings>();
        if (_mapSettings == null)
        {
            Debug.LogError("OOPSALA we have an ERROR!");
        }
    }
Ejemplo n.º 25
0
        private static float GetWithEvent(MapSettings setting, float value)
        {
            var _event = new MapSettingEvent(setting, value);

            EventManager.Invoke(_event);

            return(_event.Canceled ? value : _event.Value);
        }
Ejemplo n.º 26
0
    public static void GenerateFirstRoom(Room room, MapSettings settings, Random rng)
    {
        room.roomWidth  = settings.roomWidth.Random(rng);
        room.roomHeight = settings.roomHeight.Random(rng);

        room.Position.X = Mathf.RoundToInt((settings.columns / 2f) - (room.roomWidth / 2f));
        room.Position.Y = Mathf.RoundToInt((settings.rows / 2f) - (room.roomHeight / 2f));
    }
 void Start()
 {
     _mapSettings = _gameManager._worldManager._mapSettings;
     if (_mapSettings == null)
     {
         Debug.LogError("OOPSALA we have an ERROR!");
     }
 }
Ejemplo n.º 28
0
    public void OnLoadMap()
    {
        MapSettings settings = MapManager.Instance.SelectedMapAsset.Settings;

        skillsCounter = new SkillsCounter(settings.SkillsCounter);
        GameEvents.UI.OnSkillsLoaded.SafeInvoke();
        //LevelController.TriggerLemmingUsedSkill();
    }
Ejemplo n.º 29
0
    public static void Generate(Map map, MapSettings settings)
    {
        var rng = SetUpRandom(settings);

        GenerateTilesArray(map, settings, rng);
        GenerateRoomsAndCorridors(map, settings, rng);

        SetMapData(map);
    }
Ejemplo n.º 30
0
 public MapHandler(MessageHub messageHub, ISession session, MapSettings settings)
 {
     _session    = session;
     _messageHub = messageHub;
     _messageHub.Post(new CreateMapCommand
     {
         MapSettings = settings
     });
 }
Ejemplo n.º 31
0
    public MapHandler(IMapLoader mapLoader, AssetBundle mapAsset, MapSettings mapSettings, int mapLayer)
    {
        this.mapLoader = mapLoader;
        this.bundle = mapAsset;
        this.mapSettings = mapSettings;
        this.mapLayer = mapLayer;

        this.mapOffset = new Vector3(mapSettings.length / 2, HUDConstants.MAP_HEIGHT, mapSettings.width / 2);
        this.mapBounds = new Rect();
    }
Ejemplo n.º 32
0
    public void setTarget(Transform target)
    {
        this.target = target;

        var bundle = AssetBundle.LoadFromFile(string.Format("{0}/{1}", System.IO.Directory.GetCurrentDirectory(), HUDConstants.PATH_MAP_BUNDLE));
        if (bundle == null)
        {
            Debug.Log("Settings data not found!");
            return;
        }
        var settingsData = bundle.mainAsset as TextAsset;
        var mapSettings = new MapSettings(settingsData.text);

        this.mapHandler = new MapHandler(this, bundle, mapSettings, LayerMask.NameToLayer(HUDConstants.LAYER_MAP));
        this.mapHandler.Start(target.position);
    }
Ejemplo n.º 33
0
    private static void CreateMapPlanesFromSelection()
    {
        // Get minimap data from file
        var settingsData = AssetDatabase.LoadMainAssetAtPath("Assets/Game/HUD/Code/Minimap/MinimapSettings.txt") as TextAsset;
        var mapSettings = new MapSettings(settingsData.text);

        var length = mapSettings.length;
        var width = mapSettings.width;

        var mesh = CreatePlanesMesh(length, width);

        // Create missing folders
        EditorHelper.CreateAssetFolderIfNotExists("Game/HUD/Models/Minimap");
        EditorHelper.CreateAssetFolderIfNotExists("Game/HUD/Materials/Minimap");
        EditorHelper.CreateAssetFolderIfNotExists("Game/HUD/Prefabs/Minimap");

        // Create minimap plane mesh
        AssetDatabase.CreateAsset(mesh, "Assets/Game/HUD/Models/Minimap/MinimapSegment.mesh");

        // Get all files from selection
        var selection = Selection.GetFiltered(typeof(Texture), SelectionMode.DeepAssets);
        if (selection != null) {
            for (int i = 0; i < selection.Length; i++) {
                // Parse texture
                var texture = selection[i] as Texture;
                if (texture != null) {
                    var mat = CreateMaterial(texture, texture.name);

                    // Create minimap plane material
                    AssetDatabase.CreateAsset(mat, string.Format("Assets/Game/HUD/Materials/Minimap/{0}.mat", texture.name));

                    // Create minimap prefab
                    var prefab = PrefabUtility.CreatePrefab(string.Format("Assets/Game/HUD/Prefabs/Minimap/{0}.prefab", texture.name), CreatePrefab(mesh, texture.name));

                    // Set prefab properties
                    prefab.GetComponent<Renderer>().sharedMaterial = mat;
                    prefab.GetComponent<MeshFilter>().sharedMesh = mesh;
                    prefab.GetComponent<MeshRenderer>().castShadows = false;
                    prefab.GetComponent<MeshRenderer>().receiveShadows = false;

                }
            }
            AssetDatabase.Refresh();
        }
    }
Ejemplo n.º 34
0
        public MapSettings LoadMapSettings(string name)
        {
            MapSettings settings = new MapSettings(name);
            if (!Directory.Exists(propsPath)) Directory.CreateDirectory(propsPath);
            if (!File.Exists(propsPath + name + ".properties"))
            {
                SaveMapSettings(settings);
                return settings;
            }

            foreach (string line in File.ReadAllLines(propsPath + name + ".properties"))
            {
                try
                {
                    if (line[0] != '#')
                    {
                        string[] sp;
                        string value = line.Substring(line.IndexOf(" = ") + 3);
                        switch (line.Substring(0, line.IndexOf(" = ")).ToLower())
                        {
                            case "fast-chance":
                                settings.fast = (byte)MathHelper.Clamp(decimal.Parse(value), 0, 100);
                                break;
                            case "killer-chance":
                                settings.killer = (byte)MathHelper.Clamp(decimal.Parse(value), 0, 100);
                                break;
                            case "destroy-chance":
                                settings.destroy = (byte)MathHelper.Clamp(decimal.Parse(value), 0, 100);
                                break;
                            case "water-chance":
                                settings.water = (byte)MathHelper.Clamp(decimal.Parse(value), 0, 100);
                                break;
                            case "layer-chance":
                                settings.layer = (byte)MathHelper.Clamp(decimal.Parse(value), 0, 100);
                                break;
                            case "layer-height":
                                settings.layerHeight = int.Parse(value);
                                break;
                            case "layer-count":
                                settings.layerCount = int.Parse(value);
                                break;
                            case "layer-interval":
                                settings.layerInterval = double.Parse(value);
                                break;
                            case "round-time":
                                settings.roundTime = double.Parse(value);
                                break;
                            case "flood-time":
                                settings.floodTime = double.Parse(value);
                                break;
                            case "block-flood":
                                sp = value.Split(',');
                                settings.blockFlood = new Pos(ushort.Parse(sp[0]), ushort.Parse(sp[1]), ushort.Parse(sp[2]));
                                break;
                            case "block-layer":
                                sp = value.Split(',');
                                settings.blockLayer = new Pos(ushort.Parse(sp[0]), ushort.Parse(sp[1]), ushort.Parse(sp[2]));
                                break;
                            case "safe-zone":
                                sp = value.Split('-');
                                string[] p1 = sp[0].Split(','), p2 = sp[1].Split(',');
                                settings.safeZone = new Pos[] { new Pos(ushort.Parse(p1[0]), ushort.Parse(p1[1]), ushort.Parse(p1[2])), new Pos(ushort.Parse(p2[0]), ushort.Parse(p2[1]), ushort.Parse(p2[2])) };
                                break;
                        }
                    }
                }
                catch (Exception e) { Server.ErrorLog(e); }
            }
            return settings;
        }
Ejemplo n.º 35
0
 public MapData GenerateMapData(MapSettings settings)
 {
     MapData data = new MapData(settings);
     data.killer = rand.Next(1, 101) <= settings.killer;
     data.destroy = rand.Next(1, 101) <= settings.destroy;
     data.water = rand.Next(1, 101) <= settings.water;
     data.layer = rand.Next(1, 101) <= settings.layer;
     data.fast = rand.Next(1, 101) <= settings.fast && !data.water;
     data.block = data.water ? (data.killer ? Block.activedeathwater : Block.water) : (data.fast ? (data.killer ? Block.fastdeathlava : Block.lava_fast) : (data.killer ? Block.activedeathlava : Block.lava));
     return data;
 }
Ejemplo n.º 36
0
        public void LoadMap(string name)
        {
            if (String.IsNullOrEmpty(name) || !HasMap(name)) return;

            name = name.ToLower();
            Level oldMap = null;
            if (active && map != null) oldMap = map;
            Command.all.Find("load").Use(null, name);
            map = Level.Find(name);

            if (map != null)
            {
                mapSettings = LoadMapSettings(name);
                mapData = GenerateMapData(mapSettings);

                map.setPhysics(mapData.destroy ? 2 : 1);
                map.motd = "Lava Survival: " + map.name.Capitalize();
                map.overload = 1000000;
                map.unload = false;
                map.loadOnGoto = false;
                Level.SaveSettings(map);
            }
            
            if (active && map != null)
            {
                sendingPlayers = true;
                try
                {
                    Player.players.ForEach(delegate(Player pl)
                    {
                        if (pl.level == oldMap)
                        {
                            if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, "");
                            else Command.all.Find("goto").Use(pl, map.name);
                        }
                    });
                    if (OnMapChange != null)
                        OnMapChange(oldMap, map);
                    oldMap.Unload(true, false);
                }
                catch { }
                sendingPlayers = false;

                StartRound();
            }
        }
Ejemplo n.º 37
0
 /// <summary>
 ///     マップ設定を書き出す
 /// </summary>
 /// <param name="map">マップ設定</param>
 /// <param name="writer">ファイル書き込み用</param>
 private static void WriteMap(MapSettings map, TextWriter writer)
 {
     if (map == null)
     {
         return;
     }
     writer.WriteLine();
     writer.WriteLine("map = {");
     writer.WriteLine("  {0} = all", map.All ? "yes" : "no");
     writer.WriteLine();
     foreach (int id in map.Yes)
     {
         writer.WriteLine("  yes = {0}", id);
     }
     foreach (int id in map.No)
     {
         writer.WriteLine("  no = {0}", id);
     }
     if (map.Top != null || map.Bottom != null)
     {
         writer.WriteLine();
     }
     if (map.Top != null)
     {
         writer.WriteLine("  top = {{ x = {0} y = {1} }}", map.Top.X, map.Top.Y);
     }
     if (map.Bottom != null)
     {
         writer.WriteLine("  bottom = {{ x = {0} y = {1} }}", map.Bottom.X, map.Bottom.Y);
     }
     writer.WriteLine("}");
 }
Ejemplo n.º 38
0
    private void LoadFolderSettings(string folderName)
    {
      if (folderName == string.Empty)
      {
        folderName = "root";
      }
      object o;
      FolderSettings.GetFolderSetting(folderName, "VideoFiles", typeof(MapSettings), out o);
      if (o != null)
      {
        _mapSettings = o as MapSettings;

        if (_mapSettings == null)
        {
          _mapSettings = new MapSettings();
        }

        CurrentSortAsc = _mapSettings.SortAscending;
        CurrentSortMethod = (VideoSort.SortMethod)_mapSettings.SortBy;
        currentLayout = (Layout)_mapSettings.ViewAs;
      }
      else
      {
        Share share = _virtualDirectory.GetShare(folderName);

        if (share != null)
        {
          if (_mapSettings == null)
          {
            _mapSettings = new MapSettings();
          }
          CurrentSortAsc = _mapSettings.SortAscending;
          CurrentSortMethod = (VideoSort.SortMethod)_mapSettings.SortBy;
          currentLayout = (Layout)share.DefaultLayout;
          CurrentLayout = (Layout)share.DefaultLayout;
        }
      }

      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        if (xmlreader.GetValueAsBool("movies", "rememberlastfolder", false))
        {
          xmlreader.SetValue("movies", "lastfolder", folderName);
        }
      }

      SwitchLayout();
      UpdateButtonStates();
    }
Ejemplo n.º 39
0
        /// <summary>
        ///     マップ設定を構文解析する
        /// </summary>
        /// <param name="lexer">字句解析器</param>
        /// <returns>マップ設定</returns>
        private static MapSettings ParseMap(TextLexer lexer)
        {
            // =
            Token token = lexer.GetToken();
            if (token.Type != TokenType.Equal)
            {
                Log.InvalidToken(LogCategory, token, lexer);
                return null;
            }

            // {
            token = lexer.GetToken();
            if (token.Type != TokenType.OpenBrace)
            {
                Log.InvalidToken(LogCategory, token, lexer);
                return null;
            }

            MapSettings map = new MapSettings();
            while (true)
            {
                token = lexer.GetToken();

                // ファイルの終端
                if (token == null)
                {
                    Log.MissingCloseBrace(LogCategory, "map", lexer);
                    break;
                }

                // } (セクション終端)
                if (token.Type == TokenType.CloseBrace)
                {
                    break;
                }

                // 無効なトークン
                if (token.Type != TokenType.Identifier)
                {
                    Log.InvalidToken(LogCategory, token, lexer);
                    lexer.SkipLine();
                    continue;
                }

                string keyword = token.Value as string;
                if (string.IsNullOrEmpty(keyword))
                {
                    continue;
                }
                keyword = keyword.ToLower();

                // yes
                if (keyword.Equals("yes"))
                {
                    // =
                    token = lexer.GetToken();
                    if (token.Type != TokenType.Equal)
                    {
                        Log.InvalidToken(LogCategory, token, lexer);
                        lexer.SkipLine();
                        continue;
                    }

                    // プロヴィンスID
                    token = lexer.GetToken();
                    if (token.Type == TokenType.Number)
                    {
                        map.Yes.Add((int) (double) token.Value);
                        continue;
                    }

                    if (token.Type == TokenType.Identifier)
                    {
                        string s = token.Value as string;
                        if (string.IsNullOrEmpty(s))
                        {
                            continue;
                        }
                        s = s.ToLower();

                        // all
                        if (s.Equals("all"))
                        {
                            map.All = true;
                            continue;
                        }
                    }

                    // 無効なトークン
                    Log.InvalidToken(LogCategory, token, lexer);
                    continue;
                }

                // no
                if (keyword.Equals("no"))
                {
                    // =
                    token = lexer.GetToken();
                    if (token.Type != TokenType.Equal)
                    {
                        Log.InvalidToken(LogCategory, token, lexer);
                        lexer.SkipLine();
                        continue;
                    }

                    // プロヴィンスID
                    token = lexer.GetToken();
                    if (token.Type == TokenType.Number)
                    {
                        map.No.Add((int) (double) token.Value);
                        continue;
                    }

                    if (token.Type == TokenType.Identifier)
                    {
                        string s = token.Value as string;
                        if (string.IsNullOrEmpty(s))
                        {
                            continue;
                        }
                        s = s.ToLower();

                        // all
                        if (s.Equals("all"))
                        {
                            map.All = false;
                            continue;
                        }
                    }

                    // 無効なトークン
                    Log.InvalidToken(LogCategory, token, lexer);
                    continue;
                }

                // top
                if (keyword.Equals("top"))
                {
                    MapPoint point = ParsePoint(lexer);
                    if (point == null)
                    {
                        Log.InvalidSection(LogCategory, "top", lexer);
                        continue;
                    }

                    // マップの範囲(左上)
                    map.Top = point;
                    continue;
                }

                // bottom
                if (keyword.Equals("bottom"))
                {
                    MapPoint point = ParsePoint(lexer);
                    if (point == null)
                    {
                        Log.InvalidSection(LogCategory, "bottom", lexer);
                        continue;
                    }

                    // マップの範囲(右下)
                    map.Bottom = point;
                    continue;
                }

                // 無効なトークン
                Log.InvalidToken(LogCategory, token, lexer);
                lexer.SkipLine();
            }

            return map;
        }
Ejemplo n.º 40
0
 void Start()
 {
     instance = this;
     playerName = PlayerPrefs.GetString("Player Name");
     currentMap = mapList[0];
 }
Ejemplo n.º 41
0
 void ClientGetMultiplayerSettings(string map, string mode, string others)
 {
     currentMap = GetMap(map);
 }
Ejemplo n.º 42
0
        public void SaveMapSettings(MapSettings settings)
        {
            if (!Directory.Exists(propsPath)) Directory.CreateDirectory(propsPath);

            File.Create(propsPath + settings.name + ".properties").Dispose();
            using (StreamWriter SW = File.CreateText(propsPath + settings.name + ".properties"))
            {
                SW.WriteLine("#Lava Survival properties for " + settings.name);
                SW.WriteLine("fast-chance = " + settings.fast);
                SW.WriteLine("killer-chance = " + settings.killer);
                SW.WriteLine("destroy-chance = " + settings.destroy);
                SW.WriteLine("water-chance = " + settings.water);
                SW.WriteLine("layer-chance = " + settings.layer);
                SW.WriteLine("layer-height = " + settings.layerHeight);
                SW.WriteLine("layer-count = " + settings.layerCount);
                SW.WriteLine("layer-interval = " + settings.layerInterval);
                SW.WriteLine("round-time = " + settings.roundTime);
                SW.WriteLine("flood-time = " + settings.floodTime);
                SW.WriteLine("block-flood = " + settings.blockFlood.ToString());
                SW.WriteLine("block-layer = " + settings.blockLayer.ToString());
                SW.WriteLine(String.Format("safe-zone = {0}-{1}", settings.safeZone[0].ToString(), settings.safeZone[1].ToString()));
            }
        }
Ejemplo n.º 43
0
 public MapData(MapSettings settings)
 {
     fast = false;
     killer = false;
     destroy = false;
     water = false;
     layer = false;
     block = Block.lava;
     currentLayer = 1;
     roundTimer = new Timer(TimeSpan.FromMinutes(settings.roundTime).TotalMilliseconds); roundTimer.AutoReset = false;
     floodTimer = new Timer(TimeSpan.FromMinutes(settings.floodTime).TotalMilliseconds); floodTimer.AutoReset = false;
     layerTimer = new Timer(TimeSpan.FromMinutes(settings.layerInterval).TotalMilliseconds); layerTimer.AutoReset = true;
 }
Ejemplo n.º 44
0
 public AppSettings()
 {
     Server = new ServerSettings();
     Map = new MapSettings();
 }