コード例 #1
0
ファイル: SkillSystem.cs プロジェクト: klutch/Loderpit
        // Perform throw rope skill
        public void performThrowRopeSkill(int entityId, ThrowRopeSkill throwRopeSkill, Vector2 anchor)
        {
            PerformingSkillsComponent performingSkillsComponent = EntityManager.getPerformingSkillsComponent(entityId);
            HasProxyComponent hasProxyComponent = EntityManager.getHasProxyComponent(entityId);
            IsProxyComponent isProxyComponent = EntityManager.getIsProxyComponent(entityId);
            GroupComponent groupComponent;
            ExecuteThrowRopeSkill executeSkill;

            // Find group
            if (isProxyComponent != null)
            {
                groupComponent = SystemManager.groupSystem.getGroupComponentContaining(isProxyComponent.proxyForId);
            }
            else
            {
                groupComponent = SystemManager.groupSystem.getGroupComponentContaining(entityId);
            }

            // Check for has proxy component
            if (hasProxyComponent != null)
            {
                EntityManager.removeComponent(hasProxyComponent.proxyId, ComponentType.PositionTarget);
                performThrowRopeSkill(hasProxyComponent.proxyId, throwRopeSkill, anchor);
                return;
            }

            // Create execute skill object
            executeSkill = new ExecuteThrowRopeSkill(
                throwRopeSkill,
                anchor,
                () =>
                {
                    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;
                });

            // Check for a group
            if (groupComponent != null)
            {
                LimitedRangeFormation formation = new LimitedRangeFormation(groupComponent.entities, groupComponent.activeFormation.position, groupComponent.activeFormation.speed, float.MinValue, anchor.X - 4f);

                groupComponent.addFormation(formation);
                executeSkill.formationToRemove = formation;
            }

            EntityManager.addComponent(entityId, new PositionTargetComponent(entityId, anchor.X, throwRopeSkill.range));
            performingSkillsComponent.executingSkills.Add(executeSkill);
        }
コード例 #2
0
ファイル: SkillSystem.cs プロジェクト: klutch/Loderpit
        // Execute throw rope
        private void executeThrowRope(int entityId, ExecuteThrowRopeSkill executeThrowRopeSkill)
        {
            PerformingSkillsComponent performSkillsComponent = EntityManager.getPerformingSkillsComponent(entityId);
            IsProxyComponent isProxyComponent = EntityManager.getIsProxyComponent(entityId);
            GroupComponent groupComponent;

            // Handle proxies
            if (isProxyComponent != null)
            {
                groupComponent = SystemManager.groupSystem.getGroupComponentContaining(isProxyComponent.proxyForId);
            }
            else
            {
                groupComponent = SystemManager.groupSystem.getGroupComponentContaining(entityId);
            }

            EntityFactory.createRope(executeThrowRopeSkill.anchor);
            EntityManager.removeComponent(entityId, ComponentType.PositionTarget);

            if (groupComponent != null)
            {
                float currentPosition = groupComponent.getFormation(FormationType.LimitedRange).position;

                groupComponent.getFormation(FormationType.Default).position = currentPosition;
                groupComponent.removeFormation(executeThrowRopeSkill.formationToRemove);
            }

            removeExecutedSkill(entityId, executeThrowRopeSkill);
        }