// Start is called before the first frame update
 void Start()
 {
     animator    = GetComponent <Animator>();
     rigidbody   = GetComponent <Rigidbody2D>();
     movement    = new Vector2(0, 0);
     healthPoint = FindObjectOfType <HealthPoint>();
 }
Exemple #2
0
    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);
        }
    }
Exemple #3
0
 /// <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--;
            }
        }
Exemple #6
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.transform.CompareTag("Player"))
     {
         HealthPoint playerHealth = collision.transform.GetComponent <HealthPoint>();
         playerHealth.TakeDamage(1);
     }
 }
Exemple #7
0
        private static void FactoryInitialize()
        {
            const int numberToPreAllocate = 20;

            for (int i = 0; i < numberToPreAllocate; i++)
            {
                HealthPoint instance = new HealthPoint(mContentManagerName, false);
                mPool.AddToPool(instance);
            }
        }
Exemple #8
0
 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();
        }
    }
Exemple #10
0
 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));
Exemple #11
0
        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);
    }
Exemple #13
0
        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);
        }
Exemple #14
0
 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 ();
 }
Exemple #15
0
 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;
 }
Exemple #16
0
        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]);
                }
            }
        }
Exemple #17
0
        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);
        }
Exemple #18
0
 public void Recover(HealthPoint inc)
 => hp = hp.Recover(inc, maxHp);
Exemple #19
0
 // Start is called before the first frame update
 void Start()
 {
     healthPoint = FindObjectOfType <HealthPoint>();
 }
Exemple #20
0
 /// <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);
 }
Exemple #21
0
 public MaxHealthPoint(HealthPoint value)
 {
     MaxHealth = value;
 }
Exemple #22
0
    void Awake()
    {
        playerHP = GameObject.FindWithTag("HealthPoint").GetComponent <HealthPoint> ();

        isActive = false;
    }
Exemple #23
0
 public void Damaged(HealthPoint val)
 => hp = hp.Reduce(val);