示例#1
0
        public ExecuteRainOfFireSkill(Skill skill, Func<bool> isDelayConditionMetCallback)
            : base(skill, isDelayConditionMetCallback)
        {
            RainOfFireSkill rainOfFireSkill = skill as RainOfFireSkill;

            _delay = rainOfFireSkill.tickCount * rainOfFireSkill.tickDelay;
        }
示例#2
0
        public ExecuteFrenzySkill(Skill skill, Func<bool> isDelayConditionMetCallback)
            : base(skill, isDelayConditionMetCallback)
        {
            FrenzySkill frenzySkill = skill as FrenzySkill;

            _delay = frenzySkill.duration;
        }
示例#3
0
 public ExecutePowerSwingSkill(Skill skill, int defenderId, Func<bool> isDelayConditionMetCallback)
     : base(skill)
 {
     _defenderId = defenderId;
     _delay = 60;
     _isDelayConditionMetCallback = isDelayConditionMetCallback;
 }
示例#4
0
 public ExecuteBuildBridgeSkill(Skill skill, Vector2 anchorA, Vector2 anchorB, Func<bool> isDelayConditionMetCallback)
     : base(skill, isDelayConditionMetCallback)
 {
     _anchorA = anchorA;
     _anchorB = anchorB;
     _delay = calculateDelay();
 }
示例#5
0
        public SkillPaneComponent(SkillsScreen screen, Texture skillIcon, List<Texture> unfilledOrbTextures, List<Texture> filledOrbTextures, int entityId, Skill skill, Vector2f position, int additionalLevelValue)
            : base(screen)
        {
            _skillsScreen = screen;
            _position = position;
            _skillIcon = skillIcon;
            _skill = skill;
            _additionalLevelValue = additionalLevelValue;

            _unfilledOrbs = new List<RectangleShape>();
            _filledOrbs = new List<RectangleShape>();
            _numOrbs = unfilledOrbTextures.Count;
            for (int i = 0; i < _numOrbs; i++)
            {
                Texture unfilledOrbTexture = unfilledOrbTextures[i];
                Texture filledOrbTexture = filledOrbTextures[i];
                RectangleShape unfilledShape = new RectangleShape();
                RectangleShape filledShape;

                unfilledShape.Texture = unfilledOrbTexture;
                unfilledShape.Size = new Vector2f(unfilledShape.Texture.Size.X, unfilledShape.Texture.Size.Y);
                unfilledShape.Position = position + new Vector2f(i * 39f, 138);
                filledShape = new RectangleShape(unfilledShape);
                filledShape.Texture = filledOrbTexture;

                _unfilledOrbs.Add(unfilledShape);
                _filledOrbs.Add(filledShape);
            }

            _font = ResourceManager.getResource<Font>("immortal_font");
            _text = new Text(SystemManager.skillSystem.getSkillName(skill.type), _font, 24);
            _text.Position = position;
            _text.Color = Color.White;

            _shape = new RectangleShape();
            _shape.Texture = skillIcon;
            _shape.Size = new Vector2f(skillIcon.Size.X, skillIcon.Size.Y);
            _shape.Position = position + new Vector2f(0, 32f);
        }
示例#6
0
 // Handle initialize gale force skill
 private void handleInitializeGaleForce(int entityId)
 {
     SystemManager.skillSystem.performGaleForceSkill(entityId, _initializingSkill as GaleForceSkill);
     _initializingSkill = null;
 }
示例#7
0
        // Handle initialize golem stance
        private void handleInitializeGolemStance(int entityId)
        {
            bool isSkillAlreadyActive = false;
            AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(entityId);

            // Check if golem stance is already active
            foreach (int spellId in affectedBySpellEntitiesComponent.spellEntities)
            {
                SpellTypeComponent spellTypeComponent = EntityManager.getSpellTypeComponent(spellId);

                if (spellTypeComponent != null && spellTypeComponent.spellType == SpellType.GolemStance)
                {
                    isSkillAlreadyActive = true;
                    break;
                }
            }

            if (isSkillAlreadyActive)
            {
                // Disable skill
                SystemManager.skillSystem.disableGolemStance(entityId);
                _initializingSkill = null;
            }
            else if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
            {
                // Enable skill
                SystemManager.skillSystem.enableGolemStance(entityId, _initializingSkill as GolemStanceSkill, Game.worldMouse);
                _initializingSkill = null;
            }
        }
示例#8
0
 public ExecuteFatalitySkill(Skill skill, int targetEntityId, Func<bool> isDelayConditionMetCallback)
     : base(skill, isDelayConditionMetCallback)
 {
     _targetEntityId = targetEntityId;
     _delay = 60;
 }
示例#9
0
        public bool trySpendSkillOrb(Skill skill)
        {
            int entityId = skill.entityId;
            int newNumSkillsBought = _numSkillsBought + 1;

            // Stop if no orbs left
            if (newNumSkillsBought > _numSkillOrbs)
            {
                return false;
            }

            // Stop if at max skill level
            if (newNumSkillsBought > SkillSystem.MAX_SKILL_LEVEL)
            {
                return false;
            }

            // Remember skill to buy
            if (!_skillsBought.ContainsKey(entityId))
            {
                _skillsBought.Add(entityId, new Dictionary<SkillType, int>());
            }
            if (!_skillsBought[entityId].ContainsKey(skill.type))
            {
                _skillsBought[entityId].Add(skill.type, 0);
            }
            _skillsBought[entityId][skill.type]++;
            _numSkillsBought++;
            return true;
        }
示例#10
0
        // Handles input for the player's team
        private void handleInput()
        {
            if (Game.inFocus)
            {
                int selectedEntityId = getTeammateEntityId(_selectedTeammate);
                CharacterComponent characterComponent = EntityManager.getCharacterComponent(selectedEntityId);
                SkillsComponent skillsComponent = EntityManager.getSkillsComponent(selectedEntityId);
                List<Skill> skills = skillsComponent.activatableSkills;
                int minNum = (int)Key.Num1;
                int maxNum = (int)Key.Num8;
                int count = 0;

                // Read key states
                if (Game.newKeyState.isPressed(Key.A) && Game.oldKeyState.isReleased(Key.A))
                {
                    selectPreviousTeammate();
                }
                if (Game.newKeyState.isPressed(Key.D) && Game.oldKeyState.isReleased(Key.D))
                {
                    selectNextTeammate();
                }
                if (Game.newKeyState.isPressed(Key.Q) && Game.oldKeyState.isReleased(Key.Q))
                {
                    SystemManager.groupSystem.decreaseActiveFormationSpeed(_playerGroup.entityId);
                }
                if (Game.newKeyState.isPressed(Key.E) && Game.oldKeyState.isReleased(Key.E))
                {
                    SystemManager.groupSystem.increaseActiveFormationSpeed(_playerGroup.entityId);
                }
                if (Game.newKeyState.isPressed(Key.Escape))
                {
                    _initializingSkill = null;
                }
                for (int i = minNum; i < maxNum; i++)
                {
                    if (count == skills.Count)
                    {
                        break;
                    }

                    if (Game.newKeyState.isPressed((Key)i) && Game.oldKeyState.isReleased((Key)i))
                    {
                        Skill skill = skills[count];

                        // Make sure skill is ready to be used, with the exception of melee/ranged attacks
                        if (skill.type == SkillType.MeleeAttack || skill.type == SkillType.MeleeAttack)
                        {
                            _initializingSkill = skill;
                        }
                        else if (skill.cooldown == 0)
                        {
                            _initializingSkill = skill;
                        }
                    }

                    count++;
                }

                // Handle actions
                if (_initializingSkill != null)
                {
                    if (_initializingSkill.cooldown == 0)
                    {
                        switch (_initializingSkill.type)
                        {
                            // Common
                            case SkillType.MeleeAttack:
                            case SkillType.RangedAttack:
                                handleInitializeAttack(selectedEntityId);
                                break;

                            // Defender
                            case SkillType.ShieldBash:
                                handleInitializeShieldBash(selectedEntityId);
                                break;
                            case SkillType.Riposte:
                                handleInitializeRiposte(selectedEntityId);
                                break;
                            case SkillType.GolemStance:
                                handleInitializeGolemStance(selectedEntityId);
                                break;

                            // Engineer
                            case SkillType.ThrowRope:
                                handleInitializeThrowRope(selectedEntityId);
                                break;
                            case SkillType.BuildBridge:
                                handleInitializeBuildBridge(selectedEntityId);
                                break;
                            case SkillType.ProximityMine:
                                handleInitializeProximityMine(selectedEntityId);
                                break;
                            case SkillType.Fortification:
                                handleInitializeFortification(selectedEntityId);
                                break;

                            // Archer
                            case SkillType.PowerShot:
                                handleInitializePowerShot(selectedEntityId);
                                break;
                            case SkillType.ArrowTime:
                                handleInitializeArrowTime(selectedEntityId);
                                break;
                            case SkillType.Volley:
                                handleInitializeVolley(selectedEntityId);
                                break;

                            // Fighter
                            case SkillType.PowerSwing:
                                handleInitializePowerSwing(selectedEntityId);
                                break;
                            case SkillType.Fatality:
                                handleInitializeFatality(selectedEntityId);
                                break;
                            case SkillType.Frenzy:
                                handleInitializeFrenzy(selectedEntityId);
                                break;

                            // Mage
                            case SkillType.Fireball:
                                handleInitializeFireball(selectedEntityId);
                                break;
                            case SkillType.RainOfFire:
                                handleInitializeRainOfFire(selectedEntityId);
                                break;
                            case SkillType.GaleForce:
                                handleInitializeGaleForce(selectedEntityId);
                                break;

                            // Healer
                            case SkillType.HealingBlast:
                                handleInitializeHealingBlast(selectedEntityId);
                                break;
                            case SkillType.Infusion:
                                handleInitializeInfusion(selectedEntityId);
                                break;
                            case SkillType.Dispel:
                                handleInitializeDispel(selectedEntityId);
                                break;
                        }
                    }
                }
            }
        }
示例#11
0
 public ExecuteFortificationSkill(Skill skill, Vector2 target, Func<bool> isDelayConditionMetCallback)
     : base(skill, isDelayConditionMetCallback)
 {
     _target = target;
     _delay = 180;
 }
示例#12
0
 // Handle initialize riposte skill
 private void handleInitializeRiposte(int entityId)
 {
     SystemManager.skillSystem.performRiposteSkill(entityId, _initializingSkill as RiposteSkill);
     _initializingSkill = null;
 }
示例#13
0
 // Handle initialization of the throw rope skill
 private void handleInitializeThrowRope(int selectedEntityId)
 {
     _createRopeAnchor = Game.worldMouse;
     if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
     {
         SystemManager.skillSystem.performThrowRopeSkill(selectedEntityId, _initializingSkill as ThrowRopeSkill, _createRopeAnchor);
         _initializingSkill = null;
     }
 }
示例#14
0
        // Handle initialize infusion skill
        private void handleInitializeInfusion(int entityId)
        {
            if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
            {
                FactionComponent factionComponent = EntityManager.getFactionComponent(entityId);
                int targetEntityId = Helpers.findEntityWithinRange(Game.worldMouse, 1f, factionComponent.faction);

                if (targetEntityId != -1)
                {
                    SystemManager.skillSystem.performInfusionSkill(entityId, _initializingSkill as InfusionSkill, targetEntityId);
                    _initializingSkill = null;
                }
            }
        }
示例#15
0
 public ExecuteGolemStanceSkill(Skill skill, Vector2 position, Func<bool> isDelayConditionMetCallback)
     : base(skill, isDelayConditionMetCallback)
 {
     _position = position;
 }
示例#16
0
 public ExecuteRangedAttackSkill(Skill skill, int defenderId)
     : base(skill)
 {
     _defenderId = defenderId;
 }
示例#17
0
 public ExecuteThrowRopeSkill(Skill skill, Vector2 anchor, Func<bool> isDelayConditionMetCallback)
     : base(skill, isDelayConditionMetCallback)
 {
     _anchor = anchor;
     _delay = calculateDelay();
 }
示例#18
0
 public ExecuteFireballSkill(Skill skill, Vector2 target, Func<bool> isDelayConditionMetCallback)
     : base(skill, isDelayConditionMetCallback)
 {
     _delay = 60;
     _target = target;
 }
示例#19
0
 // Handle initialize power swing skill
 private void handleInitializePowerSwing(int selectedEntityId)
 {
     if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
     {
         SystemManager.skillSystem.performPowerSwingSkill(selectedEntityId, _initializingSkill as PowerSwingSkill, Game.worldMouse);
         _initializingSkill = null;
     }
 }
示例#20
0
 // Select next teammate
 public void selectNextTeammate()
 {
     _selectedTeammate = _selectedTeammate + 1 > _playerGroup.entities.Count - 1 ? 0 : _selectedTeammate + 1;
     _initializingSkill = null;
 }
示例#21
0
 // Handle initialize shield bash skill
 private void handleInitializeShieldBash(int entityId)
 {
     SystemManager.skillSystem.performShieldBashSkill(entityId, _initializingSkill as ShieldBashSkill);
     _initializingSkill = null;
 }
示例#22
0
 // Select previous teammate
 public void selectPreviousTeammate()
 {
     _selectedTeammate = _selectedTeammate - 1 < 0 ? _playerGroup.entities.Count - 1 : _selectedTeammate - 1;
     _initializingSkill = null;
 }
示例#23
0
 // Handle initialize volley skill
 private void handleInitializeVolley(int entityId)
 {
     if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
     {
         SystemManager.skillSystem.performVolleySkill(entityId, _initializingSkill as VolleySkill, Game.worldMouse);
         _initializingSkill = null;
     }
 }
示例#24
0
        // Handle initialize arrow time skill
        private void handleInitializeArrowTime(int entityId)
        {
            ArrowTimeSkill arrowTimeSkill = _initializingSkill as ArrowTimeSkill;

            // Handle setup
            if (!_initializingArrowTime)
            {
                _slowMotionEntityId = EntityFactory.createSlowMotionSpell(arrowTimeSkill.timeToLive);
                _initializingArrowTime = true;
            }

            // Check for end of setup
            if (!EntityManager.doesEntityExist(_slowMotionEntityId))
            {
                if (_arrowTimeTargets.Count > 0)
                {
                    SystemManager.skillSystem.performArrowTimeSkill(entityId, arrowTimeSkill, new List<int>(_arrowTimeTargets));
                }

                _slowMotionEntityId = -1;
                _initializingArrowTime = false;
                _initializingSkill = null;
                _arrowTimeTargets.Clear();
                return;
            }

            // Accumulate targets
            if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
            {
                int targetEntityId = Helpers.findEntityWithinRange(Game.worldMouse, 1f, new List<Faction>(new [] { Faction.Enemy, Faction.Neutral }), entityId);

                if (targetEntityId != -1 && !_arrowTimeTargets.Contains(targetEntityId))
                {
                    _arrowTimeTargets.Add(targetEntityId);
                }
            }
        }
示例#25
0
        /* Attack an entity
         *   The attacking entity makes an attack roll.
         *   If the attack roll equals or beats the defenders armor class, the attacker makes a hit roll.
         *
         * Attack Roll:
         *  d20 + strength modifier
         *
         * Hit Roll:
         *  Weapon damage + strength modifier
         *
         * Returns true if the attack was a success, and false if it was a miss
         */
        public bool attack(
            Skill attackSkill,
            int attackerId,
            int defenderId,
            int extraDamage = 0,    // TODO: -- this parameter could be co-opted into a damage die
            string attackDie = null,
            string hitDie = null)
        {
            StatSystem statSystem = SystemManager.statSystem;
            StatsComponent defenderStats = EntityManager.getStatsComponent(defenderId);
            AffectedBySpellEntitiesComponent attackerSpells = EntityManager.getAffectedBySpellEntitiesComponent(attackerId);
            AffectedBySpellEntitiesComponent defenderSpells = EntityManager.getAffectedBySpellEntitiesComponent(defenderId);
            PositionComponent defenderPositionComponent = EntityManager.getPositionComponent(defenderId);
            PositionComponent attackerPositionComponent = EntityManager.getPositionComponent(attackerId);
            BloodColorComponent defenderBloodColorComponent = EntityManager.getBloodColorComponent(defenderId);
            RiposteComponent defenderRiposteComponent = null;
            int defenderArmorClass = SystemManager.statSystem.getArmorClass(defenderId);
            int attackRoll;
            Vector2 relative = defenderPositionComponent.position - attackerPositionComponent.position;

            attackDie = attackDie ?? SystemManager.statSystem.getAttackDie(attackerId);
            hitDie = hitDie ?? SystemManager.statSystem.getDamageDie(attackerId);
            attackRoll = Roller.roll(attackDie) + statSystem.getStatModifier(statSystem.getStrength(attackerId));

            // Check defender for riposte spell effect unless attacking skill is a riposte skill (to prevent a possible endless loop)
            if (attackSkill.type != SkillType.Riposte)
            {
                foreach (int spellId in defenderSpells.spellEntities)
                {
                    if ((defenderRiposteComponent = EntityManager.getRiposteComponent(spellId)) != null)
                    {
                        break;
                    }
                }
            }

            // Handle riposte
            if (defenderRiposteComponent != null)
            {
                SkillsComponent defenderSkillsComponent = EntityManager.getSkillsComponent(defenderId);
                RiposteSkill riposteSkill = defenderSkillsComponent.getSkill(SkillType.Riposte) as RiposteSkill;

                if (Roller.roll(defenderRiposteComponent.chanceToRiposte) == 1)
                {
                    attack(riposteSkill, defenderId, attackerId);
                    addMessage(defenderPositionComponent.position, "Riposte");
                    return false;
                }
            }

            // Proceed with normal attack process
            if (attackRoll >= defenderArmorClass)
            {
                // Roll damage
                int hitRoll = Roller.roll(hitDie);
                int damage = hitRoll + extraDamage;

                // Apply damage
                applyDamage(attackerId, defenderId, damage);
                addMessage(defenderPositionComponent.position, "-" + damage.ToString());

                // Create shot trail
                if (attackSkill.type == SkillType.RangedAttack || attackSkill.type == SkillType.Piercing || attackSkill.type == SkillType.ArrowTime)
                {
                    Color color = Color.White;

                    if (attackSkill.type == SkillType.RangedAttack)
                    {
                        color = (attackSkill as RangedAttackSkill).damageType == DamageType.Fire ? Color.Red : color;
                    }
                    else if (attackSkill.type == SkillType.Piercing)
                    {
                        color = Color.Cyan;
                    }

                    SystemManager.particleRenderSystem.addShotTrail(color, attackerPositionComponent.position, defenderPositionComponent.position);
                }

                // Blood particle effects
                if (defenderBloodColorComponent != null)
                {
                    SystemManager.particleRenderSystem.addBloodParticleEffect(defenderBloodColorComponent.color, defenderPositionComponent.position, (Vector2.Normalize(relative) + new Vector2(0, -1f)) * 4f, 8);
                }

                // Check for attacker procs
                foreach (int spellId in attackerSpells.spellEntities)
                {
                    ProcComponent procComponent = EntityManager.getProcComponent(spellId);

                    if (procComponent != null)
                    {
                        if (procComponent.onHitOther != null)
                        {
                            procComponent.onHitOther(attackSkill, attackerId, defenderId);
                        }
                    }
                }

                // Check for defender procs
                foreach (int spellId in defenderSpells.spellEntities)
                {
                    ProcComponent procComponent = EntityManager.getProcComponent(spellId);

                    if (procComponent != null)
                    {
                        if (procComponent.onHitByOther != null)
                        {
                            procComponent.onHitByOther(attackSkill, attackerId, defenderId);
                        }
                    }
                }

                // Check defender for damage shields
                foreach (int spellId in defenderSpells.spellEntities)
                {
                    DamageShieldComponent damageShieldComponent = EntityManager.getDamageShieldComponent(spellId);

                    if (damageShieldComponent != null)
                    {
                        // Apply damage shield damage
                        applySpellDamage(attackerId, Roller.roll(damageShieldComponent.damageDie));
                    }
                }

                return true;
            }
            else
            {
                // Miss
                addMessage(defenderPositionComponent.position, "Miss");

                return false;
            }
        }
示例#26
0
 // Handle initialization of a melee attack
 private void handleInitializeAttack(int selectedEntityId)
 {
     if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
     {
         if (_initializingSkill.type == SkillType.MeleeAttack)
         {
             SystemManager.skillSystem.performMeleeAttackSkill(selectedEntityId, _initializingSkill as MeleeAttackSkill, Game.worldMouse);
         }
         else if (_initializingSkill.type == SkillType.RangedAttack)
         {
             SystemManager.skillSystem.performRangedAttackSkill(selectedEntityId, _initializingSkill as RangedAttackSkill, Game.worldMouse);
         }
         _initializingSkill = null;
     }
 }
示例#27
0
文件: Skill.cs 项目: klutch/Loderpit
 public ExecuteSkill(Skill skill, Func<bool> isDelayConditionMetCallback = null)
 {
     _skill = skill;
     _isDelayConditionMetCallback = isDelayConditionMetCallback;
 }
示例#28
0
 // Handle initialization of the build bridge skill
 private void handleInitializeBuildBridge(int selectedEntityId)
 {
     if (Game.newMouseState.isLeftButtonPressed && !Game.oldMouseState.isLeftButtonPressed)
     {
         // Set first anchor
         _createBridgeAnchorA = Game.worldMouse;
         _firstBridgeAnchorSet = true;
     }
     else if (!Game.newMouseState.isLeftButtonPressed && Game.oldMouseState.isLeftButtonPressed)
     {
         // Perform action
         SystemManager.skillSystem.performBuildBridgeSkill(selectedEntityId, _initializingSkill as BuildBridgeSkill, _createBridgeAnchorA, _createBridgeAnchorB);
         _firstBridgeAnchorSet = false;
         _initializingSkill = null;
     }
     if (_firstBridgeAnchorSet)
     {
         // Set second anchor
         _createBridgeAnchorB = Game.worldMouse;
     }
     else
     {
         // Reset anchors
         _createBridgeAnchorA = Game.worldMouse;
         _createBridgeAnchorB = Game.worldMouse;
     }
 }
示例#29
0
 public ExecutePiercingSkill(Skill skill, int defenderId)
     : base(skill)
 {
     _defenderId = defenderId;
 }
示例#30
0
 // Handle initialize frenzy skill
 private void handleInitializeFrenzy(int entityId)
 {
     SystemManager.skillSystem.performFrenzySkill(entityId, _initializingSkill as FrenzySkill);
     _initializingSkill = null;
 }