Exemple #1
0
        public static void DestroyBuilding()
        {
            Random r = new Random();

            int i = r.Next(0, 5);

            if (i == 0)
            {
                forestLevel = 1; ParticleSystem.CreateInstance(new Vector2(15, 117), "smoke", true, 3);
            }
            if (i == 1)
            {
                mineLevel = 1; ParticleSystem.CreateInstance(new Vector2(50, 64), "smoke", true, 3);
            }
            if (i == 2)
            {
                villageLevel = 1; ParticleSystem.CreateInstance(new Vector2(260, 150), "smoke", true, 3);
            }
            if (i == 3)
            {
                churchLevel = 1; ParticleSystem.CreateInstance(new Vector2(240, 50), "smoke", true, 3);
            }
            if (i == 4)
            {
                fieldsLevel = 1; ParticleSystem.CreateInstance(new Vector2(80, 150), "smoke", true, 3);
            }

            SoundManager.PlayEffect("destroy");
        }
Exemple #2
0
 public void AddItem(Entity item_)
 {
     items.Add(item_);
     for (int x = items.Count - 1; x >= 0; x--)
     {
         if (items[x] == null || items[x].exists == false)
         {
             items.RemoveAt(x);
         }
         else if (x >= 0)
         {
             items[x].pos = GetSlotPos(x + 1).ToVector2() * 32;
         }
     }
     ParticleSystem.CreateInstance(item_.pos - new Vector2(16, 16), "appear", true, 0.23f);
     CheckRecipes(GetPool());
     if (item_.Name != "mask")
     {
         SoundManager.PlayEffect("hit5");
     }
     else
     {
         SoundManager.PlayEffect("hit2");
     }
 }
Exemple #3
0
        protected void UpdateGame(float es_)
        {
            dist.Update(es_);
            if (gameState == GameState.Dead && dist.Complete())
            {
                inven.LoseItem();
                ParticleSystem.CreateInstance(new Vector2(16, 48), "appear", true, 0.23f);
                dist.Reset();
            }
            easeIn.Update(es_);
            if (easeIn.Complete())
            {
                easeIn.Stop();
            }
            if (gameState != GameState.TransitionG)
            {
                Vector2 input = Vector2.Zero;
                if (gameState == GameState.Game)
                {
                    if (ipp.Pressed("w") || ipp.Pressed("up"))
                    {
                        input.Y -= 1;
                    }

                    if (ipp.Pressed("s") || ipp.Pressed("down"))
                    {
                        input.Y += 1;
                    }

                    if (ipp.JustPressed("d") || ipp.JustPressed("right"))
                    {
                        input.X = 1;
                    }
                }

                player.Input(input);
                player.Move();
                EntityCollection.MoveGroup("enemies");

                player.MultMov(es_);
                EntityCollection.MultMovGroup("enemies", es_);

                HandleCollisions();

                player.Update(es_);
                EntityCollection.UpdateGroup("enemies", es_);
                EntityCollection.UpdateGroup("pickups", es_);
            }
            ParticleSystem.UpdateAll(es_);

            ts.Update(es_, player.pos.X - 32);

            inven.Update(es_);

            EntityCollection.RecycleAll();
        }
Exemple #4
0
 public void LoseItem()
 {
     for (int x = items.Count - 1; x >= 0; x--)
     {
         if (items[x].exists)
         {
             ParticleSystem.CreateInstance(items[x].pos - new Vector2(16, 16), "appear", true, 0.23f);
             items[x].exists = false;
             items.RemoveAt(x);
             break;
         }
     }
 }
Exemple #5
0
        protected void HandleCollisions()
        {
            player.touchWallD = false;
            if (player.pos.Y + player.mov.Y + 32 > 92)
            {
                player.vel.Y      = 0;
                player.mov.Y     -= (player.pos.Y + player.mov.Y + 32 - 92);
                player.touchWallD = true;
            }

            foreach (var tile in EntityCollection.GetGroup("tiles"))
            {
                foreach (Entity enemy in EntityCollection.GetGroup("enemies"))
                {
                    CollisionSolver.SolveEntTileCollision(enemy, tile);
                }
            }

            foreach (var tile in EntityCollection.GetGroup("tiles"))
            {
                foreach (Entity enemy in EntityCollection.GetGroup("enemies"))
                {
                    CollisionSolver.SecondPassCollision(enemy, tile);
                }
            }

            foreach (var tile in EntityCollection.GetGroup("slots"))
            {
                if (tile.PredictIntersect(player, new Vector2(player.pos.X + player.mov.X - 33, 0)))
                {
                    if (player.vel.Y < 0)
                    {
                        player.vel.Y = 0;
                    }
                }
            }


            foreach (Entity en in EntityCollection.GetGroup("enemies"))
            {
                if (!en.isDestroyed && player.PredictIntersect(en))
                {
                    if (en.pos.Y - player.pos.Y > 16 && player.vel.Y > 0)
                    {
                        player.React("headJump");
                        en.React("headJump");
                        ParticleSystem.CreateInstance(en.pos + new Vector2(8, -16), "stars", true);
                        SoundManager.PlayEffect("hit3");
                    }
                    else if (!player.invin)
                    {
                        player.ToggleInvin();
                        inven.LoseHP();
                        SoundManager.PlayEffect("hit4");
                    }
                }
            }
            if (!player.Answer("sliding"))
            {
                foreach (var pickup in EntityCollection.GetGroup("pickups"))
                {
                    bool x = false;
                    foreach (FRectangle rect in player.MovHB())
                    {
                        foreach (FRectangle rect2 in pickup.MovHB())
                        {
                            if (rect.Intersects(rect2))
                            {
                                if (pickup.exists)
                                {
                                    x = true;
                                }
                            }
                        }
                    }
                    if (x)
                    {
                        inven.AddItem(pickup.SubEntities()[0]);
                        pickup.exists = false;
                    }
                }
            }
        }