Ejemplo n.º 1
0
 public ExecuteProximityMineSkill(ProximityMineSkill skill, Vector2 target, Func<bool> isDelayConditionMetCallback)
     : base(skill, isDelayConditionMetCallback)
 {
     _target = target;
     _delay = 120;
 }
Ejemplo n.º 2
0
        // Perform proximity mine skill
        public void performProximityMineSkill(int entityId, ProximityMineSkill skill, Vector2 target)
        {
            PerformingSkillsComponent performingSkillsComponent = EntityManager.getPerformingSkillsComponent(entityId);
            HasProxyComponent hasProxyComponent = EntityManager.getHasProxyComponent(entityId);

            // Handle proxy
            if (hasProxyComponent != null)
            {
                EntityManager.removeComponent(hasProxyComponent.proxyId, ComponentType.PositionTarget);
                performProximityMineSkill(hasProxyComponent.proxyId, skill, target);
                return;
            }

            // Create execute skill object
            performingSkillsComponent.executingSkills.Add(new ExecuteProximityMineSkill(
                skill,
                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;
                }));

            EntityManager.addComponent(entityId, new PositionTargetComponent(entityId, target.X, skill.range));
        }