CharacterHealth FixtureCreateHealth(string characterName) { Configuration.ClearInstance(); UpdateManager.ClearInstance(); System.GC.Collect(); var obj = new GameObject(); obj.name = characterName; config = obj.AddComponent <Configuration>(); Assert.NotNull(config); umgr = obj.AddComponent <UpdateManager>(); Assert.NotNull(umgr); var objx = new GameObject(); Character character = objx.AddComponent <Character>(); Assert.NotNull(character); CharacterHealth health = objx.GetComponent <CharacterHealth>(); Assert.NotNull(health); PlatformerCollider2D col2d = objx.GetComponent <PlatformerCollider2D>(); Assert.NotNull(col2d); return(health); }
public override void OnAwake(bool notify = true) { base.OnAwake(notify); aiInput = instance.GetComponentInChildren <AIInput>(); if (aiInput == null) { Debug.LogWarning("AIInput is expected in the prefab"); return; } pc2d = instance.GetComponentInChildren <PlatformerCollider2D>(); character = instance.GetComponentInChildren <Character>(); aiInput.SetX(1); character.onAreaChange += OnAreaChange; character.onStateChange += OnStateChange; pc2d.onLeftWall += OnLeftWall; pc2d.onRightWall += OnRightWall; }
void FixtureCreateHealth() { Configuration.ClearInstance(); UpdateManager.ClearInstance(); System.GC.Collect(); var obj = new GameObject(); config = obj.AddComponent <Configuration>(); Assert.NotNull(config); umgr = obj.AddComponent <UpdateManager>(); Assert.NotNull(umgr); var objx = new GameObject(); character = objx.AddComponent <Character>(); Assert.NotNull(character); health = objx.GetComponent <CharacterHealth>(); Assert.NotNull(health); col2d = objx.GetComponent <PlatformerCollider2D>(); Assert.NotNull(col2d); health.onHeal += () => { onHealCalled = true; }; health.onDamage += () => { onDamageCalled = true; }; health.onImmunity += () => { onImmunityCalled = true; }; health.onMaxHealth += () => { onMaxHealthCalled = true; }; health.onInjured += (Damage dt, CharacterHealth to) => { onInjuredCalled = true; }; health.onHurt += (Damage dt, CharacterHealth to) => { onHurtCalled = true; }; health.onDeath += () => { onDeathCalled = true; }; health.onGameOver += () => { onGameOverCalled = true; }; health.onInvulnerabilityStart += () => { onInvulnerabilityStartCalled = true; }; health.onInvulnerabilityEnd += () => { onInvulnerabilityEndCalled = true; }; health.onRespawn += () => { onRespawnCalled = true; }; ResetCallbacks(); }