public void ShowWin(bool record = false) { WinTime.text = LevelSettings.SecondsToTime(GameState.Instance.CurrentLevelTime); WinRecord.SetActive(record); WinPanel.SetActive(true); NextLevelButton.SetActive(GameState.Instance.NextLevel != null); }
public void Awake() { BestScore = InitInteger("BestScore", BestScore); Gems = InitInteger("Gems", Gems); LevelSettings = InitLevelSettings(); }
/// <summary> /// Runs after all other update calls, ensuring that lastDayTick gets updated AFTER all humans have called IsNewDay(). /// After all, we don't want a day to end early. /// </summary> void LateUpdate() { if (Time.time - lastDayTick > LevelSettings.GetActiveLevelSettings().DayLength) { lastDayTick = Time.time; } }
private static void ChangeSpawnerWaveStatus(WaveSyncroPrefabSpawner spawner, int levelNumber, int waveNumber, bool isActivate) { var statusText = isActivate ? "activate" : "deactivate"; if (spawner == null) { LevelSettings.LogIfNew(string.Format("Spawner was NULL. Cannot {0} wave# {1} in level# {2}", statusText, waveNumber, levelNumber)); return; } foreach (var wave in spawner.waveSpecs) { if (wave.SpawnLevelNumber + 1 != levelNumber || wave.SpawnWaveNumber + 1 != waveNumber) { continue; } if (LevelSettings.IsLoggingOn) { Debug.Log(string.Format("Logging '{0}' in spawner '{1}' for wave# {2}, level# {3}.", statusText, spawner.name, waveNumber, levelNumber)); } wave.enableWave = isActivate; return; } LevelSettings.LogIfNew(string.Format("Could not locate a wave matching wave# {0}, level# {1}, in spawner '{2}'.", waveNumber, levelNumber, spawner.name)); }
void OnEnable() { Column = (int)RoundToNearest(transform.position.x, _cellSize); Row = (int)RoundToNearest(transform.position.y, _cellSize); _levelSettings = FindObjectOfType <LevelSettings>(); _renderer = GetComponent <Renderer>(); _gameController = FindObjectOfType <GameController>(); _cellAlignment = GetComponent <CellAlignment>(); _cellSize = _cellAlignment.cellSize; _gameController.RegisterCell(this); _gameController.Dropped += HandleGameDrop; _initialScale = transform.localScale; _initialColor = _levelSettings.cellColor; _fillColor = _levelSettings.fillColor; _fillScale = _levelSettings.fillScale; _fillSpeed = _levelSettings.fillSpeed; _currentTargetColor = _initialColor; _currentDesiredScale = _initialScale; Debug.Log($"Enabled new cell: {gameObject.name} with indexes [{Column}:{Row}]"); }
// Update is called once per frame void Update() { var moveAmt = Input.GetAxis("Horizontal") * MOVE_SPEED * Time.deltaTime; if (moveAmt == 0) { this.rend.materials[0].mainTexture = stableShip; } else if (moveAmt > 0) { this.rend.materials[0].mainTexture = rightShip; } else { this.rend.materials[0].mainTexture = leftShip; } var pos = this.trans.position; pos.x += moveAmt; this.trans.position = pos; if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space)) { var spawnPos = this.trans.position; spawnPos.z += 15; if (!string.IsNullOrEmpty(customEventName) && LevelSettings.CustomEventExists(customEventName)) { LevelSettings.FireCustomEvent(customEventName, this.trans); } PoolBoss.SpawnOutsidePool(ProjectilePrefab.transform, spawnPos, ProjectilePrefab.transform.rotation); } }
public void LoadReplayAndStart(SoundodgerLevel level, Replay replay, LevelSettings settings) { player = new ReplayingPlayer(replay); Replay = replay; ActiveMod = replay.Mod; hitIterator = new TimeIter <TsVal <InvincibilityType> >( replay.Hits, x => x.Time, OnNewHit); slomoIterator = new TimeIter <TsVal <bool> >( replay.SlomoToggles, x => x.Time, OnNewSlomo); BurstShot.InitRandom(replay.BurstSeed); watchingReplayText = new SimpleText { Text = $"[ replay ]", Font = Fonts.Content.Orkney13, Color = new Color(Color.Gray, 0.8f), Position = new Vector2(NoisEvader.ScreenBounds.Width * 0.5f, NoisEvader.ScreenBounds.Height * 0.95f), YOrigin = YOrigin.Center, XOrigin = XOrigin.Center }; InitAndStart(level, ActiveMod, settings); }
public void DebugInit() { GameConfig = Resources.Load <GameConfiguration>("GameConfig"); CurrentLevel = GameConfig.Levels[0]; NextLevel = GameConfig.Levels[1]; CurrentLevelTime = 0.0; }
public void InitializeLevel(Spatial levelNode, LevelSettings levelSettings) { Level = levelNode; SetLevelSettings(levelSettings); Reset(); SetPhysicsProcess(true); }
// UpgradeSettings public static void SetLevelSettings(LevelSettings NewLevelSettings) { string json = JsonUtility.ToJson(NewLevelSettings); PlayerPrefs.SetString("LevelSettings", json); LevelSettings = NewLevelSettings; }
private void UpdateResourceList() { AddDefaultResourceNodes(); string prj2Path = string.Empty; if (_ide.SelectedLevel.SpecificFile == "$(LatestFile)") { prj2Path = Path.Combine(_ide.SelectedLevel.FolderPath, _ide.SelectedLevel.GetLatestPrj2File()); } else { prj2Path = Path.Combine(_ide.SelectedLevel.FolderPath, _ide.SelectedLevel.SpecificFile); } Prj2Loader.LoadedObjects levelObjects = new Prj2Loader.LoadedObjects(); using (FileStream stream = new FileStream(prj2Path, FileMode.Open, FileAccess.Read, FileShare.Read)) levelObjects = Prj2Loader.LoadFromPrj2OnlyObjects(prj2Path, stream); LevelSettings settings = levelObjects.Settings; AddTextureFileNodes(settings); AddWadFileNodes(settings); AddGeometryFileNodes(settings); label_Loading.Visible = false; treeView_Resources.Invalidate(); }
public ObjectInstance MergeGetSingleObject(Editor editor) { Prj2Loader.LoadedObjects loadedObjects = CreateObjects(); ObjectInstance obj = (ObjectInstance)loadedObjects.Objects[0]; LevelSettings newLevelSettings = editor.Level.Settings.Clone(); obj.CopyDependentLevelSettings(new Room.CopyDependentLevelSettingsArgs(null, newLevelSettings, loadedObjects.Settings, true)); editor.UpdateLevelSettings(newLevelSettings); // A little workaround to detect script id collisions already if (obj is IHasScriptID) { Room testRoom = editor.SelectedRoom; try { testRoom.AddObject(editor.Level, obj); testRoom.RemoveObject(editor.Level, obj); } catch (ScriptIdCollisionException) { ((IHasScriptID)obj).ScriptId = null; } } return(obj); }
/// <summary> /// NPC random movement /// if the velocity decreases the npc has some chance of changing their direction /// then the velocity is gradually increased /// </summary> public void RandomMovement() { // checks if we need to increase the velocity bool increase_vel = false; // the velocity norm to check how fast we are going float vel_norm = myRigidbody.velocity.sqrMagnitude; // if we are getting too slow if (vel_norm < MinVelocity) { // increase velocity later on increase_vel = true; // we have a 20% chance of changing our direction or we are at a dancefloor (or drunk) :-) if (UnityEngine.Random.value < 0.2f || (LevelSettings.GetActiveSceneName() == "YouVsVirus_Leveldisco")) { // Random.onUnitSphere returns a random point on the surface of a sphere with radius 1 // so we do not change the velocity, just the direction myRigidbody.velocity = UnityEngine.Random.onUnitSphere; } } // Stop! This is too fast! if (vel_norm > MaxVelocity) { vel_norm = MaxVelocity; increase_vel = false; } // we are slow at the moment but do not want to become too fast if (vel_norm < MaxVelocity && increase_vel == true) { // increase the velocity in every call to this function myRigidbody.velocity *= (1f + AccelerationFactor); } }
public void NewArea( EnvTypeInfo envTypeInfo, List <SpawnsInfo> spawnsInfos, LevelSettings levelSettings, LevelView outputLevel, Action <LevelAreaView> onDone = null) { // DebugUtils.Log( // "LevelAreaGeneratorView.NewArea(); envType={0}", envType); area = outputLevel.NewArea(envTypeInfo); if (spawnsInfos.Count == 0) { if (onDone != null) { onDone(area); } return; } Profiler.BeginSample("LevelAreaGeneratorView.NewArea()"); this.envTypeInfo = envTypeInfo; this.spawnsInfos = spawnsInfos; this.levelSettings = levelSettings; this.onDone = onDone; level = outputLevel; spawnsInfosIndex = 0; NextObjectType(); reservedSpawnPoints.Clear(); InvokeRepeating("NewObject", objectSpawnRate, objectSpawnRate); Profiler.EndSample(); }
// ReSharper disable once UnusedMember.Local void Start() { var poolNames = new List <string>(); // ReSharper disable once TooWideLocalVariableScope WavePrefabPool poolScript; for (var i = 0; i < transform.childCount; i++) { var pool = transform.GetChild(i); if (poolNames.Contains(pool.name)) { LevelSettings.LogIfNew("You have more than one Prefab Pool with the name '" + pool.name + "'. Please fix this before continuing."); LevelSettings.IsGameOver = true; return; } poolScript = pool.GetComponent <WavePrefabPool>(); if (poolScript == null) { LevelSettings.LogIfNew("The Prefab Pool '" + pool.name + "' has no Prefab Pool script. Please delete it and fix this before continuing."); LevelSettings.IsGameOver = true; return; } poolNames.Add(pool.name); } }
private void InitObject( LevelObjectView obj, ObjectTypeInfo objectTypeInfo, ObjectProtoInfo objectProtoInfo, SpawnLocation spawnLocation, LevelSettings levelSettings) { obj.transform.rotation = Quaternion.Euler(0f, spawnLocation.IsXFlipped ? 180f : 0f, 0f); var alternating = obj.GetComponent <AlternatingView>(); if (alternating != null) { int materialIndex = UnityEngine.Random.Range( 0, objectProtoInfo.AvailableMaterials.Length); alternating.Material = objectProtoInfo.AvailableMaterials[materialIndex]; } if (objectTypeInfo.Type == playerObjectType) { List <int> skillIds = playerStateStorage.Get().SkillIds; for (int i = 0; i < skillIds.Count; ++i) { Skill skill = skillStorage.Get(skillIds[i]); BaseSkill baseSkill = skillStorage.GetBase(skill.BaseId); ISkillHelper skillHelper = skillHelperStorage.Get(baseSkill.Type); skillHelper.AddSkill(skill, obj.gameObject); } } }
/// <summary> /// FixedUpdate: FixedUpdate is often called more frequently than Update. /// It can be called multiple times per frame, if the frame rate is low and /// it may not be called between frames at all if the frame rate is high. /// All physics calculations and updates occur immediately after FixedUpdate. /// When applying movement calculations inside FixedUpdate, you do not need /// to multiply your values by Time.deltaTime. This is because FixedUpdate /// is called on a reliable timer, independent of the frame rate. /// </summary> void FixedUpdate() { if (CanMove() && !LevelSettings.GetActiveEndLevelController().levelHasFinished) { ProcessMovementInput(); } }
// Use this for initialization public void Awake() { LevelSettings buildableResources = GameObject.Find("GameSettings").GetComponent<GameSettingsScript>().availableResources; availableResources = new LevelSettings(buildableResources.bananas,buildableResources.obstacles,buildableResources.monkeys,buildableResources.figures,new Goal()); //availableResources = new LevelSettings(true,true,true,true, new Goal()); statHandler = GameObject.Find("InitHolder").GetComponent<InitScript>(); }
public static LevelSettings FromDataString(string data) { LevelSettings levelSettings = new LevelSettings(); string[] splitData = data.Split(splitChar_1); double doubleValue; int intValue; if (splitData.Length == paramCount) { levelSettings.levelName = splitData[0]; if (double.TryParse(splitData[1], out doubleValue)) { levelSettings.time = doubleValue; } if (int.TryParse(splitData[2], out intValue)) { levelSettings.doors = intValue; } if (int.TryParse(splitData[3], out intValue)) { levelSettings.walls = intValue; } return(levelSettings); } return(null); }
/// <summary> /// Modifies a World Variable by name. You can set, add, multiply or subtract the value. /// </summary> /// <param name='modifier'>Modifier.</param> /// <param name='sourceTrans'>Source trans. Optional - this will output in the debug message if the World Variable is not found.</param> public static void ModifyPlayerStat(WorldVariableModifier modifier, Transform sourceTrans = null) { var statName = modifier._statName; if (!InGamePlayerStats.ContainsKey(statName)) { LevelSettings.LogIfNew( string.Format( "Transform '{0}' tried to modify a World Variable called '{1}', which was not found in this scene.", sourceTrans == null ? LevelSettings.EmptyValue : sourceTrans.name, statName)); return; } var stat = InGamePlayerStats[statName]; switch (modifier._varTypeToUse) { case VariableType._integer: case VariableType._float: stat.ModifyVariable(modifier); break; default: LevelSettings.LogIfNew("Write code for varType: " + modifier._varTypeToUse.ToString()); break; } }
/// <summary> /// In infection status is not shown all NCPs do no sprite update within the game /// since we do not want the user to know if they are healthy or not. /// Only when the game ends, we want them all to show their true color. /// *FIXME*: This is another function that does not really belong to the CreateHumans /// game object. But handling it in another way requires a lot more reconstruction than /// we want to do at the moment. /// </summary> protected override void CummulativeSpriteUpdate() { // all NPCs show true infection statuts CreateHumans.GetComponent <Components.CreatePopLeveldemo>().CummulativeSpriteUpdate(); // then start to update infection status again LevelSettings.GetActiveLevelSettings().ShowInfectionStatus = true; }
void Start() { // player is in the house at the beginning playerHouse.GetComponent <PlayerHouse>().ShowPlayer(); // Get reference to the nonSpanableSpace class nonSpawnableSpaceClass = nonSpawnableSpaceObj.GetComponent <nonSpawnableSpace>(); // get active level settings - the get home scene always has 50% social distancing LevelSettings.GetActiveLevelSettings().SocialDistancingFactor = 18; LevelSettings.GetActiveLevelSettings().NumberOfNPCs = npcNumber; // We do not show the infection status in this level LevelSettings.GetActiveLevelSettings().ShowInfectionStatus = false; // Set the DayLength for this level LevelSettings.GetActiveLevelSettings().DayLength = 100; // this gets the Main Camera from the Scene // the grid cell has to be as large as the player's infection radius randomGridForHumans = GameObject.Find("RandomGrid").GetComponent <RandomGrid>(); // make screen Bounds 80% smaller so that NPCs are placed more in the middle since the player is at the edge randomGridForHumans.shrinkScreenBounds(0.8f); // generate the random coordinates for humans which depend on the scale of the player (who is largest), // their infection radius, since we do not want immediate infection // and the number of humans that we want to place randomGridForHumans.GenerateRandomCoords(playerPrefab.transform.localScale.x, playerPrefab.GetComponentInChildren <InfectionTrigger>().InfectionRadius, npcNumber, nonSpawnableSpaceClass); // place humans on grid CreateHumans(); }
private string GetFullFilePath(string filePath, LevelSettings settings) { string fullPath = string.Empty; if (filePath.Contains("$(LevelDirectory)")) { int foldersToGoBackCount = Regex.Matches(filePath, @"\\\.\.").Count; string partialPath = filePath.Replace("$(LevelDirectory)", string.Empty).Replace(@"\..", string.Empty); string missingPart = settings.LevelFilePath; for (int i = 0; i <= foldersToGoBackCount; i++) { missingPart = Path.GetDirectoryName(missingPart); } fullPath = missingPart + partialPath; } else { fullPath = filePath; } return(fullPath); }
public static NgParameterRange GetTimerRange(LevelSettings levelSettings, TriggerType triggerType, TriggerTargetType targetType, ITriggerParameter target) { switch (triggerType) { case TriggerType.ConditionNg: return(new NgParameterRange(NgCatalog.ConditionTrigger.MainList.DicSelect(e => (TriggerParameterUshort)e.Value))); default: switch (targetType) { case TriggerTargetType.FlipEffect: if (!(target is TriggerParameterUshort)) { return(new NgParameterRange(NgParameterKind.Empty)); } NgTriggerSubtype flipEffectSubtriggerType = NgCatalog.FlipEffectTrigger.MainList.TryGetOrDefault(((TriggerParameterUshort)target).Key); return(flipEffectSubtriggerType?.Timer ?? new NgParameterRange(NgParameterKind.Empty)); case TriggerTargetType.ActionNg: return(new NgParameterRange(NgCatalog.ActionTrigger.MainList.DicSelect(e => (TriggerParameterUshort)e.Value))); case TriggerTargetType.TimerfieldNg: return(new NgParameterRange(NgParameterKind.Empty)); default: return(new NgParameterRange(NgParameterKind.AnyNumber)); } } }
public static string LoadSettings(string fileName) { string tmpname = fileName; string gamePath = Application.dataPath; fileName = gamePath + "/" + fileName + ".txt"; string fileText; if (File.Exists(fileName)) { try { fileText = File.ReadAllText(fileName); } catch (Exception e) { return("Loading file " + tmpname + " failed"); } } else { return("File " + tmpname + " does not exist"); } LevelSettings loadedSettings = JsonConvert.DeserializeObject <LevelSettings>(fileText); UISettings.settings = loadedSettings; return("Loading file " + tmpname + " successful!"); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // Get sub properties SerializedProperty type = property.FindPropertyRelative(nameof(type)); SerializedProperty index = property.FindPropertyRelative(nameof(index)); // Set height for just one control position.height = LayoutUtilities.standardControlHeight; // Put in the property foldout property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label); position.y += position.height; if (property.isExpanded) { // Increse indent EditorGUI.indentLevel++; // Edit the type EditorGUI.PropertyField(position, type); position.y += position.height; // Get a list of all possible level ids with this type LevelID[] levelIDs = LevelSettings.GetAllLevelIDsOfType((LevelType)type.enumValueIndex); // Select the names of the levels with this type string[] names = levelIDs.Select(id => id.Data.EditorDisplayName).ToArray(); // Edit the property as a popup with the names of all the levels in this type index.intValue = EditorGUIExt.Popup(position, index.intValue, names, new GUIContent(property.displayName)); // Resume indent EditorGUI.indentLevel--; } }
void LoadLevel(string levelId) { var levels = gameDefinition.scenes.First(x => x.name == loadedScene).levels.Where(x => x.id == levelId) .ToList(); if (levels.Count > 1) { throw new InvalidOperationException("There are more than one level with id " + levelId); } if (!levels.Any()) { throw new InvalidOperationException("There is no level with id " + levelId); } levelDefinition = levels.First(); currentLevelSettings = levelDefinition.levelSettings; LevelModeButtons.instance.CreateButtons(); BuildGuides(levelDefinition.guideBubbles); BuildCases(levelDefinition.cases); if (levelDefinition.sandbox != null) { LevelModeController.instance.InitSandboxMode(); } else { LevelModeController.instance.InitCaseMode(); } }
// Use this for initialization void Start() { freeSpaceManager = GameObject.Find("GlobalManagers").GetComponent <FreeSpaceManager>(); currentStep = -1; NextStep(); levelSettings = GameObject.Find("LevelSettings").GetComponent <LevelSettings>(); }
/// <summary> /// Infects this human if it is susceptible. /// </summary> public void Infect() { // the standard non-party case if (LevelSettings.GetActiveSceneName() != "YouVsVirus_Leveldisco") { if (IsSusceptible()) { SetCondition(EXPOSED); } } else // the party case { if (IsSusceptible()) { // both friend and player have a 10% chance of getting exposed if (this.tag == "Player" || this.tag == "Friend") { if (UnityEngine.Random.value < 0.2) { SetCondition(EXPOSED); } } // rest of npcs have increasing chance of getting infected else if (UnityEngine.Random.value < num_inf * 0.028) { num_inf++; SetCondition(EXPOSED); } } } }
//////////////////////////////////////////////////////////////////// public void ApplyLevelSettings(LevelSettings settings) { if (settings.PlayerCount > 0 && settings.PreferedLayer != null) { currentLevelSetings = settings; } }
// Awake is called the moment this component is created void Start() { // player is in the house at the beginning PlayerHouse.GetComponent <PlayerHouse>().ShowPlayer(); NPCs = new List <NPC>(npcNumber); NPC_AIs = new List <NPC_AI>(npcAINumber); // get active level settings - the scene has 18% social distancing LevelSettings.GetActiveLevelSettings().SocialDistancingFactor = 18; // our NPC number LevelSettings.GetActiveLevelSettings().NumberOfNPCs = npcNumber + npcAINumber; // time-scale is slow and infection status is not shown during game LevelSettings.GetActiveLevelSettings().DayLength = 100f; LevelSettings.GetActiveLevelSettings().ShowInfectionStatus = false; // the grid cell has to be as large as the player's infection radius randomGridForHumans = GameObject.Find("RandomGrid").GetComponent <RandomGrid>(); // generate the random coordinates for humans which depend on the scale of the player (who is largest), // their infection radius, since we do not want immediate infection // and the number of humans that we want to place randomGridForHumans.GenerateRandomCoords(3 * playerPrefab.transform.localScale.x, playerPrefab.GetComponentInChildren <InfectionTrigger>().InfectionRadius, npcNumber + npcAINumber); // place humans on grid (NPC, NPC_AI, player) CreateHumans(); Player.withMask = true; // set the paths for the NPC_AIs // these are fixed floats at the moment // maybe there is a better more "relative" way do handle this SetPathsforNPC_AIs(); }
void Awake() { if (s_settings != null) { throw new System.InvalidProgramException("there is more than one level settings object!"); } s_settings = this; }
void Awake() { if (s_settings != null) { throw new System.InvalidProgramException("there is more than one level settings object!"); } s_settings = this; playerSpawner = GetComponent<PlayerSpawner>(); }
public static FunctionButtons AddControlButtons(LevelSettings settings, string itemName) { GUIContent settingsIcon; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (CoreGameKitInspectorResources.SettingsTexture != null) { settingsIcon = new GUIContent(CoreGameKitInspectorResources.SettingsTexture, "Click to edit " + itemName); } else { settingsIcon = new GUIContent("Edit", "Click to edit " + itemName); } if (GUILayout.Button(settingsIcon, EditorStyles.toolbarButton)) { return FunctionButtons.Edit; } return FunctionButtons.None; }
public static void ExportLevelDataToXML(NitroOverlay overlay, int levelID, LevelSettings levelSettings, Dictionary<uint, LevelObject> levelObjects, List<LevelTexAnim>[] texAnims, string filename = "level.xml") { m_Overlay = overlay; m_LevelID = levelID; m_LevelSettings = levelSettings; m_LevelObjects = levelObjects; m_TexAnims = texAnims; m_NumAreas = m_Overlay.Read8(0x74); m_FileName = filename; m_Path = Path.GetDirectoryName(m_FileName); ExportXML(); System.IO.File.WriteAllBytes(m_Path + "/OVL_" + (m_LevelID + 103) + ".bin", m_Overlay.m_Data); }
public void SpawnPlayers() { _currentLevel = LevelSettings.Current; _players = new Dictionary<EndPoint, SpawnedPlayer>(); foreach (RoomPlayerInfo player in ConnectedPlayers) { GameObject newShip = (GameObject)Instantiate(BoatPrefab, _currentLevel.SpawnPoints[player.SpawnPointID].position, Quaternion.identity); SpawnedPlayer sPlayer = new SpawnedPlayer(newShip, player); // Self if (player.PlayerID == PlayerID) { // Create camera for player GameObject cam = (GameObject)Instantiate(CameraPrefab, newShip.transform.position, Quaternion.identity); cam.GetComponent<CameraMovement>().Target = newShip.transform; _currentPlayer = sPlayer; _currentPlayer.Manager.PartChanged += AddPartUpdate; foreach (CannonManager group in _currentPlayer.Manager.CannonGroups) { foreach (Cannon cannon in group.cannons) { cannon.OnShoot += Cannon_OnShoot; } } UpdateNetworkPackage(); } // Other player else { _players.Add(player.UdpEP, sPlayer); Destroy(newShip.GetComponent<Rigidbody>()); } } }
public IEnumerator SpawnBarrier(LevelSettings.BarrierType size, float deltaPosition, float sideProbability, bool waitForEnd) { Debug.Log("SpawnBarrier start"); var barrierMover = GetFreeBarrier(); if (barrierMover) { barrierMover.Reset(); barrierMover.Size = size; barrierMover.enabled = true; if (lastBarrierMover != null) { var pos = barrierMover.transform.position; pos.y = lastBarrierMover.transform.position.y - deltaPosition; //Debug.LogFormat("Position: {0} {1} {2}", barrierMover.transform.position, pos, lastBarrierMover.transform.position.y); barrierMover.transform.position = pos; barrierMover.newStartPosition = pos; //Debug.Break(); } { double r = random.NextDouble(); if (r < sideProbability) { switch (currentSide) { case LevelSettings.Start.Position.Left: currentSide = LevelSettings.Start.Position.Right; break; case LevelSettings.Start.Position.Right: currentSide = LevelSettings.Start.Position.Left; break; default: Debug.LogError("Mover.Side"); break; } } } barrierMover.Side = currentSide; while (!barrierMover.spawnNext) { //Debug.Log("SpawnBarrier " + barrierMover.spawnNext); yield return null; } lastBarrierMover = barrierMover; //Debug.Log("SpawnBarrier " + barrierMover.spawnNext); if (waitForEnd) { while (barrierMover.enabled) { //Debug.Log("barrierMover enabled = " + barrierMover.enabled); yield return null; } } } Debug.Log("SpawnBarrier finish"); }
private IEnumerator StartBlock(LevelSettings levelSettings, int blockIndex) { lastBarrierMover = null; Debug.LogFormat("StartBlock({0})", blockIndex); LevelSettings.Block block = levelSettings.blocks[blockIndex]; LevelSettings.DifficultyLevel difficultyLevel = levelSettings.difficultyLevels[block.difficultyLevel]; currentHorisontalTime = block.switchDelay; yield return StartCoroutine(ChangeSpeedTo(block.startSpeed)); int count = block.quantity; float distanceToNextBarrier = difficultyLevel.gapMultiplier; for (int i = 0; i < count; ++i) { var size = difficultyLevel.sizeProbability.getBarrierSize(random.NextDouble()); Debug.LogFormat("SpawnBarrier({0})", i); var coroutine = SpawnBarrier(size, distanceToNextBarrier, difficultyLevel.sideProbability, i + 1 == count); yield return StartCoroutine(coroutine); Debug.LogFormat("SpawnBarrier({0}) finish", i); //yield return new WaitForSeconds(difficultyLevel.gapMultiplier); } Debug.LogFormat("StartBlock({0}) finish", blockIndex); }
void Cleanup() { s_settings = null; }
public LevelSettings() : base() { Current = this; }
void Reset() { print("reset?"); levelSettings = GetComponent<LevelSettings>(); levelSettings.Set(); }
// ReSharper disable once FunctionComplexityOverflow public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(); EditorGUI.indentLevel = 0; _settings = (LevelSettings)target; var isInProjectView = DTInspectorUtility.IsPrefabInProjectView(_settings); WorldVariableTracker.ClearInGamePlayerStats(); DTInspectorUtility.DrawTexture(CoreGameKitInspectorResources.LogoTexture); _isDirty = false; if (isInProjectView) { DTInspectorUtility.ShowRedErrorBox("You have selected the LevelWaveSettings prefab in Project View."); DTInspectorUtility.ShowRedErrorBox("Do not drag this prefab into the Scene. It will be linked to this prefab if you do. Click the button below to create a LevelWaveSettings prefab in the Scene."); EditorGUILayout.Separator(); GUI.contentColor = DTInspectorUtility.BrightButtonColor; EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button("Create LevelWaveSettings Prefab", EditorStyles.toolbarButton, GUILayout.Width(180))) { CreateLevelSettingsPrefab(); } EditorGUILayout.EndHorizontal(); GUI.contentColor = Color.white; return; } var allStats = KillerVariablesHelper.AllStatNames; var playerStatsHolder = _settings.transform.FindChild(LevelSettings.WorldVariablesContainerTransName); if (playerStatsHolder == null) { Debug.LogError("You have no child prefab of LevelSettings called '" + LevelSettings.WorldVariablesContainerTransName + "'. " + LevelSettings.RevertLevelSettingsAlert); DTInspectorUtility.ShowRedErrorBox("Please check the console. You have a breaking error."); return; } EditorGUI.indentLevel = 0; DTInspectorUtility.StartGroupHeader(); var newUseWaves = EditorGUILayout.BeginToggleGroup(" Use Global Waves", _settings.useWaves); if (newUseWaves != _settings.useWaves) { if (Application.isPlaying) { DTInspectorUtility.ShowAlert("Cannot change this setting at runtime."); } else { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Use Global Waves"); _settings.useWaves = newUseWaves; } } DTInspectorUtility.EndGroupHeader(); if (_settings.useWaves) { EditorGUI.indentLevel = 0; DTInspectorUtility.StartGroupHeader(1); var newUseMusic = GUILayout.Toggle(_settings.useMusicSettings, " Use Music Settings"); if (newUseMusic != _settings.useMusicSettings) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Use Music Settings"); _settings.useMusicSettings = newUseMusic; } EditorGUILayout.EndVertical(); if (_settings.useMusicSettings) { EditorGUI.indentLevel = 0; var newGoMusic = (LevelSettings.WaveMusicMode)EditorGUILayout.EnumPopup("G.O. Music Mode", _settings.gameOverMusicSettings.WaveMusicMode); if (newGoMusic != _settings.gameOverMusicSettings.WaveMusicMode) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change G.O. Music Mode"); _settings.gameOverMusicSettings.WaveMusicMode = newGoMusic; } if (_settings.gameOverMusicSettings.WaveMusicMode == LevelSettings.WaveMusicMode.PlayNew) { var newWaveMusic = (AudioClip)EditorGUILayout.ObjectField("G.O. Music", _settings.gameOverMusicSettings.WaveMusic, typeof(AudioClip), true); if (newWaveMusic != _settings.gameOverMusicSettings.WaveMusic) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "assign G.O. Music"); _settings.gameOverMusicSettings.WaveMusic = newWaveMusic; } } if (_settings.gameOverMusicSettings.WaveMusicMode != LevelSettings.WaveMusicMode.Silence) { var newMusicVol = EditorGUILayout.Slider("G.O. Music Volume", _settings.gameOverMusicSettings.WaveMusicVolume, 0f, 1f); if (newMusicVol != _settings.gameOverMusicSettings.WaveMusicVolume) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change G.O. Music Volume"); _settings.gameOverMusicSettings.WaveMusicVolume = newMusicVol; } } else { var newFadeTime = EditorGUILayout.Slider("Silence Fade Time", _settings.gameOverMusicSettings.FadeTime, 0f, 15f); if (newFadeTime != _settings.gameOverMusicSettings.FadeTime) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Silence Fade Time"); _settings.gameOverMusicSettings.FadeTime = newFadeTime; } } } EditorGUILayout.EndVertical(); EditorGUI.indentLevel = 0; DTInspectorUtility.AddSpaceForNonU5(); DTInspectorUtility.StartGroupHeader(1); var newEnableWarp = GUILayout.Toggle(_settings.enableWaveWarp, " Custom Start Wave?"); if (newEnableWarp != _settings.enableWaveWarp) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Custom Start Wave?"); _settings.enableWaveWarp = newEnableWarp; } EditorGUILayout.EndVertical(); if (_settings.enableWaveWarp) { EditorGUI.indentLevel = 0; KillerVariablesHelper.DisplayKillerInt(ref _isDirty, _settings.startLevelNumber, "Custom Start Level#", _settings); KillerVariablesHelper.DisplayKillerInt(ref _isDirty, _settings.startWaveNumber, "Custom Start Wave#", _settings); } EditorGUILayout.EndVertical(); DTInspectorUtility.ResetColors(); var newDisableSyncro = EditorGUILayout.Toggle("Syncro Spawners Off", _settings.disableSyncroSpawners); if (newDisableSyncro != _settings.disableSyncroSpawners) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Syncro Spawners Off"); _settings.disableSyncroSpawners = newDisableSyncro; } var newStart = EditorGUILayout.Toggle("Auto Start Waves", _settings.startFirstWaveImmediately); if (newStart != _settings.startFirstWaveImmediately) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Auto Start Waves"); _settings.startFirstWaveImmediately = newStart; } var newDestroy = (LevelSettings.WaveRestartBehavior)EditorGUILayout.EnumPopup("Wave Restart Mode", _settings.waveRestartMode); if (newDestroy != _settings.waveRestartMode) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Wave Restart Mode"); _settings.waveRestartMode = newDestroy; } } EditorGUILayout.EndToggleGroup(); DTInspectorUtility.AddSpaceForNonU5(); DTInspectorUtility.StartGroupHeader(); var newUse = EditorGUILayout.BeginToggleGroup(" Use Initialization Options", _settings.initializationSettingsExpanded); if (newUse != _settings.initializationSettingsExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Use Initialization Options"); _settings.initializationSettingsExpanded = newUse; } if (_settings.initializationSettingsExpanded) { DTInspectorUtility.BeginGroupedControls(); DTInspectorUtility.ShowColorWarningBox("When LevelSettings has finished initializing, fire the Custom Events below"); EditorGUILayout.BeginHorizontal(); GUI.contentColor = DTInspectorUtility.AddButtonColor; GUILayout.Space(10); if (GUILayout.Button(new GUIContent("Add", "Click to add a Custom Event"), EditorStyles.toolbarButton, GUILayout.Width(50))) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "Add Initialization Custom Event"); _settings.initializationCustomEvents.Add(new CGKCustomEventToFire()); } GUILayout.Space(10); if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last Custom Event"), EditorStyles.toolbarButton, GUILayout.Width(50))) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "Remove Initialization Custom Event"); _settings.initializationCustomEvents.RemoveAt(_settings.initializationCustomEvents.Count - 1); } GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); if (_settings.initializationCustomEvents.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You have no Custom Events selected to fire."); } DTInspectorUtility.VerticalSpace(2); // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _settings.initializationCustomEvents.Count; i++) { var anEvent = _settings.initializationCustomEvents[i].CustomEventName; anEvent = DTInspectorUtility.SelectCustomEventForVariable(ref _isDirty, anEvent, _settings, "Custom Event"); if (anEvent == _settings.initializationCustomEvents[i].CustomEventName) { continue; } _settings.initializationCustomEvents[i].CustomEventName = anEvent; } DTInspectorUtility.EndGroupedControls(); } EditorGUILayout.EndToggleGroup(); DTInspectorUtility.EndGroupHeader(); EditorGUI.indentLevel = 0; var newPersist = EditorGUILayout.Toggle("Persist Between Scenes", _settings.persistBetweenScenes); if (newPersist != _settings.persistBetweenScenes) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Persist Between Scenes"); _settings.persistBetweenScenes = newPersist; } var newLogging = EditorGUILayout.Toggle("Log Messages", _settings.isLoggingOn); if (newLogging != _settings.isLoggingOn) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Log Messages"); _settings.isLoggingOn = newLogging; } var hadNoListener = _settings.listener == null; var newListener = (LevelSettingsListener)EditorGUILayout.ObjectField("Listener", _settings.listener, typeof(LevelSettingsListener), true); if (newListener != _settings.listener) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "assign Listener"); _settings.listener = newListener; if (hadNoListener && _settings.listener != null) { _settings.listener.sourceTransName = _settings.transform.name; } } if (Application.isPlaying && PoolBoss.IsServer) { DTInspectorUtility.StartGroupHeader(1, false); EditorGUILayout.LabelField("Game Status Panel", EditorStyles.boldLabel); //EditorGUILayout.EndVertical(); if (LevelSettings.IsGameOver) { GUI.backgroundColor = Color.red; DTInspectorUtility.ShowRedErrorBox("Game Status: GAME OVER"); } else { GUI.backgroundColor = Color.green; DTInspectorUtility.ShowLargeBarAlertBox("Game Status: NOT OVER"); } if (_settings.useWaves) { if (LevelSettings.WavesArePaused) { GUI.backgroundColor = Color.red; DTInspectorUtility.ShowRedErrorBox("Wave Status: Paused"); } else { GUI.backgroundColor = Color.green; EditorGUILayout.BeginHorizontal(); DTInspectorUtility.ShowLargeBarAlertBox("Playing Level: [" + (LevelSettings.CurrentLevel + 1) + "] Wave: [" + LevelSettings.CurrentLevelWave + "]"); EditorGUILayout.EndHorizontal(); } } GUI.backgroundColor = Color.green; EditorGUILayout.BeginHorizontal(); if (LevelSettings.WavesArePaused) { if (GUILayout.Button("Unpause", EditorStyles.miniButton, GUILayout.Width(70))) { LevelSettings.UnpauseWave(); } } else { if (GUILayout.Button("Pause", EditorStyles.miniButton, GUILayout.Width(70))) { LevelSettings.PauseWave(); } } var hasNextWave = LevelSettings.HasNextWave; if (!LevelSettings.WavesArePaused && hasNextWave) { GUILayout.Space(4); if (GUILayout.Button("Next Wave", EditorStyles.miniButton, GUILayout.Width(70))) { LevelSettings.EndWave(); } } EditorGUILayout.EndHorizontal(); DTInspectorUtility.AddSpaceForNonU5(); GUI.backgroundColor = Color.white; EditorGUILayout.EndVertical(); } DTInspectorUtility.VerticalSpace(4); // Pool Boss section var state = _settings.killerPoolingExpanded; var text = "Pool Boss"; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (!state) { GUI.backgroundColor = DTInspectorUtility.InactiveHeaderColor; } else { GUI.backgroundColor = DTInspectorUtility.ActiveHeaderColor; } GUILayout.BeginHorizontal(); #if UNITY_3_5_7 if (!state) { text += " (Click to expand)"; } #else text = "<b><size=11>" + text + "</size></b>"; #endif if (state) { text = "\u25BC " + text; } else { text = "\u25BA " + text; } if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) { state = !state; } GUILayout.Space(2f); EditorGUI.indentLevel = 0; if (state != _settings.killerPoolingExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Pool Boss"); _settings.killerPoolingExpanded = state; } EditorGUILayout.EndHorizontal(); GUI.color = Color.white; var poolingHolder = _settings.transform.FindChild(LevelSettings.KillerPoolingContainerTransName); if (poolingHolder == null) { Debug.LogError("You have no child prefab of LevelSettings called '" + LevelSettings.KillerPoolingContainerTransName + "'. " + LevelSettings.RevertLevelSettingsAlert); return; } if (_settings.killerPoolingExpanded) { DTInspectorUtility.BeginGroupedControls(); var kp = poolingHolder.GetComponent<PoolBoss>(); if (kp == null) { Debug.LogError("You have no PoolBoss script on your " + LevelSettings.KillerPoolingContainerTransName + " subprefab. " + LevelSettings.RevertLevelSettingsAlert); return; } DTInspectorUtility.ShowColorWarningBox(string.Format("You have {0} Pool Item(s) set up. Click the button below to configure Pooling.", kp.poolItems.Count)); EditorGUILayout.BeginHorizontal(); GUI.contentColor = DTInspectorUtility.BrightButtonColor; GUILayout.Space(10); if (GUILayout.Button("Configure Pooling", EditorStyles.toolbarButton, GUILayout.Width(120))) { Selection.activeGameObject = poolingHolder.gameObject; } GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); DTInspectorUtility.EndGroupedControls(); } // end Pool Boss section // create Prefab Pools section EditorGUI.indentLevel = 0; DTInspectorUtility.VerticalSpace(2); state = _settings.createPrefabPoolsExpanded; text = "Prefab Pools"; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (!state) { GUI.backgroundColor = DTInspectorUtility.InactiveHeaderColor; } else { GUI.backgroundColor = DTInspectorUtility.ActiveHeaderColor; } GUILayout.BeginHorizontal(); #if UNITY_3_5_7 if (!state) { text += " (Click to expand)"; } #else text = "<b><size=11>" + text + "</size></b>"; #endif if (state) { text = "\u25BC " + text; } else { text = "\u25BA " + text; } if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) { state = !state; } GUILayout.Space(2f); if (state != _settings.createPrefabPoolsExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Prefab Pools"); _settings.createPrefabPoolsExpanded = state; } EditorGUILayout.EndHorizontal(); if (_settings.createPrefabPoolsExpanded) { DTInspectorUtility.BeginGroupedControls(); // BUTTONS... EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(100)); EditorGUI.indentLevel = 0; // Add expand/collapse buttons if there are items in the list EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(100)); // A little space between button groups GUILayout.Space(6); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); GUI.color = Color.white; var pools = LevelSettings.GetAllPrefabPools; if (pools.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You currently have no Prefab Pools."); } foreach (var pool in pools) { DTInspectorUtility.StartGroupHeader(1, false); EditorGUILayout.BeginHorizontal(); GUILayout.Label(pool.name); GUILayout.FlexibleSpace(); var buttonPressed = DTInspectorUtility.AddControlButtons(_settings, "Prefab Pool"); if (buttonPressed == DTInspectorUtility.FunctionButtons.Edit) { Selection.activeGameObject = pool.gameObject; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } if (pools.Count > 0) { DTInspectorUtility.VerticalSpace(2); } DTInspectorUtility.StartGroupHeader(); EditorGUI.indentLevel = 1; var newExp = DTInspectorUtility.Foldout(_settings.newPrefabPoolExpanded, "Create New Prefab Pools"); if (newExp != _settings.newPrefabPoolExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle expand Create New Prefab Pools"); _settings.newPrefabPoolExpanded = newExp; } EditorGUILayout.EndVertical(); if (_settings.newPrefabPoolExpanded) { EditorGUI.indentLevel = 0; var newPoolName = EditorGUILayout.TextField("New Pool Name", _settings.newPrefabPoolName); if (newPoolName != _settings.newPrefabPoolName) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change New Pool Name"); _settings.newPrefabPoolName = newPoolName; } EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); GUI.contentColor = DTInspectorUtility.AddButtonColor; if (GUILayout.Button("Create Prefab Pool", EditorStyles.toolbarButton, GUILayout.MaxWidth(110))) { CreatePrefabPool(); } GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); DTInspectorUtility.EndGroupedControls(); } GUI.color = Color.white; // end create prefab pools section // create spawners section EditorGUI.indentLevel = 0; DTInspectorUtility.VerticalSpace(2); state = _settings.spawnersExpanded; text = "Syncro Spawners"; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (!state) { GUI.backgroundColor = DTInspectorUtility.InactiveHeaderColor; } else { GUI.backgroundColor = DTInspectorUtility.ActiveHeaderColor; } GUILayout.BeginHorizontal(); #if UNITY_3_5_7 if (!state) { text += " (Click to expand)"; } #else text = "<b><size=11>" + text + "</size></b>"; #endif if (state) { text = "\u25BC " + text; } else { text = "\u25BA " + text; } if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) { state = !state; } GUILayout.Space(2f); EditorGUILayout.EndHorizontal(); if (state != _settings.spawnersExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Syncro Spawners"); _settings.spawnersExpanded = state; } if (_settings.spawnersExpanded) { DTInspectorUtility.BeginGroupedControls(); // BUTTONS... EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(100)); EditorGUI.indentLevel = 0; // Add expand/collapse buttons if there are items in the list EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(100)); // A little space between button groups GUILayout.Space(6); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); // end create spawners section GUI.color = Color.white; var spawners = LevelSettings.GetAllSpawners; if (spawners.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You currently have no Syncro Spawners."); } GUI.backgroundColor = DTInspectorUtility.BrightButtonColor; foreach (var spawner in spawners) { DTInspectorUtility.StartGroupHeader(1, false); EditorGUILayout.BeginHorizontal(); GUILayout.Label(spawner.name); GUILayout.FlexibleSpace(); var buttonPressed = DTInspectorUtility.AddControlButtons(_settings, "Spawner"); if (buttonPressed == DTInspectorUtility.FunctionButtons.Edit) { Selection.activeGameObject = spawner.gameObject; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } GUI.backgroundColor = Color.white; if (spawners.Count > 0) { DTInspectorUtility.VerticalSpace(2); } DTInspectorUtility.StartGroupHeader(); EditorGUI.indentLevel = 1; var newExp = DTInspectorUtility.Foldout(_settings.createSpawnerExpanded, "Create New"); if (newExp != _settings.createSpawnerExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle expand _settings.createSpawnerExpanded"); _settings.createSpawnerExpanded = newExp; } EditorGUILayout.EndVertical(); if (_settings.createSpawnerExpanded) { EditorGUI.indentLevel = 0; var newName = EditorGUILayout.TextField("New Spawner Name", _settings.newSpawnerName); if (newName != _settings.newSpawnerName) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change New Spawner Name"); _settings.newSpawnerName = newName; } var newType = (LevelSettings.SpawnerType)EditorGUILayout.EnumPopup("New Spawner Color", _settings.newSpawnerType); if (newType != _settings.newSpawnerType) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change New Spawner Color"); _settings.newSpawnerType = newType; } EditorGUILayout.BeginHorizontal(EditorStyles.boldLabel); GUILayout.Space(10); GUI.contentColor = DTInspectorUtility.AddButtonColor; if (GUILayout.Button("Create Spawner", EditorStyles.toolbarButton, GUILayout.MaxWidth(110))) { CreateSpawner(); } GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); DTInspectorUtility.EndGroupedControls(); } GUI.color = Color.white; // Player stats EditorGUI.indentLevel = 0; DTInspectorUtility.VerticalSpace(2); state = _settings.gameStatsExpanded; text = "World Variables"; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (!state) { GUI.backgroundColor = DTInspectorUtility.InactiveHeaderColor; } else { GUI.backgroundColor = DTInspectorUtility.ActiveHeaderColor; } GUILayout.BeginHorizontal(); #if UNITY_3_5_7 if (!state) { text += " (Click to expand)"; } #else text = "<b><size=11>" + text + "</size></b>"; #endif if (state) { text = "\u25BC " + text; } else { text = "\u25BA " + text; } if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) { state = !state; } GUILayout.Space(2f); if (state != _settings.gameStatsExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle World Variables"); _settings.gameStatsExpanded = state; } EditorGUILayout.EndHorizontal(); if (_settings.gameStatsExpanded) { DTInspectorUtility.BeginGroupedControls(); // BUTTONS... GUI.color = Color.white; var variables = LevelSettings.GetAllWorldVariables; if (variables.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You currently have no World Variables."); } foreach (var worldVar in variables) { DTInspectorUtility.StartGroupHeader(1, false); EditorGUILayout.BeginHorizontal(); GUILayout.Label(worldVar.name); GUILayout.FlexibleSpace(); var variable = worldVar.GetComponent<WorldVariable>(); GUI.contentColor = DTInspectorUtility.BrightTextColor; GUILayout.Label(WorldVariableTracker.GetVariableTypeFriendlyString(variable.varType)); GUI.contentColor = Color.white; var buttonPressed = DTInspectorUtility.AddControlButtons(_settings, "World Variable"); if (buttonPressed == DTInspectorUtility.FunctionButtons.Edit) { Selection.activeGameObject = worldVar.gameObject; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } GUI.backgroundColor = Color.white; DTInspectorUtility.VerticalSpace(3); EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); GUI.contentColor = DTInspectorUtility.BrightButtonColor; if (GUILayout.Button("World Variable Panel", EditorStyles.toolbarButton, GUILayout.MaxWidth(130))) { Selection.objects = new Object[] { playerStatsHolder.gameObject }; return; } GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); DTInspectorUtility.EndGroupedControls(); } // end Player stats GUI.color = Color.white; _settings._frames++; _isDirty = true; // level waves DTInspectorUtility.VerticalSpace(2); state = _settings.showLevelSettings; text = "Level Waves"; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (!state) { GUI.backgroundColor = DTInspectorUtility.InactiveHeaderColor; } else { GUI.backgroundColor = DTInspectorUtility.ActiveHeaderColor; } GUILayout.BeginHorizontal(); #if UNITY_3_5_7 if (!state) { text += " (Click to expand)"; } #else text = "<b><size=11>" + text + "</size></b>"; #endif if (state) { text = "\u25BC " + text; } else { text = "\u25BA " + text; } if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) { state = !state; } GUILayout.Space(2f); if (state != _settings.showLevelSettings) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Level Waves"); _settings.showLevelSettings = state; } EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if (_settings.showLevelSettings) { if (_settings.useWaves) { DTInspectorUtility.BeginGroupedControls(); EditorGUI.indentLevel = 0; // Space will handle this for the header if (_settings.LevelTimes.Count > 0) { var newRepeat = (LevelSettings.LevelLoopMode)EditorGUILayout.EnumPopup("Last Level Completed", _settings.repeatLevelMode); if (newRepeat != _settings.repeatLevelMode) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Last Level Completed"); _settings.repeatLevelMode = newRepeat; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Level Wave Settings"); // BUTTONS... EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(100)); // Add expand/collapse buttons if there are items in the list if (_settings.LevelTimes.Count > 0) { GUI.contentColor = DTInspectorUtility.BrightButtonColor; const string collapseIcon = "Collapse"; var content = new GUIContent(collapseIcon, "Click to collapse all"); var masterCollapse = GUILayout.Button(content, EditorStyles.toolbarButton); const string expandIcon = "Expand"; content = new GUIContent(expandIcon, "Click to expand all"); var masterExpand = GUILayout.Button(content, EditorStyles.toolbarButton); if (masterExpand) { ExpandCollapseAll(true); } if (masterCollapse) { ExpandCollapseAll(false); } GUI.contentColor = Color.white; } else { GUILayout.FlexibleSpace(); } EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(50)); var addText = string.Format("Click to add level{0}.", _settings.LevelTimes.Count > 0 ? " at the end" : ""); // Main Add button GUI.contentColor = DTInspectorUtility.AddButtonColor; if (GUILayout.Button(new GUIContent("Add", addText), EditorStyles.toolbarButton)) { _isDirty = true; CreateNewLevelAfter(); } GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); // ReSharper disable TooWideLocalVariableScope // ReSharper disable RedundantAssignment var levelButtonPressed = DTInspectorUtility.FunctionButtons.None; var waveButtonPressed = DTInspectorUtility.FunctionButtons.None; // ReSharper restore RedundantAssignment // ReSharper restore TooWideLocalVariableScope EditorGUI.indentLevel = 0; if (_settings.LevelTimes.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You have no Levels set up."); } var levelToDelete = -1; var levelToInsertAt = -1; var waveToInsertAt = -1; var waveToDelete = -1; int? waveToCopy = null; for (var l = 0; l < _settings.LevelTimes.Count; l++) { EditorGUI.indentLevel = 0; var levelSetting = _settings.LevelTimes[l]; DTInspectorUtility.StartGroupHeader(); EditorGUILayout.BeginHorizontal(); // Display foldout with current state EditorGUI.indentLevel = 1; state = DTInspectorUtility.Foldout(levelSetting.isExpanded, string.Format("Level {0} Waves & Settings", (l + 1))); if (state != levelSetting.isExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle expand Level Waves & Settings"); levelSetting.isExpanded = state; } levelButtonPressed = DTInspectorUtility.AddFoldOutListItemButtons(l, _settings.LevelTimes.Count, "level", false); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUI.indentLevel = 0; if (levelSetting.isExpanded) { var newOrder = (LevelSettings.WaveOrder)EditorGUILayout.EnumPopup("Wave Sequence", levelSetting.waveOrder); if (newOrder != levelSetting.waveOrder) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Wave Sequence"); levelSetting.waveOrder = newOrder; } for (var w = 0; w < levelSetting.WaveSettings.Count; w++) { var showVisualize = false; var waveSetting = levelSetting.WaveSettings[w]; DTInspectorUtility.StartGroupHeader(1); EditorGUILayout.BeginHorizontal(); EditorGUI.indentLevel = 1; // Display foldout with current state var innerExpanded = DTInspectorUtility.Foldout(waveSetting.isExpanded, "Wave " + (w + 1)); if (innerExpanded != waveSetting.isExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle expand Wave"); waveSetting.isExpanded = innerExpanded; } if (GUILayout.Button(new GUIContent("Visualize", "Visualize Waves of All Spawners"), EditorStyles.toolbarButton, GUILayout.Width(64))) { showVisualize = true; } waveButtonPressed = DTInspectorUtility.AddFoldOutListItemButtons(w, levelSetting.WaveSettings.Count, "wave", true, false, true); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (waveSetting.isExpanded) { EditorGUI.indentLevel = 0; if (waveSetting.skipWaveType == LevelSettings.SkipWaveMode.Always) { DTInspectorUtility.ShowColorWarningBox("This wave is set to be skipped."); } if (string.IsNullOrEmpty(waveSetting.waveName)) { waveSetting.waveName = "UNNAMED"; } var newWaveName = EditorGUILayout.TextField("Wave Name", waveSetting.waveName); if (newWaveName != waveSetting.waveName) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Wave Name"); waveSetting.waveName = newWaveName; } var newWaveType = (LevelSettings.WaveType)EditorGUILayout.EnumPopup("Wave Type", waveSetting.waveType); if (newWaveType != waveSetting.waveType) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Wave Type"); waveSetting.waveType = newWaveType; } if (waveSetting.waveType == LevelSettings.WaveType.Timed) { var newEnd = EditorGUILayout.Toggle("End When All Destroyed", waveSetting.endEarlyIfAllDestroyed); if (newEnd != waveSetting.endEarlyIfAllDestroyed) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle End Early When All Destroyed"); waveSetting.endEarlyIfAllDestroyed = newEnd; } var newDuration = EditorGUILayout.IntSlider("Duration (sec)", waveSetting.WaveDuration, 1, 2000); if (newDuration != waveSetting.WaveDuration) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Duration"); waveSetting.WaveDuration = newDuration; } } switch (waveSetting.skipWaveType) { case LevelSettings.SkipWaveMode.IfWorldVariableValueAbove: case LevelSettings.SkipWaveMode.IfWorldVariableValueBelow: EditorGUILayout.Separator(); break; } var newSkipType = (LevelSettings.SkipWaveMode)EditorGUILayout.EnumPopup("Skip Wave Type", waveSetting.skipWaveType); if (newSkipType != waveSetting.skipWaveType) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Skip Wave Type"); waveSetting.skipWaveType = newSkipType; } switch (waveSetting.skipWaveType) { case LevelSettings.SkipWaveMode.IfWorldVariableValueAbove: case LevelSettings.SkipWaveMode.IfWorldVariableValueBelow: var missingStatNames = new List<string>(); missingStatNames.AddRange(allStats); missingStatNames.RemoveAll(delegate(string obj) { return waveSetting.skipWavePassCriteria.HasKey(obj); }); var newStat = EditorGUILayout.Popup("Add Skip Wave Limit", 0, missingStatNames.ToArray()); if (newStat != 0) { AddWaveSkipLimit(missingStatNames[newStat], waveSetting); } if (waveSetting.skipWavePassCriteria.statMods.Count == 0) { DTInspectorUtility.ShowRedErrorBox("You have no Skip Wave Limits. Wave will never be skipped."); } else { EditorGUILayout.Separator(); int? indexToDelete = null; for (var i = 0; i < waveSetting.skipWavePassCriteria.statMods.Count; i++) { var modifier = waveSetting.skipWavePassCriteria.statMods[i]; var buttonPressed = DTInspectorUtility.FunctionButtons.None; switch (modifier._varTypeToUse) { case WorldVariableTracker.VariableType._integer: buttonPressed = KillerVariablesHelper.DisplayKillerInt(ref _isDirty, modifier._modValueIntAmt, modifier._statName, _settings, true, true); break; case WorldVariableTracker.VariableType._float: buttonPressed = KillerVariablesHelper.DisplayKillerFloat(ref _isDirty, modifier._modValueFloatAmt, modifier._statName, _settings, true, true); break; default: Debug.LogError("Add code for varType: " + modifier._varTypeToUse.ToString()); break; } KillerVariablesHelper.ShowErrorIfMissingVariable(modifier._statName); if (buttonPressed == DTInspectorUtility.FunctionButtons.Remove) { indexToDelete = i; } } DTInspectorUtility.ShowColorWarningBox("Limits are inclusive: i.e. 'Above' means >="); if (indexToDelete.HasValue) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "remove Skip Wave Limit"); waveSetting.skipWavePassCriteria.DeleteByIndex(indexToDelete.Value); } EditorGUILayout.Separator(); } break; } if (_settings.useMusicSettings) { if (l > 0 || w > 0) { var newMusicMode = (LevelSettings.WaveMusicMode)EditorGUILayout.EnumPopup("Music Mode", waveSetting.musicSettings.WaveMusicMode); if (newMusicMode != waveSetting.musicSettings.WaveMusicMode) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Music Mode"); waveSetting.musicSettings.WaveMusicMode = newMusicMode; } } if (waveSetting.musicSettings.WaveMusicMode == LevelSettings.WaveMusicMode.PlayNew) { var newWavMusic = (AudioClip)EditorGUILayout.ObjectField("Music", waveSetting.musicSettings.WaveMusic, typeof(AudioClip), true); if (newWavMusic != waveSetting.musicSettings.WaveMusic) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Wave Music"); waveSetting.musicSettings.WaveMusic = newWavMusic; } } if (waveSetting.musicSettings.WaveMusicMode != LevelSettings.WaveMusicMode.Silence) { var newVol = EditorGUILayout.Slider("Music Volume", waveSetting.musicSettings.WaveMusicVolume, 0f, 1f); if (newVol != waveSetting.musicSettings.WaveMusicVolume) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Music Volume"); waveSetting.musicSettings.WaveMusicVolume = newVol; } } else { var newFadeTime = EditorGUILayout.Slider("Silence Fade Time", waveSetting.musicSettings.FadeTime, 0f, 15f); if (newFadeTime != waveSetting.musicSettings.FadeTime) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Silence Fade Time"); waveSetting.musicSettings.FadeTime = newFadeTime; } } } if (!Application.isPlaying) { DTInspectorUtility.VerticalSpace(2); var spawnersUsed = FindMatchingSpawners(l, w); if (spawnersUsed.Count == 0) { DTInspectorUtility.ShowLargeBarAlertBox("You have no Spawners using this Wave."); } else { GUI.contentColor = DTInspectorUtility.BrightTextColor; GUILayout.Label("Spawners using this wave: " + spawnersUsed.Count, EditorStyles.boldLabel); GUI.contentColor = Color.white; } foreach (var spawner in spawnersUsed) { DTInspectorUtility.StartGroupHeader(0, false); EditorGUILayout.BeginHorizontal(); GUILayout.Label(spawner.name); GUILayout.FlexibleSpace(); var buttonPressed = DTInspectorUtility.AddControlButtons(_settings, "World Variable"); if (buttonPressed == DTInspectorUtility.FunctionButtons.Edit) { Selection.activeGameObject = spawner.gameObject; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } DTInspectorUtility.VerticalSpace(2); EditorGUILayout.LabelField("Wave Completed Options", EditorStyles.boldLabel); var newPause = EditorGUILayout.Toggle("Pause Global Waves", waveSetting.pauseGlobalWavesWhenCompleted); if (newPause != waveSetting.pauseGlobalWavesWhenCompleted) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Pause Global Waves"); waveSetting.pauseGlobalWavesWhenCompleted = newPause; } DTInspectorUtility.StartGroupHeader(0, false); // beat level variable modifiers var newBonusesEnabled = EditorGUILayout.BeginToggleGroup(" Wave Completion Bonus", waveSetting.waveBeatBonusesEnabled); if (newBonusesEnabled != waveSetting.waveBeatBonusesEnabled) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Wave Completion Bonus"); waveSetting.waveBeatBonusesEnabled = newBonusesEnabled; } EditorGUILayout.EndVertical(); if (waveSetting.waveBeatBonusesEnabled) { var missingBonusStatNames = new List<string>(); missingBonusStatNames.AddRange(allStats); missingBonusStatNames.RemoveAll(delegate(string obj) { return waveSetting .waveDefeatVariableModifiers .HasKey(obj); }); var newBonusStat = EditorGUILayout.Popup("Add Variable Modifer", 0, missingBonusStatNames.ToArray()); if (newBonusStat != 0) { AddBonusStatModifier(missingBonusStatNames[newBonusStat], waveSetting); } if (waveSetting.waveDefeatVariableModifiers.statMods.Count == 0) { if (waveSetting.waveBeatBonusesEnabled) { DTInspectorUtility.ShowColorWarningBox( "You currently are using no modifiers for this wave."); } } else { EditorGUILayout.Separator(); int? indexToDelete = null; for (var i = 0; i < waveSetting.waveDefeatVariableModifiers.statMods.Count; i++) { var modifier = waveSetting.waveDefeatVariableModifiers.statMods[i]; var buttonPressed = DTInspectorUtility.FunctionButtons.None; switch (modifier._varTypeToUse) { case WorldVariableTracker.VariableType._integer: buttonPressed = KillerVariablesHelper.DisplayKillerInt( ref _isDirty, modifier._modValueIntAmt, modifier._statName, _settings, true, true); break; case WorldVariableTracker.VariableType._float: buttonPressed = KillerVariablesHelper.DisplayKillerFloat(ref _isDirty, modifier._modValueFloatAmt, modifier._statName, _settings, true, true); break; default: Debug.LogError("Add code for varType: " + modifier._varTypeToUse.ToString()); break; } KillerVariablesHelper.ShowErrorIfMissingVariable(modifier._statName); if (buttonPressed == DTInspectorUtility.FunctionButtons.Remove) { indexToDelete = i; } } if (indexToDelete.HasValue) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "delete Variable Modifier"); waveSetting.waveDefeatVariableModifiers.DeleteByIndex(indexToDelete.Value); } } } EditorGUILayout.EndToggleGroup(); DTInspectorUtility.VerticalSpace(2); DTInspectorUtility.StartGroupHeader(0, false); // beat level Custom Events to fire var newExp = EditorGUILayout.BeginToggleGroup(" Wave Completion Custom Events", waveSetting.useCompletionEvents); if (newExp != waveSetting.useCompletionEvents) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Wave Completion Completion Custom Events"); waveSetting.useCompletionEvents = newExp; } EditorGUILayout.EndVertical(); if (waveSetting.useCompletionEvents) { DTInspectorUtility.BeginGroupedControls(); DTInspectorUtility.ShowColorWarningBox("When wave completed, fire the Custom Events below"); EditorGUILayout.BeginHorizontal(); GUI.contentColor = DTInspectorUtility.AddButtonColor; GUILayout.Space(10); if (GUILayout.Button(new GUIContent("Add", "Click to add a Custom Event"), EditorStyles.toolbarButton, GUILayout.Width(50))) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "Add Wave Completion Custom Event"); waveSetting.completionCustomEvents.Add(new CGKCustomEventToFire()); } GUILayout.Space(10); if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last Custom Event"), EditorStyles.toolbarButton, GUILayout.Width(50))) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "Remove Last Wave Completion Custom Event"); waveSetting.completionCustomEvents.RemoveAt(waveSetting.completionCustomEvents.Count - 1); } GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); if (waveSetting.completionCustomEvents.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You have no Custom Events selected to fire."); } if (waveSetting.completionCustomEvents.Count > 0) { DTInspectorUtility.VerticalSpace(2); } // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < waveSetting.completionCustomEvents.Count; i++) { var anEvent = waveSetting.completionCustomEvents[i].CustomEventName; anEvent = DTInspectorUtility.SelectCustomEventForVariable(ref _isDirty, anEvent, _settings, "Custom Event"); if (anEvent == waveSetting.completionCustomEvents[i].CustomEventName) { continue; } waveSetting.completionCustomEvents[i].CustomEventName = anEvent; } DTInspectorUtility.EndGroupedControls(); } EditorGUILayout.EndToggleGroup(); } if (showVisualize) { var allSpawners = LevelSettings.GetAllSpawners; // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < allSpawners.Count; i++) { var aSpawner = allSpawners[i]; aSpawner.gameObject.DestroyChildrenImmediateWithMarker(); var spawn = aSpawner.GetComponent<WaveSyncroPrefabSpawner>(); // ReSharper disable ForCanBeConvertedToForeach for (var wave = 0; wave < spawn.waveSpecs.Count; wave++) { // ReSharper restore ForCanBeConvertedToForeach spawn.waveSpecs[wave].visualizeWave = false; } } var spawnersUsed = FindMatchingSpawners(l, w); foreach (var spawner in spawnersUsed) { // ReSharper disable once ForCanBeConvertedToForeach for (var lw = 0; lw < spawner.waveSpecs.Count; lw++) { var aWave = spawner.waveSpecs[lw]; // ReSharper disable once InvertIf if (aWave.SpawnLevelNumber == l && aWave.SpawnWaveNumber == w) { aWave.visualizeWave = true; //Debug.Log(spawner.name + " : " + l + " : " + w); spawner.SpawnWaveVisual(aWave); } } } } switch (waveButtonPressed) { case DTInspectorUtility.FunctionButtons.Remove: if (levelSetting.WaveSettings.Count <= 1) { DTInspectorUtility.ShowAlert("You cannot delete the only Wave in a Level. Delete the Level if you like."); } else { waveToDelete = w; } _isDirty = true; break; case DTInspectorUtility.FunctionButtons.Add: waveToInsertAt = w; _isDirty = true; break; case DTInspectorUtility.FunctionButtons.Copy: waveToCopy = w; break; } EditorGUILayout.EndVertical(); DTInspectorUtility.AddSpaceForNonU5(); } if (waveToDelete >= 0) { if (DTInspectorUtility.ConfirmDialog("Delete wave? This cannot be undone.")) { DeleteWave(levelSetting, waveToDelete, l); _isDirty = true; } } if (waveToInsertAt > -1) { InsertWaveAfter(levelSetting, waveToInsertAt, l); _isDirty = true; } if (waveToCopy.HasValue) { CloneWave(levelSetting, waveToCopy.Value, l); _isDirty = true; } } switch (levelButtonPressed) { case DTInspectorUtility.FunctionButtons.Remove: if (DTInspectorUtility.ConfirmDialog("Delete level? This cannot be undone.")) { levelToDelete = l; _isDirty = true; } break; case DTInspectorUtility.FunctionButtons.Add: _isDirty = true; levelToInsertAt = l; break; } EditorGUILayout.EndVertical(); if (!levelSetting.isExpanded) { continue; } DTInspectorUtility.VerticalSpace(0); DTInspectorUtility.AddSpaceForNonU5(3); } if (levelToDelete > -1) { DeleteLevel(levelToDelete); } if (levelToInsertAt > -1) { CreateNewLevelAfter(levelToInsertAt); } DTInspectorUtility.EndGroupedControls(); } else { DTInspectorUtility.BeginGroupedControls(); EditorGUILayout.LabelField(" Level Wave Settings (DISABLED)"); DTInspectorUtility.EndGroupedControls(); } } // level waves EditorGUI.indentLevel = 0; DTInspectorUtility.VerticalSpace(2); state = _settings.showCustomEvents; text = "Custom Events"; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (!state) { GUI.backgroundColor = DTInspectorUtility.InactiveHeaderColor; } else { GUI.backgroundColor = DTInspectorUtility.ActiveHeaderColor; } GUILayout.BeginHorizontal(); #if UNITY_3_5_7 if (!state) { text += " (Click to expand)"; } #else text = "<b><size=11>" + text + "</size></b>"; #endif if (state) { text = "\u25BC " + text; } else { text = "\u25BA " + text; } if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) { state = !state; } GUILayout.Space(2f); if (state != _settings.showCustomEvents) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle Custom Events"); _settings.showCustomEvents = state; } EditorGUILayout.EndHorizontal(); GUI.color = Color.white; if (_settings.showCustomEvents) { DTInspectorUtility.BeginGroupedControls(); var newEvent = EditorGUILayout.TextField("New Event Name", _settings.newEventName); if (newEvent != _settings.newEventName) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change New Event Name"); _settings.newEventName = newEvent; } EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); GUI.contentColor = DTInspectorUtility.AddButtonColor; if (GUILayout.Button("Create New Event", EditorStyles.toolbarButton, GUILayout.Width(100))) { CreateCustomEvent(_settings.newEventName); } GUILayout.Space(10); var hasExpanded = false; foreach (var t in _settings.customEvents) { if (!t.eventExpanded) { continue; } hasExpanded = true; break; } var buttonText = hasExpanded ? "Collapse All" : "Expand All"; if (GUILayout.Button(buttonText, EditorStyles.toolbarButton, GUILayout.Width(100))) { ExpandCollapseCustomEvents(!hasExpanded); } GUILayout.Space(10); if (GUILayout.Button("Sort Alpha", EditorStyles.toolbarButton, GUILayout.Width(100))) { SortCustomEvents(); } GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); if (_settings.customEvents.Count == 0) { DTInspectorUtility.ShowColorWarningBox("You currently have no custom events."); } EditorGUILayout.Separator(); int? customEventToDelete = null; int? eventToRename = null; for (var i = 0; i < _settings.customEvents.Count; i++) { DTInspectorUtility.StartGroupHeader(); EditorGUI.indentLevel = 1; var anEvent = _settings.customEvents[i]; EditorGUILayout.BeginHorizontal(); var exp = DTInspectorUtility.Foldout(anEvent.eventExpanded, anEvent.EventName); if (exp != anEvent.eventExpanded) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "toggle expand Custom Event"); anEvent.eventExpanded = exp; } GUILayout.FlexibleSpace(); if (Application.isPlaying) { var receivers = LevelSettings.ReceiversForEvent(anEvent.EventName); GUI.contentColor = DTInspectorUtility.BrightButtonColor; if (receivers.Count > 0) { if (GUILayout.Button("Select", EditorStyles.toolbarButton, GUILayout.Width(50))) { var matches = new List<GameObject>(receivers.Count); foreach (var t in receivers) { matches.Add(t.gameObject); } Selection.objects = matches.ToArray(); } } if (GUILayout.Button("Fire!", EditorStyles.toolbarButton, GUILayout.Width(50))) { LevelSettings.FireCustomEvent(anEvent.EventName, _settings.transform.position); } GUI.contentColor = DTInspectorUtility.BrightTextColor; GUILayout.Label(string.Format("Receivers: {0}", receivers.Count)); GUI.contentColor = Color.white; } else { var newName = GUILayout.TextField(anEvent.ProspectiveName, GUILayout.Width(170)); if (newName != anEvent.ProspectiveName) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Proposed Event Name"); anEvent.ProspectiveName = newName; } var buttonPressed = DTInspectorUtility.AddCustomEventDeleteIcon(true); switch (buttonPressed) { case DTInspectorUtility.FunctionButtons.Remove: customEventToDelete = i; break; case DTInspectorUtility.FunctionButtons.Rename: eventToRename = i; break; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (!anEvent.eventExpanded) { EditorGUILayout.EndVertical(); DTInspectorUtility.AddSpaceForNonU5(); continue; } EditorGUI.indentLevel = 0; var rcvMode = (LevelSettings.EventReceiveMode)EditorGUILayout.EnumPopup("Send To Receivers", anEvent.eventRcvMode); if (rcvMode != anEvent.eventRcvMode) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Send To Receivers"); anEvent.eventRcvMode = rcvMode; } if (rcvMode == LevelSettings.EventReceiveMode.WhenDistanceLessThan || rcvMode == LevelSettings.EventReceiveMode.WhenDistanceMoreThan) { KillerVariablesHelper.DisplayKillerFloat(ref _isDirty, anEvent.distanceThreshold, "Distance Threshold", _settings); } if (rcvMode != LevelSettings.EventReceiveMode.Never) { var rcvFilter = (LevelSettings.EventReceiveFilter)EditorGUILayout.EnumPopup("Valid Receivers", anEvent.eventRcvFilterMode); if (rcvFilter != anEvent.eventRcvFilterMode) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Valid Receivers"); anEvent.eventRcvFilterMode = rcvFilter; } } switch (anEvent.eventRcvFilterMode) { case LevelSettings.EventReceiveFilter.Closest: case LevelSettings.EventReceiveFilter.Random: var newQty = EditorGUILayout.IntField("Valid Qty", anEvent.filterModeQty); if (newQty != anEvent.filterModeQty) { UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _settings, "change Valid Qty"); anEvent.filterModeQty = Math.Max(1, newQty); } break; } EditorGUILayout.EndVertical(); DTInspectorUtility.AddSpaceForNonU5(); } if (customEventToDelete.HasValue) { _settings.customEvents.RemoveAt(customEventToDelete.Value); } if (eventToRename.HasValue) { RenameEvent(_settings.customEvents[eventToRename.Value]); } DTInspectorUtility.EndGroupedControls(); } if (GUI.changed || _isDirty) { EditorUtility.SetDirty(target); // or it won't save the data!! } //DrawDefaultInspector(); }
private IEnumerator StartLevel(LevelSettings levelSettings) { if (levelSettings.blocks != null) { int blocksCount = levelSettings.blocks.Length; for (int i = 0; i < blocksCount; ++i) { yield return StartCoroutine(StartBlock(levelSettings, i)); } } }
public void SetTemperature(LevelSettings.LevelAmbientTemperature levelAmbientTemperature) { Debug.Log("setting temperature..."); temperature = levelAmbientTemperature; setBreath(); }
public void instantiateNewLevelSettings() { availableResources = new LevelSettings(bananaToggle,obstacleToggle,monkeyToggle,figureToggle, goalToreach); }
public void fillInTileWithObstacles(LevelSettings generate) { this.gameObject.transform.parent.GetComponent<ItemSpawner>().fillThisTile(this.gameObject, generate); }
/// <summary> /// will fill the tile with pickups /// </summary> /// <param name="tileToFill">the position where the objects will be spawned in</param> /// <param name="settings">rules for the spawner</param> public void fillThisTile(GameObject tileToFill,LevelSettings generate) { spaceUsed = new bool[3, 3, 10]; for (int i = 0; i < depthRow; i++) { if (generate.obstacles) createObstacles(tileToFill,i); if (generate.bananas) createPickUps(tileToFill,i); if (generate.figures) createPowerUps(); } }