public void RespawnPlayer(GameObject player, TimedLife newTimedLife) { if (cooldown > 0) { return; } cooldown = WaitTimePerDeath; player.GetComponent <Platformer2DUserControl>().IsAlive = false; player.GetComponent <Rigidbody2D>().simulated = false; this.player = player; player.GetComponent <Animator>().enabled = false; player.GetComponent <PlatformerCharacter2D>().ResetEverything(); SpriteRenderer[] renderers = player.GetComponentsInChildren <SpriteRenderer>(); foreach (SpriteRenderer renderer in renderers) { renderer.enabled = false; } if (PrevTimeLife != null) { PrevTimeLife.IsActived = true; } PrevTimeLife = newTimedLife; playerNameTextMover.Reduce(); if (resetManager != null) { resetManager.ResetLevel(); } }
public TrooperBullet(Actor firerIn) : base() { firer = firerIn; life = new TimedLife(1f); double xImpulse = 300 * (int)Body.Facing; //double yImpulse = 0f; //Body.AddImpulse(new Vector2d(xImpulse, yImpulse)); damage = 6f; rotationSpeed = 10f; }
protected override void OnUpdate() { for (int i = 0; i < data.Length; i++) { TimedLife timedLife = data.timedLives[i]; timedLife.TimeToLive -= Time.deltaTime; data.timedLives[i] = timedLife; if (timedLife.TimeToLive <= 0) { PostUpdateCommands.DestroyEntity(data.Entities[i]); } } }
private void handlePizzaComplete(int pizzaIndex) { Entity pizzaEntity = pizzaData.Entities[pizzaIndex]; PizzaGroup pizzaGroup = pizzaData.PizzaGroup[pizzaIndex]; Position2D pizzaPosition = pizzaData.Position[pizzaIndex]; PizzaCost pizzaCost = pizzaData.PizzaCost[pizzaIndex]; // Pizza is done. Debug.Log("PIZZA DONE - " + pizzaGroup.PizzaId + ": " + pizzaCost.OrderCost + " | " + pizzaCost.ActualCost); // Update global score. PostUpdateCommands.CreateEntity(); PostUpdateCommands.AddComponent(new DeductScore { Value = pizzaCost.ActualCost }); PostUpdateCommands.AddSharedComponent(new ScoringGroup { GroupId = 0 }); // Delete this Pizza. MoveSpeed toWindow = new MoveSpeed { speed = BootStrap.GameSettings.ArrowSpeed }; TimedLife timedLife = new TimedLife { TimeToLive = 10.0f }; PostUpdateCommands.AddComponent(pizzaEntity, toWindow); PostUpdateCommands.AddComponent(pizzaEntity, timedLife); PostUpdateCommands.RemoveComponent <PizzaGroup>(pizzaEntity); // TODO: While ingredients are flying off with the pizza, arrows could hit them. for (int i = 0; i < IngredientData.CalculateLength(); i++) { Entity ingredientEntity = IngredientData.GetEntityArray()[i]; //PostUpdateCommands.AddComponent(ingredientEntity, toWindow); //PostUpdateCommands.AddComponent(ingredientEntity, timedLife); //PostUpdateCommands.RemoveComponent<PizzaGroup>(ingredientEntity); PostUpdateCommands.DestroyEntity(ingredientEntity); } // Create new Pizza. createNewPizza(pizzaIndex); }
public virtual void Kill(bool isFacingRight) { if (IsDead) { return; } IsDead = true; if (_characterInput != null) { _characterInput.MoveParticles.Stop(); } TimedLife gibLife = null; if (SpawnUponDeath != null) { gibLife = SpawnGibs(isFacingRight); if (characterSounds != null) { characterSounds.PlayDeath(); } } if (zombieSoundPlayer != null) { var zombieSound = Instantiate(zombieSoundPlayer).GetComponent <CharacterSounds>(); Debug.Log("zombieSound == null?" + zombieSound == null); zombieSound.PlayDeath(); } if (IsPlayer) { respawner.RespawnPlayer(gameObject, gibLife); } else { Destroy(gameObject); } }