Example #1
0
        public IEnumerable <RlEvent> handle(RlEv.GiveDamage hit)
        {
            var stats = hit.entity.get <Performance>();
            var hp    = stats.hp;
            var rest  = hp.val - hit.amount;

            hp.setCurrent(rest);

            if (hp.val <= 0)
            {
                yield return(new RlEv.Death(hit.entity, hit.cause));
            }

            yield break;
        }
Example #2
0
        Anim visualize(RlEv.GiveDamage damage)
        {
            var entity = damage.entity;
            var bar    = entity.get <CharaView>()?.bar;

            if (bar == null)
            {
                return(null);
            }

            var   hp       = entity.get <Performance>().hp;
            float preRatio = (float)hp.val / (float)hp.max;
            float newRatio = (float)(hp.val - damage.amount) / (float)hp.max;

            // TODO: add non-blocking animations and play them explicitly
            bar.barAnimTween(preRatio, newRatio).Start();

            return(null);
        }