Пример #1
0
        public void BuildRandom()
        {
            TotemBase totemBase = new TotemBase();

            m_allSections.Add(totemBase);
            m_attachedSections.Add(totemBase);

            //Set the order of the totem sections
            int amountOfSections = m_sectionsToPlace.Count;

            for (int i = 0; i < amountOfSections; ++i)
            {
                int index = Program.Random.Next(0, m_sectionsToPlace.Count);
                m_allSections.Add(m_sectionsToPlace[index]);
                m_attachedSections.Add(m_sectionsToPlace[index]);
                m_sectionsToPlace.RemoveAt(index);
            }
            //Place the totem sections in the world
            TotemSection above = null, below = null;

            for (int i = 0; i < m_allSections.Count; ++i)
            {
                if (i == 0)
                {
                    below = null;
                    m_allSections[i].Transform.PosY = 0;
                }
                else
                {
                    below = m_allSections[i - 1];
                    m_allSections[i].Transform.PosY = below.Top;
                }

                if (i == m_allSections.Count - 1)
                {
                    above = null;
                }
                else
                {
                    above = m_allSections[i + 1];
                }

                m_allSections[i].Transform.ParentTransform = m_transform;
                m_allSections[i].PlaceOnTotem(this, above, below);
            }
        }
Пример #2
0
        protected void Push(Player player, float force)
        {
            m_physics.Throw(force, -5, (float)Program.Random.NextDouble());
            m_physics.GroundLevel = 0;
            m_totemInstance.Detach(this);

            if (m_below != null)
            {
                m_below.m_above = m_above;
            }
            if (m_above != null)
            {
                m_above.ChainPush();
                m_above.m_below = m_below;
            }

            float previous = Top;

            m_sprite.Origin = new Vector2(0.5f, 0.5f);
            float next = Top;

            m_transform.Position       += m_transform.ParentTransform.PositionGlobal;
            m_transform.PosY           -= next - previous;
            m_transform.ParentTransform = null;
            m_totemInstance             = null;
            m_below = null;
            m_above = null;

            if (Game1.old_kbs.IsKeyDown(Keys.Space))
            {
                m_transform.Scale = new Vector2(0);
                m_explosion.Generate(10, new Object[] { m_transform.PositionGlobal, player });
            }

            if (player.ComboCount >= Game1.scoreBorder.ScoreMultiplierMax)
            {
                m_generator.Generate(Game1.scoreBorder.ScoreMultiplierMax, new object[] { m_transform.PositionGlobal, player });
            }
            else
            {
                m_generator.Generate(player.ComboCount, new object[] { m_transform.PositionGlobal, player });
            }
        }
Пример #3
0
 public void PlaceOnTotem(Totem totem, TotemSection sectionAbove, TotemSection sectionBelow)
 {
     m_totemInstance = totem;
     m_above         = sectionAbove;
     m_below         = sectionBelow;
 }
Пример #4
0
 internal void Detach(TotemSection section)
 {
     m_attachedSections.Remove(section);
     m_detachedSections.Add(section);
 }
Пример #5
0
        public void BuildFromFile(string filename)
        {
            string file = "Content/Levels/" + filename + ".txt";

            string[] lines;
            try
            {
                lines = System.IO.File.ReadAllLines(file);
            }
            catch
            {
                return;
            }
            List <TotemSection> sectionsToAdd = new List <TotemSection>();

            for (int i = lines.Length - 1; i > -1; --i)
            {
                if (lines[i].StartsWith("| |"))
                {
                    sectionsToAdd.Add(new NormalSection(SectionType.Bilateral));
                }
                if (lines[i].StartsWith("[ |"))
                {
                    sectionsToAdd.Add(new MetalSection(SectionType.Left));
                }
                if (lines[i].StartsWith("| ]"))
                {
                    sectionsToAdd.Add(new MetalSection(SectionType.Right));
                }
                if (lines[i].StartsWith("[ ]"))
                {
                    sectionsToAdd.Add(new MetalSection(SectionType.Bilateral));
                }
                if (lines[i].StartsWith("{ |"))
                {
                    sectionsToAdd.Add(new SpikeSection(SectionType.Left));
                }
                if (lines[i].StartsWith("| }"))
                {
                    sectionsToAdd.Add(new SpikeSection(SectionType.Right));
                }
                if (lines[i].StartsWith("{ }"))
                {
                    sectionsToAdd.Add(new SpikeSection(SectionType.Bilateral));
                }

                if (lines[i].Contains("pD"))
                {
                    m_powerUpList.Add(new PowerUp(sectionsToAdd.Count, true));
                }

                if (lines[i].Contains("pG"))
                {
                    m_powerUpList.Add(new PowerUp(sectionsToAdd.Count, false));
                }
            }


            Console.WriteLine(m_powerUpList.Count);

            TotemBase totemBase = new TotemBase();

            m_allSections.Add(totemBase);
            m_attachedSections.Add(totemBase);
            m_allSections.AddRange(sectionsToAdd);
            m_attachedSections.AddRange(sectionsToAdd);
            TotemTop totemTop = new TotemTop();

            m_allSections.Add(totemTop);
            m_attachedSections.Add(totemTop);


            //Place the totem sections in the world
            TotemSection above = null, below = null;

            for (int i = 0; i < m_allSections.Count; ++i)
            {
                if (i == 0)
                {
                    below = null;
                    m_allSections[i].Transform.PosY = 0;
                }
                else
                {
                    below = m_allSections[i - 1];
                    m_allSections[i].Transform.PosY = below.Top;
                }

                if (i == m_allSections.Count - 1)
                {
                    above = null;
                }
                else
                {
                    above = m_allSections[i + 1];
                }

                m_allSections[i].Transform.ParentTransform = m_transform;
                m_allSections[i].PlaceOnTotem(this, above, below);
            }

            // Place powers up in the world
            //
            for (int i = 0; i < m_powerUpList.Count; i++)
            {
                // Place power up at posY of totem section
                //
                int index = m_powerUpList[i].IndexTotemToPlacePowerUp;
                m_powerUpList[i].Transform.ParentTransform = m_transform;
                m_powerUpList[i].Transform.PosY            = m_allSections[index].Transform.PosY - deltaPosYCorrection;

                // Place power up at left or right
                //
                if (m_powerUpList[i].IsToLeft)
                {
                    m_powerUpList[i].Transform.PosX = -distanceFromTotemCenter;
                }
                else
                {
                    m_powerUpList[i].Transform.PosX = distanceFromTotemCenter;
                }
            }
        }
Пример #6
0
        protected void Push(Player player, float force)
        {
            m_physics.Throw(force, -5, (float)Program.Random.NextDouble());
            m_physics.GroundLevel = 0;
            m_totemInstance.Detach(this);

            if(m_below != null)
                m_below.m_above = m_above;
            if (m_above != null)
            {
                m_above.ChainPush();
                m_above.m_below = m_below;
            }

            float previous = Top;
            m_sprite.Origin = new Vector2(0.5f, 0.5f);
            float next = Top;
            m_transform.Position += m_transform.ParentTransform.PositionGlobal;
            m_transform.PosY -= next - previous;
            m_transform.ParentTransform = null;
            m_totemInstance = null;
            m_below = null;
            m_above = null;

            if (Game1.old_kbs.IsKeyDown(Keys.Space))
            {
                m_transform.Scale = new Vector2(0);
                m_explosion.Generate(10, new Object[] { m_transform.PositionGlobal, player });
            }

            if (player.ComboCount >= Game1.scoreBorder.ScoreMultiplierMax)
            {
                m_generator.Generate(Game1.scoreBorder.ScoreMultiplierMax, new object[] { m_transform.PositionGlobal, player });
            }
            else
            {
                m_generator.Generate(player.ComboCount, new object[] { m_transform.PositionGlobal, player });
            }
        }
Пример #7
0
 public void PlaceOnTotem(Totem totem, TotemSection sectionAbove, TotemSection sectionBelow)
 {
     m_totemInstance = totem;
     m_above = sectionAbove;
     m_below = sectionBelow;
 }
Пример #8
0
 internal void Detach(TotemSection section)
 {
     m_attachedSections.Remove(section);
     m_detachedSections.Add(section);
 }