Esempio n. 1
0
        public void LoadContent()
        {
            XmlManager <Chemical> chemicalLoader = new XmlManager <Chemical>();

            foreach (string chemicalSource in ChemicalSource)
            {
                string[] split    = chemicalSource.Split('/');
                string   s        = (split[split.Length - 1]).Replace(".xml", String.Empty);
                Chemical chemical = chemicalLoader.Load(chemicalSource);
                if (chemical.NickName != String.Empty)
                {
                    s = chemical.NickName;
                }

                while (chemicals.ContainsKey(s))
                {
                    s += "*";
                }
                chemicalName.Add(s);
                chemical.LoadContent();
                chemicals.Add(s, chemical);
            }
            if (chemicalName.Count() > 0)
            {
                CurrentChemicalName = chemicalName[0];
            }
            tag.FontName = "Fonts/OCRAExt";
            tag.Path     = "Misc/off_white";
            tag.LoadContent();
            shadow.Path = "Misc/shadow";
            shadow.LoadContent();
        }
Esempio n. 2
0
 public void Update(GameTime gameTime, ref Player player)
 {
     if (IsActive)
     {
         if (!isTransitioning)
         {
             menu.Update(gameTime);
         }
         Transition(gameTime);
         arrow.Update(gameTime);
         background.Update(gameTime);
         foreach (Image i in scrollingText)
         {
             i.Update(gameTime);
         }
         if (newPartyMember != String.Empty)
         {
             XmlManager <Chemical> chemicalLoader = new XmlManager <Chemical>();
             Chemical chemical = chemicalLoader.Load("Content/Load/Chemical/" + newPartyMember + ".xml");
             chemical.LoadContent();
             string[] str          = newPartyMember.Split('/');
             string   chemicalName = str[str.Length - 1];
             player.ChemicalManager.AddChemical(chemical);
             newPartyMember = String.Empty;
         }
     }
 }
Esempio n. 3
0
 public void AddChemical(Chemical chemical)
 {
     while (chemicals.ContainsKey(chemical.Name))
     {
         chemical.Name += "*";
     }
     if (!chemicals.ContainsKey(chemical.Name))
     {
         chemicals.Add(chemical.Name, chemical);
         chemicalName.Add(chemical.Name);
     }
 }
Esempio n. 4
0
        public void LoadTempChemical(string name, string series)
        {
            string xmlPath = "Content/Load/Chemical/" + series + "/" + name + ".xml";
            XmlManager <Chemical> chemicalLoader = new XmlManager <Chemical>();
            Chemical chemical = chemicalLoader.Load(xmlPath);

            chemical.IsTemp   = true;
            chemical.InBattle = true;
            while (chemicals.ContainsKey(name))
            {
                name += "*";
            }
            chemical.LoadContent();
            chemicalName.Add(name);
            chemicals.Add(name, chemical);
            tempChemicalName.Add(name);
        }
Esempio n. 5
0
        /// <summary>
        /// GameplayScreen: Update all chemicals in player party
        /// </summary>
        public void Update(GameTime gameTime, Player player)
        {
            Chemical chemical = new Chemical();

            for (int count = 0; count < Math.Min(maxVisibleChemicals, chemicals.Count); count++)
            {
                if (count > 0)
                {
                    chemical = chemicals[chemicalName[count - 1]];
                    if (Vector2.Distance(chemical.Image.Position, chemicals[chemicalName[count]].Image.Position) > chemicals[chemicalName[count]].Dimensions.X * 3)
                    {
                        chemicals[chemicalName[count]].Image.Position = player.Image.Position;
                    }
                }
                else if (Vector2.Distance(player.Image.Position, chemicals[chemicalName[count]].Image.Position) > chemicals[chemicalName[count]].Dimensions.X * 3)
                {
                    chemicals[chemicalName[count]].Image.Position = player.Image.Position;
                }
                chemicals[chemicalName[count]].Update(gameTime, ref player, chemical, count);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// chemical follows player, GameplayScreen
        /// </summary>
        public void Update(GameTime gameTime, ref Player player, Chemical chemical, int count)
        {
            Vector2 v, p;

            if (count == 0)
            {
                v = player.Velocity;
                p = player.Image.Position;
            }
            else
            {
                v = chemical.Velocity;
                p = chemical.Image.Position;
            }
            v.Normalize();
            bool right = v.X > 0 && p.X > (Image.Position.X);
            bool left  = v.X < 0 && p.X < (Image.Position.X);
            bool down  = v.Y > 0 && p.Y > (Image.Position.Y);
            bool up    = v.Y < 0 && p.Y < (Image.Position.Y);

            Velocity = Vector2.Zero;
            int   padding  = 5;
            float distance = Vector2.Distance(p, Image.Position);

            if (distance > (Dimensions.X + Dimensions.Y) * 0.5f)
            {
                float halfDimensionsX = Dimensions.X / 1.9f;
                float halfDimensionsY = Dimensions.Y / 1.9f;
                halfDimensionsX = halfDimensionsY = (halfDimensionsX + halfDimensionsY) / 2f;
                if (right && up)
                {
                    if ((p.X > Image.Position.X + halfDimensionsX) && (p.Y < Image.Position.Y - halfDimensionsY))
                    {
                        Velocity = new Vector2(1, -1);
                    }
                    else if (p.X < Image.Position.X + halfDimensionsX)
                    {
                        Velocity = new Vector2(-1, -1);
                    }
                    else if (p.X > Image.Position.Y - halfDimensionsY)
                    {
                        Velocity = new Vector2(1, 1);
                    }
                }
                else if (right && down)
                {
                    if ((p.X > Image.Position.X + halfDimensionsX) && (p.Y > Image.Position.Y + halfDimensionsY))
                    {
                        Velocity = new Vector2(1, 1);
                    }
                    else if (p.X < Image.Position.X + halfDimensionsX)
                    {
                        Velocity = new Vector2(-1, 1);
                    }
                    else if (p.Y < Image.Position.Y + halfDimensionsY)
                    {
                        Velocity = new Vector2(1, -1);
                    }
                }
                else if (left && down)
                {
                    if ((p.X < Image.Position.X - halfDimensionsX) && (p.Y > Image.Position.Y + halfDimensionsY))
                    {
                        Velocity = new Vector2(-1, 1);
                    }
                    else if (p.X > Image.Position.X - halfDimensionsX)
                    {
                        Velocity = new Vector2(1, 1);
                    }
                    else if (p.Y < Image.Position.Y + halfDimensionsY)
                    {
                        Velocity = new Vector2(-1, -1);
                    }
                }
                else if (left && up)
                {
                    if ((p.X < Image.Position.X - halfDimensionsX) && (p.Y < Image.Position.Y - halfDimensionsY))
                    {
                        Velocity = new Vector2(-1, -1);
                    }
                    else if (p.X > Image.Position.X - halfDimensionsX)
                    {
                        Velocity = new Vector2(1, -1);
                    }
                    else if (p.Y > Image.Position.Y - halfDimensionsY)
                    {
                        Velocity = new Vector2(-1, 1);
                    }
                }
                else if (right || left)
                {
                    if (p.Y > (Image.Position.Y + padding))
                    {
                        Velocity = new Vector2(0, 1);
                    }
                    else if (p.Y < (Image.Position.Y - padding))
                    {
                        Velocity = new Vector2(0, -1);
                    }
                    else if (right && p.X > (Image.Position.X + Dimensions.X + padding))
                    {
                        Velocity = new Vector2(1, 0);
                    }
                    else if (left)
                    {
                        Velocity = new Vector2(-1, 0);
                    }
                }
                else if (down || up)
                {
                    if (p.X > (Image.Position.X + padding))
                    {
                        Velocity = new Vector2(1, 0);
                    }
                    else if (p.X < (Image.Position.X - padding))
                    {
                        Velocity = new Vector2(-1, 0);
                    }
                    else if (down)
                    {
                        Velocity = new Vector2(0, 1);
                    }
                    else if (count > 0)
                    {
                        if (up && p.Y < (Image.Position.Y - Dimensions.Y - padding * 2))
                        {
                            Velocity = new Vector2(0, -1);
                        }
                    }
                    else if (count == 0 && up)
                    {
                        Velocity = new Vector2(0, -1);
                    }
                }
                Image.IsActive = true;
            }

            if (Velocity != Vector2.Zero)
            {
                Velocity.Normalize();
                if (distance > (Dimensions.X + Dimensions.Y) * 0.77f)
                {
                    Velocity *= (player.MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds * 1.5f);
                }
                else
                {
                    Velocity *= (player.MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
                }
                Image.Position += Velocity;
                if (player.Velocity.X < 0)
                {
                    Image.SpriteSheetEffect.CurrentFrame.Y = 0;
                }
                else if (player.Velocity.X > 0)
                {
                    Image.SpriteSheetEffect.CurrentFrame.Y = 1;
                }
            }
            Image.Update(gameTime);
        }
Esempio n. 7
0
        string reactionHistoryFormula(Chemical chemical)
        {
            string s = String.Empty;

            switch (chemical.Series)
            {
            case Series.Alkane:
                if (reactionHistory.Contains("Alkane"))
                {
                    if (chemical.Name == "Methane")
                    {
                        s = "CO2 + 4H2 = CH4";
                    }
                    else
                    {
                        s = chemical.Name.Replace("ane", "ene").ToLower() + " + H2Ni + HEAT" + "\n\r" + "= " + chemical.Name.ToLower();
                    }
                }
                else
                {
                    string element = chemical.GetElement(Element.C).ToString();
                    if (element == "0" || element == "1")
                    {
                        element = String.Empty;
                    }
                    s      += "??? + ??? = " + "C" + element;
                    element = chemical.GetElement(Element.H).ToString();
                    s      += "H" + element;
                }
                break;

            case Series.Alkene:
                int      count = 0;
                string[] str   = { "Alkene_Hydration", "Alkene_Halogenation", "Alkene_Hydrohalogenation", "Alkene_Hydrogenation" };
                foreach (string reaction in str)
                {
                    if (reactionHistory.Contains(reaction))
                    {
                        s += reaction.Replace("Alkene_", "") + ", ";
                        if (count == 2)
                        {
                            s += "\n\r";
                        }
                    }
                    else
                    {
                        s += "???, ";
                    }
                    if (count == 1)
                    {
                        s += "\n\r";
                    }
                    count++;
                }
                break;

            case Series.Alcohol:
                if (reactionHistory.Contains("Alcohol"))
                {
                    s = chemical.Name.Replace("anol", "ene").ToLower() + " + NaOH + HEAT" + "\n\r" + "= " + chemical.Name.ToLower();
                }
                else
                {
                    string element = chemical.GetElement(Element.C).ToString();
                    if (element == "0" || element == "1")
                    {
                        element = String.Empty;
                    }
                    s      += "??? + ??? = " + "C" + element;
                    element = (chemical.GetElement(Element.H) - 1).ToString();
                    s      += "H" + element + "OH";
                }
                break;

            case Series.Halogenoalkane:
                s = String.Empty;
                if (reactionHistory.Contains("Halogenoalkane_Halogenation"))
                {
                    string a = chemical.Name.Replace("ane", "ene").ToLower();
                    s = a + " + HBr + HEAT" + "\n\r" + "= " + chemical.Name.ToLower();
                }
                // CAUTION: halogenoalkane_Hydrohalogenation is missing, but not a priority to sort out here
                else
                {
                    string element = chemical.GetElement(Element.C).ToString();
                    if (element == "0" || element == "1")
                    {
                        element = String.Empty;
                    }
                    s      += "??? + ??? = " + "C" + element;
                    element = chemical.GetElement(Element.H).ToString();
                    s      += "H" + element + "Br";
                }
                break;
            }
            return(s);
        }
Esempio n. 8
0
        void propertyInfoMenu()
        {
            foreach (Image image in infoImage)
            {
                image.UnloadContent();
            }
            infoImage.Clear();
            Vector2  dimensions = new Vector2(menu.Image.Position.X + menu.Image.SourceRect.Width / 2, 50);
            Chemical chemical   = chemicalManager.GetChemical(selectedItem);

            //1: Chemical Name
            Image i = new Image();

            i.FontName    = "Fonts/OCRAsmall";
            i.Text        = selectedItem.ToUpper();
            i.TextColor   = Color.Black;
            i.Position    = new Vector2(dimensions.X - font.MeasureString(i.Text).X / 2f, dimensions.Y);
            dimensions.Y += 55f;
            dimensions.X  = menu.Image.Position.X + 38f;
            infoImage.Add(i);

            //2: Chemical Properties Labels
            i       = new Image();
            i.Text  = "Series: " + chemical.Series.ToString();
            i.Text += "\n\r\n\r";

            i.Text += "Bond Enthalpy:\n\r\n\r";
            i.Text += "Formation Enthalpy:\n\r\n\r";
            i.Text += "Combustion Enthalpy:\n\r\n\r\n\r";

            i.Text += "Boiling Pt:\n\r";
            i.Text += "Atomic Mass:\n\r";
            i.Text += "Experience:\n\r\n\r";
            i.Text += "INFO: ";

            switch (chemical.Series.ToString())
            {
            case "Alkane":
                i.Text += "used as fuels.\n\rrelatively unreactive.";
                break;

            case "Alkene":
                i.Text += "double bonds.\n\rused in polymers.\n\rsmoky combustion.";
                break;

            case "Alcohol":
                i.Text += "hydroxyl group.\n\r";
                if (chemical.Name == "Ethanol")
                {
                    i.Text += "used in drinks.";
                }
                break;

            case "Halogenoalkane":
                if (chemical.Name == "Bromomethane")
                {
                    i.Text += "not flammable.\n\r*fire extinguisher*";
                }
                else
                {
                    i.Text += "flammable.\n\rfairly reactive.\n\r";
                }
                break;
            }

            i.FontName    = "Fonts/OCRAExt";
            i.TextColor   = Color.Black;
            i.Position    = new Vector2(dimensions.X, dimensions.Y);
            dimensions.Y += menu.Image.Font.MeasureString(" ").Y * 3;
            infoImage.Add(i);

            //3: Chemical Thermodynamic Properties (orange)
            i             = new Image();
            i.Text        = "  " + chemical.CurrentHealth.ToString() + "/" + chemical.Health.ToString() + " kJ/mol" + "\n\r\n\r";
            i.Text       += "  " + chemical.BaseDamage.ToString() + " kJ/mol\n\r\n\r";
            i.Text       += "  " + chemical.MaxDamage.ToString() + " kJ/mol\n\r\n\r";
            i.FontName    = "Fonts/OCRAExt";
            i.TextColor   = Color.DarkOrange;
            i.Position    = new Vector2(dimensions.X, dimensions.Y);
            dimensions.Y += menu.Image.Font.MeasureString(" ").Y * 6;
            infoImage.Add(i);

            //4: Chemical Brief Properties (blue)
            i           = new Image();
            i.Text      = "              " + chemical.BoilingPoint + " K\n\r";
            i.Text     += "              " + chemical.Mass + "\n\r";
            i.Text     += "              ";
            i.Text     += chemical.Experience;
            i.Text     += "\n\r\n\r";
            i.FontName  = "Fonts/OCRAExt";
            i.TextColor = Color.CornflowerBlue;
            i.Position  = new Vector2(dimensions.X, dimensions.Y);
            infoImage.Add(i);

            //5: Page Number
            i          = new Image();
            i.FontName = "Fonts/OCRAExt";
            i.Text     = "2/2";
            i.Path     = "Misc/page";
            i.Position = new Vector2(ScreenManager.Instance.Dimensions.X - 47, menu.Image.SourceRect.Height - 23);
            page.LoadContent();
            infoImage.Add(i);

            foreach (Image image in infoImage)
            {
                image.LoadContent();
            }
        }
Esempio n. 9
0
        void chemicalInfoMenu()
        {
            foreach (Image image in infoImage)
            {
                image.UnloadContent();
            }
            infoImage.Clear();
            Vector2  dimensions = new Vector2(menu.Image.Position.X + menu.Image.SourceRect.Width / 2, 50);
            Chemical chemical   = chemicalManager.GetChemical(selectedItem);

            //1: Chemical Name
            Image i = new Image();

            i.FontName    = "Fonts/OCRAsmall";
            i.Text        = selectedItem.ToUpper();
            i.TextColor   = Color.Black;
            i.Position    = new Vector2(dimensions.X - font.MeasureString(i.Text).X / 2f, dimensions.Y);
            dimensions.Y += 50f;
            infoImage.Add(i);

            //2: Chemical Image
            i                   = new Image();
            i.Path              = "Chemical/" + chemical.Series.ToString() + "/" + chemical.Name;
            i.Effects           = "SpriteSheetEffect";
            i.SpriteSheetEffect = new SpriteSheetEffect();
            i.SpriteSheetEffect.AmountOfFrames = new Vector2(2, 2);
            i.SpriteSheetEffect.SwitchFrame    = 500;
            i.Position    = new Vector2(dimensions.X - 64, dimensions.Y);
            i.IsActive    = true;
            dimensions.Y += 100f;
            infoImage.Add(i);

            //3: Chemical Formula
            i            = new Image();
            i.Path       = "Chemical/Diagram/" + chemical.Name;
            i.Position   = new Vector2(dimensions.X - 187.5f, dimensions.Y);
            dimensions.Y = menu.Image.Position.Y + menu.Image.SourceRect.Height - 120f;
            infoImage.Add(i);

            //4: Reaction History Label
            i          = new Image();
            i.FontName = "Fonts/OCRAExt";
            if (chemical.Series == Series.Alkene)
            {
                i.Text = "Addition Reactions:";
            }
            else
            {
                i.Text = "Reaction History:";
            }
            i.TextColor   = Color.Black;
            i.Position    = new Vector2(dimensions.X - menu.Image.Font.MeasureString(i.Text).X / 2f, dimensions.Y);
            dimensions.Y += menu.Image.Font.MeasureString(i.Text).Y + 3;
            infoImage.Add(i);

            //5: Reaction History/Potential Unlock
            i          = new Image();
            i.FontName = "Fonts/OCRAExt";
            i.Text     = "???";
            //TEST: Unlock breeding route
            //if (!reactionHistory.Contains("Alkane")) reactionHistory.Add("Alkane");
            i.Text      = reactionHistoryFormula(chemical);
            i.TextColor = Color.Black;
            i.Position  = new Vector2(dimensions.X - menu.Image.Font.MeasureString(i.Text).X / 2f, dimensions.Y);
            infoImage.Add(i);

            //6: Page Number
            i          = new Image();
            i.FontName = "Fonts/OCRAExt";
            i.Text     = "1/2";
            i.Path     = "Misc/page";
            i.Position = new Vector2(ScreenManager.Instance.Dimensions.X - 47, menu.Image.SourceRect.Height - 23);
            page.LoadContent();
            infoImage.Add(i);

            foreach (Image image in infoImage)
            {
                image.LoadContent();
            }
        }