Beispiel #1
0
 public void CollisionRight(ITangible obj)
 {
     if (!(obj is IEnemy || obj is IProjectile))
     {
         normal.CollisionRight(obj);
     }
 }
        public void CollisionAbove(ITangible obj)
        {
            if (obj.State is SKoopaShellMovingRight || obj.State is SKoopaShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingLeft || obj.State is SKoopaShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingRight || obj.State is SBuzzyBeetleShellMovingLeft || obj.State is SBuzzyBeetleShellMovingRight || obj.State is SBuzzyBeetleUpsideDownShellMovingLeft || obj.State is SBuzzyBeetleUpsideDownShellMovingRight)
            {
                HUD.KoopaShellSequence(obj);

                subject.State = new SBuzzyBeetleDead(subject);
            }

            if (obj is IPlayer)
            {
                if (((IPlayer)obj).Decorator is StarPlayer)
                {
                    HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_KILL_BUZZYBEETLE;
                    HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_KILL_BUZZYBEETLE));
                    subject.State = new SBuzzyBeetleDead(subject);
                }
                else if (!(subject.State is SBuzzyBeetleShelledUpsideDown || subject.State is SBuzzyBeetleUpsideDownShellMovingLeft || subject.State is SBuzzyBeetleUpsideDownShellMovingRight))
                {
                    HUD.StompingPoints(obj);
                    subject.State = new SBuzzyBeetleShelled(subject);
                }
                else
                {
                    HUD.StompingPoints(obj);
                    subject.State = new SBuzzyBeetleShelledUpsideDown(subject);
                }
            }
        }
Beispiel #3
0
 public void CollisionBelow(ITangible obj)
 {
     if (!(subject.State is SHammerBroDead))
     {
         if (!(subject.State is SHammerBroJump) && obj is IBlock && !(obj is BlockHidden && obj.State is SBlockIdle))
         {
             subject.Position = new Vector2(subject.Position.X, ((IBlock)obj).Hitbox.Top() - Hitboxes.HAMMERBRO_HEIGHT - Hitboxes.HAMMERBRO_OFFSET_Y);
             subject.Velocity = new Vector2(subject.Velocity.X, 0);
         }
         if (obj is IBlock && (obj.State is SBlockGettingBumped || obj.State is SBlockBroken))
         {
             HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_BUMP_HAMMERBRO;
             HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_BUMP_HAMMERBRO));
             subject.State = new SHammerBroDead(subject);
         }
         if ((obj is IPlayer && ((IPlayer)obj).Decorator is StarPlayer) || obj is Fireball || obj.State is SKoopaShellMovingRight || obj.State is SKoopaShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingRight || obj.State is SRedKoopaShellMovingRight || obj.State is SRedKoopaShellMovingLeft || obj.State is SRedKoopaUpsideDownShellMovingLeft || obj.State is SRedKoopaShellMovingLeft || obj.State is SRedKoopaUpsideDownShellMovingRight || obj.State is SBuzzyBeetleShellMovingLeft || obj.State is SBuzzyBeetleShellMovingRight || obj.State is SBuzzyBeetleUpsideDownShellMovingLeft || obj.State is SBuzzyBeetleUpsideDownShellMovingRight)
         {
             if (obj is Fireball || (obj is IPlayer && ((IPlayer)obj).Decorator is StarPlayer))
             {
                 HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_KILL_HAMMERBRO;
                 HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_KILL_HAMMERBRO));
             }
             else
             {
                 HUD.KoopaShellSequence(obj);
             }
             subject.State = new SHammerBroDead(subject);
         }
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer)
     {
         ((MazeCheckpoint)subject).Collected = true;
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer)
     {
         subject.IsActive = false;
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer)
     {
         subject.State = new STransitionPointActive(subject);
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer && subject is Vine && ((IPlayer)type).Position.Y < 0)
     {
         LevelTransition((IPlayer)type);
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer)
     {
         CheckCheckpoints();
     }
 }
 public void CollisionAbove(ITangible type)
 {
     if (type is IPlayer && subject.State is SSpringboardIdle)
     {
         subject.State = new SSpringboardCompressing(subject);
     }
 }
 public void CollisionBelow(ITangible obj)
 {
     if (subject.State is SSpinyEgg && obj is IBlock)
     {
         if (HUD.level.player.Position.X < subject.Position.X)
         {
             subject.State = new SSpinyMovingLeft(subject);
         }
         else
         {
             subject.State = new SSpinyMovingRight(subject);
         }
     }
     if (obj is IBlock && !(obj is BlockHidden && obj.State is SBlockIdle))
     {
         subject.Position = new Vector2(subject.Position.X, ((IBlock)obj).Hitbox.Top() - Hitboxes.SPINY_HEIGHT - Hitboxes.SPINY_OFFSET_Y);
         subject.Velocity = new Vector2(subject.Velocity.X, 0);
     }
     if (!(subject.State is SSpinyDeadLeft || subject.State is SSpinyDeadRight))
     {
         if ((obj is IPlayer && ((IPlayer)obj).Decorator is StarPlayer) || obj is Fireball || obj.State is SKoopaShellMovingRight || obj.State is SKoopaShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingRight || obj.State is SRedKoopaShellMovingRight || obj.State is SRedKoopaShellMovingLeft || obj.State is SRedKoopaUpsideDownShellMovingLeft || obj.State is SRedKoopaShellMovingLeft || obj.State is SRedKoopaUpsideDownShellMovingRight || obj.State is SBuzzyBeetleShellMovingLeft || obj.State is SBuzzyBeetleShellMovingRight || obj.State is SBuzzyBeetleUpsideDownShellMovingLeft || obj.State is SBuzzyBeetleUpsideDownShellMovingRight)
         {
             if (obj is IProjectile || (obj is IPlayer && ((IPlayer)obj).Decorator is StarPlayer))
             {
                 HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_KILL_SPINY;
                 HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_KILL_SPINY));
             }
             else
             {
                 HUD.KoopaShellSequence(obj);
             }
             subject.State = new SSpinyDeadLeft(subject);
         }
     }
 }
Beispiel #11
0
        //Gets the closest Tangible in a list
        public static ITangible GetClosest(ITangible tangible, List <ITangible> objects)
        {
            if (objects.Count == 0)
            {
                return(null);
            }

            //If it is within another ITargetables radius, take the closest ITangible center it's within, ignoring radius
            List <ITangible> targetsWithin =
                objects.Where(t => (t.Position - tangible.Position).magnitude - t.SizeRadius < 0)
                .OrderBy(t => (t.Position - tangible.Position).sqrMagnitude).ToList();

            if (targetsWithin.Count > 0)
            {
                return(targetsWithin[0]);
            }

            //Else, return the closest tangible based on other tangible's size radii
            List <ITangible> targetsOrdered = objects.OrderBy(t =>
                                                              (t.Position - tangible.Position).magnitude - t.SizeRadius).ToList();

            if (targetsOrdered.Count == 0)
            {
                return(null);
            }
            return(targetsOrdered[0]);
        }
        public void CollisionBelow(ITangible obj)
        {
            if ((obj is IPlayer && ((IPlayer)obj).Decorator is StarPlayer) || obj.State is SKoopaShellMovingRight || obj.State is SKoopaShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingRight || obj.State is SBuzzyBeetleShellMovingLeft || obj.State is SBuzzyBeetleShellMovingRight || obj.State is SBuzzyBeetleUpsideDownShellMovingLeft || obj.State is SBuzzyBeetleUpsideDownShellMovingRight)
            {
                if ((obj is IPlayer && ((IPlayer)obj).Decorator is StarPlayer) && obj is IProjectile)
                {
                    HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_KILL_BUZZYBEETLE;
                    HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_KILL_BUZZYBEETLE));
                }
                else
                {
                    HUD.KoopaShellSequence(obj);
                }
                subject.State = new SBuzzyBeetleDead(subject);
            }

            if ((obj is IBlock && (obj.State is SBlockGettingBumped || obj.State is SBlockBroken)))
            {
                HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_BUMP_BUZZYBEETLE;
                HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_BUMP_BUZZYBEETLE));
                subject.State = new SBuzzyBeetleShelledUpsideDown(subject);
            }
            else if (obj is IBlock && !(obj is BlockHidden && obj.State is SBlockIdle))
            {
                subject.Position = new Vector2(subject.Position.X, ((IBlock)obj).Hitbox.Top() - Hitboxes.BUZZYBEETLE_HEIGHT - Hitboxes.BUZZYBEETLE_OFFSET_Y);
                subject.Velocity = new Vector2(subject.Velocity.X, 0);
            }
        }
 public void SetTangible(ITangible tangible, ITangibleState state, PhysicsBundle physics)
 {
     tangible.State        = state;
     tangible.Position     = physics.position;
     tangible.Velocity     = physics.velocity;
     tangible.Acceleration = physics.acceleration;
 }
 public void CollisionAbove(ITangible type)
 {
     if (type is IPlayer)
     {
         subject.State = new SPlatformMovingDown(subject, width);
     }
 }
Beispiel #15
0
        public virtual void Update(float deltaTime)
        {
            switch (Phase)
            {
            case ActionPhase.COOLDOWN:
                CurrentCooldown = Mathf.Max(0, CurrentCooldown - deltaTime);
                break;

            case ActionPhase.FOCUS:
                if (Agent.CurrentAction == this)
                {
                    CurrentFocusTime += deltaTime;
                }
                else
                {
                    CurrentFocusTime = 0;

                    Debug.Log("Lost focus");
                }

                if (CurrentFocusTime >= FocusTime)
                {
                    CurrentFocusTime = 0;
                    FireAction(StoredTarget, deltaTime);
                    StoredTarget = null;
                    Triggered    = false;
                }
                break;

            default:
                break;
            }
        }
Beispiel #16
0
 public void CollisionAbove(ITangible type)
 {
     if (type is IPlayer)
     {
         subject.Position += new Vector2(0, 1f);
         ((ScalePlatform)subject).partner.Position -= new Vector2(0, 1f);
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer)
     {
         HUD.FlagpolePoints(type.Position.Y, subject.Position.Y);
         subject.State = new SFlagpoleFlagPulledDown(subject);
     }
 }
Beispiel #18
0
 bool FindInactive(ITangible obj)
 {
     if (obj is Fireball && (!obj.IsActive || !camera.IsInView(obj)))
     {
         fireballCount = fireballCount < 0 ? 0 : fireballCount - 1;
     }
     return(!obj.IsActive);
 }
Beispiel #19
0
 public bool IsInView(ITangible obj)
 {
     return
         (obj.Position.X + obj.Hitbox.Width >= PosX &&
          obj.Position.X <= PosX + Width &&
          obj.Position.Y + obj.Hitbox.Height >= PosY &&
          obj.Position.Y <= PosY + Height);
 }
        public Boolean TestCollision(ITangible tangible1, ITangible tangible2, WindowsGame2.Collider.CollisionFrom expected)
        {
            tangible1.Update();
            tangible2.Update();

            WindowsGame2.Collider.CollisionFrom returned = collider.CollisionDirection(tangible1, tangible2);
            Console.WriteLine("Expected " + expected.ToString() + ", and got " + returned.ToString());
            return(expected == returned);
        }
 public void CollisionAbove(ITangible type)
 {
     if (type is IPlayer)
     {
         HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_COLLECT_MUSHROOM;
         HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_COLLECT_MUSHROOM));
         subject.IsActive = false;
     }
 }
Beispiel #22
0
        public void TestCollision(ITangible dyn, ITangible obj)
        {
            CollisionFrom direction = CollisionDirection(dyn, obj);

            if (direction != CollisionFrom.None)
            {
                collisions.Add(new Tuple <ITangible, ITangible, CollisionFrom>(dyn, obj, direction));
            }
        }
 public void CollisionRight(ITangible type)
 {
     if ((type is IPlayer && ((IPlayer)type).Decorator is StarPlayer))
     {
         subject.State = new SBulletDead(subject, left);
         HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_KILL_BULLETBILL;
         HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_KILL_BULLETBILL));
     }
 }
 public void CollisionRight(ITangible obj)
 {
     if (obj is BowserFireball || obj is Hammer)
     {
         ICommand c = new PowerDownPlayerCommand(subject);
         CommandScheduler.Queue(c);
     }
     if (obj is Axe)
     {
         DestroyBowserBridge();
         subject.Velocity = new Vector2(subject.Velocity.X, 0f);
         subject.AutoMove = new FinishCastleAutoMovement(subject);
     }
     if (obj is FlagpoleFlag)
     {
         subject.AutoMove = new FinishLevelAutoMovement(subject);
         SoundPanel.PlaySoundEffect(Sound.flagpoleEffect);
     }
     else if (obj is FireFlower || (obj is Mushroom && subject.State is ISmallMarioState))
     {
         ICommand c = new PowerUpPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if (obj is Star)
     {
         ICommand c = new StarPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if (obj is IEnemy)
     {
         if (!(obj.State is SHammerBroDead || obj.State is SKoopaShelled || obj.State is SKoopaShelledUpsideDown || obj.State is SKoopaWarning || obj.State is SKoopaWarningUpsideDown || obj.State is SGoombaStomped || obj.State is SBuzzyBeetleShelled || obj.State is SBuzzyBeetleShelledUpsideDown || obj.State is SKoopaShellMovingRight || obj.State is SKoopaUpsideDownShellMovingRight || obj.State is SBuzzyBeetleShellMovingRight || obj.State is SBuzzyBeetleUpsideDownShellMovingRight))
         {
             ICommand c = new PowerDownPlayerCommand(subject);
             CommandScheduler.Queue(c);
         }
     }
     else if (obj is IBlock && !(obj is BlockHidden && obj.State is SBlockIdle) && !(obj is LevelTransitionPoint || obj is MazeCheckpoint || obj is MazeFinish))
     {
         // handle block collision
         subject.Position = new Vector2(((IBlock)obj).Hitbox.Left() - Hitboxes.BLOCK_WIDTH + Hitboxes.SMALL_MARIO_IDLE_OFFSET_X, subject.Position.Y);
         subject.Velocity = new Vector2(0f, subject.Velocity.Y);
     }
     if (obj is IRope)
     {
         if (!(subject.State is IClimbingMarioState) && subject.State is IRightMarioState)
         {
             subject.Position = new Vector2(((IRope)obj).Hitbox.Left() - Hitboxes.SMALL_MARIO_CLIMBING_WIDTH, subject.Position.Y);
             ((IPlayerState)subject.State).Climb();
         }
         else if (obj.Hitbox.Top() - subject.Hitbox.Bottom() > -5 || subject.Hitbox.Top() - obj.Hitbox.Bottom() > -5)
         {
             subject.Position = new Vector2(subject.Position.X, subject.Position.Y + 1);
         }
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer)
     {
         HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_COLLECT_FIREFLOWER;
         HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_COLLECT_FIREFLOWER));
         subject.IsActive = false;
     }
 }
 public void CollisionRight(ITangible obj)
 {
     if ((obj is IPlayer && ((IPlayer)obj).Decorator is StarPlayer) || obj is IProjectile || (obj.State is SKoopaShellMovingLeft || obj.State is SKoopaShellMovingRight || obj.State is SKoopaUpsideDownShellMovingLeft || obj.State is SKoopaUpsideDownShellMovingRight || obj.State is SBuzzyBeetleShellMovingLeft || obj.State is SBuzzyBeetleShellMovingRight || obj.State is SBuzzyBeetleUpsideDownShellMovingLeft || obj.State is SBuzzyBeetleUpsideDownShellMovingRight))
     {
         HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_KILL_PIRANHAPLANT;
         HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_KILL_PIRANHAPLANT));
         SoundPanel.PlaySoundEffect(Sound.kickEffect);
         subject.IsActive = false;
     }
 }
 public void CollisionRight(ITangible type)
 {
     if ((type is IPlayer && ((IPlayer)type).Decorator is StarPlayer) || type is Fireball)
     {
         subject.State = new SCheepCheepDeadLeft(subject);
         HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_KILL_CHEEPCHEEP;
         HUD.level.AddParticle(new Score(subject.Position, HotDAMN.SCORE_KILL_CHEEPCHEEP));
         Sound.kickEffect.Play();
     }
 }
 public void CollisionRight(ITangible type)
 {
     if (type is IPlayer)
     {
         subject.IsActive              = false;
         HUD.SCORE[HUD.currentPlayer] += HotDAMN.SCORE_COLLECT_COIN;
         HUD.COINS[HUD.currentPlayer]++;
         SoundPanel.PlaySoundEffect(Sound.coinEffect);
     }
 }
Beispiel #29
0
 public void CollisionAbove(ITangible type)
 {
     if (type is IPlayer)
     {
         subject.IsActive = false;
         HUD.LIVES[HUD.currentPlayer]++;
         HUD.level.AddParticle(new Score(subject.Position, 0));
         SoundPanel.PlaySoundEffect(Sound.powerup1upEffect);
     }
 }
Beispiel #30
0
 public void CollisionAbove(ITangible type)
 {
     if (subject.State is SPlatformMovingRight)
     {
         type.Position += subject.Velocity;
     }
     else if (type is IPlayer)
     {
         subject.State = new SPlatformMovingRight(subject, width);
     }
 }