private IEnumerator PostStart() { yield return(null); Dungeonator.CellData data = GameManager.Instance.Dungeon.data[((Vector2)self.LastPosition).ToIntVector2(VectorConversions.Floor)]; Vector2 cellCenter = data.position.ToVector2() + new Vector2(0.5f, 0.5f); if (registeredCells.ContainsKey(data) && beginInactive) { VFXToolbox.DoStringSquirt("Cell Killed for Dupe Register", data.position.ToVector2() + new Vector2(0.5f, 0.5f), Color.blue); UnityEngine.Object.Destroy(self.gameObject); yield break; } initialCell = data; if (data.IsAnyFaceWall()) { VFXToolbox.DoStringSquirt("Cell Killed for Wall overlap", data.position.ToVector2() + new Vector2(0.5f, 0.5f), Color.blue); UnityEngine.Object.Destroy(self.gameObject); yield break; } self.transform.position = cellCenter; self.specRigidbody.Reinitialize(); yield break; }
public void KillCell(Dungeonator.CellData targetCell) { if (registeredCells.ContainsKey(targetCell)) { VFXToolbox.DoStringSquirt("Cell Killed", targetCell.position.ToVector2() + new Vector2(0.5f, 0.5f), Color.blue); registeredCells[targetCell].DieInAir(); registeredCells.Remove(targetCell); } else { Debug.LogWarning("Tried to kill an unregistered cell, but we caught it."); } }
public void BirthCell(Dungeonator.CellData targetCell) { if (registeredCells.ContainsKey(targetCell)) { Debug.LogWarning("Tried to birth a cell where a cell already lives!"); return; } else { if (!targetCell.IsAnyFaceWall()) { GameObject gameObject = SpawnManager.SpawnProjectile(GOLProjPrefab.gameObject, targetCell.position.ToVector2() + new Vector2(0.5f, 0.5f), Quaternion.identity, true); gameObject.GetComponent <GameOfLifeProjectile>().beginInactive = false; Projectile component = gameObject.GetComponent <Projectile>(); if (component != null && GameManager.Instance.PrimaryPlayer != null) { component.Owner = GameManager.Instance.PrimaryPlayer; component.Shooter = GameManager.Instance.PrimaryPlayer.specRigidbody; } VFXToolbox.DoStringSquirt("Cell Birthed", targetCell.position.ToVector2() + new Vector2(0.5f, 0.5f), Color.blue); registeredCells.Add(targetCell, component); } } }