public override void PlayGame(object data) { Debug.Log("Game Core goto PlayGame"); var c = SimplePool.Spawn(postItem, new Vector2(0, 5), Quaternion.identity); SoundManager.Play("dropItem"); //UIPerfectToast.instance.Show("LET'S GO!!!"); }
/// <summary> /// 生成冬季平台 /// </summary> private void SpawnWinterPlatform(int ranObstacleDir) { int index = Random.Range(0, vars.winterPlarformGroup.Count); //GameObject go = Instantiate(vars.winterPlarformGroup[index]); GameObject go = SimplePool.Spawn(vars.winterPlarformGroup[index]); go.transform.position = platformSpawnPosition; go.GetComponent <PlatformScript>().Init(selectSprite, fallTime, ranObstacleDir); }
// ================================================================================= protected override void Awake() { _pPool = new SimplePool <GameObject>(OnCreateItem, OnDestroyItem, 0); if (pTransformParents == null) { pTransformParents = transform; } }
protected override void OnAwake() { confirmButton.onClick.AddListener(Confirm); clearButton.onClick.AddListener(Clear); var pool = itemCellsParent.FindOrCreate("Caches"); ZetanUtility.SetActive(pool, false); caches = new SimplePool <ItemSlot>(itemCellPrefab, poolRoot: pool); }
// Update is called once per frame void Update() { currDespawnTime += Time.deltaTime; if (currDespawnTime >= despawnTime) { SimplePool.Despawn(gameObject); } }
public void Init() { playerModel = GameController_Reactive.Instance.PlayerModel; rb = GetComponent <Rigidbody>(); audioSource = GetComponent <AudioSource>(); SimplePool.Preload(boltPrefab, boltsContainer, 10); }
private void OnCollisionEnter2D(Collision2D collision) { SoundManager.Play("boom"); var a = Instantiate(explosion, new Vector3(this.transform.position.x - 0.25f, this.transform.position.y - 0.85f, 0), Quaternion.identity); GameCoreManager.coreManager.earthWake = true; Debug.Log("hahi"); SimplePool.Despawn(this.gameObject); }
private void OnTriggerEnter(Collider other) { if (Hit != null) { Hit.Invoke(); } SimplePool.Despawn(other.gameObject); }
AudioSource NewSource() { GameObject go = SimplePool.Spawn(AudioClipPlayerPrefab, Vector3.zero, Quaternion.identity); go.transform.parent = this.transform; AudioSource src = go.GetComponent <AudioSource>(); return(src); }
public void MiningTask(GameObject go, Vector3 position) { var info = GameData.Instance.rawmaterialWorkloadDic[MenuType.Mining]; view.onUpdateWorload?.Invoke(info.Workload); var result = TaskHandler.Instance.taskSystem.EnqueueTask(() => { Task task = new MiningTask.Excavate { TargetPosition = position, Name = "采矿", PrefabGame = go, Parent = go.transform.parent.gameObject, Workload = info.Workload, ExcavateAction = (MiningTask.Excavate currentTask) => { var currentWorkload = currentTask.Workload; FunctionUpdater.Create(() => { currentWorkload -= Time.deltaTime; view.onUpdateWorload?.Invoke(info.Workload); go.transform.parent.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, currentWorkload); PlayerController.Instance.PlayMining(true); if (currentWorkload <= 0f) { SimplePool.Despawn(go); GameObject newGo = SimplePool.Spawn(ResourcesManager.LoadPrefab("Prefabs/General_Stone"), go.transform.parent.position, Quaternion.identity); newGo.transform.SetParent(go.transform.parent, false); newGo.transform.position = go.transform.parent.position; PlayerController.Instance.PlayMining(false); WorkerTaskAI.Instance.FinishTheWork(); return(true); } else { return(false); } }); } }; return(task); }); if (result) { SimplePool.Despawn(go); } }
public void InitBulletInControl(Vector3 DirecShot, Vector3 AngleShoot, float Velocity, float SpeedMoveTween, float Damage) { currentBullet = SimplePool.Spawn(prefabBullet, shotPos.position, Quaternion.identity); currentBullet.SetBulletControl(this); currentBullet.transform.SetParent(transform); currentBullet.SetBaseBulletVelocity(DirecShot, AngleShoot, Velocity, SpeedMoveTween); currentBullet.SetBulletDame(Damage); currentBulletQuantity++; }
private void CleanUpDragPreviews() { while (dragPreviewGameObjects.Count > 0) { GameObject go = dragPreviewGameObjects[0]; dragPreviewGameObjects.RemoveAt(0); SimplePool.Despawn(go); } }
void SpawnEnemyPickup() { GameObject prefab = (Random.Range(0, 2) == 0) ? enemyPrefab : pickupPrefab; float xPos = (Random.Range(0, 2) == 0) ? leftLane : rightLane; Vector3 pos = new Vector3(xPos, Camera.main.ScreenToWorldPoint(new Vector3(xPos, Screen.height)).y, 0); GameObject obj = SimplePool.Spawn(prefab, pos, Quaternion.identity) as GameObject; obj.transform.SetParent(transform); }
void OnTriggerExit(Collider other) { if (!other.CompareTag("Boundary")) { return; } SimplePool.Despawn(gameObject); }
void OnCollisionEnter2D(Collision2D other) { PuckSpeedLimiter puck = other.transform.GetComponentInParent <PuckSpeedLimiter>(); if (puck != null) { SimplePool.Spawn(impactVFXPrefab, (Vector3)(other.contacts[0].point) + Vector3.back); } }
private void Fracture() { for (int i = 0; i < FracturePieces; i++) { var piece = SimplePool.Spawn(MeteorFragments, gameObject.transform.position, gameObject.transform.rotation); var pieceRB = piece.GetComponent <Rigidbody2D>(); pieceRB.velocity = Random.onUnitSphere * FragmentSpeed; } }
protected void InitBullet(Vector3 shootPosition, Vector3 shootDirection, float bulletVelocity, float bulletDamage) { currentBullet = SimplePool.Spawn(bulletPrefab, shootPosition, Quaternion.identity); currentBullet.BulletController(this); currentBullet.transform.SetParent(transform); currentBullet.SetBulletVelocity(Vector3.Normalize(shootDirection) * bulletVelocity); currentBullet.SetBulletDamage(bulletDamage); currentBulletQuantity++; }
public void SpawnGuest(int fixFloor = 99) { int currentFloor = Random.Range(0, HotelController.Instance.hotel.floors.Count); int targetFloor = currentFloor; float maxWaitingTime = Random.Range(50f, 120f); // maxWaitingTime = Random.Range(1, 2f); while (targetFloor == currentFloor) { targetFloor = Random.Range(0, HotelController.Instance.hotel.floors.Count); } if (fixFloor != 99) { currentFloor = fixFloor; targetFloor = 1; } Guest guest = new Guest(currentFloor, targetFloor, maxWaitingTime); GameObject guestGO = SimplePool.Spawn(guestPrefab, Vector3.zero, Quaternion.identity); guestGO.transform.SetParent(worldTransform); guestGO.transform.position = new Vector3(4.5f, (float)currentFloor, 0f); guestGO.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); guestGO.transform.eulerAngles = new Vector3(0f, 90f, 0f); guestGO.GetComponent <FaceCanvas>().hud.gameObject.SetActive(true); guestGO.SetActive(true); guests.Add(guest); guestGameObjects.Add(guestGO); guestToGameObjectMap.Add(guest, guestGO); gameObjectToGuestMap.Add(guestGO, guest); guestGO.transform.DOMove(new Vector3(Random.Range(-1.8f, 1.2f), guestGO.transform.position.y, Random.Range(-0.5f, 1.5f)), Random.Range(2f, 3f)) .OnComplete(() => GuestReadyForLift(guest, guestGO)); guestGO.name = "Guest"; FaceCanvas hud = guestGO.GetComponent <FaceCanvas>(); hud.targetFloorText.text = HotelController.Instance.GetFloor(targetFloor).shortName; guest.hud = hud; UpdatePatienceBar(guest); guestCount[currentFloor]++; UpdateLeftPanel(currentFloor); spawnGap = Mathf.Max(minSpawnGap, spawnGap - spawnReduce); }
void Awake() { t = gameObject.GetComponent <Transform>(); if (!SimplePool.PoolExists(projectilePrefab.name)) { SimplePool.CreatePool(projectilePrefab); } }
void CleanDragPreview() { while (dragHighlightCellObjects.Count > 0) { GameObject obj = dragHighlightCellObjects [0]; dragHighlightCellObjects.RemoveAt(0); SimplePool.Despawn(obj); } }
private void Awake() { GameManager.Set(this); pixelsPerScreenPixel = (int)(45f / Camera.main.orthographicSize); visualChunkContainer = GameObject.FindGameObjectWithTag("Container").transform; colliderChunkContainer = GameObject.FindGameObjectWithTag("Container").transform; lightChunkContainer = GameObject.FindGameObjectWithTag("Container").transform; SimplePool.Preload(colliderChunkPrefab, colliderChunkContainer, 2000); }
private void CleanupProjectileImages() { for (int i = projectileImages.Count - 1; i >= 0; i--) { projectileImages[i].transform.SetParent(unusedImageParent); SimplePool.Despawn(projectileImages[i].gameObject); projectileImages.RemoveAt(i); } }
public override void OnBulletDespawn() { currentBulletQuantity--; if (currentBulletQuantity <= 0) { rotateTween.Kill(); SimplePool.Despawn(gameObject); } }
protected override void Start() { base.Start(); tileHighlights = new GameObject[numHighlights]; for (int i = 0; i < numHighlights; i++) { tileHighlights[i] = SimplePool.Spawn(tileHighlightPrefab, Vector3.zero, Quaternion.identity); } }
void SpawnSpeechBubble() { if (specificCurrentUser != null) { GameObject userBubble = SimplePool.Spawn(prefabUserSpeechBubble); userBubble.transform.SetParent(userBubblesContainer); userBubble.transform.position = transform.position + userBubbleOffset; userBubble.GetComponent <UserSpeechBubble>().InitUserBubble(specificCurrentUser); } }
Contagion AddContagion(GameObject targetRoot, float massNerf = 1) { Contagion result = targetRoot.gameObject.AddComponent <Contagion>(); GameObject effects = SimplePool.Spawn(contagionPrefab); effects.transform.SetParent(targetRoot.transform, false); result.Initialize(duration, massNerf, this, effects.GetComponent <ContagionEffects>()); contagions.Add(result); return(result); }
public void ClearPreviews() { // Clean up old drag previews while (dragPreviewGameObjects.Count > 0) { GameObject go = dragPreviewGameObjects[0]; dragPreviewGameObjects.RemoveAt(0); SimplePool.Despawn(go); } }
IEnumerator LoadSceneAsync(int sceneIndex) { SimplePool.Reset(); var operation = SceneManager.LoadSceneAsync(sceneIndex); while (!operation.isDone) { yield return(null); } }
public BaseEnemy Spawn(int targetHealth, int targetMoveSpeed) { BaseEnemy enemyClone = SimplePool.Spawn(enemyPrefab.gameObject).GetComponent <BaseEnemy>(); enemyClone.Initialize(targetHealth, targetMoveSpeed); enemyClone.transform.SetParent(transform); enemyClone.transform.localPosition = Vector3.zero; enemyClone.transform.localEulerAngles = Vector3.zero; return(enemyClone); }
public override void OnCast() { GameObject _prefab = Resources.Load(string.Format(CONSTANT.PathFormatProjectilePrefabs, projectile)) as GameObject; GameObject obj = SimplePool.Spawn(_prefab, parent.sourceUnit.ShootPosition); obj.transform.SetParent(BattleManager.Instance.transform); //obj.transform.position = shootpoint; obj.GetComponent <IndieProjectileObject>().FlyToTarget(parent.sourceUnit.CurrentTarget, ProjectOnHit, speed); }
/// <summary> /// Initialize this enemy and set its movement to the target direction. /// </summary> /// <param name="direction">Which direction should we be traveling in at the start.</param> /// <param name="pool">The optional pool to release this enemy too. Using this can increase performance.</param> public void Initialize(Vector3 direction, SimplePool pool = null) { animator.SetBool("Dead", false); gameObject.layer = enemyLayer; movement.Direction = direction; movement.speed = initialSpeed; movement.Lock = false; // Reset death events if necessary if (deathTrigger != null) { deathTrigger.Pool = pool; deathTrigger.OnInitialize(); } }
/// <summary> Initializes the Velocity parser pool. /// This still needs to be implemented. /// </summary> private void initializeParserPool() { int numParsers = GetInt(RuntimeConstants.PARSER_POOL_SIZE, RuntimeConstants.NUMBER_OF_PARSERS); parserPool = new SimplePool<Parser.Parser>(numParsers); for(int i = 0; i < numParsers; i++) { parserPool.put(CreateNewParser()); } }
public void Start() { Instance = this; }