Exemple #1
0
        public Enemy(CharacterProfile profile, bool czyPojemnik, float zasiegWzr, float zasiegOgl)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed   += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
                Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();

            isContainer   = czyPojemnik;
            isSeen        = false;
            isReachable   = false;
            _ZasiegWzroku = zasiegWzr;
            _ZasiegOgolny = zasiegOgl;
            _Statistics   = Profile.Statistics.statistics_Clone();
            State         = StateTypes.IDLE;

            //DROPPRIZE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            if (Profile.DropPrizeID == "")
            {
                Profile.DropPrizeID = "pPusty";
            }

            DropPrize = PrizeManager.P[Profile.DropPrizeID].prize_Clone();
            List <DescribedProfile> lista_tym  = new List <DescribedProfile>();
            List <DescribedProfile> lista_tym2 = new List <DescribedProfile>(DropPrize.ItemsList);

            if (DropPrize.ItemsList.Count > 2)
            {
                for (int i = 0; i < 2; i++)
                {
                    int Los = Engine.Singleton.Random.Next(lista_tym2.Count);
                    lista_tym.Add(lista_tym2[Los]);
                    lista_tym2.RemoveAt(Los);
                    DropPrize.ItemsList = new List <DescribedProfile>(lista_tym);
                }
            }

            else
            {
                DropPrize.ItemsList = new List <DescribedProfile>(DropPrize.ItemsList);
            }

            DropPrize.AmountGold = Engine.Singleton.Random.Next(DropPrize.AmountGold / 2, DropPrize.AmountGold + 1);
            DropExp = DropPrize.AmountExp;

            //PO DROPPRIZIE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            walkAnim   = Entity.GetAnimationState("WALK");
            idleAnim   = Entity.GetAnimationState("IDLE");
            attackAnim = Entity.GetAnimationState("ATTACK");
            deadAnim   = Entity.GetAnimationState("DEAD");

            //Animation("IdleLegs").Enabled = true;
            //Animation("IdleLegs").Loop = true;
            FriendlyType = Profile.FriendlyType;
            ProfName     = Profile.ProfileName;
        }
Exemple #2
0
        public Character(CharacterProfile profile)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.Capsule(
                Engine.Singleton.NewtonWorld,
                System.Math.Min(scaledSize.x, scaledSize.z),
                scaledSize.y * 2,
                Vector3.UNIT_X.GetRotationTo(Vector3.UNIT_Y),
                Engine.Singleton.GetUniqueBodyId());



            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed   += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
                Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();

            SensorNode = Node.CreateChildSceneNode(new Vector3(0, 0, System.Math.Min(scaledSize.x, scaledSize.z) * 1.5f));

            collision = new MogreNewt.CollisionPrimitives.Cylinder(
                Engine.Singleton.NewtonWorld,
                System.Math.Min(scaledSize.x, scaledSize.z) * 1.5f,
                scaledSize.y * 1,
                Vector3.UNIT_X.GetRotationTo(Vector3.UNIT_Y),
                Engine.Singleton.GetUniqueBodyId());
            ObjectSensor = new Body(Engine.Singleton.NewtonWorld, collision, true);
            ObjectSensor.SetMassMatrix(1, new Vector3(1, 1, 1));

            ObjectSensor.UserData        = this;
            ObjectSensor.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterSensorMaterialID;

            Contacts = new List <GameObject>();

            Inventory = new List <DescribedProfile>();
            Inventory = Profile.Inventory;

            AnimBlender = new CharacterAnimBlender();
            AnimBlender.SetEntity(Entity);

            ActiveQuests = new QuestManager();

            _Statistics = Profile.Statistics.statistics_Clone();

            FriendlyType = Profile.FriendlyType;

            State = Enemy.StateTypes.IDLE;

            DropExp  = 0;
            ProfName = Profile.ProfileName;

            if (Profile.DialogRoot != null && Profile.DialogRoot != "")
            {
                TalkRoot = Conversations.D[Profile.DialogRoot].Reactions.Values.ElementAt(0);
            }

            Activities = new ActivityManager();
            Waiting    = false;
        }
Exemple #3
0
        public CharacterProfileManager()
        {
            C = new Dictionary <String, CharacterProfile>();
            E = new Dictionary <string, CharacterProfile>();

            character                 = new CharacterProfile();
            character.BodyMass        = 70;
            character.BodyScaleFactor = new Vector3(1.5f, 1, 1.5f);
            character.HeadOffset      = new Vector3(0, 1.4f, 0);
            character.MeshName        = "Man.mesh";
            character.WalkSpeed       = 1.85f;
            character.PictureMaterial = "AdamMaterial";

            if (System.IO.File.Exists("Media\\Profiles\\NPCs.xml"))
            {
                XmlDocument File = new XmlDocument();
                File.Load("Media\\Profiles\\NPCs.xml");

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

                foreach (XmlNode item in Items)
                {
                    CharacterProfile Kriper = new CharacterProfile();
                    Kriper.DisplayName         = item["DisplayName"].InnerText;
                    Kriper.MeshName            = item["MeshName"].InnerText;
                    Kriper.BodyMass            = int.Parse(item["BodyMass"].InnerText);
                    Kriper.WalkSpeed           = float.Parse(item["WalkSpeed"].InnerText);
                    Kriper.DisplayNameOffset   = Vector3.ZERO;
                    Kriper.DisplayNameOffset.x = float.Parse(item["DisplayNameOffset_x"].InnerText);
                    Kriper.DisplayNameOffset.y = float.Parse(item["DisplayNameOffset_y"].InnerText);
                    Kriper.DisplayNameOffset.z = float.Parse(item["DisplayNameOffset_z"].InnerText);
                    Kriper.HeadOffset          = Vector3.ZERO;
                    Kriper.HeadOffset.x        = float.Parse(item["HeadOffset_x"].InnerText);
                    Kriper.HeadOffset.y        = float.Parse(item["HeadOffset_y"].InnerText);
                    Kriper.HeadOffset.z        = float.Parse(item["HeadOffset_z"].InnerText);
                    Kriper.BodyScaleFactor     = Vector3.ZERO;
                    Kriper.BodyScaleFactor.x   = float.Parse(item["BodyScaleFactor_x"].InnerText);
                    Kriper.BodyScaleFactor.y   = float.Parse(item["BodyScaleFactor_y"].InnerText);
                    Kriper.BodyScaleFactor.z   = float.Parse(item["BodyScaleFactor_z"].InnerText);
                    Kriper.ProfileName         = item["ProfileName"].InnerText;
                    Kriper.FriendlyType        = (Character.FriendType) int.Parse(item["FriendlyType"].InnerText);
                    Kriper.Statistics          = new Statistics(int.Parse(item["WalkaWrecz"].InnerText), int.Parse(item["Krzepa"].InnerText), int.Parse(item["Opanowanie"].InnerText), int.Parse(item["Odpornosc"].InnerText), int.Parse(item["Zrecznosc"].InnerText), int.Parse(item["Charyzma"].InnerText), int.Parse(item["Zywotnosc"].InnerText), int.Parse(item["Ataki"].InnerText));
                    Kriper.DialogRoot          = item["DialogRoot"].InnerText;
                    Kriper.MnoznikDlaShopa     = float.Parse(item["ShopMnoznik"].InnerText);

                    if (item["ShopPrizeID"].InnerText != null && item["ShopPrizeID"].InnerText != "")
                    {
                        Kriper.Gold      = (ulong)PrizeManager.P[item["ShopPrizeID"].InnerText].AmountGold;
                        Kriper.Inventory = PrizeManager.P[item["ShopPrizeID"].InnerText].ItemsList;
                    }

                    C.Add(Kriper.ProfileName, Kriper);
                }
            }

            if (System.IO.File.Exists("Media\\Profiles\\Enemies.xml"))
            {
                XmlDocument File = new XmlDocument();
                File.Load("Media\\Profiles\\Enemies.xml");

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

                foreach (XmlNode item in Items)
                {
                    CharacterProfile Kriper = new CharacterProfile();
                    Kriper.DisplayName         = item["DisplayName"].InnerText;
                    Kriper.MeshName            = item["MeshName"].InnerText;
                    Kriper.BodyMass            = int.Parse(item["BodyMass"].InnerText);
                    Kriper.WalkSpeed           = float.Parse(item["WalkSpeed"].InnerText);
                    Kriper.DisplayNameOffset   = Vector3.ZERO;
                    Kriper.DisplayNameOffset.x = float.Parse(item["DisplayNameOffset_x"].InnerText);
                    Kriper.DisplayNameOffset.y = float.Parse(item["DisplayNameOffset_y"].InnerText);
                    Kriper.DisplayNameOffset.z = float.Parse(item["DisplayNameOffset_z"].InnerText);
                    Kriper.HeadOffset          = Vector3.ZERO;
                    Kriper.HeadOffset.x        = float.Parse(item["HeadOffset_x"].InnerText);
                    Kriper.HeadOffset.y        = float.Parse(item["HeadOffset_y"].InnerText);
                    Kriper.HeadOffset.z        = float.Parse(item["HeadOffset_z"].InnerText);
                    Kriper.BodyScaleFactor     = Vector3.ZERO;
                    Kriper.BodyScaleFactor.x   = float.Parse(item["BodyScaleFactor_x"].InnerText);
                    Kriper.BodyScaleFactor.y   = float.Parse(item["BodyScaleFactor_y"].InnerText);
                    Kriper.BodyScaleFactor.z   = float.Parse(item["BodyScaleFactor_z"].InnerText);
                    Kriper.ProfileName         = item["ProfileName"].InnerText;
                    Kriper.FriendlyType        = (Character.FriendType) int.Parse(item["FriendlyType"].InnerText);
                    Kriper.Statistics          = new Statistics(int.Parse(item["WalkaWrecz"].InnerText), int.Parse(item["Krzepa"].InnerText), int.Parse(item["Opanowanie"].InnerText), int.Parse(item["Odpornosc"].InnerText), int.Parse(item["Zrecznosc"].InnerText), int.Parse(item["Charyzma"].InnerText), int.Parse(item["Zywotnosc"].InnerText), int.Parse(item["Ataki"].InnerText));
                    Kriper.ZasiegOgolny        = int.Parse(item["ZasiegOgolny"].InnerText);
                    Kriper.ZasiegWzroku        = int.Parse(item["ZasiegWzroku"].InnerText);
                    Kriper.DropPrizeID         = item["DropPrize"].InnerText;
                    Kriper.IloscRzutow         = int.Parse(item["IloscRzutow"].InnerText);
                    Kriper.JakoscRzutow        = int.Parse(item["JakoscRzutow"].InnerText);
                    Kriper.DystansKontaktu     = float.Parse(item["DystansKontaktu"].InnerText);

                    E.Add(item["ProfileName"].InnerText, Kriper);
                }
            }
        }