// Update is called once per frame void FixedUpdate() { cameraPos = Camera.main.transform.position.y; if (cameraPos < 40) { if (!waitingSpawn) { if (itemSpawn.Count == 0) { specialQueueIncrement %= 20; if (specialQueueIncrement == 19) { QueueStairs(); } else if (specialQueueIncrement == 10) { QueueDivider(); } else { QueueRandom(); spawnDelay -= 0.008f; nextSpawnTime = spawnDelay; } specialQueueIncrement++; } else { SpawnItem nextItem = itemSpawn.Dequeue(); Instantiate(nextItem.item, nextItem.position, Quaternion.identity, blockParent); StartCoroutine(SpawnWait(nextItem.time)); } } } }
/// <summary> /// Handles operation SpawnItem: Creates a new Item and optionally subscribes an InterestArea to it. /// </summary> public OperationResponse OperationSpawnItem(PeerBase peer, OperationRequest request) { log.InfoFormat("Spawn item operation started for peer: {0}", this.Peer.ToString()); var operation = new SpawnItem(peer.Protocol, request); if (!operation.IsValid) { log.InfoFormat("Spawn item operation invalid"); return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); var item = new Item(operation.Position, operation.Rotation, operation.Properties, this, operation.ItemId, operation.ItemType, this.World); if (this.World.ItemCache.AddItem(item)) { log.InfoFormat("adding item"); this.AddItem(item); return(this.ItemOperationSpawn(item, operation)); } log.InfoFormat("Spawn item operation for peer: {0}", this.Peer.ToString()); item.Dispose(); return(operation.GetOperationResponse((int)ReturnCode.ItemAlreadyExists, "ItemAlreadyExists")); }
public L2DropItem(SpawnItem pck) { this.ObjectID = pck.ObjectID; this.ItemID = pck.ItemID; this.Count = pck.Count; this.X = pck.X; this.Y = pck.Y; this.Z = pck.Z; }
void spawn(SpawnItem item) { GameObject obj = item.gameObject; obj.transform.localScale = new Vector3(item.scale, item.scale, item.scale); Vector3 pos = Random.onUnitSphere * ((planet.transform.localScale.x / 2) + item.zOffset); Quaternion rot = Quaternion.FromToRotation(Vector3.down, planet.transform.position - pos); Instantiate(obj, pos, rot); }
/// <summary> /// Fisher–Yates Shuffle Alg. Perfectly Random shuffle, O(n) /// </summary> private void ShuffleBag(List <SpawnItem> bag) { for (int i = 0; i < bag.Count - 2; i++) { int j = random.Next(i, bag.Count); SpawnItem swap = bag[i]; bag[i] = bag[j]; bag[j] = swap; } }
// Use this for initialization void Start() { PlayerComponent = GameObject.FindWithTag("Player") ; //POBIERAMY OD RODZICA SKRYPT spawnItem = GetComponentInParent<SpawnItem>() ; //JESLI SZUKANIE SIE POWIODLO TO PRZYPISUJEMY COMPONENT DO OBIEKTU if( PlayerComponent != null ) { Debug.Log( "PlayerComponent is empty ( FastShoot )" ) ; } }
private void gvAttachmentTypes_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) { if (_curItemButton == null || _pack == null || CurrentLevel == null || !e.Column.Name.StartsWith(AttachmentColNamePrefix)) { return; } SpawnItem item = _curItemButton.Item; string attachmentType = (string)e.Row; int index = int.Parse(e.Column.Name.Replace(AttachmentColNamePrefix, String.Empty)); SpawnItemAttachment[] attachments = item.Attachments.Where(att => att.Type == attachmentType).ToArray(); SpawnItemAttachment attach = index < attachments.Length ? attachments[index] : null; if (e.IsGetData) { if (attach != null) { e.Value = attachments[index].Name; } else { e.Value = null; } } else if (e.IsSetData) { string attachmentName = (string)e.Value; if (attachmentName == null) { if (attach != null) { item.Attachments.Remove(attach); } } else { if (attach != null) { attach.Name = attachmentName; } else { attach = new SpawnItemAttachment(attachmentType, attachmentName); item.Attachments.Add(attach); } } _curItemButton.Refresh(); UpdatePrognosis(); _curItemButton.Refresh(); } }
void Start() { spawnee = GetComponentInChildren <SpawnItem>(); // dist.Add(0, "Yennefer"); foreach (KeyValuePair <int, string> ie in dist) { Debug.Log(ie.Key); Debug.Log(ie.Value); } }
private SpawnItemButton AddSpawnItemButton(Control pnlLine, SpawnItem item) { var btnItem = new SpawnItemButton(item, (fileName) => ilSpawnItemTypesLarge.Images[GetImageIndex(ilSpawnItemTypesLarge, fileName, false)], (fileName) => ilAttachmentNames.Images[GetImageIndex(ilAttachmentNames, fileName, false)]); btnItem.ContextMenu = cmButton; btnItem.MouseDown += btnItem_MouseDown; pnlLine.Controls.Add(btnItem); pnlLine.Refresh(); return(btnItem); }
private void spawn(SpawnItem item) { if (item.Formation == null) { spawn(item.Prefab, Vector2.zero); } else { foreach (var position in item.Formation.Positions) { spawn(item.Prefab, position); } } }
private SpawnItem RollForWeapon(Spawner MainSpawner, int HandID) { // Currently forces to spawn a weapon from the force orders in the main hand. Does not care whether the weapon makes sense on the character. if (HandID == 0 && MainSpawner.GetSpawnOrdersForce().Count > 0) { SpawnerOrder OrderForce = MainSpawner.GetSpawnOrdersForce()[0]; SpawnItem ForcedItem = new SpawnItem { SpawnWeight = 1, SpawnWeapon = OrderForce.RollForWeapon() }; MainSpawner.SpawnOrderForceFulfilled(OrderForce); return(ForcedItem); } SpawnItem[] AllowedWeaponList = Weapons(HandID); SpawnerOrder[] OrdersForbid = MainSpawner.GetSpawnOrderForbid(); for (int i = 0; i < OrdersForbid.Length; i++) { AllowedWeaponList = OrdersForbid[i].RemoveWeaponsFromList(AllowedWeaponList); } int NumberOfWeapons = AllowedWeaponList.Length; int TotalWeight = 0; for (int i = 0; i < AllowedWeaponList.Length; i++) { TotalWeight += AllowedWeaponList[i].SpawnWeight; } int RolledNumber = Random.Range(0, TotalWeight); int WeightCounter = 0; for (int i = 0; i < AllowedWeaponList.Length; i++) { WeightCounter += AllowedWeaponList[i].SpawnWeight; if (RolledNumber < WeightCounter) { return(AllowedWeaponList[i]); } } return(new SpawnItem()); // Should not be reachable! }
private OperationResponse ItemOperationSpawn(Item item, SpawnItem operation) { // this should always return Ok MethodReturnValue result = this.CheckAccess(item); if (result.IsOk) { item.Rotation = operation.Rotation; item.Spawn(operation.Position); ((World)this.World).Radar.AddItem(item, operation.Position); } operation.OnComplete(); return(operation.GetOperationResponse(result)); }
private GameObject SpawnItem(SpawnItem item) { var spawnedItem = LeanPool.Spawn(item.prefabToSpawn, transform.position, transform.rotation, (item.spawnOnRoot)?null:transform); if (logToFilter) { ConsoleProDebug.LogToFilter($"{item.nameIdentifier} spawned by {name} at {spawnedItem.transform.position}", "Create"); } item.itemCount--; _count++; if (useEvents) { OnSpawnedItem?.Invoke(item); } return(spawnedItem); }
// Use this for initialization void Start() { GameObject PlayerComponent = GameObject.FindWithTag("Player") ; //POBIERAMY OD RODZICA SKRYPT spawnItem = GetComponentInParent<SpawnItem>() ; //JESLI SZUKANIE SIE POWIODLO TO PRZYPISUJEMY COMPONENT DO OBIEKTU if( PlayerComponent != null ) { player = PlayerComponent.GetComponent<PlayerMove>() ; } //JESLI NIE ZNALEZLISMY LUB PRZYPISANIE SIE NIE POWIODLO WYSWIETLAMY TEKST if(player == null) { Debug.Log( " can't find Player PlayerMove " ) ; } }
private void AddSpawnItemInToSpawnList(Vector3 spawnPos, List <SpawnItem> bag, List <SpawnItem> fullBag) { SpawnItem spawn = BagPop(bag, fullBag); // If there are too many entities, do not add more to spawn list. var spawnedEntities = worldRoot.GetTree().GetNodesInGroup(Constants.SPAWNED_GROUP); if (spawnedEntities.Count >= maxAliveEntities) { return; } spawn.Position = spawnPos; itemsToSpawn.Enqueue(spawn); }
private GemCell ConvertToGemCell(SpawnItem spawn) { int gem = GemConverter.GetGemInt(spawn.GemName); GemCell newGemCell = GemCellPool.Instance.GetOneGemCell(gem); newGemCell.InitGem(); var thisGem = newGemCell.Gem; if (thisGem.AllowBG) { int bg = GemBGConverter.GetGemInt(spawn.BgName); newGemCell.InitBgGem(bg); } if (thisGem.AllowFG) { int fg = GemFGConverter.GetGemInt(spawn.FgName); newGemCell.InitFgGem(fg); } return newGemCell; }
private GemCell ConvertToGemCell(SpawnItem spawn) { int gem = GemConverter.GetGemInt(spawn.GemName); GemCell newGemCell = GemCellPool.Instance.GetOneGemCell(gem); newGemCell.InitGem(); var thisGem = newGemCell.Gem; if (thisGem.AllowBG) { int bg = GemBGConverter.GetGemInt(spawn.BgName); newGemCell.InitBgGem(bg); } if (thisGem.AllowFG) { int fg = GemFGConverter.GetGemInt(spawn.FgName); newGemCell.InitFgGem(fg); } return(newGemCell); }
private OperationResponse ItemOperationSpawn(MmoItem item, SpawnItem operation, InterestArea interestArea, MmoActor actor) { // this should always return Ok //MethodReturnValue result = this.CheckAccess(item, actor); //if (result) { // item.Rotation = operation.Rotation; // item.Spawn(operation.Position); // if (interestArea != null) { // lock (interestArea.SyncRoot) { // interestArea.SubscribeItem(item); // } // } //} //operation.OnComplete(); //return operation.GetOperationResponse(result); return(operation.GetOperationResponse(MethodReturnValue.Ok)); }
/// <summary> /// Spawns randomly on a timer. /// </summary> /// <returns>IEnumerator.</returns> IEnumerator RandomSpawn() { for (; ;) { if (portalSpawnTime > 0f) { yield return(new WaitForSeconds(portalSpawnTime)); } else { yield return(new WaitForSeconds(Random.Range(20, 80))); } GameObject port = Instantiate(portalPrefab, point.position, portalPrefab.transform.rotation); SpawnItem portalSpawn = port.GetComponentInChildren <SpawnItem>(); portalSpawn.setUp(); } }
private void SpawnItemsInSpawnList() { if (queuedSpawn != null) { SpawnQueuedSpawn(); } else if (itemsToSpawn.Count > 0) { SpawnItem spawn = itemsToSpawn.Dequeue(); if (spawn == null) { return; } var enumeraable = spawn.Spawn(); if (enumeraable != null) { queuedSpawn = enumeraable.GetEnumerator(); SpawnQueuedSpawn(); } } }
/// <summary> /// Handles operation SpawnItem: Creates a new Item and optionally subscribes an InterestArea to it. /// </summary> public OperationResponse OperationSpawnItem(PeerBase peer, OperationRequest request) { var operation = new SpawnItem(peer.Protocol, request); if (!operation.IsValid) { return(new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() }); } operation.OnStart(); var item = new Item(operation.Position, operation.Rotation, operation.Properties, this, operation.ItemId, operation.ItemType, this.World); if (this.World.ItemCache.AddItem(item)) { this.AddItem(item); return(this.ItemOperationSpawn(item, operation)); } item.Dispose(); return(operation.GetOperationResponse((int)ReturnCode.ItemAlreadyExists, "ItemAlreadyExists")); }
IEnumerator preload() { yield return(null); for (int k = 0; k < settings.Length; k++) { SpawnPoolSettings setting = settings[k]; for (int i = 0; i < setting.spawnItemList.Count; i++) { SpawnItem item = setting.spawnItemList[i]; for (int j = 0; j < item.amount; j++) { createGameObject(item.prefab); } } } yield return(null); if (splashScreenDone) { LoadNextScene(); } loadingDone = true; }
public SpawnItemButton(SpawnItem item, Func <string, Image> getTypeImageByFileName, Func <string, Image> getAttachImageByFileName) : base() { if (item == null) { throw new ArgumentNullException("item"); } if (getTypeImageByFileName == null) { throw new ArgumentNullException("getTypeImageByFileName"); } if (getAttachImageByFileName == null) { throw new ArgumentNullException("getAttachImageByFileName"); } _getTypeImageByFileName = getTypeImageByFileName; _getAttachImageByFileName = getAttachImageByFileName; Item = item; FlatStyle = FlatStyle.Flat; Size = new Size(PackForm.PixelInSec, 75); }
/// <summary> /// "Pops" 0th item out of shuffled bag. /// If bag is empty, shuffle bag. /// </summary> /// <param name="bag">Bag to pop from</param> /// <param name="fullBag">Full bag needed to fill other bag if it runs out</param> /// <returns>Next Spawn Item</returns> private SpawnItem BagPop(List <SpawnItem> bag, List <SpawnItem> fullBag) { if (bag.Count == 0) { FillBag(bag, fullBag); } SpawnItem pop = bag[0]; bag.RemoveAt(0); switch (pop) { case ChunkItem chunkPop: chunkPop.WorldNode = worldRoot; break; case MicrobeItem microbePop: microbePop.WorldNode = worldRoot; break; } return(pop); }
public int FindWeight(SpawnItem s) { return(s.weight); }
void Start() { objBroken.SetActive(true); objFixed.SetActive(false); spawner = FindObjectOfType <SpawnItem>(); }
void SimulateAR() { if (Input.GetMouseButton(0)) { bool touchedObject = false; Ray ray = CameraSingleton.Instance.GetActiveCamera().ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { TouchObject o = hit.collider.gameObject.GetComponent <TouchObject>(); if (o) { o.OnTouch(); touchedObject = true; } } if (!touchedObject) { RaycastHit tHit; Vector3 rotatedForward = Quaternion.Euler(Random.Range(-6f, 6f), Random.Range(-6f, 6f), 0f) * ray.direction; Ray rotatedRay = new Ray(ray.origin, rotatedForward); bool cancelOut = false; // Randomly select an item to spawn from the list SpawnItem item = WeightedSelection.RandomItem <SpawnItem>(spawnPrefabs, FindWeight); if (Physics.Raycast(rotatedRay, out tHit)) { for (int i = 0; i < spawnedObjects.Count; i++) { if (spawnedObjects[i] != null) { float d = Vector3.Distance(tHit.point, spawnedObjects[i].obj.transform.position); float padding = item.positionPadding + spawnedObjects[i].positionPadding; if (d < padding) { cancelOut = true; break; } } else { randomGrassLocation.text = "Found a null grass object! Removing"; spawnedObjects.Remove(spawnedObjects[i]); } } #if TESTING if (Time.timeSinceLevelLoad > lastSample + 1f) { hitPointText.text = "Hit point: " + tHit.Point.ToString(); closestGrassText.text = "No longer calculating"; grassObjectsCount.text = "Grass count: " + spawnedObjects.Count.ToString(); if (spawnedObjects.Count > 0) { randomGrassLocation.text = spawnedObjects[Random.Range(0, spawnedObjects.Count)].transform.position.ToString(); } lastSample = Time.timeSinceLevelLoad; } #endif if (cancelOut) { return; } GameObject newObj = item.DoSetup(tHit.point, GameObject.Find("TestingArea").transform); SpawnedItem newItem = new SpawnedItem(); newItem.obj = newObj; newItem.positionPadding = item.positionPadding; spawnedObjects.Add(newItem); newObj.transform.rotation = Quaternion.Euler(0.0f, Random.Range(-360f, 360f), 0f); } } } }
void Update() { #if UNITY_EDITOR SimulateAR(); return; #endif _QuitOnConnectionErrors(); // The tracking state must be FrameTrackingState.Tracking in order to access the Frame. if (Frame.TrackingState != FrameTrackingState.Tracking) { const int LOST_TRACKING_SLEEP_TIMEOUT = 15; Screen.sleepTimeout = LOST_TRACKING_SLEEP_TIMEOUT; return; } Screen.sleepTimeout = SleepTimeout.NeverSleep; Frame.GetNewPlanes(ref m_newPlanes); // Iterate over planes found in this frame and instantiate corresponding GameObjects to visualize them. for (int i = 0; i < m_newPlanes.Count; i++) { // Instantiate a plane visualization prefab and set it to track the new plane. The transform is set to // the origin with an identity rotation since the mesh for our prefab is updated in Unity World // coordinates. GameObject planeObject = Instantiate(m_trackedPlanePrefab, Vector3.zero, Quaternion.identity, transform); planeObject.GetComponent <TrackedPlaneVisualizer>().SetTrackedPlane(m_newPlanes[i]); planeObject.GetComponent <Renderer>().material.SetFloat("_UvRotation", Random.Range(0.0f, 360.0f)); } // Disable the snackbar UI when no planes are valid. bool showSearchingUI = true; Frame.GetAllPlanes(ref m_allPlanes); for (int i = 0; i < m_allPlanes.Count; i++) { if (m_allPlanes[i].IsValid) { showSearchingUI = false; break; } } m_searchingForPlaneUI.SetActive(showSearchingUI); if (Input.touches.Length > 0) { TouchPhase t = Input.touches[0].phase; //just look at first touch until we decide how to handle multitouch if (t == TouchPhase.Ended) { tapMode = false; } Ray ray = CameraSingleton.Instance.GetActiveCamera().ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (t == TouchPhase.Began) { TouchObject o = hit.collider.gameObject.GetComponent <TouchObject>(); if (o) { o.OnTouch(); tapMode = true; } } } if (!tapMode && t != TouchPhase.Ended) { TrackableHit tHit; TrackableHitFlag raycastFilter = TrackableHitFlag.PlaneWithinBounds | TrackableHitFlag.PlaneWithinPolygon; Vector3 rotatedForward = Quaternion.Euler(Random.Range(-6f, 6f), Random.Range(-6f, 6f), 0f) * ray.direction; Ray rotatedRay = new Ray(ray.origin, rotatedForward); bool cancelOut = false; // Randomly select an item to spawn from the list SpawnItem item = WeightedSelection.RandomItem <SpawnItem>(spawnPrefabs, FindWeight); if (Session.Raycast(rotatedRay, raycastFilter, out tHit)) { for (int i = 0; i < spawnedObjects.Count; i++) { if (spawnedObjects[i] != null) { float d = Vector3.Distance(tHit.Point, spawnedObjects[i].obj.transform.position); float padding = item.positionPadding + spawnedObjects[i].positionPadding; if (d < padding) { cancelOut = true; break; } } else { randomGrassLocation.text = "Found a null grass object! Removing"; spawnedObjects.Remove(spawnedObjects[i]); } } #if TESTING if (Time.timeSinceLevelLoad > lastSample + 1f) { hitPointText.text = "Hit point: " + tHit.Point.ToString(); closestGrassText.text = "No longer calculating"; grassObjectsCount.text = "Grass count: " + spawnedObjects.Count.ToString(); if (spawnedObjects.Count > 0) { randomGrassLocation.text = spawnedObjects[Random.Range(0, spawnedObjects.Count)].transform.position.ToString(); } lastSample = Time.timeSinceLevelLoad; } #endif if (cancelOut) { return; } // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical // world evolves. var anchor = Session.CreateAnchor(tHit.Point, Quaternion.identity); GameObject newObj = item.DoSetup(tHit.Point, anchor.transform); SpawnedItem newItem = new SpawnedItem(); newItem.obj = newObj; newItem.positionPadding = item.positionPadding; spawnedObjects.Add(newItem); newObj.transform.rotation = Quaternion.Euler(0.0f, Random.Range(-360f, 360f), 0f); // Use a plane attachment component to maintain y-offset from the plane (occurs after anchor updates). newObj.GetComponent <PlaneAttachment>().Attach(tHit.Plane); } } } }
/// <summary> /// Adds item to spawnItems, which is used for spawning Spawn Events /// </summary> public void AddSpawnItem(SpawnItem spawnItem) { spawnItems.Add(spawnItem); }
void Awake() { worktop = GetComponent <Worktop>(); squashedGrapeSpawner = GetComponent <SpawnItem>(); }
private void AddSpawnItem(Control pnlLine, SpawnItemButton btnInsertAfter, bool isBindCurrent, SpawnItem newItem = null) { var line = GetLine(pnlLine); var insertAfterItem = btnInsertAfter == null ? null : btnInsertAfter.Item; if (newItem == null) { newItem = line.InsertItem(Pack.SpawnItemConfig.Types.Keys.First(), insertAfterItem); } else { line.InsertItem(newItem, insertAfterItem); } var newBtn = AddSpawnItemButton(pnlLine, newItem); if (isBindCurrent) { BindSpawnItem(newBtn); } IsNeedSave = true; UpdatePrognosis(); }
internal void Add(SpawnItem item) { enemiesToSpawn.Add(item); }
private void Start() { spawnItem = GameObject.FindObjectOfType <SpawnItem>(); }
void Start() { bottleSpawner = GetComponent <SpawnItem>(); worktop = GetComponent <Worktop>(); worktop.onPlaceItem.AddListener((item) => TakeItem(item)); }