Beispiel #1
0
        public Image GetFrame(Locateable loc)
        {
            double idx     = locs[loc].Index;
            bool   running = locs[loc].Running;

            if (!continuous && !running)
            {   // restart
                idx     = -1;
                running = true;
            }
            idx += rate;
            if (idx >= frameCount - 1)
            {
                if (!continuous && Ended != null)
                {
                    running = false;
                    Ended(this, loc);
                }
            }

            if (idx >= frameCount)
            {
                if (continuous)
                {
                    idx = 0;
                }
                else
                {
                    idx = frameCount - 1;
                }
            }
            locs[loc] = new AnimationState(running, idx);
            return(frames[(int)idx]);
        }
Beispiel #2
0
 public void AddLocateable(Locateable loc)
 {
     if (continuous)
     {
         AnimationState aState = new AnimationState(true, Game.rand.Next(0, frameCount));
         locs.Add(loc, aState);
     }
     else
     {
         AnimationState aState = new AnimationState(false, -1);
         locs.Add(loc, aState);
     }
 }
Beispiel #3
0
        void ani_Ended(Animation ani, Locateable loc)
        {
            Projectile maybeMe = (Projectile)loc;

            if (this == maybeMe)
            {
                if (EndedRange != null)
                {   // notify that I'm done due to animation ending
                    EndedRange(this);
                }
            }
            else
            {
            }
        }
Beispiel #4
0
        protected bool Overlapping(Locateable loc1, Locateable loc2)
        {
            int    depth    = (int)(Math.Max(loc1.Height, loc2.Height) * 1 / 4.0f);
            Vector pointing = loc2.Position - loc1.Position;
            double dist     = pointing.Magnitude;

            if (dist < depth)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
 public void aniMelee_Ended(Animation ani, Locateable loc)
 {
     if (loc is Mob)
     {
         Mob maybeMe = (Mob)loc;
         if (this == maybeMe)
         {
             aniMelee.Ended -= aniMelee_Ended;
             Action          = MobAction.None;
             if (MeleeCombatEnded != null)
             {
                 MeleeCombatEnded(this, Contacts);
             }
         }
     }
 }
Beispiel #6
0
        void aniRanged_Ended(Animation ani, Locateable loc)
        {
            if (loc is Mob)
            {
                Mob maybeMe = (Mob)loc;
                if (this == maybeMe)
                {// 1st make sure we're still aiming at target...
                    Vector unit;
                    Mob    target = CheckForTarget();
                    if (target != null)
                    {   // we still see enemy, so aim at him...
                        Vector pointing = target.Position - Position;
                        unit     = pointing.Unitized;
                        Velocity = 0.01 * unit;
                    }
                    else
                    {// target is missing, so prepare to launch at last known dir anyway
                        unit = Velocity.Unitized;
                    }

                    RangedWeapon rw = (RangedWeapon)EquippedWeapon;
                    Vector       offset;
                    if (Type == MobType.Dragon)
                    {
                        offset = 50 * unit;
                    }
                    else
                    {
                        offset = 15 * unit;
                    }
                    Vector     projPos = Position + offset;
                    Projectile proj    = rw.Launch(projPos, unit, this);
                    aniRanged.Ended -= aniRanged_Ended;
                    Action           = MobAction.None;
                    if (RangedCombatEnded != null)
                    {
                        RangedCombatEnded(proj);
                    }
                }
            }
        }