public Character( GameWorld world, ModCharacterDfnXML chaData, ModCharacterSkinDfnXML chaSkin, Mogre.Vector3 initPosition, bool isBot) : base(-1, world) { this.world = world; this.isBot = isBot; this.chaData = chaData; skin = chaSkin; Id = id; brain = new DecisionSystem(this); weaponSystem = new WeaponSystem(this, null); equipmentSystem = new EquipmentSystem(this); currentActivity = new Idle(); moveInfo = new MoveInfo(CharacterController.RUN_SPEED); health = new HealthInfo(this); messageQueue = new List <CharacterMessage>(); initEquipments(); mesh = new CharacterController(world, chaData, chaSkin, initPosition, isBot); controller = (CharacterController)mesh; }
public Character( GameWorld world, ModCharacterDfnXML xmlData, ModCharacterSkinDfnXML skinXmlData, Mogre.Vector3 initPosition, bool isBot) : base(-1, world) { this.world = world; this.xmlData = xmlData; this.skinXmlData = skinXmlData; position = initPosition; Id = id; brain = new DecisionSystem(this); weaponSystem = new WeaponSystem(this, null); equipmentSystem = new EquipmentSystem(this); currentActivity = new Idle(); moveInfo = new MoveInfo(CharacterController.RUN_SPEED); health = new HealthInfo(this); messageQueue = new List <CharacterMessage>(); initEquipments(); renderable = new CharacterController(world, this, isBot); controller = (CharacterController)renderable; }
List <Entity> itemAttached; //Item that attached to character public CharacterController( GameWorld world, Character character, bool isBot = true) : base(world.Camera) { this.world = world; controlled = !isBot; itemAttached = new List <Entity>(); charaMeshName = chaSkin.Mesh; physicsScene = world.PhysicsScene; physics = physicsScene.Physics; cotrollerManager = physics.ControllerManager; this.chaData = character.XmlData; this.chaSkin = character.SkinXmlData; setupBody(character.Position); if (controlled) { setupCamera(camera); } else { movementController = new EntityMovementController(entity, world.CurrentMap.Navmesh); } //setupAnimations(); setupPhysics(); }
List <Entity> itemAttached; //Item that attached to character public CharacterController( GameWorld world, ModCharacterDfnXML chaData, ModCharacterSkinDfnXML chaSkin, Mogre.Vector3 initPosition, bool isBot = true) : base(world.Camera) { this.world = world; controlled = !isBot; itemAttached = new List <Entity>(); charaMeshName = chaSkin.Mesh; physicsScene = world.PhysicsScene; physics = physicsScene.Physics; cotrollerManager = physics.ControllerManager; this.chaData = chaData; this.chaSkin = chaSkin; setupBody(initPosition); if (controlled) { setupCamera(camera); } //setupAnimations(); setupPhysics(); }
public override void Run() { var moddata = ScreenManager.Instance.ModData; chaData = moddata.CharacterInfos.Where(o => o.ID == chaID).FirstOrDefault(); if (chaData == null) { throw new Exception("Character Data can't be null!"); } var skinData = moddata.SkinInfos.Where(o => o.ID == chaData.Skin).FirstOrDefault(); if (skinData == null) { throw new Exception("Character Skin Data can't be null!"); } var idleSkinAnim = skinData[ChaAnimType.CAT_IDLE]; if (idleSkinAnim == null) { throw new Exception("Idle Skin Anim Data can't be null!"); } var idleAnim = moddata.AnimationInfos.Where(o => o.ID == idleSkinAnim.AnimID).FirstOrDefault(); if (idleAnim == null) { throw new Exception("Idle Anim Data can't be null!"); } discordPanel = UIManager.Instance.CreatePanel("discordPanel", 0.3f, 1); discordPanel.Padding.PaddingLeft = 0.01f; discordPanel.Padding.PaddingRight = 0.01f; discordPanel.ChangeRow(UI.ValueType.Abosulte, 0.05f); discordPanel.AddRow(UI.ValueType.Percent); var txtDiscord = UIManager.Instance.CreateStaticText("txtDiscord", "Discord"); txtDiscord.MetricMode = GuiMetricsMode.GMM_RELATIVE; discordInventoryPanel = UIManager.Instance.CreatePanel("discordInventoryPanel", 0.3f, 1, 0, 0, 9, 3); discordPanel.AddWidget(1, 1, txtDiscord, AlignMode.Center); discordPanel.AddWidget(2, 1, discordInventoryPanel, AlignMode.Center, AlignMode.Center, DockMode.Fill); int currRow = 1; int currCol = 1; for (int i = 0; i < 9; i++) { var invSlot = new PanelTemplateWidget("DiscordInvSlot_" + (i + 1).ToString(), "InventorySlot"); discordInventoryPanel.AddWidget(currRow, currCol, invSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); if ((i + 1) % 3 == 0) { currRow++; currCol = 1; } else { currCol++; } } playerPanel = UIManager.Instance.CreatePanel("playerPanel", 0.4f, 1, 0.3f); playerPanel.ChangeRow(UI.ValueType.Abosulte, 0.6f); playerPanel.AddRow(UI.ValueType.Abosulte, 0.4f); playerEquipPanel = UIManager.Instance.CreatePanel("playerEquipPanel", 1, 1); playerEquipPanel.Padding.PaddingLeft = 0.01f; playerEquipPanel.Padding.PaddingRight = 0.01f; playerPreviewPanel = UIManager.Instance.CreatePanel("playerPreviewPanel", 1, 1); playerPreviewPanel.Padding.PaddingLeft = 0.01f; playerPreviewPanel.Padding.PaddingRight = 0.01f; playerPreviewPanel.ChangeCol(UI.ValueType.Abosulte, 0.6f); playerPreviewPanel.AddCol(UI.ValueType.Abosulte, 0.4f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.05f); playerPreviewPanel.AddRow(UI.ValueType.Abosulte, 0.1f); playerEquipPanel.ChangeRow(UI.ValueType.Abosulte, 0.05f); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddRow(UI.ValueType.Percent); playerEquipPanel.AddCol(UI.ValueType.Percent); playerEquipPanel.AddCol(UI.ValueType.Percent); playerPanel.AddWidget(1, 1, playerEquipPanel, AlignMode.Left, AlignMode.Center, DockMode.Fill); playerPanel.AddWidget(2, 1, playerPreviewPanel, AlignMode.Left, AlignMode.Center, DockMode.Fill); var txtOutfit = UIManager.Instance.CreateStaticText("txtOutfit", "Outfit"); var txtArms = UIManager.Instance.CreateStaticText("txtArms", "Arms"); txtOutfit.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtArms.MetricMode = GuiMetricsMode.GMM_RELATIVE; playerEquipPanel.AddWidget(1, 2, txtOutfit, AlignMode.Center); playerEquipPanel.AddWidget(1, 3, txtArms, AlignMode.Center); for (int i = 0; i < 9; i++) { var equipSlot = new PanelTemplateWidget("EquipSlot_" + (i + 1).ToString(), "InventorySlot"); switch (i) { case 0: playerEquipPanel.AddWidget(2, 2, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 1: playerEquipPanel.AddWidget(3, 2, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 2: playerEquipPanel.AddWidget(4, 2, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 3: playerEquipPanel.AddWidget(5, 1, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 4: playerEquipPanel.AddWidget(2, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 5: playerEquipPanel.AddWidget(3, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 6: playerEquipPanel.AddWidget(4, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 7: playerEquipPanel.AddWidget(3, 1, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; case 8: playerEquipPanel.AddWidget(5, 3, equipSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); break; } } meshLayer = OverlayManager.Singleton.Create("CharacterPreview"); meshLayer.ZOrder = (ushort)(UIManager.Instance.GetCursorContainer().ZOrder - 1); gameObject = new Character(world, chaData, skinData, new Mogre.Vector3(), true); float length = gameObject.Mesh.Entity.BoundingBox.Size.Length * 2; gameObject.Mesh.Entity.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_MAX; gameObject.Mesh.EntityNode.Translate(new Mogre.Vector3(-2f, -6.3f, -1.0f * length)); gameObject.Mesh.EntityNode.Scale(0.7f, 0.8f, 0.8f); meshLayer.Add3D(gameObject.MeshNode); meshLayer.Show(); var txtPreviewHeadArmourTotal = UIManager.Instance.CreateStaticText("txtPreviewHeadArmourTotal", "Head Armour Total: 0"); var txtPreviewBodyArmourTotal = UIManager.Instance.CreateStaticText("txtPreviewBodyArmourTotal", "Body Armour Total: 0"); var txtPreviewLegArmourTotal = UIManager.Instance.CreateStaticText("txtPreviewLegArmourTotal", "Leg Armour Total: 0"); var txtPreviewEncumbrance = UIManager.Instance.CreateStaticText("txtPreviewEncumbrance", "Encumbrance: 0"); txtPreviewHeadArmourTotal.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtPreviewBodyArmourTotal.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtPreviewLegArmourTotal.MetricMode = GuiMetricsMode.GMM_RELATIVE; txtPreviewEncumbrance.MetricMode = GuiMetricsMode.GMM_RELATIVE; var btnReturn = UIManager.Instance.CreateButton("btnInventoryReturn", "Return", 200); btnReturn.MetricMode = GuiMetricsMode.GMM_RELATIVE; btnReturn.OnClick += (sender) => { ScreenManager.Instance.ChangeScreenReturn(); }; playerPreviewPanel.AddWidget(2, 2, txtPreviewHeadArmourTotal, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(3, 2, txtPreviewBodyArmourTotal, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(4, 2, txtPreviewLegArmourTotal, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(5, 2, txtPreviewEncumbrance, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); playerPreviewPanel.AddWidget(6, 2, btnReturn, AlignMode.Center, AlignMode.Center, DockMode.FillWidth); backpackPanel = UIManager.Instance.CreatePanel("backpackPanel", 0.3f, 1, 0.7f, 0); backpackPanel.Padding.PaddingRight = 0.01f; backpackPanel.Padding.PaddingLeft = 0.01f; backpackPanel.ChangeRow(UI.ValueType.Abosulte, 0.05f); backpackPanel.AddRow(UI.ValueType.Percent); backpackPanel.AddRow(UI.ValueType.Abosulte, 0.03f); var txtInvTitle = UIManager.Instance.CreateStaticText("txtInvTitle", "Inventory"); txtInvTitle.MetricMode = GuiMetricsMode.GMM_RELATIVE; backpackInventoryPanel = UIManager.Instance.CreateScrollablePanel("backpackInventoryPanel", 1, 1, 0, 0, 20, 3); backpackPanel.AddWidget(1, 1, txtInvTitle, AlignMode.Center, AlignMode.Center, DockMode.Fill); backpackPanel.AddWidget(2, 1, backpackInventoryPanel, AlignMode.Center, AlignMode.Center, DockMode.Fill); int curRow = 1; int curCol = 1; for (int i = 0; i < 60; i++) { var invSlot = new PanelTemplateWidget("InvSlot_" + (i + 1).ToString(), "InventorySlot"); invSlot.Height = 0.1f; backpackInventoryPanel.ChangeRow(UI.ValueType.Abosulte, invSlot.Height, curRow); backpackInventoryPanel.AddWidget(curRow, curCol, invSlot, AlignMode.Center, AlignMode.Center, DockMode.Fill); if ((i + 1) % 3 == 0) { curRow++; curCol = 1; } else { curCol++; } } }