Example #1
0
        public bool IsCastingSpell(ChampionTypes champ, PlayerActionType action)
        {
            SpellTypes spell = ChampionTypesHelper.GetSpellFromAction(champ, action);

            return(TimeOfLastSpellUse(spell).TotalSeconds +
                   SpellsHelper.Info(spell).CastingTime.TotalSeconds >= Server.Instance.GetTime().TotalSeconds);
        }
Example #2
0
        public bool IsOnCooldown(SpellTypes spell)
        {
            TimeSpan lastUse = TimeOfLastSpellUse(spell);

            return(lastUse == TimeSpan.Zero ? false :
                   lastUse.TotalSeconds + SpellsHelper.Info(spell).Cooldown.TotalSeconds >
                   Server.Instance.GetTime().TotalSeconds);
        }
        private SpellCastInfo SpellCastInfo(SpellTypes spell)
        {
            int spellNum = SpellsHelper.SpellNumber(spell);

            switch (spellNum)
            {
            case SpellsHelper.SPELL_1: return(Spell1);

            case SpellsHelper.SPELL_2: return(Spell2);

            case SpellsHelper.SPELL_3: return(Spell3);

            case SpellsHelper.SPELL_4: return(Spell4);

            default:
                throw new NotImplementedException("Spell number not supported.");
            }
        }
Example #4
0
        const double RADIANS_BETWEEN_PROJECTILES = Math.PI / 36.0;         // ~5 degrees
        void CastChampionSpell(ICharacter champ, PlayerAction action)
        {
            Debug.Assert(action.Target != null);

            // aim in the direction of the spell
            champ.FacingLeft = action.Target.X < champ.Position.X + champ.CollisionWidth / 2f;

            SpellTypes type        = ChampionTypesHelper.GetSpellFromAction(champ.Type, action.Type);
            int        projectiles = SpellsHelper.Info(type).Projectiles;
            Vec2       spawn       = champ.GetHandsPosition();

            double angle = 0.0;

            if (action.Target != null)
            {
                Vec2 dir = action.Target - spawn;
                angle = Math.Atan2(dir.Y, dir.X);                                     // current angle
                double completeArc = RADIANS_BETWEEN_PROJECTILES * (projectiles - 1); // complete arc that we'll cover
                angle -= completeArc / 2f;                                            // start from the lowest angle
            }

            for (int i = 0; i < projectiles; ++i)
            {
                Vec2 dir = Vec2.Zero;
                if (action.Target != null)
                {
                    double current = angle + i * RADIANS_BETWEEN_PROJECTILES;
                    dir = new Vec2((float)Math.Cos(current), (float)Math.Sin(current));
                }

                LinearSpell spell = new LinearSpell(
                    IDGenerator.GenerateID(),
                    champ.Team,
                    spawn,
                    spawn + dir,
                    type,
                    champ);

                CastSpell(spell, action.Target);
            }
        }