public void spawnLooseShell() { int shellType = -1; Vector3 shellPosition = transform.position; if (shellCount > 1) { shellType = stacker.getTopShellId(); shellPosition = stacker.getTopShell().position; } else if (shellCount == 1) { if (mySpriteId != -1) { shellType = mySpriteId; } } Transform shellObject = Instantiate(spawnShell, shellPosition, transform.rotation); shellObject.GetComponent <SpriteRenderer>().sprite = shellList.getShellSprite(shellType); shellObject.GetComponent <ShellPickUp>().shellType = shellType; float randomAngle = Random.Range(0, Mathf.PI * 2); shellObject.GetComponent <ConstantMove>().velocity = new Vector2(Mathf.Cos(randomAngle), Mathf.Sin(randomAngle)) * shellLossVelocity; }
public void addShell(int addType) { int shellType = (int)Random.Range(0, shellPrefabs.Length); Transform newShell = Instantiate(shellPrefabs[shellType], transform.position, Quaternion.identity); randomizeAngle(newShell); newShell.parent = transform; newShell.GetComponent <SpriteRenderer>().sprite = shellList.getShellSprite(addType); children.Add(newShell); shellId.Add(addType); }