Пример #1
0
        public void AddItem(bool Left)
        {
            switch (Engine.Singleton.HumanController.HUD.Category)
            {
            case HUD.InventoryCategory.WAYPOINT:
                WayPoint newWayPoint = new WayPoint();
                newWayPoint.Position    = AimPosition;
                newWayPoint.DisplayName = Engine.Singleton.CurrentLevel.Name + "_NEW_WP";

                Engine.Singleton.ObjectManager.Add(newWayPoint);
                break;

            case HUD.InventoryCategory.DESCRIBED:
                Described newItem = new Described(InventoryItem);
                if (Left)
                {
                    newItem.Position = AimPosition;
                }
                else
                {
                    newItem.Position = Camera.Position;
                }

                if (!Engine.Singleton.HumanController.Gravity)
                {
                    newItem.Body.SetMassMatrix(0, Vector3.ZERO);
                }

                Engine.Singleton.ObjectManager.Add(newItem);
                break;

            case HUD.InventoryCategory.CHARACTER:
                Character newCharacter = new Character(InventoryCharacter);
                if (Left)
                {
                    newCharacter.Position = AimPosition;
                }
                else
                {
                    newCharacter.Position = Camera.Position;
                }

                if (!Engine.Singleton.HumanController.Gravity)
                {
                    newCharacter.Body.SetMassMatrix(0, Vector3.ZERO);
                }

                //   Console.WriteLine(newCharacter.Position.ToString());
                //   Console.WriteLine(AimPosition.ToString());
                //   Console.WriteLine(Camera.Position.ToString());
                Engine.Singleton.ObjectManager.Add(newCharacter);
                break;

            case HUD.InventoryCategory.ENEMY:
                Enemy newEnemy = new Enemy(InventoryCharacter);
                if (Left)
                {
                    newEnemy.Position = AimPosition;
                }
                else
                {
                    newEnemy.Position = Camera.Position;
                }

                if (!Engine.Singleton.HumanController.Gravity)
                {
                    newEnemy.Body.SetMassMatrix(0, Vector3.ZERO);
                }

                //   Console.WriteLine(newCharacter.Position.ToString());
                //   Console.WriteLine(AimPosition.ToString());
                //   Console.WriteLine(Camera.Position.ToString());
                Engine.Singleton.ObjectManager.Add(newEnemy);
                break;
            }
        }
Пример #2
0
        public void Load()
        {
            while (Engine.Singleton.ObjectManager.Objects.Count > 0)
            {
                Engine.Singleton.ObjectManager.Destroy(Engine.Singleton.ObjectManager.Objects[0]);
            }

            //*************************************************************//
            //                                                             //
            //                            ITEMY                            //
            //                                                             //
            //*************************************************************//

            if (System.IO.File.Exists("Media\\Maps\\" + CurrentLevel.Name + "\\Items.xml"))
            {
                XmlDocument File = new XmlDocument();
                File.Load("Media\\Maps\\" + CurrentLevel.Name + "\\Items.xml");

                XmlElement  root  = File.DocumentElement;
                XmlNodeList Items = root.SelectNodes("//items/item");

                foreach (XmlNode item in Items)
                {
                    if (item["DescribedProfile"].InnerText != "")
                    {
                        Described newDescribed = new Described(WorldCreator.Items.I[item["DescribedProfile"].InnerText]);
                        Vector3   Position     = new Vector3();

                        Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText));
                        newDescribed.Orientation = Orientation;

                        Position.x             = float.Parse(item["Position_x"].InnerText);
                        Position.y             = float.Parse(item["Position_y"].InnerText);
                        Position.z             = float.Parse(item["Position_z"].InnerText);
                        newDescribed.Position  = Position;
                        newDescribed.Activator = item["Activator"].InnerText;

                        Engine.Singleton.ObjectManager.Add(newDescribed);
                    }

                    if (item["ItemSword"].InnerText != "")
                    {
                        Described newDescribed = new Described(WorldCreator.Items.I[item["ItemSword"].InnerText]);
                        Vector3   Position     = new Vector3();

                        Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText));
                        newDescribed.Orientation = Orientation;

                        Position.x             = float.Parse(item["Position_x"].InnerText);
                        Position.y             = float.Parse(item["Position_y"].InnerText);
                        Position.z             = float.Parse(item["Position_z"].InnerText);
                        newDescribed.Position  = Position;
                        newDescribed.Activator = item["Activator"].InnerText;

                        Engine.Singleton.ObjectManager.Add(newDescribed);
                    }
                }
            }

            //*************************************************************//
            //                                                             //
            //                            NPCs                             //
            //                                                             //
            //*************************************************************//

            if (System.IO.File.Exists("Media\\Maps\\" + CurrentLevel.Name + "\\NPCs.xml"))
            {
                XmlDocument File = new XmlDocument();
                File.Load("Media\\Maps\\" + CurrentLevel.Name + "\\NPCs.xml");

                XmlElement  root  = File.DocumentElement;
                XmlNodeList Items = root.SelectNodes("//npcs//npc");

                foreach (XmlNode item in Items)
                {
                    Character newCharacter = new Character(WorldCreator.CharacterProfileManager.C[item["ProfileName"].InnerText]);
                    Vector3   Position     = new Vector3();

                    Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText));
                    newCharacter.Orientation = Orientation;

                    Position.x            = float.Parse(item["Position_x"].InnerText);
                    Position.y            = float.Parse(item["Position_y"].InnerText);
                    Position.z            = float.Parse(item["Position_z"].InnerText);
                    newCharacter.Position = Position;

                    Engine.Singleton.ObjectManager.Add(newCharacter);
                }
            }

            //*************************************************************//
            //                                                             //
            //                           ENEMIES                           //
            //                                                             //
            //*************************************************************//

            if (System.IO.File.Exists("Media\\Maps\\" + CurrentLevel.Name + "\\Enemies.xml"))
            {
                XmlDocument File = new XmlDocument();
                File.Load("Media\\Maps\\" + CurrentLevel.Name + "\\Enemies.xml");

                XmlElement  root  = File.DocumentElement;
                XmlNodeList Items = root.SelectNodes("//enemies//enemy");

                foreach (XmlNode item in Items)
                {
                    Enemy   newCharacter = new Enemy(WorldCreator.CharacterProfileManager.E[item["ProfileName"].InnerText]);
                    Vector3 Position     = new Vector3();

                    Quaternion Orientation = new Quaternion(float.Parse(item["Orientation_w"].InnerText), float.Parse(item["Orientation_x"].InnerText), float.Parse(item["Orientation_y"].InnerText), float.Parse(item["Orientation_z"].InnerText));
                    newCharacter.Orientation = Orientation;

                    Position.x            = float.Parse(item["Position_x"].InnerText);
                    Position.y            = float.Parse(item["Position_y"].InnerText);
                    Position.z            = float.Parse(item["Position_z"].InnerText);
                    newCharacter.Position = Position;

                    Engine.Singleton.ObjectManager.Add(newCharacter);
                }
            }

            //*************************************************************//
            //                                                             //
            //                         WAYPOINTS                           //
            //                                                             //
            //*************************************************************//

            if (System.IO.File.Exists("Media\\Maps\\" + CurrentLevel.Name + "\\Waypoints.xml"))
            {
                XmlDocument File = new XmlDocument();
                File.Load("Media\\Maps\\" + CurrentLevel.Name + "\\Waypoints.xml");

                XmlElement  root  = File.DocumentElement;
                XmlNodeList Items = root.SelectNodes("//waypoints//waypoint");

                foreach (XmlNode item in Items)
                {
                    WayPoint newWP = new WayPoint();
                    newWP.DisplayName = item["DisplayName"].InnerText;
                    Vector3 pos = new Vector3(float.Parse(item["Position_x"].InnerText),
                                              float.Parse(item["Position_y"].InnerText),
                                              float.Parse(item["Position_z"].InnerText));
                    newWP.Position = pos;

                    Engine.Singleton.ObjectManager.Add(newWP);
                }
            }
        }