예제 #1
0
            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;
            }
예제 #2
0
 private void EndStreak(Projectile projectileResponsible)
 {
     if (projectileResponsible != null)
     {
         PunishmentRayHitOnce baseProj = projectileResponsible.GetComponent <PunishmentRayHitOnce>();
         if (baseProj != null)
         {
             return;
         }
     }
     if (this.gun.CurrentOwner != null && this.gun.CurrentOwner is PlayerController)
     {
         if (HitStreak > 0)
         {
             VFXToolbox.DoStringSquirt("STREAK LOST", this.gun.CurrentOwner.transform.position, Color.red);
         }
         int damageThreshold = 10;
         if ((this.gun.CurrentOwner as PlayerController).PlayerHasActiveSynergy("Spare The Rod"))
         {
             damageThreshold = 20;
         }
         if (HitStreak >= damageThreshold)
         {
             this.gun.CurrentOwner.healthHaver.ApplyDamage(0.5f, Vector2.zero, "STREAK LOST", CoreDamageTypes.None, DamageCategory.Normal, true, null, false);
         }
     }
     HitStreak = 0;
 }
예제 #3
0
 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.");
     }
 }
예제 #4
0
 private void OnHitEnemy(Projectile bullet, SpeculativeRigidbody enemy, bool fatal)
 {
     if (bullet && enemy)
     {
         if (UnityEngine.Random.value <= 0.05f)
         {
             VFXToolbox.DoStringSquirt(BraveUtility.RandomElement(dialogue), enemy.Position.GetPixelVector2(), ExtendedColours.honeyYellow);
             if (bullet.ProjectilePlayerOwner() && bullet.ProjectilePlayerOwner().PlayerHasActiveSynergy("De4l 0f 4 Lif3tim3"))
             {
                 LootEngine.SpawnCurrency(enemy.Position.GetPixelVector2(), UnityEngine.Random.Range(2, 5));
             }
         }
     }
 }
예제 #5
0
 public override void OnReloadPressed(PlayerController player, Gun gun, bool manualReload)
 {
     if (CurrentColourFiringMode == ColourType.RED)
     {
         CurrentColourFiringMode = ColourType.YELLOW;
         VFXToolbox.DoStringSquirt("YELLOW", gun.sprite.WorldCenter, ExtendedColours.honeyYellow);
     }
     else if (CurrentColourFiringMode == ColourType.YELLOW)
     {
         CurrentColourFiringMode = ColourType.BLUE;
         VFXToolbox.DoStringSquirt("BLUE", gun.sprite.WorldCenter, Color.blue);
     }
     else if (CurrentColourFiringMode == ColourType.BLUE)
     {
         CurrentColourFiringMode = ColourType.RED;
         VFXToolbox.DoStringSquirt("RED", gun.sprite.WorldCenter, Color.red);
     }
     base.OnReloadPressed(player, gun, manualReload);
 }
예제 #6
0
 public override void OnReloadPressed(PlayerController player, Gun gun, bool bSOMETHING)
 {
     base.OnReloadPressed(player, gun, bSOMETHING);
     if ((gun.ClipCapacity == gun.ClipShotsRemaining) || (gun.CurrentAmmo == gun.ClipShotsRemaining))
     {
         if (currentMode == 7)
         {
             currentMode             = 1;
             overrideAmmoConsumption = ModeAmmoCosts[currentMode];
             VFXToolbox.DoStringSquirt(ModeNames[1], player.transform.position, Color.red);
         }
         else
         {
             currentMode++;
             overrideAmmoConsumption = ModeAmmoCosts[currentMode];
             VFXToolbox.DoStringSquirt(ModeNames[currentMode], player.transform.position, Color.red);
         }
     }
 }
예제 #7
0
        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);
                }
            }
        }
예제 #8
0
        public IEnumerator HandleGeneration()
        {
            generationRunning = true;
            if (GameManager.Instance.Dungeon != null && GameManager.Instance.Dungeon.data != null && !Dungeon.IsGenerating)
            {
                Dictionary <Dungeonator.CellData, int> birthCandidates = new Dictionary <Dungeonator.CellData, int>();

                if (GameManager.Instance.PrimaryPlayer)
                {
                    VFXToolbox.DoStringSquirt("Generation", GameManager.Instance.PrimaryPlayer.CenterPosition, Color.red);
                }
                //1 - Any live cell with fewer than two live neighbours dies, as if by underpopulation.
                //2 - Any live cell with two or three live neighbours lives on to the next generation.
                //3 - Any live cell with more than three live neighbours dies, as if by overpopulation.
                //4 - Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

                //this is where we start a new generation. The first step is to apply any planned births or deaths from the previous generation
                if (plannedBirths != null && plannedBirths.Count > 0)
                {
                    for (int birth = plannedBirths.Count - 1; birth >= 0; birth--)//Births
                    {
                        BirthCell(plannedBirths[birth]);
                        yield return(null);
                    }
                    plannedBirths.Clear();
                }
                if (plannedDeaths != null && plannedDeaths.Count > 0)
                {
                    for (int death = plannedDeaths.Count - 1; death >= 0; death--)//Deaths
                    {
                        KillCell(plannedDeaths[death]);
                        yield return(null);
                    }
                    plannedDeaths.Clear();
                }

                //The second step is, after a frame delay, to calculate what births and deaths need to happen in the next generation
                yield return(null);

                for (int i = registeredCells.Keys.Count - 1; i >= 0; i--)
                {
                    if (registeredCells.ElementAt(i).Value == null)
                    {
                        registeredCells.Remove(registeredCells.ElementAt(i).Key);
                    }
                    else
                    {
                        List <Dungeonator.CellData> Neighbors = new List <Dungeonator.CellData>();
                        Neighbors.AddRange(GameManager.Instance.Dungeon.data.GetCellNeighbors(registeredCells.ElementAt(i).Key, true));
                        int numberOfNeighbors = NumberOfLiveCells(Neighbors);

                        //Mark cells for death in the next generation if they have more than 3 neighbors or fewer than 2
                        if (numberOfNeighbors > 3 || numberOfNeighbors < 2)
                        {
                            plannedDeaths.Add(registeredCells.ElementAt(i).Key);
                        }


                        //We need to register all empty cells and figure out how many neighbors they have to figure out if they should come alive
                        //So we iterate through all alive cells, and add all their dead neighbors to a dictionary that stores how many times they have been checked
                        //Since they are checked by each alive cell, the amount of times they have been checked will tell us how many alive neighbors they have
                        foreach (Dungeonator.CellData potNeighbor in Neighbors)
                        {
                            if (!registeredCells.ContainsKey(potNeighbor))
                            {
                                if (birthCandidates.ContainsKey(potNeighbor))
                                {
                                    birthCandidates[potNeighbor]++;
                                }
                                else
                                {
                                    birthCandidates.Add(potNeighbor, 1);
                                }
                            }
                            // yield return null;
                        }
                        foreach (Dungeonator.CellData potBirth in birthCandidates.Keys)
                        {
                            if (birthCandidates[potBirth] == 3)
                            {
                                plannedBirths.Add(potBirth);
                            }
                        }
                    }
                }
            }
            generationRunning = false;
            timer             = 0.5f;
            yield break;
        }