// Start is called before the first frame update void Start() { animator = GetComponent <Animator>(); rigidbody = GetComponent <Rigidbody2D>(); movement = new Vector2(0, 0); healthPoint = FindObjectOfType <HealthPoint>(); }
void OnTriggerEnter(Collider other) { if (other.tag == "Player") { GameObject HPBar = GameObject.FindWithTag("HealthPoint"); HealthPoint HP = null; if (HPBar) { HP = HPBar.GetComponent <HealthPoint> (); } if (HP) { Vector3 direction = (transform.position - other.gameObject.transform.position).normalized; HP.TakeDamage(damage, direction); } } if (other.gameObject.layer == LayerMask.NameToLayer("Enemy")) { EnemyHealth HP = other.gameObject.GetComponent <EnemyHealth> (); if (HP) { HP.TakeDamage(damage * 2, Vector3.zero); } } // If it's flammable block. FlammableBlock block = other.gameObject.GetComponent <FlammableBlock> (); if (block) { block.TakeHit(damage); } }
/// <summary> /// Makes the argument objectToMakeUnused marked as unused. This method is generated to be used /// by generated code. Use Destroy instead when writing custom code so that your code will behave /// the same whether your Entity is pooled or not. /// </summary> public static void MakeUnused(HealthPoint objectToMakeUnused, bool callDestroy) { if (callDestroy) { objectToMakeUnused.Destroy(); } }
public void DisplayMaxHealthPoint() { var health = new HealthPoint(100); var max = new MaxHealthPoint(health); Assert.IsFalse(string.IsNullOrWhiteSpace(max.Display())); }
public void UpdateHealthState() { int lvAggravated = Player.Aggravated; int lvLethal = Player.Lethal; int lvBash = Player.Bash; int lvHealthPointIndex = 1; while (lvAggravated > 0) { HealthPoint lvHp = ((HealthPoint)this.Controls.Find("healthPoint" + lvHealthPointIndex, true)[0]); lvHp.State = HealthPoint.StateEnum.Aggravated; lvHp.SetHealthState(); lvHealthPointIndex++; lvAggravated--; } while (lvLethal > 0) { HealthPoint lvHp = ((HealthPoint)this.Controls.Find("healthPoint" + lvHealthPointIndex, true)[0]); lvHp.State = HealthPoint.StateEnum.Lethal; lvHp.SetHealthState(); lvHealthPointIndex++; lvLethal--; } while (lvBash > 0) { HealthPoint lvHp = ((HealthPoint)this.Controls.Find("healthPoint" + lvHealthPointIndex, true)[0]); lvHp.State = HealthPoint.StateEnum.Bash; lvHp.SetHealthState(); lvHealthPointIndex++; lvBash--; } }
public void OnCollisionEnter2D(Collision2D collision) { if (collision.transform.CompareTag("Player")) { HealthPoint playerHealth = collision.transform.GetComponent <HealthPoint>(); playerHealth.TakeDamage(1); } }
private static void FactoryInitialize() { const int numberToPreAllocate = 20; for (int i = 0; i < numberToPreAllocate; i++) { HealthPoint instance = new HealthPoint(mContentManagerName, false); mPool.AddToPool(instance); } }
void Awake() { _originalDisplay = _display.sprite; _settings = FindObjectOfType <Settings> (); _shake = GetComponent <ObjectShake> (); _meshHits.ForEach(x => x.onHit += OnHit); _hp = GetComponent <HealthPoint> (); _skillController = GetComponent <TheDaystarSkillController> (); _currentAppearanceState = _appearances.Length; }
protected override void OnCollision(RaycastHit hit) { HealthPoint hp = hit.collider.GetComponent <HealthPoint>(); if (hp != null && hp.IsAlive == true) { hp.DoDamage(GetProjectileHitData(hit, projectileBehaviour.ProjectileDamage)); GetComponentInChildren <MeshRenderer>().enabled = false; KillProjectile(); } }
private static Actor CreateActor( ActorId id, HealthPoint hp) => new Actor( id, new ActorType("Test"), new MaxHealthPoint(new HealthPoint(500)), hp, new Attack(50), new Speed(59), new Magic(50));
private static Actor CreateActor() { var actorId = new ActorId("TestActor"); var actorType = new ActorType("TestActor"); var health = new HealthPoint(100); var max = new MaxHealthPoint(health); var attack = new Attack(50); var speed = new Speed(50); var magic = new Magic(50); return(new Actor(actorId, actorType, max, health, attack, speed, magic)); }
void Start() { animate = GetComponent <Animator>(); controller = GetComponent <CharacterController>(); inventory.ItemUsed += Inventory_ItemUsed; inventory.ItemRemoved += Inventory_ItemRemoved; mHealthPoint = Hud.transform.Find("HealthPoint").GetComponent <HealthPoint>(); mHealthPoint.Min = 0; mHealthPoint.Max = health; // let the gameObject fall down //gameObject.transform.position = new Vector3(404, 1, 180); }
public void TestDieAndRevive() { var actor = CreateActor(); Assert.IsTrue(actor.Alive); var damage = new HealthPoint(1000); actor.Damaged(damage); Assert.IsFalse(actor.Alive); var recover = new HealthPoint(1); actor.Recover(recover); Assert.IsTrue(actor.Alive); }
void Start() { healthPoints = new HealthPoint[] { new HealthPoint(50.0f), new HealthPoint(50.0f), new HealthPoint(50.0f), new HealthPoint(50.0f), new HealthPoint(50.0f) }; agent = gameObject.GetComponent<NavMeshAgent> (); _transform = gameObject.GetComponent<Transform> (); creatureObject = gameObject; creatureAI = GetComponent<BasicCreatureAI> (); creatureAI.init (); }
public Actor( ActorId actorId, ActorType actorType, MaxHealthPoint maxHp, HealthPoint hp, Attack attack, Speed speed, Magic magic) { ActorId = actorId; ActorType = actorType; this.maxHp = maxHp; this.hp = hp; this.attack = attack; this.speed = speed; this.magic = magic; }
void IJobChunk.Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <DamageCount> _damageCount = chunk.GetNativeArray(_damageCountHandle); NativeArray <HealthPoint> _healthPoint = chunk.GetNativeArray(_healthPointHandle); NativeArray <Entity> _entity = chunk.GetNativeArray(_EntityHandle); for (int i = 0; i < _damageCount.Length; i++) { _healthPoint[i] = new HealthPoint() { _healthPoint = _healthPoint[i]._healthPoint + _damageCount[i]._heal - _damageCount[i]._damageExplosionCount - _damageCount[i]._damageFireCount }; _damageCount[i] = new DamageCount(); if (_healthPoint[i]._healthPoint <= 0) { _ecb.DestroyEntity(chunkIndex, _entity[i]); } } }
public static HealthPoint CreateNew(Layer layer, float x = 0, float y = 0) { if (string.IsNullOrEmpty(mContentManagerName)) { throw new System.Exception("You must first initialize the factory to use it. You can either add PositionedObjectList of type HealthPoint (the most common solution) or call Initialize in custom code"); } HealthPoint instance = null; instance = new HealthPoint(mContentManagerName, false); instance.AddToManagers(layer); instance.X = x; instance.Y = y; if (mScreenListReference != null) { if (SortAxis == FlatRedBall.Math.Axis.X) { var index = mScreenListReference.GetFirstAfter(x, Axis.X, 0, mScreenListReference.Count); mScreenListReference.Insert(index, instance); } else if (SortAxis == FlatRedBall.Math.Axis.Y) { var index = mScreenListReference.GetFirstAfter(y, Axis.Y, 0, mScreenListReference.Count); mScreenListReference.Insert(index, instance); } else { // Sort Z not supported mScreenListReference.Add(instance); } } if (EntitySpawned != null) { EntitySpawned(instance); } return(instance); }
public void Recover(HealthPoint inc) => hp = hp.Recover(inc, maxHp);
// Start is called before the first frame update void Start() { healthPoint = FindObjectOfType <HealthPoint>(); }
/// <summary> /// Makes the argument objectToMakeUnused marked as unused. This method is generated to be used /// by generated code. Use Destroy instead when writing custom code so that your code will behave /// the same whether your Entity is pooled or not. /// </summary> public static void MakeUnused(HealthPoint objectToMakeUnused) { MakeUnused(objectToMakeUnused, true); }
public MaxHealthPoint(HealthPoint value) { MaxHealth = value; }
void Awake() { playerHP = GameObject.FindWithTag("HealthPoint").GetComponent <HealthPoint> (); isActive = false; }
public void Damaged(HealthPoint val) => hp = hp.Reduce(val);