Inheritance: MonoBehaviour
        public void MarioLuigiCollisionTest(Mario mario, Luigi luigi, SoundEffects sound)
        {
            Rectangle marioRectangle = myMario.GetRectangle();
            Rectangle luigiRectangle = luigi.GetRectangle();
            Rectangle intersectionRectangle;

            intersectionRectangle = Rectangle.Intersect(marioRectangle, luigiRectangle);

            if (!intersectionRectangle.IsEmpty)
            {
                if (intersectionRectangle.Width > intersectionRectangle.Height)
                {
                    if (marioRectangle.Y > luigiRectangle.Y)
                    {
                        luigi.BoostJump();
                        sound.Bump();

                    }
                    else if (luigiRectangle.Y > marioRectangle.Y)
                    {
                        mario.BoostJump();
                        sound.Bump();
                    }
                }
            }
        }
        public Tuple<int, bool> EnemyCollisionTest(Mario mario, HUD hud, IList<IEnemy> enemies, int x, SoundEffects sound)
        {
            Rectangle marioRectangle = myMario.GetRectangle();
            Rectangle enemyRectangle;
            bool enemyKilled = false;
            bool invincible = myMario.Invincible();
            int xpos = x;
            Rectangle intersectionRectangle;
            Queue<IEnemy> doomedEnemies = new Queue<IEnemy>();

            foreach (IEnemy enemy in enemies)
            {

                enemyRectangle = enemy.GetRectangle();
                intersectionRectangle = Rectangle.Intersect(marioRectangle, enemyRectangle);

                if (!intersectionRectangle.IsEmpty)
                {

                    if (intersectionRectangle.Width >= intersectionRectangle.Height)
                    {
                        sound.Bump();
                        doomedEnemies.Enqueue(enemy);
                        hud.marioEnemyKill(mario);
                        enemyKilled = true;
                    }
                    else if (invincible)
                    {
                        doomedEnemies.Enqueue(enemy);
                    }
                    else
                    {
                        myMario.Hit();
                        if (marioRectangle.X < enemyRectangle.X)
                        {
                            xpos = xpos - intersectionRectangle.Width;
                        }
                        else
                        {
                            xpos = xpos + intersectionRectangle.Width;

                        }
                        if (myMario.IsDead())
                        {
                            hud.lifeLostMario();
                        }
                    }

                }
            }

            while (doomedEnemies.Count() > 0)
            {
                IEnemy enemie = doomedEnemies.Dequeue();
                enemies.Remove(enemie);
            }

            return new Tuple<int,bool>(xpos, enemyKilled);
        }
Example #3
0
 public FireMarioState(Mario mario, Level level)
 {
     this.mario = mario;
     this.level = level;
     nextFrame = 0;
     spriteFrameCount = MarioConstants.fireMarioIdleFrameCount;
     marioSprite = FireMarioSpriteFactory.CreateIdleMarioSprite(mario.isMovingRight, level, mario.location);
 }
Example #4
0
 public Trap(Level level,int width,int height,Vector2 location)
 {
     this.level = level;
     this.mario = level.mario;
     trapBorder.Width = width;
     trapBorder.Height = height;
     trapBorder.X = (int)location.X;
     trapBorder.Y = (int)location.Y;
 }
Example #5
0
 public DeadMarioState(Mario mario, Level level)
 {
     this.mario = mario;
     this.level = level;
     deathAnimation = MarioConstants.deathAnimation;
     marioSprite = DeadMarioSpriteFactory.CreateDeadMarioSprite(level);
     level.gameStatus.lifeCount--;
     collider.Height = marioSprite.Texture.Height;
     collider.Width = marioSprite.Texture.Width;
     collider.X = (int)mario.location.X;
     collider.Y = (int)mario.location.Y;
 }
Example #6
0
        public void TestMarioOnLeftOfBlockCollisionHandling()
        {
            Mario      mario = new Mario(new Vector2(101, 100));
            FloorBlock block = new FloorBlock(new Vector2(120, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle blockRect = block.GetRectangle();

            Game1.Side collisionType = Game1.Side.Right;
            MarioBlockCollisionHandler.HandleCollision(mario, block, collisionType);

            //Assert.AreEqual(102, mario.location.X);
        }
Example #7
0
 void OnCollisionEnter2D(Collision2D other)
 {
     Debug.Log(other.gameObject.tag + " Kill layer");
     if (other.gameObject.tag != "Player")
     {
         Destroy(other.gameObject);
     }
     else
     {
         Mario mario = other.gameObject.GetComponent <Mario> ();
         mario.FreezeAndDie();
     }
 }
Example #8
0
 public void Shrink()
 {
     marioState = marioState.Exit(marioState.prevMario);
     if (marioState == null)
     {
         uiManager.TakeLife();
         gameObject.SetActive(false);
     }
     else
     {
         StartCoroutine("Invulnerable");
     }
 }
Example #9
0
        public ClimbingSmallMarioState(Mario mario)
        {
            this.mario = mario;

            if (!mario.isJumping)
            {
                mario.physicsObject.aerialSpeed = 0;
            }

            mario.isJumping = false;
            mario.isFalling = false;
            mario.sprite    = new SmallClimbingMarioSprite(mario);
        }
Example #10
0
 public override void Kill(Mario mario = null)
 {
     if (mario == null)
     {
         base.Kill();
     }
     else
     {
         Destroy(GetComponent <AISimpleMovement>());
         GetComponent <Animator>().SetBool("IsDied", true);
         Destroy(gameObject, 2.0f);
     }
 }
Example #11
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         Mario mario = other.GetComponent <Mario>();
         mario.curState = Mario.State.Finish;
         Camera.main.GetComponent <AudioSource>().Stop();
         Camera.main.GetComponent <AudioSource>().clip = stageComplete;
         Camera.main.GetComponent <AudioSource>().time = 0;
         Camera.main.GetComponent <AudioSource>().loop = false;
         Camera.main.GetComponent <AudioSource>().Play();
     }
 }
Example #12
0
        public void TestMarioOnTopOfBlockCollisionHandling()
        {
            Mario      mario = new Mario(new Vector2(100, 110));
            FloorBlock block = new FloorBlock(new Vector2(100, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle blockRect = block.GetRectangle();

            Game1.Side collisionType = Game1.Side.Bottom;
            MarioBlockCollisionHandler.HandleCollision(mario, block, collisionType);

            //Assert.AreEqual(111, mario.location.Y);
        }
Example #13
0
    protected override void OnHit(GameObject gameObject)
    {
        Mario mario = gameObject.GetComponent <Mario>();

        if (mario.state == 0)
        {
            anim.SetTrigger("hit");
        }
        else
        {
            Debug.Log("explor");
        }
    }
Example #14
0
    void OnCollisionEnter2D(Collision2D collider)
    {
        //Get object for the player
        Mario mario = collider.gameObject.GetComponent <Mario>();

        //If our platform collides with the player, it will fall and disapear
        if (mario)
        {
            Debug.Log("Mario");
            this.GetComponent <Rigidbody2D>().gravityScale = 1f;
            Destroy(this.gameObject);
        }
    }
Example #15
0
        public void TestMarioOnBottomOfEnemyCollisionDetector()
        {
            Mario  mario = new Mario(new Vector2(100, 115));
            Goomba enemy = new Goomba(new Vector2(100, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle enemyRect = enemy.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(marioRect, enemyRect);
            Game1.Side expectedType  = Game1.Side.Top;
            Assert.AreEqual(expectedType, collisionType);
        }
        public RightBigFallingMarioState(Mario mario)
        {
            this.mario = mario;

            if (!mario.isJumping)
            {
                mario.physicsObject.aerialSpeed = 0;
            }

            mario.direction = true;
            mario.isJumping = false;
            mario.isFalling = true;
            mario.sprite    = new RightBigJumpingMarioSprite(mario);
        }
Example #17
0
    private void Start()
    {
        mario = MarioController.Instance.mario;
        textActionMapping.Add(TextAction.SetDitchClothesText, SetImageTextPreSpin);
        textActionMapping.Add(TextAction.SetLetsGoText, SetImageTextFirstPlatformTrigger);
        textActionMapping.Add(TextAction.SetExcuseText, SetImageTextFirstJumpFail);
        textActionMapping.Add(TextAction.SetThoughtText, SetImageTextSecondJumpFail);

        if (GameController.Instance.textFreeMode == true)
        {
            MarioController.Instance.mario.textHolder.transform.localPosition            = new Vector3(-200f, -200f, 0);
            MarioController.Instance.mario.customText.gameObject.transform.localPosition = new Vector3(-200f, -200f, 0);
        }
    }
Example #18
0
    IEnumerator SmallLeftAgain()
    {
        float     runDistance    = 0.07f;
        float     runSpeed       = MarioController.Instance.FreakoutBaseSpeed * 2f;
        Mario     mario          = MarioController.Instance.mario;
        Transform marioTransform = mario.gameObject.transform;

        for (float t = 0.0f; t < runDistance; t += Time.deltaTime)
        {
            mario.skeletonSprite.GetComponent <SpriteRenderer>().flipX = true;
            marioTransform.position += Vector3.left * runSpeed * Time.deltaTime;
            yield return(null);
        }
    }
 public void MarioFlagCollision(Mario mario, List <IBackground> backgroundElements)
 {
     if (!mario.animated)
     {
         animation = false;
     }
     if (!animation)
     {
         foreach (IBackground bg in backgroundElements)
         {
             if (bg is Flag)
             {
                 Flag tempFlag = bg as Flag;
                 if (!tempFlag.isDown)
                 {
                     if (mario.state.marioSprite.desRectangle.Right > bg.backgroundSprite.desRectangle.Right)
                     {
                         //score part
                         mario.isScored = true;
                         if (mario.position.Y < bg.backgroundSprite.desRectangle.Y + GameConstants.Fifty)
                         {
                             mario.score = GameConstants.Score1500;
                         }
                         else if (mario.position.Y >= bg.backgroundSprite.desRectangle.Y + GameConstants.Fifty && mario.position.Y < bg.backgroundSprite.desRectangle.Y + GameConstants.Fifty * GameConstants.Three)
                         {
                             mario.score = GameConstants.Score1000;
                         }
                         else
                         {
                             mario.score = GameConstants.Score500;
                         }
                         mario.totalScore += mario.score;
                         Vector2 newP;
                         newP.X             = mario.position.X;
                         newP.Y             = mario.position.Y - GameConstants.Three;
                         mario.textPosition = newP;
                         MediaPlayer.Stop();
                         MarioSoundManager.instance.playSound(MarioSoundManager.FLAGPOLE);
                         MarioSoundManager.instance.playSound(MarioSoundManager.STAGECLEAR);
                         myGame.keyboardController.keysEnabled = false;
                         bg.moveDown     = true;
                         mario.animated  = true;
                         mario.animation = GameConstants.FlagAnimation;
                         animation       = true;
                     }
                 }
             }
         }
     }
 }
Example #20
0
    void OnTriggerEnter2D(Collider2D other)
    {
        sounds[0].Play();

        Mario mario = other.GetComponent <Mario>();

        if (mario != null)
        {
            //mario.transform.SetParent (gameObject.transform);
            mario.Die();

            life += marioHealth;
        }
    }
Example #21
0
        public void TestMarioOnTopOfItemCollision()
        {
            Mario       mario       = new Mario(new Vector2(100, 86));
            RedMushroom redMushroom = new RedMushroom(new Vector2(100, 100));

            Rectangle marioRect       = mario.GetRectangle();
            Rectangle redMushroomRect = redMushroom.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(marioRect, redMushroomRect);

            Assert.AreEqual(collisionType, Game1.Side.Bottom);
        }
Example #22
0
 public void BulletCollisions(Mario mario, Bullet bullet, List <Bullet> listBullets, char[,] gameGround, List <Monster> listMonsters, MapGraound map)
 {
     if (bullet.X + 2 < map.Width - 1)
     {
         if (gameGround[bullet.X + 1, bullet.Y - 1] == 'X')
         {
             listBullets.Remove(bullet);
             if (ShotButton == true)
             {
                 mario.MarioShoot(mario, listBullets);
             }
         }
     }
 }
Example #23
0
 // Use this for initialization
 void Start()
 {
     poweredUp      = true;
     animator       = GetComponent <Animator>();
     mario          = this;
     xvel           = 0;
     yvel           = 0;
     jump           = JumpState.SlowJump;
     jumping        = false;
     grounded       = true;
     spriteRenderer = GetComponent <SpriteRenderer>();
     score          = GameObject.Find("Score").GetComponent <Score>();
     coins          = GameObject.Find("Coins").GetComponent <Coins>();
 }
Example #24
0
    public void MarioEnteringPipeHandler()
    {
        //get mario gameObject
        Mario mario = MarioSprite.transform.parent.GetComponent <Mario>();

        if (goingThroughPipe)
        {
            mario.transform.position = new Vector2(mario.transform.position.x, mario.transform.position.y - 1f * Time.deltaTime);

            marioInsidePipeTimer.Tick(Time.deltaTime);
            if (marioInsidePipeTimer.IsFinished())
            {
                if (mapManager.currentMap == MapManager.E_MAP_ID.START_MAP)
                {
                    mapManager.CreateMap(MapManager.E_MAP_ID.UNDERGROUND_MAP);
                }
                else
                {
                    mapManager.CreateMap(MapManager.E_MAP_ID.START_MAP);
                }
                return;
            }
        }


        //get mario info
        Vector2 marioSize      = MarioSprite.GetComponent <SpriteRenderer>().bounds.size;
        Vector2 marioPos       = MarioSprite.transform.position;
        Vector2 marioFeetPoint = new Vector2(marioPos.x, marioPos.y - marioSize.y / 2);
        //get pipe info
        Vector2 collSize = new Vector2(GetComponent <SpriteRenderer>().bounds.size.x / 3, 2.5f);
        Vector2 collPos  = new Vector2(transform.position.x, transform.position.y + GetComponent <SpriteRenderer>().bounds.size.y / 2);

        //if it's inside and is down pressed
        if (marioFeetPoint.x > collPos.x - collSize.x / 2 && marioFeetPoint.x < collPos.x + collSize.x / 2 &&
            marioFeetPoint.y > collPos.y - collSize.y / 2 && marioFeetPoint.y < collPos.y + collSize.y / 2 &&
            (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) && mario.grounded)
        {
            MarioSprite.GetComponent <SpriteRenderer>().sortingLayerName = "BackgroundEntities";
            Mario marioScr = MarioSprite.transform.parent.GetComponent <Mario>();
            marioScr.canBeControled = false;
            marioScr.SetVelocity(new Vector2(0, 0));
            goingThroughPipe = true;
            if (!isPipeSoundSpawned)
            {
                audioManager.CreateFreeAudioObject(AudioManager.E_AUDIO_ID.PIPE);
                isPipeSoundSpawned = true;
            }
        }
    }
Example #25
0
        public void TestMarioOnTopOfBlockCollisionDetector()
        {
            Mario      mario = new Mario(new Vector2(100, 100));
            FloorBlock block = new FloorBlock(new Vector2(100, 110));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle blockRect = block.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(marioRect, blockRect);

            Assert.AreEqual(collisionType, Game1.Side.Bottom);
        }
Example #26
0
        public void TestMarioOnBottomOfItemCollision()
        {
            Mario      mario  = new Mario(new Vector2(100, 100));
            FireFlower flower = new FireFlower(new Vector2(100, 86));

            Rectangle marioRect  = mario.GetRectangle();
            Rectangle flowerRect = flower.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(marioRect, flowerRect);

            Assert.AreEqual(collisionType, Game1.Side.Top);
        }
Example #27
0
        public IActionResult Index()
        {
            Item i = new Mario();

            i.Sell();

            Item xbox = new GameConsole();

            xbox.Sell();

            i = new GameConsole();

            return(View());
        }
Example #28
0
        static void Main(string[] args)
        {
            //    Console.WriteLine("Hello World!");
            Mario mario = new Mario();

            mario.numOfLives        = 3;
            mario.currentLevel      = "World 1-1";
            mario.sizeOfMario       = Mario.Size.small;
            mario.canShootFireBalls = false;
            mario.isJumping         = false;


            Console.WriteLine("\n Mario is running through the level and meets a Gooba. Set Mario to jumping so he can kill it");
            //enter your code here.
            mario.isJumping = true;
            Console.WriteLine("***** Mario is jumping? " + mario.isJumping);

            Console.WriteLine("\n Mario squashes the Gooba. Now he needs to land!");
            //enter your code here.
            mario.isJumping = false;
            Console.WriteLine("***** Mario is jumping? " + mario.isJumping + ". He landed on the Gooba!");

            Console.WriteLine("\n Mario hits a block and finds a 1UP. Increase Mario's life by one.");
            //enter your code here.
            mario.numOfLives += 1;
            Console.WriteLine("***** Mario has " + mario.numOfLives + " lives now");

            Console.WriteLine("\n Mario finds a secret Fire Flower and can now shoot fireballs. Change mario!");
            //enter your code here.
            mario.canShootFireBalls = true;
            Console.WriteLine("***** Mario can shoot fireballs? " + mario.canShootFireBalls);


            Console.WriteLine("\n Mario finds another power up mushroom and gets big. Change Mario");
            //enter your code here.
            mario.sizeOfMario = Mario.Size.large;
            Console.WriteLine("***** Mario is " + mario.sizeOfMario);


            Console.WriteLine("\n Mario finds a stash of gold coins. Give Mario 10 coins.");
            //enter your code here.
            mario.numOfCoins += 10;
            Console.WriteLine("***** Mario has " + mario.numOfCoins + " coins now");

            Console.WriteLine("\n Mario finshes the level! Change Mario's current level to World 1-2");
            //enter your code here.
            mario.currentLevel = "World 1-2";
            Console.WriteLine("***** Congratulations! Mario is entering " + mario.currentLevel + " now!");
        }
Example #29
0
        public void TestMarioOnBottomOfEnemyCollisionHandling()
        {
            Mario  mario = new Mario(new Vector2(100, 115));
            Goomba enemy = new Goomba(new Vector2(100, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle enemyRect = enemy.GetRectangle();

            Game1.Side collisionType = Game1.Side.Top;
            MarioEnemyCollisionHandler.HandleCollision(mario, enemy, collisionType);
            bool actualValue   = mario.IsDying();
            bool expectedValue = true;

            Assert.AreEqual(expectedValue, actualValue);
        }
        public LeftIceFallingMarioState(Mario mario)
        {
            this.mario = mario;

            if (!mario.isJumping)
            {
                mario.physicsObject.aerialSpeed = 0;
            }

            mario.direction = false;
            mario.isJumping = false;
            mario.isFalling = true;
            mario.IceMario  = true;
            mario.sprite    = new LeftIceJumpingMarioSprite(mario);
        }
Example #31
0
 public void BulletCollisionsWithMonsters(Mario mario, Bullet bullet, List <Bullet> listBullets, List <Monster> listMonsters)
 {
     for (int i = 0; i < listMonsters.Count; i++)
     {
         if (bullet.X + 1 == listMonsters[i].X && bullet.Y == listMonsters[i].Y)
         {
             listMonsters.Remove(listMonsters[i]);
             listBullets.Remove(bullet);
             if (ShotButton == true)
             {
                 mario.MarioShoot(mario, listBullets);
             }
         }
     }
 }
Example #32
0
    // Use this for initialization
    void Start()
    {
        t_LevelManager = FindObjectOfType <LevelManager> ();
        mario          = FindObjectOfType <Mario> ();
        m_Animator     = GetComponent <Animator> ();
        m_Rigidbody2D  = GetComponent <Rigidbody2D> ();
        isReviving     = false;
        isRolling      = false;

        starmanBonus      = 200;    // ???
        rollingShellBonus = 500;    // ???
        hitByBlockBonus   = 100;    // ???
        fireballBonus     = 100;    // ???
        stompBonus        = 500;
    }
Example #33
0
    IEnumerator FourthRight()
    {
        float     runDistance    = 0.25f;
        float     runSpeed       = MarioController.Instance.FreakoutBaseSpeed * 1f;
        Mario     mario          = MarioController.Instance.mario;
        Transform marioTransform = mario.gameObject.transform;

        for (float t = 0.0f; t < runDistance; t += Time.deltaTime)
        {
            mario.skeletonSprite.GetComponent <SpriteRenderer>().flipX = false;
            marioTransform.position += Vector3.right * runSpeed * Time.deltaTime;
            yield return(null);
        }
        MarioDoneFreaking();
    }
Example #34
0
    IEnumerator ThirdLeft()
    {
        float     runDistance    = 0.2f;
        float     runSpeed       = MarioController.Instance.FreakoutBaseSpeed * 1.1f;
        Mario     mario          = MarioController.Instance.mario;
        Transform marioTransform = mario.gameObject.transform;

        for (float t = 0.0f; t < runDistance; t += Time.deltaTime)
        {
            mario.skeletonSprite.GetComponent <SpriteRenderer>().flipX = true;
            marioTransform.position += Vector3.left * runSpeed * Time.deltaTime;
            yield return(null);
        }
        StartCoroutine(FourthRight());
    }
Example #35
0
        public override void HandleIdleTransition()
        {
            this.bowser.HitboxType = HitboxTypes.Full;

            if (Mario.GetInstance().PositionInGame.X > this.bowser.PositionInGame.X)
            {
                this.bowser.IsFacingLeft = false;
            }
            else
            {
                this.bowser.IsFacingLeft = true;
            }

            this.bowser.ChangeState(new BowserIdleState(this.bowser));
        }
 public MarioEnemyCollisionManager(IList enemies, Mario mario, Level level)
 {
     this.enemies = enemies;
     this.level = level;
     this.mario = mario;
 }
Example #37
0
 public MarioItemCollision(Mario mario)
 {
     myMario = mario;
 }
Example #38
0
 public MarioLuigiCollision(Mario mario)
 {
     myMario = mario;
 }
Example #39
0
 public MarioDeadStateCommand(Mario mario, Level level)
 {
     this.mario = mario;
     this.level = level;
 }
Example #40
0
 public MarioBlockCollision(Mario mario)
 {
     myMario = mario;
 }
Example #41
0
 public MarioCollisionHandler(Mario mario, Level level)
 {
     this.mario = mario;
     this.level = level;
 }
Example #42
0
 public MarioEnemyCollision(Mario mario)
 {
     myMario = mario;
 }
        private void OnLoadItems()
        {
            var middlePoint = new Point(EditingContext.SurfaceWidth / 2, EditingContext.SurfaceHeight / 2);

            const int marioWidth = 200;
            const int marioHeight = 240;

            var mario = new Mario { Left = middlePoint.X - marioWidth / 2D, Top = middlePoint.Y - marioHeight / 2D, Width = marioWidth, Height = marioHeight };
            var bubble = new Bubble
                         {
                             Left = mario.Right - 70,
                             Top = mario.Top - 170,
                             Width = 250,
                             Height = 280,
                             Text = "WOW. Much decoupled. So AOP. Such Patterns.",
                             Background = new Color(255, 0, 255, 80),
                             TextColor = new Color(255, 0, 0, 0),
                             FontSize = 16D,
                             FontName = "Comic Sans MS"
                         };

            Items.Add(mario);
            Items.Add(bubble);
        }
Example #44
0
 public static void Main()
 {
     var marioGame = new Mario();
     marioGame.Run();
 }
Example #45
0
 public MarioRunLeftCommand(Mario mario)
 {
     this.mario = mario;
 }
Example #46
0
 public MarioJumpCommand(Mario mario)
 {
     this.mario = mario;
 }