// Update is called once per frame public void Run() { switch (GameState) { case "Starting": Starting.Invoke(); break; case "Dying": Dying.Invoke(); break; case "Playing": Playing.Invoke(); break; case "Ending": Ending.Invoke(); break; case "Winning": Winning.Invoke(); break; } }
void RunStates() //Command will loop either state because switch is in update { switch (GameState) { case "Starting": Starting.Invoke(); break; //stop and get out of the switch block case "Loading": Loading.Invoke(); break; //stop and get out of the switch block case "Dying": Dying.Invoke(); break; //stop and get out of the switch block case "Playing": Playing.Invoke(); break; //stop and get out of the switch block case "Ending": Ending.Invoke(); break; //stop and get out of the switch block } }
// Update is called once per frame public void Run() { switch (GameState) { case GameStates.States.Starting: Starting.Invoke(); break; case GameStates.States.Loading: Loading.Invoke(); break; case GameStates.States.Playing: Playing.Invoke(); break; case GameStates.States.Dying: Dying.Invoke(); break; case GameStates.States.Ending: Ending.Invoke(); break; } }
protected override void Die() { Target.AddMoney(Reward); Dying?.Invoke(this); GetComponent <GoblinStateMachine>().ResetOnDie(); gameObject.SetActive(false); }
// Update is called once per frame void Update() { if (Dying.isDying(gameObject)) { return; } else { float delta = Time.deltaTime; //foreach (DelayedAbility delayedAbility in delayedAbilities) //{ // if (delayedAbility.remainingDuration <= 0) // { // usingAbility.UseAbility(delayedAbility.ability, delayedAbility.target, false, false, true); // } //} for (int i = delayedAbilities.Count - 1; i >= 0; i--) { if (delayedAbilities[i].remainingDuration <= 0) { usingAbility.UseAbility(delayedAbilities[i].ability, delayedAbilities[i].target, false, false, true); } } delayedAbilities.RemoveAll(x => x.remainingDuration <= 0); foreach (DelayedAbility delayedAbility in delayedAbilities) { delayedAbility.remainingDuration -= delta; } } }
// Update is called once per frame void Update() { if (sceneLoader) { // this happens when loading starts if (sceneLoader.sceneLoading && !summonsAreChildren) { summonsAreChildren = true; SummonTracker tracker = GetComponent <SummonTracker>(); if (tracker) { // make all summons children of the player so that they become persistent for (int i = 0; i < tracker.summons.Count; i++) //foreach (Summoned summon in tracker.summons) { // don't add dying summons if (!Dying.isDying(tracker.summons[i].gameObject)) { tracker.summons[i].transform.parent = transform; } // delete old dying summons else { Destroy(tracker.summons[i]); } } } } // this happens once a scene has loaded if (!sceneLoader.sceneLoading && summonsAreChildren) { summonsAreChildren = false; SummonTracker tracker = GetComponent <SummonTracker>(); if (tracker) { // put all the summons at the players position and set their parent to null foreach (Summoned summon in tracker.summons) { // do not set their parent to null if they attach to the parent if (!summon.GetComponent <AttachToSummoner>()) { bool navmeshEnabled = false; NavMeshAgent agent = summon.GetComponent <NavMeshAgent>(); if (agent) { navmeshEnabled = agent.enabled; agent.enabled = false; } summon.transform.position = transform.position + randomPositionOnRing(0.5f); summon.transform.parent = null; if (agent && navmeshEnabled) { agent.enabled = true; } } } } } } }
private void Awake() { //cache the animator component animator = GetComponent <Animator>(); collider = GetComponent <BoxCollider2D>(); attack = GetComponent <Attack>(); dying = GetComponent <Dying>(); staticDirections = new string[] { PreparedAnimationPrefix + "Static N", PreparedAnimationPrefix + "Static NE", PreparedAnimationPrefix + "Static E", PreparedAnimationPrefix + "Static SE", PreparedAnimationPrefix + "Static S", PreparedAnimationPrefix + "Static SW", PreparedAnimationPrefix + "Static W", PreparedAnimationPrefix + "Static NW" }; runDirections = new string[] { PreparedAnimationPrefix + "Run N", PreparedAnimationPrefix + "Run NE", PreparedAnimationPrefix + "Run E", PreparedAnimationPrefix + "Run SE", PreparedAnimationPrefix + "Run S", PreparedAnimationPrefix + "Run SW", PreparedAnimationPrefix + "Run W", PreparedAnimationPrefix + "Run NW" }; }
public void Awake() { rigidBody = GetComponent <Rigidbody2D>(); renderer = GetComponentInChildren <CharacterRenderer>(); attack = GetComponent <Attack>(); dying = GetComponent <Dying>(); soundPlayer = GetComponentInChildren <CharacterSoundsPlayer>(); }
public void Apply_NotACharacter_Test() { var entity = Mock.Of <IEntity>(); var dying = new Dying(1); dying.Apply(entity); Assert.IsTrue(true); // If we made it here without exception then the test passed }
void Start() { references = GetComponent <CreationReferences>(); dying = GetComponent <Dying>(); if (dying) { dying.deathEvent += OnDeath; } }
public void Apply_Character_WithExistingDyingCondition_Test() { var character = CreateMockCharacter(); character.Conditions.Add(new Dying(1)); var dying = new Dying(2); dying.Apply(character); }
public void TakeDamage(float damage) { _health -= damage; if (_health <= 0) { Dying?.Invoke(this); } }
public void Die(Dying _actor) { SelfDestroyer destroyer = GetComponent <SelfDestroyer>(); if (destroyer) { destroyer.die(); } }
public void TakeDamage(int damage) { _health -= damage; if (_health <= 0) { Dying?.Invoke(this); Destroy(gameObject); } }
// Start is called before the first frame update public override void OnInspectorGUI() { DrawDefaultInspector(); Dying script = (Dying)target; if (GUILayout.Button("Убить")) { script.Die(); } }
public void TakeDamage(int damage) { _health -= damage; _animator.SetTrigger("Hit"); if (_health <= 0) { Dying?.Invoke(this); // передаем в событие спавнера экземпляр класса enemy } }
public void OnDeath(Dying me) { if (tracker) { if (tracker.summons.Contains(this)) { tracker.summons.Remove(this); } } }
private void Die() { _isDying = true; _attackState.enabled = false; _moveState.enabled = false; _jumpState.enabled = false; Dying?.Invoke(this); _animator.Play("Die"); Destroy(gameObject, _dieTime); }
public void Apply_Character_NoConditions_Test() { var character = CreateMockCharacter(); var dying = new Dying(1); dying.Apply(character); Assert.AreEqual(EntityIds.DYING_CONDITION_ID, character.Conditions[0].Id); Assert.AreEqual(1, character.Conditions[0].Level); Assert.AreSame(dying, character.Conditions[0]); Assert.IsTrue(character.Conditions.Any(c => c.Id == EntityIds.UNCONSCIOUS_CONDITION_ID)); }
public void TakeDamage(int damage) { if (damage >= _health) { _health = 0; Dying?.Invoke(this); Destroy(gameObject); return; } _health -= damage; }
public void Takedamage(int damage) { _health -= damage; if (_health <= 0) { Dying?.Invoke(this); _animator.Play("Die"); Destroy(gameObject, .3f); } }
public void startPullingEnemy(GameObject enemy) { // add the enemy to the list enemiesToPull.Add(enemy); // subscribe to its death event to remove it from the list Dying dyingState = enemy.GetComponent <Dying>(); if (dyingState) { dyingState.deathEvent += stopPullingEnemy; } }
public void Remove_NoConditions_Test() { var character = CreateMockCharacter(); var dying = new Dying(1); dying.Apply(character); dying.Remove(character); Assert.AreEqual(1, character.Conditions.Count); var wounded = character.Conditions.FirstOrDefault(c => c.Id == EntityIds.WOUNDED_CONDITION_ID); Assert.IsNotNull(wounded); Assert.AreEqual(1, wounded.Level); }
public void Remove_WithExistingWoundedCondition_Test() { var character = CreateMockCharacter(); var wounded = new Wounded(1); wounded.Apply(character); var dying = new Dying(1); dying.Apply(character); dying.Remove(character); Assert.AreEqual(1, character.Conditions.Count); Assert.AreEqual(2, character.Conditions.First(c => c.Id == wounded.Id).Level); }
// need to unsubscribe from all the death events when this object is destroyed public void OnDeath() { Dying dyingState = null; foreach (GameObject enemy in enemiesToPull) { dyingState = enemy.GetComponent <Dying>(); if (dyingState) { dyingState.deathEvent -= stopPullingEnemy; } } }
public void Apply_Character_WithExistingWoundedCondition_Test() { var character = CreateMockCharacter(); var wounded = new Wounded(1); wounded.Apply(character); var dying = new Dying(1); dying.Apply(character); Assert.AreEqual(2, character.Conditions.First(c => c.Id == dying.Id).Level); Assert.AreEqual(1, character.Conditions.First(c => c.Id == wounded.Id).Level); Assert.AreEqual(ConditionGroup.DeathAndDying, character.Conditions[0].Group); }
public void Kill() { Dying?.Invoke(this); OnDying(); if (m_DeathAnimation != null) { m_DeathAnimation.Resume(); } else { die(); } }
public void TakeDamage(int damage) { _animator.SetTrigger("TakeDamage"); _audioSource.Play(); _currentHealth -= damage; HealthChanged?.Invoke(_currentHealth, _health); if (_currentHealth <= 0) { Dying?.Invoke(this); StartCoroutine(EnemyDying(_audioSource.clip.length)); } }
public void onNearbyDeath(Dying dyingComponent) { // do not react to unsummon if (dyingComponent.unsummoned) { return; } increasedDamage += damageGainOnNearbyDeath; if (areaGainOnNearbyDeath != 0) { StartCoroutine(castAfterDelay()); } }
// Use this for initialization void Start() { if (transform.parent) { Dying dying = transform.parent.GetComponent <Dying>(); if (dying) { dying.setDelays(0f, 0f); } if (detach) { transform.parent = null; } } }