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!!!"); }
AudioSource NewSource() { GameObject go = SimplePool.Spawn(AudioClipPlayerPrefab, Vector3.zero, Quaternion.identity); go.transform.parent = this.transform; AudioSource src = go.GetComponent <AudioSource>(); return(src); }
/// <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); }
void ShowDamageFloatingText(Unit unit, Weapon weapon) { FloatingText floatingText = SimplePool.Spawn(FloatingTextPrefab).GetComponent <FloatingText>(); floatingText.transform.position = unit.transform.position; floatingText.Color(Color.red); floatingText.Text("-" + weapon.Damage); floatingText.StartMovingAttached(-30, unit); }
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); }
void SpawnMissFloatingText(Projectile projectile) { FloatingText floatingText = SimplePool.Spawn(FloatingTextPrefab).GetComponent <FloatingText>(); floatingText.transform.position = projectile.transform.position; floatingText.Color(MissColor); floatingText.Text("MISS"); floatingText.StartMoving(); }
private void FireArrowOnTarget(UnitObject target) { GameObject _prefab = Resources.Load(string.Format(CONSTANT.PathFormatProjectilePrefabs, projectile)) as GameObject; Vector2 startPos = new Vector2(target.transform.position.x, target.transform.position.y + 3); GameObject obj = SimplePool.Spawn(_prefab, startPos); obj.transform.SetParent(BattleManager.Instance.transform); obj.GetComponent <IndieProjectileObject>().FlyToTarget(target, ProjectOnHit, speed); }
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); }
// Creates a new random tile from a pool of tile game objects. public GameObject createNewTile() { int randIndex = Random.Range(0, tileList.Count); GameObject myTile = SimplePool.Spawn(tileList[randIndex], transform.position, transform.rotation); myTile.GetComponent <WorldTile>().purchased = true; myTile.transform.Translate(Vector3.down * 12f); myTile.transform.SetParent(GameObject.FindGameObjectWithTag("TileHolder").transform); return(myTile); }
public virtual void Shoot() { lastShootTime = Time.time + currentWeaponDefinition.GetCooldown(); currentWeaponDefinition.SpentAmmo(); BaseBullet bulletClone = SimplePool.Spawn(bullet.gameObject).GetComponent <BaseBullet>(); bulletClone.transform.position = bulletExitPoint.position; bulletClone.transform.forward = bulletExitPoint.forward; bulletClone.Initialize(this); }
public void Shoot(Vector3 pos, Quaternion rot) { if (canAtk) { SimplePool.Spawn(bullet, pos, rot); canAtk = false; Invoke("EnableCanAtk", atkDelay); } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Boundary")) { return; } SimplePool.Spawn(explosionPrefab, transform.position, Quaternion.identity); SimplePool.Despawn(gameObject); }
IEnumerator ProjectilesSpawn() { var eye = eyes[Random.Range(0, 3)]; while (true) { SimplePool.Spawn(eyeProjectile, eye.transform.position, Quaternion.identity); yield return(new WaitForSeconds(5f)); } }
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); }
void SpawnEnemyShips() { foreach (Transform child in transform) { GameObject spawnedEnemy = SimplePool.Spawn(basicEnemyPrefab, child.transform.position, Quaternion.identity); spawnedEnemy.GetComponent <EnemyBehaviour>().maxNumberOfHits = 2; spawnedEnemy.transform.parent = child; } //CancelInvoke(); }
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); } }
// Use this for initialization void Start() { trails = new MindMergeTrail[numTrails]; for (int i = 0; i < numTrails; i++) { GameObject spawnedTrailPrefab = SimplePool.Spawn(trailPrefab); spawnedTrailPrefab.transform.SetParent(this.transform, false); trails[i] = spawnedTrailPrefab.GetComponent <MindMergeTrail>(); trails[i].flowIn = flowIn; } }
private void Start() { if (PlayerPrefs.GetInt("Poop") == 0) { poop.SetActive(false); } else { SimplePool.Spawn(poop, poopLocation.transform.position, poop.transform.rotation); } }
public void BasicAttack() { Bullet firingBullet = SimplePool.Spawn( bullet, transform.position, Quaternion.identity ); firingBullet.SetBulletDirection(Vector3.right * facing); firingBullet.SetParty(gameObject.name); }
public Block SpawnBlock(byte width, byte height) { Block block = blockPool.Spawn(hexGrid.OffsetBlockPosition(width, height), true, blockContainerTransform); block.Coord = new BlockCoord(width, height); block.ChangeName(width, height); block.SetBlockType(RandomBlockType()); hexGrid.BlocksActive[width, height] = true; return(hexGrid.SetBlockAt(width, height, block)); }
IEnumerator Spawn() { int amount = Random.Range(1 + (int)(Time.time / 10), 5 + (int)(Time.time / 2)); for (int i = 0; i < amount; i++) { GameObject temp = SimplePool.Spawn(toSpawnTypes.RandomElement <GameObject>(), getRandomSpawnPoint(), Quaternion.identity); temp.transform.SetParent(gameObject.transform); yield return(new WaitForSeconds(0.2f)); } }
void setPlayerReady(int playerID) { Registration data = registeredPlayers[playerID]; data.ready = true; CharacterHolder characterHolder = data.context.charactersData[data.SelectedCharacterID]; characterHolder.Select(); RegisteredPlayerUIView ui = SimplePool.Spawn(playerRegistrationUIPrefab).GetComponent <RegisteredPlayerUIView>(); Transform UIParent; switch (characterHolder.character.side) { default: case Side.LEFT: //witch UIParent = UIParentWitch; break; case Side.RIGHT: UIParent = UIParentAlien; break; } if (data.localID != -1) { ui.playerColor = possiblePlayers[data.localID].color; } else { ui.playerColor = data.color; } ui.transform.SetParent(UIParent, Vector3.one, false); ui.registration = data; data.ui = ui; if (data.localID != -1) { ui.playerName = possiblePlayers[data.localID].name; } Vector2 echoPosition = data.selector.transform.position; Destroy(data.selector.gameObject); data.selector = null; spawnPlaygroundAvatar(playerID); ui.UpdateCharacterSprite(data.SelectedCharacterID); data.echoPosition = echoPosition; checkReady(); }
private void Spawn() { GameObject asteroid = SimplePool.Spawn(asteroidPrefab, Vector2.one, Quaternion.identity); asteroid.transform.localScale = Vector2.one * (0.2f + Random.Range(minSize, maxSize)); speed = Random.Range(minVelocity, maxVelocity); float spawnXPosition = transform.position.x + Random.Range(-spawnerWidth / 2, spawnerWidth / 2); asteroid.transform.position = new Vector2(spawnXPosition, transform.position.y); asteroid.transform.GetComponent <Rigidbody2D>().velocity = transform.up * speed; }
private void Shoot() { for (int i = 0; i < bulletShootDirection_Parabol.Length; i++) { currentBullet = SimplePool.Spawn(bulletPrefab_Gravity, transform.position + spawnOffset, Quaternion.identity); currentBullet.GetComponent <Rigidbody2D>().velocity = Vector3.Normalize(bulletShootDirection_Parabol[i]) * bulletInitialVelocity; currentBullet.transform.localScale = bulletShootDirection_Parabol[i].x > 0 ? Vector3.one : leftScale; currentBullet.transform.localEulerAngles = new Vector3(0, 0, Vector3.SignedAngle(currentBullet.transform.localScale.x == 1 ? Vector3.right : Vector3.left, bulletShootDirection_Parabol[i], Vector3.forward)); currentBullet.SetBulletDamage(enemyDamage); } }
// Update is called once per frame void Update() { float spawnX = Random.Range(Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).x, Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0)).x * 1.1f); Vector2 spawnPosition = new Vector2(spawnX, this.transform.position.y); if (Random.Range(0f, 100f) < randomLeafChance) { SimplePool.Spawn(leaf, spawnPosition, leaf.transform.rotation); } }
public PixelExplosion(GameObject pixelGO, Vector2 initialPosition, Color color) { int numPixels = numPixelsMin + Random.Range(0, numPixelsMax - numPixelsMin); pixels = new List <PixelParticle>(); for (int i = 0; i < numPixels; i++) //get game objects for the fx from pool { pixels.Add(new PixelParticle(SimplePool.Spawn(pixelGO, initialPosition, Quaternion.identity), initialPosition)); pixels[i].paint = color; } }
public virtual void Died() { if (healthSettings.deathParticle) { SimplePool.Spawn(healthSettings.deathParticle, transform.position, Quaternion.identity); } if (healthSettings.deathSound) { AudioSource.PlayClipAtPoint(healthSettings.deathSound, transform.position); } }
void OnCollisionEnter2D(Collision2D other) { GoalScreenTearing.self.doTear(ssfxTime, other.relativeVelocity.sqrMagnitude * tearIntensityMultiplier); ScreenShake.RandomShake(this, ssfxTime, other.relativeVelocity.sqrMagnitude * ssfxIntensityMultiplier); IIgnorePuckVFX ignore = other.collider.GetComponent <IIgnorePuckVFX>(); if (ignore == null) //if ignore exists, then we don't spawn FX, and the ignorepuckVFX spawns them { SimplePool.Spawn(impactVFXPrefab, (Vector3)(other.contacts[0].point) + Vector3.back); } }
protected virtual void FireBullet(Vector2 target) { AbstractBullet spawnedBullet = SimplePool.Spawn(bullet, this.transform.position).GetComponent <AbstractBullet>(); spawnedBullet.range = range; spawnedBullet.Target = target; spawnedBullet.Side = myShip.Side; spawnedBullet.BaseHue = myShip.BaseHue; visuals.rotation = (target - (Vector2)(this.transform.position)).ToRotation(); }
void FireMissile(Vector3 deployPos, float turretAngle) { float deployDist = Vector3.Distance(deployPos, turret.transform.position); //how far is our target GameObject firedMissile = SimplePool.Spawn(missilePrefab, turret.transform.position, Quaternion.Euler(0, 0, turretAngle)); Rigidbody2D missileRb = firedMissile.GetComponent <Rigidbody2D>(); Missile missileScript = firedMissile.GetComponent <Missile>(); missileScript.LockOn(deployDist); missileRb.velocity = missileSpeed * firedMissile.transform.up; //missile is rotated in necessary direction already }