public RosemarySpawn Spawn(Vector3 position, Quaternion rotation) { if (!isActiveAndEnabled) { Debug.LogError("Spawner not active and enabled", this); return(null); } if (!m_inactive.Any()) { return(InstantiateSpawnFromPrefab(position, rotation, SpawnMode.Spawning)); } else { var oldMode = spawnMode; spawnMode = SpawnMode.Spawning; try { var spawn = m_inactive.First(); spawn.transform.position = position; spawn.transform.rotation = rotation; spawn.gameObject.SetActive(true); return(spawn); } finally { spawnMode = oldMode; } } }
public SpawnUnit(SpawnMode mode, int owningPlayer, int spawnID, float startX, float startY, float splitRate, float mutationRate, float attackPotency, float decayRate, float directionX, float directionY, float speed, bool splitting) { this.mode=mode; this.owningPlayer=owningPlayer; this.spawnID=spawnID; this.startX=startX; this.startY=startY; this.splitRate=splitRate; this.mutationRate=mutationRate; this.attackPotency=attackPotency; this.decayRate=decayRate; this.directionX=directionX; this.directionY=directionY; this.speed=speed; this.splitting=splitting; }
public DroppedItem SpawnDroppedItem(Item item, Vector2 pos, int count = 1, SpawnMode spawnMode = SpawnMode.Fresh) { if (spawnMode == SpawnMode.Fresh) return SpawnItem(item.GetType(), count).OnDrop(pos); else return SpawnCloneItem(item).OnDrop(pos); }
private RosemarySpawn InstantiateSpawnFromPrefab(Vector3 position, Quaternion rotation, SpawnMode mode) { var oldMode = spawnMode; spawnMode = mode; try { if (prefab == null) { Debug.LogError("Prefab is null", this); return(null); } var go = Instantiate(prefab.gameObject, position, rotation, transform); go.name = prefab.name; var spawn = go.GetComponent <RosemarySpawn>(); if (!spawn.isInitialised) { go.SetActive(true); } return(spawn); } finally { spawnMode = oldMode; } }
void TriggerSpawn() { for (int i = 0; i < data.AllSpawnMode.Count; i++) { SpawnMode _mode = data.AllSpawnMode[i]; if (data.AutoDestroyAgent) { if (data.IsMonoAgent) { _mode.Mode.SpawnWithDestroy(data.MonoAgent, data.delayAutoDestroy); } else { _mode.Mode.SpawnWithDestroy(data.Agents, data.delayAutoDestroy); } } else { if (data.IsMonoAgent) { _mode.Mode.Spawn(data.MonoAgent); } else { _mode.Mode.Spawn(data.Agents); } } } Triggered = true; }
// Start is called before the first frame update void Start() { player = playerOne.GetComponent <PlayerController>(); gameMode = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameController>().mode; playerTwoController = playerTwo.GetComponent <PlayerController>(); Debug.Log(gameMode); }
void DrawSpawModeUI(SpawnPoint _point) { Layout.Horizontal(true); Layout.Space(); Layout.HelpBoxInfo("Add or Remove modes"); Layout.Vertical(true); ETUButton.Button("+", _point.AddMode, Color.yellow); ETUButton.ButtonConfirmation("Clear all modes", _point.RemoveAll, "Remove all", "Remove all modes ?", "Yes", "No", _point.AllSpawnMode.Count > 0); Layout.Vertical(false); Layout.Horizontal(false); for (int i = 0; i < _point.AllSpawnMode.Count; i++) { SpawnMode _mode = _point.AllSpawnMode[i]; Layout.Space(); Layout.Horizontal(true); _mode.Type = (SpawnType)Layout.EnumPop("Mode Type", _mode.Type); //_mode.Type = (SpawnType)EditorGUILayout.EnumPopup("Mode Type", _mode.Type); ETUButton.ButtonConfirmation("-", _point.RemoveMode, "Remove mode", $"Remove point {i + 1} ?", "Yes", "No", i); Layout.Horizontal(false); DrawModeSettings(_mode); Layout.Space(); } }
public WatermelonSpawner(Layer layer, Vector2 position, SpawnMode spawnMode, string spawnEntity) : base(layer) { AddComponent(new PositionComponent(position)); _spawnMode = spawnMode; _spawnEntityTag = spawnEntity; }
public override void Execute(string payLoad) { SpawnMode mode = null; foreach (KeyValuePair <string, SpawnMode> item in SpawnModeConfiguration.spawnModes) { if (String.Equals(payLoad, item.Key, StringComparison.OrdinalIgnoreCase)) { mode = item.Value; } continue; } if (SpawnModeConfiguration.currentMode != mode) { if (mode != null) { LoggerWrapper.Log($"Switched to \"{ mode.spawnModeName }\" - \"{mode.description}\" ", LogLevel.Message); } else { LoggerWrapper.Log("Invalid mode", LogLevel.Message); } //ToDo fix switching back to normal spawns //EnemyPopulationDataBlock.Setup(); //EnemyPopulationDataBlock.PostSetup(); SpawnModeConfiguration.currentMode = mode; } }
//Register single player game mode and update the game mode component to perform multiplayer game controller actions private void setModeDouble() { mode = SpawnMode.MULTIPLAYER; InitializeGameMode(2); gameMode = gameObject.AddComponent <TwoPlayer>(); print("GameMode set to multiplayer. GameMode value: Double"); print("Number of players: " + GetNumberPlayers()); }
//Register single player game mode and update the game mode component to perform single player game controller actions private void setModeSingle() { mode = SpawnMode.SINGLEPLAYER; InitializeGameMode(1); gameMode = gameObject.AddComponent <SinglePlayer>(); print("GameMode set to singleplayer. GameMode value: Single"); print("Number of players: " + GetNumberPlayers()); }
void GetModesScene(SpawnPoint _point) { for (int i = 0; i < _point.AllSpawnMode.Count; i++) { SpawnMode _mode = _point.AllSpawnMode[i]; DrawModeScene(_mode, _point); } }
protected void ChangeSpawnMode(SpawnMode mode) { switch (mode) { case SpawnMode.EasyMode: spawnMode = SpawnMode.EasyMode; spawnCount = 6; lerpTime = 0.01f; spawnTime = 0.25f; intervalTime = 1.5f; break; case SpawnMode.NormalMode: spawnMode = SpawnMode.NormalMode; spawnCount = 9; lerpTime = 0.02f; spawnTime = 0.4f; intervalTime = 2f; break; case SpawnMode.HardMode: spawnMode = SpawnMode.HardMode; spawnCount = 12; lerpTime = 0.05f; spawnTime = 0.3f; intervalTime = 3f; break; case SpawnMode.CarzyMode: spawnMode = SpawnMode.CarzyMode; spawnCount = 12; lerpTime = 0.075f; spawnTime = 0.25f; intervalTime = 2f; break; case SpawnMode.EndTimeMode: spawnMode = SpawnMode.EndTimeMode; spawnCount = 24; lerpTime = 0.075f; spawnTime = 0.25f; intervalTime = 2f; break; } }
private GameObject SpawnBoid(SpawnMode spawnMode) { Vector3 spawnPosition = Vector3.zero; if (spawnMode == SpawnMode.Origin) { spawnPosition = boundary.Center; } else if (spawnMode == SpawnMode.Random) { spawnPosition = boundary.RandomVolume; } else if (LeaderTransform != null) //on leader { spawnPosition = LeaderTransform.position; } return(Instantiate(boidPrefab, spawnPosition, Quaternion.identity, boidContainer)); }
/// <summary> /// Selects a spawn based on the spawn mode from the collection of child spawns that are available. /// </summary> /// <param name="inSpawn">Extension input</param> /// <param name="spawnMode">The spawn mode to use for selection</param> /// <returns></returns> public static ISpawn selectSpawn(this ISpawn inSpawn, SpawnMode spawnMode) { // Different spawn modes switch (spawnMode) { default: case SpawnMode.Random: { // Select a random spawn (Area or point) return(inSpawn.randomSpawn()); } case SpawnMode.Sequential: { // Select the next spawn (Area or point) return(inSpawn.sequentialSpawn()); } } }
//Function to set the game mode to single player or multiplayer public void InitializeGameMode(int gameChoice) { switch (gameChoice) { //if the value of gameChoice is 1 (from the main menu) then create a singleplayer game case 1: numPlayers = 1; mode = SpawnMode.SINGLEPLAYER; p1LifeSprites = new GameObject[3]; break; //if the value of gameChoice is 2 (from the main menu) then create a multiplayer game case 2: numPlayers = 2; mode = SpawnMode.MULTIPLAYER; break; } }
public void RandomSpawn(SpawnMode mode = SpawnMode.InsideSphere) { switch (mode) { default: case SpawnMode.InsideSphere: RandomSpawnInsideSphere(); break; case SpawnMode.OutsideSphere: RandomSpawnInsideSphere(false); break; case SpawnMode.OnPlane: RandomSpawnOnPlane(); break; case SpawnMode.OnSphere: RandomSpawnOnSphere(); break; } }
public Vector2 GetBallSpawnPosition(SpawnMode mode = SpawnMode.Center, int startingSide = 0) { ball.SetState(BallState.Floating); switch (mode) { case SpawnMode.Center: return(Vector2.zero); case SpawnMode.LosingTeam: return(Vector2.zero); case SpawnMode.WinningTeam: return(Vector2.zero); case SpawnMode.Random: startingSide = Random.Range(0, 2) * 2 - 1; return(new Vector2((screenBounds.x / 4) * startingSide, startPosition)); default: return(Vector2.zero); } }
public void setMode(SpawnMode mode) { spawnMode=mode; //typeText.text="Spawn Mode: "+mode; }
/// <summary> /// respawns the object if no other object is occupying the respawn area. /// otherwise reschedules respawning. NOTE: this method can only run in /// singleplayer and by a master in multiplayer. multiplayer _clients_ /// will instead use the version of 'GetSpawnPoint' that takes a position /// and rotation (called directly by the master) /// </summary> public virtual void PickSpawnPoint() { // return if the object has been destroyed (for example // as a result of loading a new level while it was gone) if (this == null) { return; } // if mode is 'SamePosition' or the level has no spawnpoints, go to initial position if ((m_SpawnMode == SpawnMode.SamePosition) || (vp_SpawnPoint.SpawnPoints.Count < 1)) { Placement.Position = m_InitialPosition; Placement.Rotation = m_InitialRotation; // if an object the size of 'RespawnCheckRadius' can't fit at // 'm_InitialPosition' ... if (Placement.IsObstructed(ObstructionRadius)) { switch (m_ObstructionSolver) { case ObstructionSolver.Wait: // ... just try again later! vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; case ObstructionSolver.AdjustPlacement: // try to adjust the position ... if (!vp_Placement.AdjustPosition(Placement, ObstructionRadius)) { // ... and only if we failed to adjust the position, try again later vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; } break; } } } else { // placement will be calculated by the spawnpoint system. // NOTE: the obstruction solution logic becomes slightly // different with spawnpoints switch (m_ObstructionSolver) { case ObstructionSolver.Wait: // if an object the size of 'RespawnCheckRadius' can't fit at // this random spawnpoint ... Placement = vp_SpawnPoint.GetRandomPlacement(0.0f, SpawnPointTag); if (Placement == null) { Placement = new vp_Placement(); m_SpawnMode = SpawnMode.SamePosition; PickSpawnPoint(); } // NOTE: no 'snap to ground' in this mode since the snap logic // of 'GetRandomPlacement' is dependent on its input value if (Placement.IsObstructed(ObstructionRadius)) { // ... skip trying to adjust the position and try again later vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; } break; case ObstructionSolver.AdjustPlacement: // if an object the size of 'RespawnCheckRadius' can't fit at // this random spawnpoint and we fail to adjust the position ... Placement = vp_SpawnPoint.GetRandomPlacement(ObstructionRadius, SpawnPointTag); if (Placement == null) { // ... try again later vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; } break; } } Respawn(); }
void DrawModeSettings(SpawnMode _mode) => _mode.Mode.DrawSettings();
/// <summary> /// respawns the object if no other object is occupying the respawn area. /// otherwise reschedules respawning. NOTE: this method can only run in /// singleplayer and by a master in multiplayer. multiplayer _clients_ /// will instead use the version of 'GetSpawnPoint' that takes a position /// and rotation (called directly by the master) /// </summary> public virtual void PickSpawnPoint() { // return if the object has been destroyed (for example // as a result of loading a new level while it was gone) if (this == null) return; // if mode is 'SamePosition' or the level has no spawnpoints, go to initial position if ((m_SpawnMode == SpawnMode.SamePosition) || (vp_SpawnPoint.SpawnPoints.Count < 1)) { Placement.Position = m_InitialPosition; Placement.Rotation = m_InitialRotation; // if an object the size of 'RespawnCheckRadius' can't fit at // 'm_InitialPosition' ... if (Placement.IsObstructed(ObstructionRadius)) { switch (m_ObstructionSolver) { case ObstructionSolver.Wait: // ... just try again later! vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; case ObstructionSolver.AdjustPlacement: // try to adjust the position ... if (!vp_Placement.AdjustPosition(Placement, ObstructionRadius)) { // ... and only if we failed to adjust the position, try again later vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; } break; } } } else { // placement will be calculated by the spawnpoint system. // NOTE: the obstruction solution logic becomes slightly // different with spawnpoints switch (m_ObstructionSolver) { case ObstructionSolver.Wait: // if an object the size of 'RespawnCheckRadius' can't fit at // this random spawnpoint ... Placement = vp_SpawnPoint.GetRandomPlacement(0.0f, SpawnPointTag); if (Placement == null) { Placement = new vp_Placement(); m_SpawnMode = SpawnMode.SamePosition; PickSpawnPoint(); } // NOTE: no 'snap to ground' in this mode since the snap logic // of 'GetRandomPlacement' is dependent on its input value if (Placement.IsObstructed(ObstructionRadius)) { // ... skip trying to adjust the position and try again later vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; } break; case ObstructionSolver.AdjustPlacement: // if an object the size of 'RespawnCheckRadius' can't fit at // this random spawnpoint and we fail to adjust the position ... Placement = vp_SpawnPoint.GetRandomPlacement(ObstructionRadius, SpawnPointTag); if (Placement == null) { // ... try again later vp_Timer.In(UnityEngine.Random.Range(MinRespawnTime, MaxRespawnTime), PickSpawnPoint, m_RespawnTimer); return; } break; } } Respawn(); }
public void StartSpawning(SpawnMode mode) { SpawnMode = mode; enabled = true; }
void DrawModeScene(SpawnMode _mode, SpawnPoint _fromSpawner) { _mode.Mode.DrawLinkToSpawner(_fromSpawner.Position); _mode.Mode.DrawSceneMode(); }
private void TryExecute(Map map, IncidentParms parms, ObjectiveDef def, IncidentCondition?condition) { LookTargets targets = new LookTargets(); string label = ""; string message = ""; if (type == IncidentType.Research) { StringBuilder sb = new StringBuilder(); foreach (ResearchProjectDef project in researchUnlocks) { sb.Append(" - " + project.LabelCap); Find.ResearchManager.FinishProject(project); } label = "ResearchIncident_SMO".Translate(); message = "ResearchIncidentDesc_SMO".Translate(sb.ToString()); } if (type == IncidentType.Reward) { SpawnMode mode = spawnSettings.mode; if (mode == SpawnMode.Target) { SpawnAround(parms.spawnCenter, map, ref targets, out bool p); } if (mode == SpawnMode.Stockpile) { List <Thing> things = SpawnThings(out List <List <Thing> > list, ref targets); List <IntVec3> cells = new List <IntVec3>(); List <Zone> zones = map.zoneManager.AllZones; for (int i = 0; i < zones.Count; i++) { Zone zone = zones[i]; if (zone is Zone_Stockpile) { cells.AddRange(zone.Cells.Where(c => c.GetFirstItem(map) == null)); } } if (cells.Count < things.Count) { IntVec3 cell = IntVec3.Invalid; if (map.areaManager.Home?.ActiveCells.Count() > 0) { PositionFilter filter = new PositionFilter(); filter.homeArea = AreaCheck.Prefer; filter.roofs = AreaCheck.Avoid; cell = filter.FindCell(map, spawnSettings.spawnList); } cell = cell.IsValid ? cell : parms.spawnCenter; DropPodUtility.DropThingGroupsNear(cell, map, list, 140, false, true, true); } else { foreach (Thing thing in things) { IntVec3 cell = cells.RandomElement(); cells.Remove(cell); targets.targets.Add(GenSpawn.Spawn(thing, cells.RandomElement(), map)); } } } if (mode == SpawnMode.DropPod) { SpawnDropPod(parms.spawnCenter, map, ref targets); } if (condition.Value == IncidentCondition.Started) { label = "StartingItems_SMO".Translate(); message = "StartingItemsDesc_SMO".Translate("'" + def.LabelCap + "'"); } if (condition.Value == IncidentCondition.Finished || condition == null) { label = "Reward_SMO".Translate(); if (def != null) { message = "RewardDesc_SMO".Translate("'" + def.LabelCap + "'"); } } } if (type == IncidentType.Appear) { SpawnAround(parms.spawnCenter, map, ref targets, out bool p); label = p ? "AppearPlural_SMO".Translate() : "Appear_SMO".Translate(); message = p ? "AppearDescPlural_SMO".Translate() : "AppearDesc_SMO".Translate(targets); } if (type == IncidentType.Skyfaller) { int count = 0; foreach (ThingSkyfaller skyfaller in spawnSettings.skyfallers) { if (Rand.Chance(skyfaller.chance)) { count++; targets.targets.Add(SkyfallerMaker.SpawnSkyfaller(skyfaller.skyfaller, skyfaller.def, parms.spawnCenter, map)); } } bool plural = count > 1; label = plural ? "Skyfaller_SMO".Translate() : "SkyfallerPlural_SMO".Translate(); message = plural ? "SkyfallerDesc_SMO".Translate() : "SkyfallerDescPlural_SMO".Translate(); } if (type == IncidentType.Raid) { List <Pawn> raiders = new List <Pawn>(); foreach (ThingValue tv in spawnSettings.spawnList) { if (Rand.Chance(tv.chance)) { for (int i = 0; i < tv.value; i++) { Pawn pawn = PawnGenerator.GeneratePawn(tv.PawnKindDef, parms.faction); raiders.Add(pawn); targets.targets.Add(pawn); } } } parms.raidArrivalMode.Worker.Arrive(raiders, parms); parms.raidStrategy.Worker.MakeLords(parms, raiders); Find.StoryWatcher.statsRecord.numRaidsEnemy++; label = "Raid_SMO".Translate(); message = "RaidDesc_SMO".Translate(PawnKinds); } Find.LetterStack.ReceiveLetter(letterLabel ?? label, letterDesc ?? message, letterDef, targets, type == IncidentType.Raid ? Faction : null, null); }
public void Spawn(Map map, IntVec3 pos, Faction faction, SpawnPosType posType = SpawnPosType.Unchanged, SpawnMode spawnMode = SpawnMode.Normal, bool wipeIfCollides = false, bool clearEdificeWhereFloor = false, List <Thing> spawnedThings = null, bool dormant = false, bool buildRoofsInstantly = false, Func <SketchEntity, IntVec3, bool> canSpawnThing = null, Action <IntVec3, SketchEntity> onFailedToSpawnThing = null) { IntVec3 offset = GetOffset(pos, posType); if (clearEdificeWhereFloor) { for (int i = 0; i < cachedTerrain.Count; i++) { if (cachedTerrain[i].def.layerable) { (cachedTerrain[i].pos + offset).GetEdifice(map)?.Destroy(); } } } foreach (SketchEntity item in entities.OrderBy((SketchEntity x) => x.SpawnOrder)) { IntVec3 intVec = item.pos + offset; if ((canSpawnThing == null || canSpawnThing(item, intVec)) && !item.Spawn(intVec, map, faction, spawnMode, wipeIfCollides, spawnedThings, dormant)) { onFailedToSpawnThing?.Invoke(intVec, item); } } if (spawnedThings != null && spawnMode == SpawnMode.TransportPod && !wipeIfCollides) { bool flag = false; for (int j = 0; j < spawnedThings.Count; j++) { for (int k = j + 1; k < spawnedThings.Count; k++) { CellRect cellRect = GenAdj.OccupiedRect(spawnedThings[j].Position, spawnedThings[j].Rotation, spawnedThings[j].def.size); CellRect other = GenAdj.OccupiedRect(spawnedThings[k].Position, spawnedThings[k].Rotation, spawnedThings[k].def.size); if (cellRect.Overlaps(other) && (GenSpawn.SpawningWipes(spawnedThings[j].def, spawnedThings[k].def) || GenSpawn.SpawningWipes(spawnedThings[k].def, spawnedThings[j].def))) { flag = true; break; } } if (flag) { break; } } if (flag) { for (int l = 0; l < spawnedThings.Count; l++) { ActiveDropPodInfo activeDropPodInfo; if ((activeDropPodInfo = (spawnedThings[l].ParentHolder as ActiveDropPodInfo)) != null) { activeDropPodInfo.spawnWipeMode = null; } } } } if (buildRoofsInstantly && spawnMode == SpawnMode.Normal) { foreach (IntVec3 suggestedRoofCell in GetSuggestedRoofCells()) { IntVec3 c = suggestedRoofCell + offset; if (c.InBounds(map) && !c.Roofed(map)) { map.roofGrid.SetRoof(c, RoofDefOf.RoofConstructed); } } } }
private void Awake() { gameMode = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameController>().mode; }
public void SpawnPlayer(Vector3 position, SpawnMode spawnMode) { ComponentMount componentMount = null; if (spawnMode != SpawnMode.Respawn && CheckIsPointInWater(Terrain.ToCell(position))) { Entity entity = DatabaseManager.CreateEntity(m_project, "Boat", throwIfNotFound: true); entity.FindComponent <ComponentBody>(throwOnError: true).Position = position; entity.FindComponent <ComponentBody>(throwOnError: true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathUtils.DegToRad(45f)); componentMount = entity.FindComponent <ComponentMount>(throwOnError: true); m_project.AddEntity(entity); position.Y += entity.FindComponent <ComponentBody>(throwOnError: true).BoxSize.Y; } string value = ""; string value2 = ""; string value3 = ""; string value4 = ""; if (spawnMode != SpawnMode.Respawn) { if (PlayerClass == PlayerClass.Female) { if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("2")) { value = ""; value2 = MakeClothingValue(37, 2); value3 = MakeClothingValue(16, 14); value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(27, 0); } else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("3")) { value = MakeClothingValue(31, 0); value2 = MakeClothingValue(13, 7) + ";" + MakeClothingValue(5, 0); value3 = MakeClothingValue(17, 15); value4 = MakeClothingValue(29, 0); } else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("4")) { value = MakeClothingValue(30, 7); value2 = MakeClothingValue(14, 6); value3 = MakeClothingValue(25, 7); value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(8, 0); } else { value = MakeClothingValue(30, 12); value2 = MakeClothingValue(37, 3) + ";" + MakeClothingValue(1, 3); value3 = MakeClothingValue(0, 12); value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(29, 0); } } else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("2")) { value = ""; value2 = MakeClothingValue(13, 0) + ";" + MakeClothingValue(5, 0); value3 = MakeClothingValue(25, 8); value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(29, 0); } else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("3")) { value = MakeClothingValue(32, 0); value2 = MakeClothingValue(37, 5); value3 = MakeClothingValue(0, 15); value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(8, 0); } else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("4")) { value = MakeClothingValue(31, 0); value2 = MakeClothingValue(15, 14); value3 = MakeClothingValue(0, 0); value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(8, 0); } else { value = MakeClothingValue(32, 0); value2 = MakeClothingValue(37, 0) + ";" + MakeClothingValue(1, 9); value3 = MakeClothingValue(0, 12); value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(29, 0); } } ValuesDictionary overrides = new ValuesDictionary { { "Player", new ValuesDictionary { { "PlayerIndex", PlayerIndex } } }, { "Intro", new ValuesDictionary { { "PlayIntro", spawnMode == SpawnMode.InitialIntro } } }, { "Clothing", new ValuesDictionary { { "Clothes", new ValuesDictionary { { "Feet", value4 }, { "Legs", value3 }, { "Torso", value2 }, { "Head", value } } } } } }; Vector2 v = ComponentIntro.FindOceanDirection(m_subsystemTerrain.TerrainContentsGenerator, position.XZ); string entityTemplateName = (PlayerClass == PlayerClass.Male) ? "MalePlayer" : "FemalePlayer"; Entity entity2 = DatabaseManager.CreateEntity(m_project, entityTemplateName, overrides, throwIfNotFound: true); entity2.FindComponent <ComponentBody>(throwOnError: true).Position = position; entity2.FindComponent <ComponentBody>(throwOnError: true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, Vector2.Angle(v, -Vector2.UnitY)); m_project.AddEntity(entity2); if (componentMount != null) { entity2.FindComponent <ComponentRider>(throwOnError: true).StartMounting(componentMount); } LastSpawnTime = m_subsystemGameInfo.TotalElapsedGameTime; int num = ++SpawnsCount; }
public PlayerData(Project project) { m_project = project; SubsystemPlayers = project.FindSubsystem <SubsystemPlayers>(throwOnError: true); SubsystemGameWidgets = project.FindSubsystem <SubsystemGameWidgets>(throwOnError: true); m_subsystemTerrain = project.FindSubsystem <SubsystemTerrain>(throwOnError: true); m_subsystemGameInfo = project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); m_subsystemSky = project.FindSubsystem <SubsystemSky>(throwOnError: true); m_playerClass = PlayerClass.Male; Level = 1f; FirstSpawnTime = -1.0; LastSpawnTime = -1.0; RandomizeCharacterSkin(); ResetName(); InputDevice = WidgetInputDevice.None; m_stateMachine.AddState("FirstUpdate", null, delegate { if (ComponentPlayer != null) { UpdateSpawnDialog(string.Format(LanguageControl.Get(fName, 4), Name, MathUtils.Floor(Level)), null, 0f, resetProgress: true); m_stateMachine.TransitionTo("WaitForTerrain"); } else { m_stateMachine.TransitionTo("PrepareSpawn"); } }, null); m_stateMachine.AddState("PrepareSpawn", delegate { if (SpawnPosition == Vector3.Zero) { if (SubsystemPlayers.GlobalSpawnPosition == Vector3.Zero) { PlayerData playerData = SubsystemPlayers.PlayersData.FirstOrDefault((PlayerData pd) => pd.SpawnPosition != Vector3.Zero); if (playerData != null) { if (playerData.ComponentPlayer != null) { SpawnPosition = playerData.ComponentPlayer.ComponentBody.Position; m_spawnMode = SpawnMode.InitialNoIntro; } else { SpawnPosition = playerData.SpawnPosition; m_spawnMode = SpawnMode.InitialNoIntro; } } else { SpawnPosition = m_subsystemTerrain.TerrainContentsGenerator.FindCoarseSpawnPosition(); m_spawnMode = SpawnMode.InitialIntro; } SubsystemPlayers.GlobalSpawnPosition = SpawnPosition; } else { SpawnPosition = SubsystemPlayers.GlobalSpawnPosition; m_spawnMode = SpawnMode.InitialNoIntro; } } else { m_spawnMode = SpawnMode.Respawn; } if (m_spawnMode == SpawnMode.Respawn) { UpdateSpawnDialog(string.Format(LanguageControl.Get(fName, 2), Name, MathUtils.Floor(Level)), LanguageControl.Get(fName, 3), 0f, resetProgress: true); } else { UpdateSpawnDialog(string.Format(LanguageControl.Get(fName, 4), Name, MathUtils.Floor(Level)), null, 0f, resetProgress: true); } m_subsystemTerrain.TerrainUpdater.SetUpdateLocation(PlayerIndex, SpawnPosition.XZ, 0f, 64f); m_terrainWaitStartTime = Time.FrameStartTime; }, delegate { if (Time.PeriodicEvent(0.1, 0.0)) { float updateProgress2 = m_subsystemTerrain.TerrainUpdater.GetUpdateProgress(PlayerIndex, 0f, 64f); UpdateSpawnDialog(null, null, 0.5f * updateProgress2, resetProgress: false); if (!(updateProgress2 < 1f) || !(Time.FrameStartTime - m_terrainWaitStartTime < 15.0)) { switch (m_spawnMode) { case SpawnMode.InitialIntro: SpawnPosition = FindIntroSpawnPosition(SpawnPosition.XZ); break; case SpawnMode.InitialNoIntro: SpawnPosition = FindNoIntroSpawnPosition(SpawnPosition, respawn: false); break; case SpawnMode.Respawn: SpawnPosition = FindNoIntroSpawnPosition(SpawnPosition, respawn: true); break; default: throw new InvalidOperationException(LanguageControl.Get(fName, 5)); } m_stateMachine.TransitionTo("WaitForTerrain"); } } }, null); m_stateMachine.AddState("WaitForTerrain", delegate { m_terrainWaitStartTime = Time.FrameStartTime; Vector2 center = (ComponentPlayer != null) ? ComponentPlayer.ComponentBody.Position.XZ : SpawnPosition.XZ; m_subsystemTerrain.TerrainUpdater.SetUpdateLocation(PlayerIndex, center, MathUtils.Min(m_subsystemSky.VisibilityRange, 64f), 0f); }, delegate { if (Time.PeriodicEvent(0.1, 0.0)) { float updateProgress = m_subsystemTerrain.TerrainUpdater.GetUpdateProgress(PlayerIndex, MathUtils.Min(m_subsystemSky.VisibilityRange, 64f), 0f); UpdateSpawnDialog(null, null, 0.5f + 0.5f * updateProgress, resetProgress: false); if ((updateProgress >= 1f && Time.FrameStartTime - m_terrainWaitStartTime > 2.0) || Time.FrameStartTime - m_terrainWaitStartTime >= 15.0) { if (ComponentPlayer == null) { SpawnPlayer(SpawnPosition, m_spawnMode); } m_stateMachine.TransitionTo("Playing"); } } }, null); m_stateMachine.AddState("Playing", delegate { HideSpawnDialog(); }, delegate { if (ComponentPlayer == null) { m_stateMachine.TransitionTo("PrepareSpawn"); } else if (m_playerDeathTime.HasValue) { m_stateMachine.TransitionTo("PlayerDead"); } else if (ComponentPlayer.ComponentHealth.Health <= 0f) { m_playerDeathTime = Time.RealTime; } }, null); m_stateMachine.AddState("PlayerDead", delegate { GameWidget.ActiveCamera = GameWidget.FindCamera <DeathCamera>(); if (ComponentPlayer != null) { string text = ComponentPlayer.ComponentHealth.CauseOfDeath; if (string.IsNullOrEmpty(text)) { text = LanguageControl.Get(fName, 12); } string arg = string.Format(LanguageControl.Get(fName, 13), text); if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Cruel) { ComponentPlayer.ComponentGui.DisplayLargeMessage(LanguageControl.Get(fName, 6), string.Format(LanguageControl.Get(fName, 7), arg, LanguageControl.Get("GameMode", m_subsystemGameInfo.WorldSettings.GameMode.ToString())), 30f, 1.5f); } else if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Adventure && !m_subsystemGameInfo.WorldSettings.IsAdventureRespawnAllowed) { ComponentPlayer.ComponentGui.DisplayLargeMessage(LanguageControl.Get(fName, 6), string.Format(LanguageControl.Get(fName, 8), arg), 30f, 1.5f); } else { ComponentPlayer.ComponentGui.DisplayLargeMessage(LanguageControl.Get(fName, 6), string.Format(LanguageControl.Get(fName, 9), arg), 30f, 1.5f); } } Level = MathUtils.Max(MathUtils.Floor(Level / 2f), 1f); }, delegate { if (ComponentPlayer == null) { m_stateMachine.TransitionTo("PrepareSpawn"); } else if (Time.RealTime - m_playerDeathTime.Value > 1.5 && !DialogsManager.HasDialogs(ComponentPlayer.GuiWidget) && ComponentPlayer.GameWidget.Input.Any) { if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Cruel) { DialogsManager.ShowDialog(ComponentPlayer.GuiWidget, new GameMenuDialog(ComponentPlayer)); } else if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Adventure && !m_subsystemGameInfo.WorldSettings.IsAdventureRespawnAllowed) { ScreensManager.SwitchScreen("GameLoading", GameManager.WorldInfo, "AdventureRestart"); } else { m_project.RemoveEntity(ComponentPlayer.Entity, disposeEntity: true); } } }, null); m_stateMachine.TransitionTo("FirstUpdate"); }
public Wave(SpawnMode spawnModeSelect, float dedicatedPowerSet, float startDelayTimeSet) { spawnMode = spawnModeSelect; dedicatedPower = dedicatedPowerSet; startDelayTime = startDelayTimeSet; }
// Start is called before the first frame update void Start() { mode = SpawnMode.SINGLEPLAYER; currentLevel = 0; }
public void RemoveForeignGameObjects(List <SpawnerSettings> biomeSpawnerSettings, List <string> validTerrainNames = null) { ProgressBar.Show(ProgressBarPriority.BiomeRemoval, "Removing Foreign GameObjects", "Removing..."); List <ResourceProtoGameObjectInstance> knownProtoInstances = new List <ResourceProtoGameObjectInstance>(); List <ResourceProtoGameObjectInstance> GoProtoInstancesToRemove = new List <ResourceProtoGameObjectInstance>(); Terrain currentTerrain = GetCurrentTerrain(); foreach (SpawnerSettings spawnerSettings in biomeSpawnerSettings) { foreach (SpawnRule sr in spawnerSettings.m_spawnerRules) { if (sr.m_resourceType == GaiaConstants.SpawnerResourceType.GameObject) { foreach (ResourceProtoGameObjectInstance instance in spawnerSettings.m_resources.m_gameObjectPrototypes[sr.m_resourceIdx].m_instances) { knownProtoInstances.Add(instance); } } } } GaiaMultiTerrainOperation operation = new GaiaMultiTerrainOperation(currentTerrain, transform, m_settings.m_range * 2f, false, validTerrainNames); operation.GetHeightmap(); operation.GetNormalmap(); operation.CollectTerrainDetails(); operation.CollectTerrainTrees(); operation.CollectTerrainGameObjects(); operation.CollectTerrainBakedMasks(); int protoIndex = 0; var allSpawners = Resources.FindObjectsOfTypeAll <Spawner>(); foreach (Spawner spawner in allSpawners) { //During the removal we have to put the spawn settings in remove mode SpawnMode originalMode = spawner.m_settings.m_spawnMode; spawner.m_settings.m_spawnMode = SpawnMode.Remove; ProgressBar.Show(ProgressBarPriority.BiomeRemoval, "Removing Foreign GameObjects", "Removing Game Objects...", protoIndex, allSpawners.Length); foreach (SpawnRule sr in spawner.m_settings.m_spawnerRules) { if (sr.m_resourceType == GaiaConstants.SpawnerResourceType.GameObject) { ResourceProtoGameObject protoGO = spawner.m_settings.m_resources.m_gameObjectPrototypes[sr.m_resourceIdx]; foreach (ResourceProtoGameObjectInstance instance in protoGO.m_instances) { if (!knownProtoInstances.Contains(instance)) { operation.SetTerrainGameObjects(ApplyBrush(operation, MultiTerrainOperationType.GameObject), protoGO, sr, spawner.m_settings, 0, ref sr.m_spawnedInstances, m_settings.m_removeForeignGameObjectStrength, false); //no need to look at other instances if this one triggered the removal already break; } } } } spawner.m_settings.m_spawnMode = originalMode; protoIndex++; } operation.CloseOperation(); #if UNITY_EDITOR //need to dirty the scene when we remove game objects EditorSceneManager.MarkSceneDirty(gameObject.scene); #endif ProgressBar.Clear(ProgressBarPriority.BiomeRemoval); }