Ejemplo n.º 1
0
        public Controller()
        {
            Width         = 10000;
            Height        = 1000;
            Rand          = new Random();
            ActiveSpiders = new List <Spider>();

            StartingX   = (Width / 2) * -1;
            GroundLevel = (Height / 2) - (PlatformThickness * 3);
            StartingY   = GroundLevel;

            Stickario = new Stickario()
            {
                X = StartingX + (PlatformThickness * 2), Y = StartingY - (PlatformThickness * 2)
            };
            // add a nest every 3rd chunk
            Nests = new SpiderNest[(Width / WorldChunkWidth) / 3];
            for (int i = 0; i < Nests.Length; i++)
            {
                // x ranges from -1*(Width/2) to (Width/2)
                var x = StartingX + (WorldChunkWidth * ((i + 1) * 3)) - (2 * PlatformThickness);
                Nests[i] = new SpiderNest()
                {
                    X = x,
                    Y = -1 * (Height / 2)
                };
                Nests[i].OnAddSpider += AddSpider;
            }

            EndMenu   = new EndMenu(Stickario);
            StartMenu = new StartMenu();
        }
Ejemplo n.º 2
0
 public EndMenu(Stickario player)
 {
     Player = player;
 }
Ejemplo n.º 3
0
        public void ObjectContact(Element element, Element elem)
        {
            Stickario stickario = null;

            if (element is Stickario)
            {
                stickario = (element as Stickario);

                if (elem is ItemBox)
                {
                    // check if we are 'under' this object
                    if (element.Y > elem.Y && element.X >= elem.X - (elem.Width / 2) && element.X < elem.X + (elem.Width / 2))
                    {
                        var box    = elem as ItemBox;
                        var action = box.Activate();

                        switch (action)
                        {
                        case ItemBoxReturn.Coin:
                            stickario.Coins++;
                            World.Play(CoinSoundPath);
                            break;

                        case ItemBoxReturn.Nothing:
                            break;

                        case ItemBoxReturn.Spike:
                            // teleport back to the begining
                            DisplayEndAndPlaySound(stickario, EndReason.DeathBySpike);
                            break;

                        default: throw new Exception("Invalid ItemBoxReturn : " + action);
                        }
                    }
                }

                // check for invisible blocks
                if (elem is InvisibleMarker)
                {
                    var marker = elem as InvisibleMarker;

                    switch (marker.Type)
                    {
                    case MarkerType.Death:
                        // teleport back to begining
                        DisplayEndAndPlaySound(stickario, EndReason.DeathByFalling);
                        break;

                    case MarkerType.FinishLine:
                        // it is a win
                        DisplayEndAndPlaySound(stickario, EndReason.AtFinish);
                        break;

                    default: throw new Exception("Unknown MarkerType : " + marker.Type);
                    }
                }
            }

            Spider spider = (elem is Spider) ? elem as Spider :
                            ((element is Spider) ? element as Spider : null);

            stickario = (elem is Stickario) ? elem as Stickario :
                        ((element is Stickario) ? element as Stickario : null);

            // spider attack
            if (spider != null && stickario != null)
            {
                // check if the spider is already disapearing
                if (!spider.IsSolid || spider.IsDead)
                {
                    // nothing
                }
                else
                {
                    // check if we are 'over' this object
                    if (stickario.Y + (stickario.Height / 2) < spider.Y - (spider.Height / 2))
                    {
                        // the spider dies
                        stickario.Kills++;

                        // play sound
                        World.Play(SplatSoundPath);
                    }
                    else
                    {
                        // teleport back to the begining
                        DisplayEndAndPlaySound(stickario, EndReason.DeathBySpider);
                    }

                    // remove the spider
                    spider.StartDeathSequence();
                }
            }

            // check if the spider hit the end
            if (spider != null && elem is InvisibleMarker)
            {
                var marker = elem as InvisibleMarker;

                switch (marker.Type)
                {
                case MarkerType.FinishLine:
                    // remove the spider
                    spider.StartDeathSequence();
                    break;
                }
            }
        }