Exemple #1
0
        // Perform fireball skill
        public void performFireballSkill(int entityId, FireballSkill fireballSkill, Vector2 target)
        {
            PerformingSkillsComponent performingSkillsComponent = EntityManager.getPerformingSkillsComponent(entityId);
            ExecuteFireballSkill executeFireballSkill = new ExecuteFireballSkill(
                fireballSkill,
                target,
                () =>
                {
                    PositionComponent positionComponent = EntityManager.getPositionComponent(entityId);
                    PositionTargetComponent positionTargetComponent = EntityManager.getPositionTargetComponent(entityId);
                    float distance = Math.Abs(positionTargetComponent.position - positionComponent.position.X);

                    return distance <= positionTargetComponent.tolerance + SKILL_RANGE_TOLERANCE;
                });

            performingSkillsComponent.executingSkills.Add(executeFireballSkill);
            EntityManager.addComponent(entityId, new PositionTargetComponent(entityId, target.X, fireballSkill.range));
        }
Exemple #2
0
        // Execute fireball
        private void executeFireball(int entityId, ExecuteFireballSkill executeFireballSkill)
        {
            FactionComponent factionComponent = EntityManager.getFactionComponent(entityId);
            PerformingSkillsComponent performingSkillsComponent = EntityManager.getPerformingSkillsComponent(entityId);
            FireballSkill fireballSkill = executeFireballSkill.skill as FireballSkill;
            List<int> hitEntities = SystemManager.explosionSystem.createExplosion(executeFireballSkill.target, fireballSkill.explosionRadius, Roller.roll(fireballSkill.explosionDamageDie), fireballSkill.explosionForce, factionComponent.attackableFactions);

            foreach (int hitEntityId in hitEntities)
            {
                if (EntityManager.doesEntityExist(hitEntityId))
                {
                    if (Roller.roll(fireballSkill.burnChanceDie) == 1)
                    {
                        EntityFactory.createDoTSpell(hitEntityId, DamageType.Fire, fireballSkill.burnDamageDie, fireballSkill.burnTickDelay, fireballSkill.burnTickCount);
                    }
                }
            }

            EntityManager.removeComponent(entityId, ComponentType.PositionTarget);
            resetCooldown(entityId, SkillType.Fireball);
            removeExecutedSkill(entityId, executeFireballSkill);
        }