private void setButton_Click(object sender, EventArgs e) { if (id.Text == "" || type.Text == "" || min.Text == "" || max.Text == "" || amount.Text == "") { MessageBox.Show("All fields must to completed before saving."); return; } int _id; int _min; int _max; int _amount; try { _id = Convert.ToInt32(id.Text); } catch { _id = 0; } try { _min = Convert.ToInt32(min.Text); } catch { _min = 0; } try { _max = Convert.ToInt32(max.Text); } catch { _max = 0; } try { _amount = Convert.ToInt32(amount.Text); } catch { _amount = 0; } Spawn = new Spawn(_id, type.Text, _min, _max, _amount); Close(); }
static string GetSpawnName (Spawn spawn) { switch (spawn) { case(Spawn.BallBounce): return "BallBounce"; case(Spawn.BallHit): return "BallHit"; case(Spawn.DustSlide): return "DustSlide"; case(Spawn.MoveCursor): return "MoveCursor"; case(Spawn.CloudEffect): return "CloudEffect"; case(Spawn.Ball): return "Ball"; case(Spawn.Explosion1): return "Explosion1"; case(Spawn.Explosion2): return "Explosion2"; case(Spawn.Zombie): return "Zombie"; case(Spawn.Exclamation): return "Exclamation"; default: Debug.LogError ("Couldn't find Spawn Name"); return ""; } }
void Start() { toggles = GameObject.Find("TowerChoice").GetComponentsInChildren<Toggle>(); choiceTowers = new Dictionary<TglTower, Tower>(); retrieveChoiceTowers(); DisableChoices(); title = GameObject.Find("txtTitle"); title.SetActive(false); smallTitle = GameObject.Find("txtSmallTitle"); tiltShift = GameObject.Find("Main Camera").GetComponent<UnityStandardAssets.ImageEffects.TiltShift>(); spawnLaps = 2; spawner = GameObject.Find("Spawn").GetComponentInChildren<Spawn>(); step = Step.STARTING; shakeAmount = 0.1F; shakeTimer = 1F; HideTowerDetails(); btnNextWave.onClick.AddListener(EndConstructionTime); nextWave = GameObject.Find("btnNextWave"); nextWave.SetActive(false); animator = ((Animator)GetComponent<Animator>()); topCam = (Camera) topCamObject.GetComponent<Camera> (); animator.Play("CameraStartAnim", -1, 0F); startTimer = Time.time; }
//spawn no longer exists public void Delete(Spawn s, ResizeValHolder rvh) { for (int i = 0; i < children.Count; i++) { DrawingVisualSpawn visual = (DrawingVisualSpawn)children[i]; if (visual.spawn.id == s.id) { children.RemoveAt(i); break; } } }
void OnLevelWasLoaded() { if (Application.loadedLevel == 1) { eControlScript = GameObject.Find("EnemyControl").GetComponent<EnemyControllerScript>(); spawnScript = GameObject.Find("EnemyControl").GetComponent<Spawn>(); timeAtLevelLoad = Time.timeSinceLevelLoad; } }
public GameStateController( EntityController entityController, InputController.UpdateWaveTimer updateWaveTimer ) { this.updateWaveTimer = updateWaveTimer; StartWaveTimer( startTimeout ); this.entityController = entityController; spawn = new Spawn( entityController ); baraksModels = GameObject.FindObjectsOfType<BaraksModel>(); AddHero(); }
void Awake() { if(instance == null){ instance = this; templatePosition(); DontDestroyOnLoad(gameObject); }else{ DestroyImmediate(this); } }
public static Transform SpawnPrefab (Spawn spawn, Vector3 pos, Vector3 rot, PoolName pool) { string poolName = GetPoolName (pool); string spawnName = GetSpawnName (spawn); Transform instance = PoolManager.Pools [poolName].Spawn (GetSpawn (spawnName).transform, pos, Quaternion.identity); instance.eulerAngles = rot; return instance; }
// Use this for initialization void Start() { enemyTags.Add ("Enemy1"); enemyTags.Add ("Enemy2"); enemyTags.Add ("Enemy3"); enemyTags.Add ("Enemy4"); mySpaw = FindObjectOfType<Spawn> (); board = FindObjectOfType<GUITest>(); }
void Start(){ pathfinder = GameObject.Find("GameManager/PathFinder").GetComponent<PathFinding>(); heatmanager = GameObject.Find("GameManager/PathFinder").GetComponent<HeatMapManager>(); grid = GameObject.Find("GameManager/PathFinder").GetComponent<Grid>(); hq = GameObject.Find ("T0Spawn").GetComponent<Spawn> (); selected = GameObject.Find ("T0Spawn").GetComponent<Spawn> (); buildSpawn = transform.FindChild ("BuildSpawn").gameObject; camera = Camera.main; }
public void Initialize(Spawn spawn) { Spawn = spawn; id.Text = spawn.SpawnID.ToString(); type.Text = spawn.SpawnType; min.Text = spawn.SpawnMinSeconds.ToString(); max.Text = spawn.SpawnMaxSeconds.ToString(); amount.Text = spawn.SpawnAmount.ToString(); }
void Start() { GameObject spawn_obj = GameObject.FindWithTag ("Spawn"); if (spawn_obj != null) { spawn = spawn_obj.GetComponent<Spawn> (); } else { Debug.Log ("Cannot find 'Spawn' script"); } }
public void AddSpawn(ushort x, ushort y, ushort z, ushort rotx, ushort roty) { Spawn workSpawn = new Spawn(); workSpawn.x = x; workSpawn.y = y; workSpawn.z = z; workSpawn.rotx = rotx; workSpawn.roty = roty; spawns.Add(workSpawn); }
public void Start() { activeMinions = new List<GameObject>(); projectile = this.GetProvider().GetAbility<Projectile>(); spawn = this.GetProvider().GetAbility<Spawn>(); colorChanger = GetComponent<ColorChanger>(); target = GetComponent<Target>(); spawn.Enable(target.Team, new LaneElement[]{GetComponent<LaneElement>()}, colorChanger.color); teamSelector = TargetManager.IsOpposing(target); GetComponent<CharacterEventListener>().AddCallback(CharacterEvents.Hit, Activate); lane = GetComponent<Lane>(); }
// Use this for initialization void Start() { GameObject spawn_obj = GameObject.FindWithTag ("Spawn"); if (spawn_obj != null) { spawn = spawn_obj.GetComponent<Spawn> (); } else { Debug.Log ("Cannot find 'Spawn' script"); } health = GetComponent<TextMesh> (); health_value = health.text.Length; }
// Use this for initialization void Start() { if (spawnScript == null) { spawnScript = GameObject.FindGameObjectWithTag("Manager").GetComponent<Spawn>(); } spawnScript.setPlayer(gameObject); netIdentity = GetComponent<NetworkIdentity>(); prefabEye = Resources.Load("Prefabs/eye"); prefabFist = Resources.Load("Prefabs/fist"); prefabMustache = Resources.Load("Prefabs/mustache"); }
public void AddTargetName(Spawn target) { DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext dc = drawingVisual.RenderOpen()) { FormattedText ft = new FormattedText( target.name + "\n" + target.ToString() + " " + Spawn.GetRace(target.race) + " / " + (SpawnClass)target.eqClass, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.ExtraLight, FontStretches.Normal), 10, Brushes.Fuchsia); // Draw text dc.DrawText(ft, new Point(10.0, 10.0)); } this.children.Add(drawingVisual); }
private Easing theEasing; //easing script //init void Start () { //properties //audio destroyAudioPlayed = false; //scripts theSpawn = gameObject.AddComponent<Spawn>(); //add new spawning script theEasing = gameObject.AddComponent<Easing>(); //add new easing script //check that rididbody2D and collider2d exist //check that duration is > 0 to prevent NaN if (gameObject.rigidbody2D != null && gameObject.collider2D != null && duration > 0.0f) { //spawn at random origin, if indicated //note: spawnOffScreen only affects random spawns if (randSpawn == true) { originPos = theSpawn.randSpawnWithBufferOffScreen(edgeBuffer, spawnOffScreen); gameObject.rigidbody2D.transform.position = originPos; } //otherwise, assume current position is intended spawn point else { originPos = getCurrentPos(); } //generate random dest pos, if indicated if (randDest == true) { destPos = getRandDestPos(); } //init private properties numLoopSegments = 0; //set initial number of loop segments completed moveStartTime = Time.time; //set initial move start time } //error else { Debug.Log("[Move] Error: Missing physics component(s) or invalid duration <= 0 - object cannot be moved"); //disable scripts theSpawn.enabled = false; theEasing.enabled = false; this.enabled = false; } } //end function
void Start() { _startTime = Time.time + 4f; playerName = (player == playerEnum.player01 ? "player01" : "player02"); audio = GameObject.Find("GameManager").GetComponent<AudioManager>() as AudioManager; spellPool = GameObject.Find("GameManager").GetComponent<SpellManager>() as SpellManager; if(!spellPool) { throw new Exception("Spell Manager is missing"); } spellOneCD = spellPool.GetCooldown(spellOne); spellTwoCD = spellPool.GetCooldown(spellTwo); spawn = transform.FindChild("Spawn").GetComponent<Spawn>(); if (!spawn) { throw new Exception("Spawn component missing"); } }
private SpawnPattern getDumbPattern() { SpawnPattern pattern = new SpawnPattern(); float x = Random.Range(0, spawnXRange) - spawnXRange/2; int length = Random.Range(0, 15) + 15; for (int i=0; i<length; i++) { Spawn s = new Spawn(); x = x + Random.Range(0, maxRandomDistX * 2) - maxRandomDistX; s.location = new Vector2(x, spawnY); s.cooldown = spawnRate - dumbSpawnRateMinus; pattern.spawns.Add(s); } return pattern; }
private SpawnPattern getDiagonalPattern() { SpawnPattern pattern = new SpawnPattern(); float x = Random.Range(0, spawnXRange) - spawnXRange/2; float xGap = Random.Range(0, .3f) + .2f; xGap *= x < 0 ? 1 : -1; int length = Random.Range(0, 7) + 5; for (int i=0; i<length; i++) { Spawn s = new Spawn(); x = x + xGap; s.location = new Vector2(x, spawnY); s.cooldown = spawnRate; pattern.spawns.Add(s); } return pattern; }
//existing spawn changed public void Update(Spawn s, ResizeValHolder rvh) { //might want to make a hash table for this so i dont have to loop int oldSpawnIndex = GetChildIndexFromSpawnID(s.id); DrawingVisualSpawn visual = (DrawingVisualSpawn)GetVisualChild(oldSpawnIndex); double oldX = (double)-visual.spawn.xLoc; double oldY = (double)-visual.spawn.yLoc; oldX = oldX - rvh.minX; oldY = oldY - rvh.minY; oldX = oldX * rvh.resizeRatio; oldY = oldY * rvh.resizeRatio; oldX = oldX + rvh.centerDistanceX; oldY = oldY + rvh.centerDistanceY; double newX = (double)-s.xLoc; double newY = (double)-s.yLoc; newX = newX - rvh.minX; newY = newY - rvh.minY; newX = newX * rvh.resizeRatio; newY = newY * rvh.resizeRatio; newX = newX + rvh.centerDistanceX; newY = newY + rvh.centerDistanceY; double offsetX = newX - oldX; double offsetY = newY - oldY; TransformGroup transformGrp = new TransformGroup(); //add to transform group and apply to visual if (visual.spawn.isSelf) { //rotate int oldHeading = Convert.ToInt32(visual.spawn.heading); int oldAngle = ((oldHeading * 360) >> 9); int newHeading = Convert.ToInt32(s.heading); int newAngle = ((newHeading * 360) >> 9); transformGrp.Children.Add(new RotateTransform((oldAngle - newAngle), oldX, oldY)); } transformGrp.Children.Add(new TranslateTransform(offsetX, offsetY)); visual.Transform = transformGrp; }
public void setParent(Spawn p) { parent = p; }
public static void BloodSplat(Vector3 worldPos, BloodSplatSize splatSize, BloodSplatType bloodColorType) { EnsureInit(); GameObject chosenTile = null; switch (bloodColorType) { case BloodSplatType.red: switch (splatSize) { case BloodSplatSize.small: chosenTile = smallBloodTile; break; case BloodSplatSize.medium: chosenTile = mediumBloodTile; break; case BloodSplatSize.large: chosenTile = largeBloodTile; break; case BloodSplatSize.Random: int rand = Random.Range(0, 3); BloodSplat(worldPos, (BloodSplatSize)rand, bloodColorType); return; } break; case BloodSplatType.green: switch (splatSize) { case BloodSplatSize.small: chosenTile = smallXenoBloodTile; break; case BloodSplatSize.medium: chosenTile = medXenoBloodTile; break; case BloodSplatSize.large: chosenTile = largeXenoBloodTile; break; case BloodSplatSize.Random: int rand = Random.Range(0, 3); BloodSplat(worldPos, (BloodSplatSize)rand, bloodColorType); return; } break; case BloodSplatType.none: return; } if (chosenTile != null) { var matrix = MatrixManager.AtPoint(Vector3Int.RoundToInt(worldPos), true); if (matrix.Matrix.Get <FloorDecal>(worldPos.ToLocalInt(matrix.Matrix), true).Count() == 0) { Spawn.ServerPrefab(chosenTile, worldPos, matrix.Objects); } } }
/// <summary> /// Spawns a ghost for the indicated mind's body and transfers the connection's control to it. /// </summary> /// <param name="conn"></param> /// <param name="oldBody"></param> /// <param name="characterSettings"></param> /// <param name="occupation"></param> /// <returns></returns> public static void ServerSpawnGhost(Mind forMind) { if (forMind == null) { Logger.LogError("Mind was null for ServerSpawnGhost", Category.Ghosts); return; } //determine where to spawn the ghost var body = forMind.GetCurrentMob(); if (body == null) { Logger.LogError("Body was null for ServerSpawnGhost", Category.Ghosts); return; } var settings = body.GetComponent <PlayerScript>().characterSettings; var connection = body.GetComponent <NetworkIdentity>().connectionToClient; var registerTile = body.GetComponent <RegisterTile>(); if (registerTile == null) { Logger.LogErrorFormat("Cannot spawn ghost for body {0} because it has no registerTile", Category.Ghosts, body.name); return; } Vector3Int spawnPosition = TransformState.HiddenPos; var objBeh = body.GetComponent <ObjectBehaviour>(); if (objBeh != null) { spawnPosition = objBeh.AssumedWorldPositionServer(); } if (spawnPosition == TransformState.HiddenPos) { //spawn ghost at occupation location if we can't determine where their body is Transform spawnTransform = SpawnPoint.GetRandomPointForJob(forMind.occupation.JobType, true); if (spawnTransform == null) { Logger.LogErrorFormat("Unable to determine spawn position for occupation {1}. Cannot spawn ghost.", Category.Ghosts, forMind.occupation.DisplayName); return; } spawnPosition = spawnTransform.transform.position.CutToInt(); } var matrixInfo = MatrixManager.AtPoint(spawnPosition, true); var parentTransform = matrixInfo.Objects; //using parentTransform.rotation rather than Quaternion.identity because objects should always //be upright w.r.t. localRotation, NOT world rotation var ghost = UnityEngine.Object.Instantiate(CustomNetworkManager.Instance.ghostPrefab, spawnPosition, parentTransform.rotation, parentTransform); forMind.Ghosting(ghost); ServerTransferPlayer(connection, ghost, body, Event.GhostSpawned, settings); //fire all hooks var info = SpawnInfo.Ghost(forMind.occupation, settings, CustomNetworkManager.Instance.ghostPrefab, SpawnDestination.At(spawnPosition, parentTransform)); Spawn._ServerFireClientServerSpawnHooks(SpawnResult.Single(info, ghost)); if (PlayerList.Instance.IsAdmin(forMind.ghost.connectedPlayer)) { var adminItemStorage = AdminManager.Instance.GetItemSlotStorage(forMind.ghost.connectedPlayer); adminItemStorage.ServerAddObserverPlayer(ghost); ghost.GetComponent <GhostSprites>().SetAdminGhost(); } }
protected override void AddReleaseForces(Spawn spawn) { spawn.GetComponent <Rigidbody> ().AddForce(0, releaseForce, releaseForce); }
GameObject InstantiateMyPlayer(Spawn spawn) { string[] instantiateData = new string[3]; instantiateData[0] = _teamNumber.ToString(); instantiateData[1] = RunTimeData.PlayerBase.PlayerName; instantiateData[2] = ((uint)RunTimeData.PlayerBase.PlayerClass).ToString(); object[] objs = new object[1]; objs[0] = instantiateData; switch (RunTimeData.PlayerBase.PlayerClass) { case SelectClass.eClass.LIGHT: return (PhotonNetwork.Instantiate("LightPlayer", spawn.transform.position, spawn.transform.rotation, 0, objs)); default: return (PhotonNetwork.Instantiate("NormalPlayer", spawn.transform.position, spawn.transform.rotation, 0, objs)); } }
public void OnDespawnServer(DespawnInfo info) { Spawn.ServerPrefab(currentState.LootDrop, gameObject.RegisterTile().WorldPositionServer); UnSubscribeFromSwitchEvent(); }
private void DequeueAndProcessServerShot() { if (queuedShots.Count > 0) { QueuedShot nextShot = queuedShots.Dequeue(); // check if we can still shoot PlayerMove shooter = nextShot.shooter.GetComponent <PlayerMove>(); PlayerScript shooterScript = nextShot.shooter.GetComponent <PlayerScript>(); if (!shooter.allowInput || shooterScript.IsGhost) { Logger.Log("A player tried to shoot when not allowed or when they were a ghost.", Category.Exploits); Logger.LogWarning("A shot was attempted when shooter is a ghost or is not allowed to shoot.", Category.Firearms); return; } if (CurrentMagazine == null || CurrentMagazine.ServerAmmoRemains <= 0 || CurrentMagazine.containedBullets[0] == null) { Logger.LogTrace("Player tried to shoot when there was no ammo.", Category.Exploits); Logger.LogWarning("A shot was attempted when there is no ammo.", Category.Firearms); return; } if (FireCountDown > 0) { Logger.LogTrace("Player tried to shoot too fast.", Category.Exploits); Logger.LogWarning("Shot was attempted to be dequeued when the fire count down is not yet at 0.", Category.Exploits); return; } GameObject toShoot = CurrentMagazine.containedBullets[0]; int quantity = CurrentMagazine.containedProjectilesFired[0]; if (toShoot == null) { Logger.LogError("Shot was attempted but no projectile or quantity was found to use", Category.Firearms); return; } //perform the actual server side shooting, creating the bullet that does actual damage DisplayShot(nextShot.shooter, nextShot.finalDirection, nextShot.damageZone, nextShot.isSuicide, toShoot.name, quantity); //trigger a hotspot caused by gun firing shooterRegisterTile.Matrix.ReactionManager.ExposeHotspotWorldPosition(nextShot.shooter.TileWorldPosition()); //tell all the clients to display the shot ShootMessage.SendToAll(nextShot.finalDirection, nextShot.damageZone, nextShot.shooter, this.gameObject, nextShot.isSuicide, toShoot.name, quantity); if (isSuppressed == false && nextShot.isSuicide == false) { Chat.AddActionMsgToChat(serverHolder, $"You fire your {gameObject.ExpensiveName()}", $"{serverHolder.ExpensiveName()} fires their {gameObject.ExpensiveName()}"); } //kickback shooterScript.pushPull.Pushable.NewtonianMove((-nextShot.finalDirection).NormalizeToInt()); if (SpawnsCasing) { if (casingPrefabOverride == null) { //no casing override set, use normal casing prefab casingPrefabOverride = Resources.Load("BulletCasing") as GameObject; } Spawn.ServerPrefab(casingPrefabOverride, nextShot.shooter.transform.position, nextShot.shooter.transform.parent); } } }
protected override void Process() { if (!BCUtils.CheckWorld(out var world)) { return; } if (Params.Count == 0) { SendOutput(GetHelp()); return; } switch (Params[0]) { case "horde": { if (!GetPos(world, out var position)) { return; } if (!GetGroup(out var groupName)) { return; } if (!GetCount(out var count)) { return; } if (!GetMinMax(out var min, out var max)) { return; } if (!GetSpawnPos(position, out var targetPos)) { return; } //todo: refine method to ensure unique id var spawnerId = DateTime.UtcNow.Ticks; for (var i = 0; i < count; i++) { var classId = EntityGroups.GetRandomFromGroup(groupName); if (!EntityClass.list.ContainsKey(classId)) { SendOutput($"Entity class not found '{classId}', from group '{groupName}'"); return; } var spawn = new Spawn { EntityClassId = classId, SpawnerId = spawnerId, SpawnPos = position, TargetPos = targetPos, MinRange = min, MaxRange = max }; EntitySpawner.SpawnQueue.Enqueue(spawn); } SendOutput($"Spawning horde of {count} around {position.x} {position.y} {position.z}"); if (targetPos != position) { SendOutput($"Moving towards {targetPos.x} {targetPos.y} {targetPos.z}"); } return; } case "entity": { if (Params.Count != 2 && Params.Count != 5) { SendOutput("Spawn entity requires an entity class name"); return; } if (!GetPos(world, out var position)) { return; } if (!GetMinMax(out var min, out var max)) { return; } if (!GetSpawnPos(position, out var targetPos)) { return; } //todo: refine method to ensure unique id var spawnerId = DateTime.UtcNow.Ticks; var classId = Params[1].GetHashCode(); if (!EntityClass.list.ContainsKey(classId)) { SendOutput($"Entity class not found '{Params[1]}'"); return; } EntitySpawner.SpawnQueue.Enqueue(new Spawn { EntityClassId = classId, SpawnerId = spawnerId, SpawnPos = position, TargetPos = position, MinRange = min, MaxRange = max }); SendOutput($"Spawning entity {Params[1]} around {position.x} {position.y} {position.z}"); if (targetPos != position) { SendOutput($"Moving towards {targetPos.x} {targetPos.y} {targetPos.z}"); } return; } case "item": { if (!GetPos(world, out var position)) { return; } if (!GetItemValue(out var item)) { return; } if (!GetCount(out var count, 1)) { return; } if (!GetMinMax(out var min, out var max, "qual")) { return; } if (item == null || item.type == ItemValue.None.type) { SendOutput("Item class not found'"); return; } var itemValue = new ItemValue(item.type, true); var quality = UnityEngine.Random.Range(min, max); if (ItemClass.list[itemValue.type].HasParts) { count = 1; for (var i = 0; i < itemValue.Parts.Length; i++) { var item2 = itemValue.Parts[i]; item2.Quality = quality; itemValue.Parts[i] = item2; } } else if (itemValue.HasQuality) { count = 1; itemValue.Quality = quality; } var itemStack = new ItemStack(itemValue, count); GameManager.Instance.ItemDropServer(itemStack, position, Vector3.zero); SendOutput($"Spawning {count}x {itemValue.ItemClass.Name} at {position.x} {position.y} {position.z}"); return; } default: SendOutput($"Unknown Sub Command {Params[0]}"); SendOutput(GetHelp()); return; } }
public void FindSpawn(Transform obj) { /* * * if (FindObjectOfType<Lava> ().lavaIsActive == true) * * { * * spawnCushion = 7.0f; * * } * * else * * { * * spawnCushion = 2.0f; * * } * */ tmpX = Mathf.Abs(obj.position.x - spawnPoints[0].transform.position.x); tmpY = Mathf.Abs(obj.position.y + 3.0f - spawnPoints[0].transform.position.y); tmpDistance = Mathf.Sqrt(Mathf.Pow(tmpX, 2) + Mathf.Pow(tmpY, 2)); distanceFromPlayer = tmpDistance; closestSpawn = 0; for (int i = 1; i < spawnPoints.Length; ++i) { tmpX = Mathf.Abs(obj.position.x - spawnPoints[i].transform.position.x); tmpY = Mathf.Abs(obj.position.y + 3.0f - spawnPoints[i].transform.position.y); //provide 3.0 units of cushion tmpDistance = Mathf.Sqrt(Mathf.Pow(tmpX, 2) + Mathf.Pow(tmpY, 2)); if (tmpDistance < distanceFromPlayer) { distanceFromPlayer = tmpDistance; closestSpawn = i; } } if (obj.position.y < spawnPoints[closestSpawn].transform.position.y) //spawn is above player { if (FindObjectOfType <Lava>().lavaIsActive == true) { //checks if covered by lava or spawning right in front of it if (spawnPoints[closestSpawn].transform.position.y >= FindObjectOfType <Lava>().transform.position.y + 16.5f || spawnPoints[closestSpawn].transform.position.y < FindObjectOfType <Lava>().transform.position.y - 16.5f) { if (closestSpawn % 2 == 1) { closestSpawn = closestSpawn + 2; //spawn a point above on right } else { ++closestSpawn; //spawn a point below on left } } else { Debug.Log("No change, spawn at closest."); } } else { if (closestSpawn % 2 == 1) { closestSpawn = closestSpawn - 2; //spawn a point below on right } else { --closestSpawn; //spawn a point below on left } } } Spawn respawn = spawnPoints[0].GetComponent <Spawn>(); if (closestSpawn < 0) { respawn = spawnPoints[0].GetComponent <Spawn>(); } else { respawn = spawnPoints[closestSpawn].GetComponent <Spawn>(); } respawn.Respawn(); }
//生成加样移动组合 public void GenerateInjectActGroup(ref Sequence seque, int [] hitsort, ref int index, ref ActionPoint[] tager, ref int[] point, ref int[] width, ref double[] width_rate, ref bool is_ok, ActionBase move_x = null) { int hit_index = 0; if (index < 4) { hit_index = hitsort[index]; } if (index == 4) { is_ok = true; return; } else if ((tager[hit_index].isdone && tager[hit_index].y == point[hit_index]) || tager[hit_index].y == -1) { index++; GenerateInjectActGroup(ref seque, hitsort, ref index, ref tager, ref point, ref width, ref width_rate, ref is_ok, move_x); } else { List <int[]> node_list = new List <int[]>(); int[] width_tem = IMask.Gen(0); for (int i = 0; i < 4; i++) { width_tem[i] = (int)(width[i] * width_rate[hit_index]); } for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { for (int k = j; k < 4; k++) { for (int l = k; l < 4; l++) { int[] point_tem = { 0, 0, 0, 0 }; point_tem[i] = tager[i].y; point_tem[j] = tager[j].y; point_tem[k] = tager[k].y; point_tem[l] = tager[l].y; for (int n = 0; n < 4; n++) { if (point_tem[n] < 0) { point_tem[n] = 0; } } bool ispass = true; int frist = 0; for (int n = 0; n < 4; n++) { if (point_tem[n] != 0) { frist = n; break; } } for (int n = frist; n < 4; n++) { if (point_tem[n] == 0 && n - 1 >= 0) { point_tem[n] = point_tem[n - 1] + width_tem[n]; } } for (int n = 0; n < frist; n++) { if (point_tem[n] == 0 && n + 1 <= 3) { point_tem[n] = point_tem[frist] - width_tem[n] * (frist - n); } } for (int n = 0; n < 4; n++) { bool isforward = n - 1 >= 0 ? point_tem[n] >= point_tem[n - 1] + width_tem[n - 1] : true; bool isback = n + 1 <= 3 ? point_tem[n] + width_tem[n] <= point_tem[n + 1] : true; ispass = isforward && isforward; if (!ispass) { break; } } if (ispass && point_tem[hit_index] == tager[hit_index].y) { node_list.Add(point_tem); } } } } } int[] minnode = node_list[0]; foreach (var node in node_list) { if (GetLoss(tager, node) < GetLoss(tager, minnode)) { minnode = node; } } List <int> left = new List <int>(); List <int> right = new List <int>(); for (int i = 0; i < 4; i++) { if (point[i] - minnode[i] < 0) { left.Add(i); } else { right.Add(i); } } left.Sort((a, b) => { return(a < b ? 1 : -1); }); right.Sort((a, b) => { return(a > b ? 1 : -1); }); var movesp_act = Spawn.create(); var move_act = Sequence.create(); string msg = ""; int[] yy = IMask.Gen(-1); int[] zz = IMask.Gen(-1); List <Enterclose> ents = new List <Enterclose>(); for (int i = 0; i < left.Count; i++) { int indextem = left[i]; if (point[indextem] != minnode[indextem]) { ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } for (int i = 0; i < right.Count; i++) { int indextem = right[i]; if (point[indextem] != minnode[indextem]) { ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]); yy[indextem] = minnode[indextem]; } } movesp_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, yy, zz)); for (int i = 0; i < 4; i++) { point[i] = minnode[i]; } move_act.AddAction(movesp_act); //得到到达的点 List <ActionPoint> done_points = new List <ActionPoint>(); List <Enterclose> entcloses = new List <Enterclose>(); for (int i = 0; i < 4; i++) { if (tager[i].y == point[i] && tager[i].isdone == false) { done_points.Add(tager[i]); entcloses.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[i]); tager[i].isdone = true; } } var run_act = Sequence.create(); //对到达的点进行分类生成 int[] injz = IMask.Gen(-1); int[] injzl = IMask.Gen(-1); int[] injzd = IMask.Gen(-1); int[] absorbs = IMask.Gen(-1); run_act.AddAction(SkWaitForAction.create(move_x)); if (done_points.Count != 0) { if (done_points[0].type == TestStepEnum.JXZT) { var injact_sp = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; absorbs[entcloses[i].Index] = (int)entcloses[0].PumpMotor.Maximum.SetValue; } injact_sp.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); injact_sp.AddAction(InjectAbsorbMove.create(3001, entcloses.ToArray(), 100, absorbs)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } run_act.AddAction(injact_sp); run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); } else if (done_points[0].type == TestStepEnum.PutTip) { var sequ = Sequence.create(); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; } sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); sequ.AddAction(MoveTo.create(3001, done_points[0].puttip_x, -1, -1)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z - 1000; } sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 1)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(sequ); } else if (done_points[0].type == TestStepEnum.AbsLiquid) { run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), IMask.Gen(-1), 0)); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z + done_points[i].deep; absorbs[entcloses[i].Index] = -(done_points[i].capacity); } run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, done_points[0].deepspeed)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].absbspeed, absorbs)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { if (done_points[i].backcapacity != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(back_act); } else if (done_points[0].type == TestStepEnum.FollowAbsLiquid) { for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; injzl[entcloses[i].Index] = done_points[i].z + done_points[i].detectordeep; injzd[entcloses[i].Index] = done_points[i].deep; absorbs[entcloses[i].Index] = -(done_points[i].capacity); } run_act.AddAction(InjectDetector.create(3001, entcloses.ToArray(), injz, injzl, injzd, 2, 1)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].absbspeed, absorbs)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { if (done_points[i].backcapacity != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(back_act); } else if (done_points[0].type == TestStepEnum.SpuLiquid) { for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; absorbs[entcloses[i].Index] = done_points[i].spucapacity + done_points[i].backcapacity; } run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].spuspeed, absorbs)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { if (done_points[i].backcapacity != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); run_act.AddAction(back_act); } else if (done_points[0].type == TestStepEnum.MixLiquid) { for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].z; absorbs[entcloses[i].Index] = done_points[i].capacity + done_points[i].backcapacity; } run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2)); run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), 100, absorbs));//把稀释液放进去 //混合操作 var mix_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); var mix_seq_act = Sequence.create(); if (done_points[i].mixtimes != 0) { for (int j = 0; j < done_points[i].mixtimes * 2; j++) { int mixz = done_points[i].z - done_points[i].mixdeep;//混合高度 if (mixz <= 0) { mixz = done_points[i].z; } absorbs[entcloses[i].Index] = j % 2 == 0 ? -done_points[i].capacity : done_points[i].capacity; injz[entcloses[i].Index] = j % 2 == 0 ? done_points[i].z : mixz; mix_seq_act.AddAction(InjectMoveTo.create(3001, ent_tem.ToArray(), -1, IMask.Gen(-1), injz, 2)); mix_seq_act.AddAction(InjectAbsorb.create(30001, ent_tem.ToArray(), 100, absorbs)); } injz[entcloses[i].Index] = done_points[i].z; mix_seq_act.AddAction(InjectMoveTo.create(3001, ent_tem.ToArray(), -1, IMask.Gen(-1), injz, 2)); absorbs[entcloses[i].Index] = (int)ent_tem[0].PumpMotor.Maximum.SetValue; mix_seq_act.AddAction(InjectAbsorbMove.create(3001, ent_tem.ToArray(), 100, absorbs)); absorbs[entcloses[i].Index] = -(done_points[i].GetTubeList().Count *done_points[i].spucapacity); mix_seq_act.AddAction(InjectAbsorb.create(3001, ent_tem.ToArray(), 100, absorbs)); } mix_act.AddAction(mix_seq_act); } run_act.AddAction(mix_act); var zb_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { injz[entcloses[i].Index] = done_points[i].zb; } zb_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz)); //回吸 var back_act = Spawn.create(); for (int i = 0; i < done_points.Count; i++) { List <Enterclose> ent_tem = new List <Enterclose>(); ent_tem.Add(entcloses[i]); if (done_points[i].backcapacity != 0 && done_points[i].mixtimes != 0) { absorbs[entcloses[i].Index] = -(done_points[i].backcapacity); back_act.AddAction(Sequence.create(SKSleep.create(500), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs))); } } zb_act.AddAction(back_act); run_act.AddAction(zb_act); } } move_act.AddAction(run_act); seque.AddAction(move_act); GenerateInjectActGroup(ref seque, hitsort, ref index, ref tager, ref point, ref width, ref width_rate, ref is_ok, move_x); } }
public override void ClearItems() { if (Armor != null) { List <Item> list = new List <Item>(Armor.Where(i => i != null && !i.Deleted)); foreach (Item armor in list) { armor.Delete(); } ColUtility.Free(list); ColUtility.Free(Armor); Armor = null; } if (DestroyedArmor != null) { List <Item> list = new List <Item>(DestroyedArmor.Where(i => i != null && !i.Deleted)); foreach (Item dest in list) { dest.Delete(); } ColUtility.Free(list); ColUtility.Free(DestroyedArmor); DestroyedArmor = null; } if (Spawn != null) { List <BaseCreature> list = new List <BaseCreature>(Spawn.Where(s => s != null && !s.Deleted)); foreach (BaseCreature spawn in list) { spawn.Delete(); } ColUtility.Free(list); ColUtility.Free(Spawn); Spawn = null; } if (Items != null) { List <Item> list = new List <Item>(Items.Where(i => i != null && !i.Deleted)); foreach (Item item in list) { item.Delete(); } ColUtility.Free(list); ColUtility.Free(Items); Items = null; } }
// public Sequence GenerateInjectActGroup(ActionPoint[] tagers, bool is_asc = true, double [] width_rate = null) { int[] point = { 0, 0, 0, 0 }; int[] width = { 0, 0, 0, 0 }; //目标要根据针头偏移 for (int i = 0; i < tagers.Length; i++) { tagers[i].index = i; } //删除为负数的参数 if (width_rate == null) { width_rate = IMask.Gen(1.0f); } tagers = tagers.ToList().Where(item => item.y >= 0).ToArray(); for (int i = 0; i < 4; i++) { bool is_timeout = false; width[i] = (int)((double)Engine.getInstance().injectorDevice.Injector.Entercloses[i].InjWidth); //得到当前各别样Y轴坐标 Engine.getInstance().injectorDevice.CanComm.ReadRegister(Engine.getInstance().injectorDevice.Injector.Entercloses[i].YMotor.RealDistance.Addr); int pointtem = Engine.getInstance().injectorDevice.CanComm.GetIntBlock(Engine.getInstance().injectorDevice.Injector.Entercloses[i].YMotor.RealDistance.Addr, 1000, out is_timeout); point[i] = pointtem + (int)Engine.getInstance().injectorDevice.Injector.Entercloses[i].TipDis; if (is_timeout) { return(null); } } //接X分组 List <ActionPoint> tager_list = tagers.ToList(); List <List <ActionPoint> > tager_group = new List <List <ActionPoint> >(); if (is_asc) { tager_list.Sort((a, b) => { return(a.x > b.x ? 1 : -1); }); } else { tager_list.Sort((a, b) => { return(a.x < b.x ? 1 : -1); }); } int x = -10; foreach (var tagerp in tager_list) { if (tagerp.x != x) { var group = new List <ActionPoint>(); group.Add(tagerp); tager_group.Add(group); x = tagerp.x; } else if (tager_group.Count != 0) { tager_group[tager_group.Count - 1].Add(tagerp); } } //生成动作组合 int index = 0; bool is_ok = false; var seque = Sequence.create(); foreach (var group in tager_group) { var move_y = Sequence.create(); ActionPoint[] tager = IMask.Gen(new ActionPoint(-1, -1, -1)); var tager_sort = IMask.Gen(new ActionPoint(-1, -1, -1)).ToList(); for (int i = 0; i < group.Count(); i++) { tager[group[i].index] = group[i]; tager_sort[group[i].index] = group[i]; } index = 0; int[] hit_sort = { 0, 1, 2, 3 }; //y轴顺序排列 tager_sort.Sort((a, b) => { return(a.hitsort <= b.hitsort ? 1 : -1); }); for (int i = 0; i < tager_sort.Count(); i++) { hit_sort[i] = tager_sort[i].index; } var spawn = Spawn.create(); ActionBase move_x = null; if (group[0].x != -1) { move_x = (ActionBase)MoveTo.create(3001, group[0].x, -1, -1); } else { move_x = SKSleep.create(0); } GenerateInjectActGroup(ref move_y, hit_sort, ref index, ref tager, ref point, ref width, ref width_rate, ref is_ok, move_x); if (is_ok) { spawn.AddAction(move_x); spawn.AddAction(move_y); seque.AddAction(spawn); } else { break; } } return(seque); }
private void SpawnRods(Vector3 pos) { Spawn.ServerPrefab("Rods", pos.CutToInt(), count: 1, scatterRadius: Spawn.DefaultScatterRadius); }
public override void Process() { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); if (usedSlot == null || usedSlot.ItemObject == null) { return; } var hasConstructionMenu = usedSlot.ItemObject.GetComponent <BuildingMaterial>(); if (hasConstructionMenu == null) { return; } var entry = hasConstructionMenu.BuildList.Entries.ToArray()[EntryIndex]; if (!entry.CanBuildWith(hasConstructionMenu)) { return; } //check if the space to construct on is passable if (!MatrixManager.IsPassableAt((Vector3Int)SentByPlayer.GameObject.TileWorldPosition(), true, includingPlayers: false)) { Chat.AddExamineMsg(SentByPlayer.GameObject, "It won't fit here."); return; } //if we are building something impassable, check if there is anything on the space other than the performer. var atPosition = MatrixManager.GetAt <RegisterTile>((Vector3Int)SentByPlayer.GameObject.TileWorldPosition(), true); if (entry.Prefab == null) { //requires immediate attention, show it regardless of log filter: Logger.Log($"Construction entry is missing prefab for {entry.Name}"); return; } var registerTile = entry.Prefab.GetComponent <RegisterTile>(); if (registerTile == null) { Logger.LogWarningFormat("Buildable prefab {0} has no registerTile, no idea if it's passable", Category.Construction, entry.Prefab); } var builtObjectIsImpassable = registerTile == null || !registerTile.IsPassable(true); foreach (var thingAtPosition in atPosition) { if (entry.OnePerTile) { //can only build one of this on a given tile if (entry.Prefab.Equals(Spawn.DeterminePrefab(thingAtPosition.gameObject))) { Chat.AddExamineMsg(SentByPlayer.GameObject, $"There's already one here."); return; } } if (builtObjectIsImpassable) { //if the object we are building is itself impassable, we should check if anything blocks construciton. //otherwise it's fine to add it to the pile on the tile if (ServerValidations.IsConstructionBlocked(SentByPlayer.GameObject, null, SentByPlayer.GameObject.TileWorldPosition())) { return; } } } //build and consume void ProgressComplete() { var spawnedObj = entry.ServerBuild(SpawnDestination.At(SentByPlayer.Script.registerTile), hasConstructionMenu); if (spawnedObj) { var conveyorBelt = spawnedObj.GetComponent <ConveyorBelt>(); if (conveyorBelt != null) { conveyorBelt.SetBeltFromBuildMenu(Direction); } Chat.AddActionMsgToChat(SentByPlayer.GameObject, $"You finish building the {entry.Name}.", $"{SentByPlayer.GameObject.ExpensiveName()} finishes building the {entry.Name}."); } } Chat.AddActionMsgToChat(SentByPlayer.GameObject, $"You begin building the {entry.Name}...", $"{SentByPlayer.GameObject.ExpensiveName()} begins building the {entry.Name}..."); ToolUtils.ServerUseTool(SentByPlayer.GameObject, usedSlot.ItemObject, ActionTarget.Tile(SentByPlayer.Script.registerTile.WorldPositionServer), entry.BuildTime, ProgressComplete); }
private bool isBanker(Spawn spawn) { //check if spawnclass is banker return false; }
private void OnWillDestroyServer(DestructionInfo arg0) { Spawn.ServerPrefab(rackParts, gameObject.TileWorldPosition().To3Int(), transform.parent); }
/*private void GameAnalyzer_OnPlayerChangeLevel(object sender, IntEventArgs e) { this.playerLevel = e.value; //this doesnt fix the problem. f**k. //this.Clear(); }*/ //something spawned public void Add(Spawn s, ResizeValHolder rvh) { DrawingVisualSpawn visual = new DrawingVisualSpawn(s); DrawVisual(ref visual, rvh, false); children.Add(visual); }
private void InitEntities(bool fullInit) { if (ShieldEnt != null) { Session.Instance.IdToBus.Remove(ShieldEnt.EntityId); ShieldEnt.Close(); } ShellActive?.Close(); _shellPassive?.Close(); _checkResourceDist = true; if (!fullInit) { if (Session.Enforced.Debug == 3) { Log.Line($"InitEntities: mode: {ShieldMode}, remove complete - ShieldId [{Shield.EntityId}]"); } return; } SelectPassiveShell(); var parent = (MyEntity)MyGrid; if (!_isDedicated) { _shellPassive = Spawn.EmptyEntity("dShellPassive", $"{Session.Instance.ModPath()}{_modelPassive}", parent, true); _shellPassive.Render.CastShadows = false; _shellPassive.IsPreview = true; _shellPassive.Render.Visible = true; _shellPassive.Render.RemoveRenderObjects(); _shellPassive.Render.UpdateRenderObject(true); _shellPassive.Render.UpdateRenderObject(false); _shellPassive.Save = false; _shellPassive.SyncFlag = false; _shellPassive.RemoveFromGamePruningStructure(); ShellActive = Spawn.EmptyEntity("dShellActive", $"{Session.Instance.ModPath()}{_modelActive}", parent, true); ShellActive.Render.CastShadows = false; ShellActive.IsPreview = true; ShellActive.Render.Visible = true; ShellActive.Render.RemoveRenderObjects(); ShellActive.Render.UpdateRenderObject(true); ShellActive.Render.UpdateRenderObject(false); ShellActive.Save = false; ShellActive.SyncFlag = false; ShellActive.SetEmissiveParts("ShieldEmissiveAlpha", Color.Transparent, 0f); ShellActive.SetEmissiveParts("ShieldDamageGlass", Color.Transparent, 0f); ShellActive.RemoveFromGamePruningStructure(); } ShieldEnt = Spawn.EmptyEntity("dShield", null, parent); ShieldEnt.Render.CastShadows = false; ShieldEnt.Render.RemoveRenderObjects(); ShieldEnt.Render.UpdateRenderObject(true); ShieldEnt.Render.Visible = false; ShieldEnt.Save = false; _shieldEntRendId = ShieldEnt.Render.GetRenderObjectID(); _updateRender = true; if (ShieldEnt != null) { Session.Instance.IdToBus[ShieldEnt.EntityId] = ShieldComp; } if (Icosphere == null) { Icosphere = new Icosphere.Instance(Session.Instance.Icosphere); } if (Session.Enforced.Debug == 3) { Log.Line($"InitEntities: mode: {ShieldMode}, spawn complete - ShieldId [{Shield.EntityId}]"); } }
/// <summary> /// Perform and display the shot locally (i.e. only on this instance of the game). Does not /// communicate anything to other players (unless this is the server, in which case the server /// will determine the effects of the bullet). Does not do any validation. This should only be invoked /// when displaying the results of a shot (i.e. after receiving a ShootMessage or after this client performs a shot) /// or when server is determining the outcome of the shot. /// </summary> /// <param name="shooter">gameobject of the shooter</param> /// <param name="finalDirection">direction the shot should travel (accuracy deviation should already be factored into this)</param> /// <param name="damageZone">targeted damage zone</param> /// <param name="isSuicideShot">if this is a suicide shot (aimed at shooter)</param> /// <param name="projectileName">the name of the projectile that should be spawned</param> /// <param name="quantity">the amount of projectiles to spawn when displaying the shot</param> public void DisplayShot(GameObject shooter, Vector2 finalDirection, BodyPartType damageZone, bool isSuicideShot, string projectileName, int quantity) { if (!MatrixManager.IsInitialized) { return; } //if this is our gun (or server), last check to ensure we really can shoot if (isServer || PlayerManager.LocalPlayer == shooter) { if (CurrentMagazine.ClientAmmoRemains <= 0) { if (isServer) { Logger.LogTrace("Server rejected shot - out of ammo", Category.Firearms); } return; } CurrentMagazine.ExpendAmmo(); } //TODO: If this is not our gun, simply display the shot, don't run any other logic if (shooter == PlayerManager.LocalPlayer) { //this is our gun so we need to update our predictions FireCountDown += 1.0 / FireRate; //add additional recoil after shooting for the next round AppendRecoil(); //Default camera recoil params until each gun is configured separately if (CameraRecoilConfig == null || CameraRecoilConfig.Distance == 0f) { CameraRecoilConfig = new CameraRecoilConfig { Distance = 0.2f, RecoilDuration = 0.05f, RecoveryDuration = 0.6f }; } Camera2DFollow.followControl.Recoil(-finalDirection, CameraRecoilConfig); } if (isSuicideShot) { GameObject projectile = Spawn.ClientPrefab(projectileName, shooter.transform.position, parent: shooter.transform.parent).GameObject; Projectile projectileComponent = projectile.GetComponent <Projectile>(); projectileComponent.Suicide(shooter, this, damageZone); } else { for (int n = 0; n < quantity; n++) { GameObject projectile = Spawn.ClientPrefab(projectileName, shooter.transform.position, parent: shooter.transform.parent).GameObject; Projectile projectileComponent = projectile.GetComponent <Projectile>(); Vector2 finalDirectionOverride = CalcDirection(finalDirection, n); projectileComponent.Shoot(finalDirectionOverride, shooter, this, damageZone); } } if (isSuppressed && SuppressedSoundA != null) { SoundManager.PlayAtPosition(SuppressedSoundA, shooter.transform.position, shooter); } else { SoundManager.PlayAtPosition(FiringSoundA, shooter.transform.position, shooter); } shooter.GetComponent <PlayerSprites>().ShowMuzzleFlash(); }
public override int HandleState(List <GamePlayer> players, SpawnManager spawnManager, LaserManager laserManager, Spawn spawn, Laser laser) { players.ToList().FirstOrDefault(p => p.Name == laser.Player).LaserStrength += spawn.Toughness; players.ToList().FirstOrDefault(p => p.Name == laser.Player).Score += spawn.Toughness; spawnManager.DestroySpawn(spawn.Id); laserManager.DestroyLaser(laser.Id); return(0); }
public void Setup(LocalBlackboard localBlackboard) { _localBlackboard = localBlackboard; if (TryGetComponent(out TypeInflictor temp)) { _typeInflictor = temp; } if (TryGetComponent(out Spawn temp2)) { _spawn = temp2; _spawn.Setup(_localBlackboard); } if (TryGetComponent(out PushInflictor temp3)) { _pushInflictor = temp3; } if (TryGetComponent(out Collection temp4)) { _collection = temp4; _collection.Setup(_localBlackboard); } if (TryGetComponent(out StunInflictor temp5)) { _stunInflictor = temp5; } if (TryGetComponent(out AttackColliderController temp6)) { _attackCollider = temp6; _attackCollider.Setup(_localBlackboard, this); } if (TryGetComponent(out DestroyAfterTime temp7)) { _destroyAfterTime = temp7; _destroyAfterTime.Setup(_spawn); } if (TryGetComponent(out DoDamage temp8)) { _doDamage = temp8; } if (TryGetComponent(out Heal temp9)) { _heal = temp9; } if (TryGetComponent(out Recharge temp10)) { _recharge = temp10; _recharge.Setup(this); } if (TryGetComponent(out IndieAttackPlayer temp11)) { _indieAttackPlayer = temp11; _indieAttackPlayer.Setup(this); } if (TryGetComponent(out AttackFXPlayer temp12)) { _attackFXPlayer = temp12; } if (TryGetComponent(out DestroyOnHit temp13)) { _destroyOnHit = temp13; } if (TryGetComponent(out RecievePhysicsPush temp14)) { temp14.Setup(_localBlackboard.currentTarget.transform); } }
public void AddSpawn(BaseCreature bc) { Spawn.Add(bc); }
private void TellSpawnWhoMadeIt(Spawn spawn) { spawn.RememberWhoMadeMe(worldObject); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); Instance = this; _Active = reader.ReadBool(); Level = reader.ReadInt(); Kills = reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { BaseCreature bc = reader.ReadMobile() as BaseCreature; if (bc != null) { bc.Spawner = this; bc.Home = HomeLocation; bc.RangeHome = HomeRange; if (Spawn == null) { Spawn = new List <ISpawnable>(); } Spawn.Add(bc); } } if (_Active) { StartTimer(); if (Spawn == null || Spawn.Count == 0) { if (Spawn == null) { Spawn = new List <ISpawnable>(); } if (Level >= Levels) { EndSimulation(); return; } else { IncreaseLevel(); } } else { int toSpawn = Math.Max(0, SpawnPerWave - (Spawn.Count + Kills)); if (toSpawn > 0) { for (int i = 0; i < toSpawn; i++) { Timer.DelayCall(NextSpawnDuration, DoSpawn); } } } } // Teleporter Fix if (version == 0) { Timer.DelayCall(TimeSpan.FromSeconds(20), () => { if (Map != null) { IPooledEnumerable eable = Map.GetItemsInRange(new Point3D(644, 2308, 0), 0); foreach (Item i in eable) { if (i is Teleporter) { ((Teleporter)i).PointDest = new Point3D(543, 2479, 2); } } } }); } }
public void ServerPerformInteraction(HandApply interaction) { //Anchor or disassemble if (CurrentState == initialState) { if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wrench)) { if (!ServerValidations.IsAnchorBlocked(interaction)) { //wrench in place ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start wrenching the turret frame into place...", $"{interaction.Performer.ExpensiveName()} starts wrenching the turret frame into place...", "You wrench the turret frame into place.", $"{interaction.Performer.ExpensiveName()} wrenches the turret frame into place.", () => { objectBehaviour.ServerSetAnchored(true, interaction.Performer); stateful.ServerChangeState(anchoredState); }); return; } Chat.AddExamineMsgFromServer(interaction.Performer, "Unable to anchor turret frame here"); } else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Crowbar)) { //deconstruct ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start deconstructing the turret frame...", $"{interaction.Performer.ExpensiveName()} starts deconstructing the turret frame...", "You deconstruct the turret frame.", $"{interaction.Performer.ExpensiveName()} deconstructs the turret frame.", () => { Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, SpawnDestination.At(gameObject), 5); _ = Despawn.ServerSingle(gameObject); }); } return; } //Adding metal or unanchor if (CurrentState == anchoredState) { if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.MetalSheet)) { //Add metal ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start adding a metal cover to the turret frame...", $"{interaction.Performer.ExpensiveName()} starts adding a metal cover to the turret frame...", "You add a metal cover to the turret frame.", $"{interaction.Performer.ExpensiveName()} adds a metal cover to the turret frame.", () => { Inventory.ServerConsume(interaction.HandSlot, 1); stateful.ServerChangeState(metalAddedState); }); } else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wrench)) { //Unanchor ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start unwrenching the turret frame from the floor...", $"{interaction.Performer.ExpensiveName()} starts unwrenching the turret frame from the floor...", "You unwrench the turret frame from the floor.", $"{interaction.Performer.ExpensiveName()} unwrenches the turret frame from the floor.", () => { objectBehaviour.ServerSetAnchored(false, interaction.Performer); stateful.ServerChangeState(initialState); }); } return; } //Wrench or remove metal if (CurrentState == metalAddedState) { if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wrench)) { //Wrench ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start wrenching the bolts on the turret frame...", $"{interaction.Performer.ExpensiveName()} starts wrenching the bolts on the turret frame...", "You wrench the bolts on the turret frame.", $"{interaction.Performer.ExpensiveName()} wrenches the bolts on the turret frame.", () => { stateful.ServerChangeState(wrenchState); }); } else if (Validations.HasUsedActiveWelder(interaction)) { //Remove metal ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start removing the metal cover from the turret frame...", $"{interaction.Performer.ExpensiveName()} starts removing the metal cover from the turret frame...", "You remove the metal cover from the turret frame.", $"{interaction.Performer.ExpensiveName()} removes the metal cover from the turret frame.", () => { Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, SpawnDestination.At(gameObject), 1); stateful.ServerChangeState(anchoredState); }); } return; } //Add gun or unwrench if (CurrentState == wrenchState) { if (Validations.HasUsedItemTrait(interaction, gunTrait)) { //Add energy gun Chat.AddActionMsgToChat(interaction, $"You place the {interaction.UsedObject.ExpensiveName()} inside the turret frame.", $"{interaction.Performer.ExpensiveName()} places the {interaction.UsedObject.ExpensiveName()} inside the turret frame."); Inventory.ServerTransfer(interaction.HandSlot, gunSlot); stateful.ServerChangeState(gunAddedState); } else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wrench)) { //Remove unwrench bolts ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start removing the bolts from the turret frame...", $"{interaction.Performer.ExpensiveName()} starts removing the bolts from the turret frame...", "You remove the bolts from the turret frame.", $"{interaction.Performer.ExpensiveName()} removes the bolts from the turret frame.", () => { stateful.ServerChangeState(metalAddedState); }); } return; } //Add prox or remove gun if (CurrentState == gunAddedState) { if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.ProximitySensor)) { //Add proximity sensor Chat.AddActionMsgToChat(interaction, $"You place the {interaction.UsedObject.ExpensiveName()} inside the turret frame.", $"{interaction.Performer.ExpensiveName()} places the {interaction.UsedObject.ExpensiveName()} inside the turret frame."); _ = Despawn.ServerSingle(interaction.UsedObject); stateful.ServerChangeState(proxAddedState); } else if (interaction.HandObject == null) { //Remove gun Chat.AddActionMsgToChat(interaction, $"You remove the {gunSlot.ItemObject.ExpensiveName()} from the frame.", $"{interaction.Performer.ExpensiveName()} removes the {gunSlot.ItemObject.ExpensiveName()} from the frame."); Inventory.ServerDrop(gunSlot); stateful.ServerChangeState(wrenchState); } return; } //Screw or remove prox if (CurrentState == proxAddedState) { if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Screwdriver)) { //Screw ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start closing the internal hatch of the turret frame...", $"{interaction.Performer.ExpensiveName()} starts closing the internal hatch of the turret frame...", "You close the internal hatch of the turret frame.", $"{interaction.Performer.ExpensiveName()} closes the internal hatch of the turret frame.", () => { stateful.ServerChangeState(screwState); }); } else if (interaction.HandObject == null) { //Remove prox Chat.AddActionMsgToChat(interaction, $"You remove the {gunSlot.ItemObject.ExpensiveName()} from the frame.", $"{interaction.Performer.ExpensiveName()} removes the {gunSlot.ItemObject.ExpensiveName()} from the frame."); Spawn.ServerPrefab(proximityPrefab, objectBehaviour.registerTile.WorldPosition, transform.parent); stateful.ServerChangeState(gunAddedState); } return; } //Add metal or unscrew if (CurrentState == screwState) { if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.MetalSheet)) { //Add metal ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start adding a metal cover to the turret frame...", $"{interaction.Performer.ExpensiveName()} starts adding a metal cover to the turret frame...", "You add a metal cover to the turret frame.", $"{interaction.Performer.ExpensiveName()} adds a metal cover to the turret frame.", () => { Inventory.ServerConsume(interaction.HandSlot, 1); stateful.ServerChangeState(secondMetalAddedState); }); } else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Screwdriver)) { //Unscrew ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start removing the bolts from the turret frame...", $"{interaction.Performer.ExpensiveName()} starts removing the bolts from the turret frame...", "You remove the bolts from the turret frame.", $"{interaction.Performer.ExpensiveName()} removes the bolts from the turret frame.", () => { stateful.ServerChangeState(proxAddedState); }); } return; } //Finish construction, or remove metal if (CurrentState == secondMetalAddedState) { if (Validations.HasUsedActiveWelder(interaction)) { //Weld to finish turret ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start welding the outer metal cover to the turret frame...", $"{interaction.Performer.ExpensiveName()} starts welding the outer metal cover to the turret frame...", "You weld the outer metal cover to the turret frame.", $"{interaction.Performer.ExpensiveName()} welds the outer metal cover to the turret frame.", () => { var spawnedTurret = Spawn.ServerPrefab(turretPrefab, objectBehaviour.registerTile.WorldPosition, transform.parent); if (spawnedTurret.Successful && spawnedTurret.GameObject.TryGetComponent <Turret>(out var turret)) { turret.SetUpTurret(gunSlot.Item.GetComponent <Gun>(), gunSlot); } _ = Despawn.ServerSingle(gameObject); });
/// <summary> /// is the function to denote that it will be pooled or destroyed immediately after this function is finished, Used for cleaning up anything that needs to be cleaned up before this happens /// </summary> void IServerDespawn.OnDespawnServer(DespawnInfo info) { Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, this.GetComponent <RegisterObject>().WorldPositionServer, count: 15); }
public SpawnProperty(Spawn s) { spawn = s; InitializeComponent(); }
public void ServerDisassemble(HandApply interaction) { tileChangeManager.RemoveTile(registerTile.LocalPositionServer, LayerType.Walls); Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, registerTile.WorldPositionServer, count: 4); Despawn.ServerSingle(gameObject); }
/// <summary> /// Spawns a new player character and transfers the connection's control into the new body. /// If existingMind is null, creates the new mind and assigns it to the new body. /// /// Fires server and client side player spawn hooks. /// </summary> /// <param name="connection">connection to give control to the new player character</param> /// <param name="occupation">occupation of the new player character</param> /// <param name="characterSettings">settings of the new player character</param> /// <param name="existingMind">existing mind to transfer to the new player, if null new mind will be created /// and assigned to the new player character</param> /// <param name="spawnPos">world position to spawn at</param> /// <param name="spawnItems">If spawning a player, should the player spawn without the defined initial equipment for their occupation?</param> /// <param name="willDestroyOldBody">if true, indicates the old body is going to be destroyed rather than pooled, /// thus we shouldn't send any network message which reference's the old body's ID since it won't exist.</param> /// /// <returns>the spawned object</returns> private static GameObject ServerSpawnInternal(NetworkConnection connection, Occupation occupation, CharacterSettings characterSettings, Mind existingMind, Vector3Int?spawnPos = null, bool spawnItems = true, bool willDestroyOldBody = false, bool showBanner = true) { //determine where to spawn them if (spawnPos == null) { Transform spawnTransform; //Spawn normal location for special jobs or if less than 2 minutes passed if (GameManager.Instance.stationTime < ARRIVALS_SPAWN_TIME || occupation.LateSpawnIsArrivals == false) { spawnTransform = SpawnPoint.GetRandomPointForJob(occupation.JobType); } else { spawnTransform = SpawnPoint.GetRandomPointForLateSpawn(); //Fallback to assistant spawn location if none found for late join if (spawnTransform == null && occupation.JobType != JobType.NULL) { spawnTransform = SpawnPoint.GetRandomPointForJob(JobType.ASSISTANT); } } if (spawnTransform == null) { Logger.LogErrorFormat( "Unable to determine spawn position for connection {0} occupation {1}. Cannot spawn player.", Category.EntitySpawn, connection.address, occupation.DisplayName); return(null); } spawnPos = spawnTransform.transform.position.CutToInt(); } //create the player object var newPlayer = ServerCreatePlayer(spawnPos.GetValueOrDefault(), occupation.SpecialPlayerPrefab); var newPlayerScript = newPlayer.GetComponent <PlayerScript>(); //get the old body if they have one. var oldBody = existingMind?.GetCurrentMob(); //transfer control to the player object ServerTransferPlayer(connection, newPlayer, oldBody, Event.PlayerSpawned, characterSettings, willDestroyOldBody); if (existingMind == null) { //create the mind of the player Mind.Create(newPlayer, occupation); } else { //transfer the mind to the new body existingMind.SetNewBody(newPlayerScript); } var ps = newPlayer.GetComponent <PlayerScript>(); var connectedPlayer = PlayerList.Instance.Get(connection); connectedPlayer.Name = ps.playerName; connectedPlayer.Job = ps.mind.occupation.JobType; UpdateConnectedPlayersMessage.Send(); //fire all hooks var info = SpawnInfo.Player(occupation, characterSettings, CustomNetworkManager.Instance.humanPlayerPrefab, SpawnDestination.At(spawnPos), spawnItems: spawnItems); Spawn._ServerFireClientServerSpawnHooks(SpawnResult.Single(info, newPlayer)); if (occupation != null && showBanner) { SpawnBannerMessage.Send( newPlayer, occupation.DisplayName, occupation.SpawnSound.AssetAddress, occupation.TextColor, occupation.BackgroundColor, occupation.PlaySound); } if (info.SpawnItems) { newPlayer.GetComponent <DynamicItemStorage>()?.SetUpOccupation(occupation); } return(newPlayer); }
public void OnDespawnServer(DespawnInfo info) { Spawn.ServerPrefab(matsOnDestroy, gameObject.TileWorldPosition().To3Int(), transform.parent, count: 4, scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true); }
private bool isClassGM(Spawn spawn) { //check if spawnclass is your class's gm return false; }
void Start() { _spawn = GameObject.Find("Spawn").GetComponent <Spawn>(); }
private bool isShopkeeper(Spawn spawn) { //check if spawnclass is shopkeeper return false; }
private void Disassemble(HandApply interaction) { Spawn.ServerPrefab(CommonPrefabs.Instance.MetalRods, gameObject.WorldPosServer(), count: 2); Despawn.ServerSingle(gameObject); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); Armor = new List <Item>(); DestroyedArmor = new List <Item>(); Items = new List <Item>(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { Item it = reader.ReadItem(); if (it != null) { if (it is CursedSuitOfArmor) { ((CursedSuitOfArmor)it).Encounter = this; } Armor.Add(it); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { Item it = reader.ReadItem(); if (it != null) { DestroyedArmor.Add(it); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { if (Spawn == null) { Spawn = new List <BaseCreature>(); } BaseCreature bc = reader.ReadMobile() as BaseCreature; if (bc != null) { if (bc is EnsorcelledArmor) { ((EnsorcelledArmor)bc).Encounter = this; } Spawn.Add(bc); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { if (Items == null) { Items = new List <Item>(); } Item item = reader.ReadItem(); if (item != null) { Items.Add(item); } } if (Spawn == null || Spawn.Count < 4) { int toSpawn = Spawn == null ? 4 : 4 - Spawn.Count; for (int i = 0; i < toSpawn; i++) { if (Spawn == null) { Spawn = new List <BaseCreature>(); } SpawnRandom(); } } }
private void SpawnSingularity() { Spawn.ServerPrefab(singularityPrefab, registerTile.WorldPositionServer, gameObject.transform.parent); }
public void SetTarget(Spawn s, ResizeValHolder rvh) { if (s.id != targetSpawnId) { //remove target indicator from previous target if (targetSpawnId != 0) { int childId = GetChildIndexFromSpawnID(targetSpawnId); if (childId != -1) { DrawingVisualSpawn visual = (DrawingVisualSpawn)GetVisualChild(childId); DrawVisual(ref visual, rvh, false); } } //set new target indicator if we have a target if (s.memoryAddress != 0) { int childId = GetChildIndexFromSpawnID(s.id); if (childId != -1) { DrawingVisualSpawn visual = (DrawingVisualSpawn)GetVisualChild(childId); DrawVisual(ref visual, rvh, true); } } targetSpawnId = s.id; } }
public void Start() { spawnPosition = GetComponent <RectTransform>(); _s = this; game = FindObjectOfType <Game>(); }