/* * void CC_CombatCommands(string arguments) * { * if (CombatManager.Instance == null | CombatManager.Instance.ActiveEntity != playerCharacter) * return; * * switch (arguments) * { * case "end": * CombatManager.Instance.AttemptEnd(); * break; * * case "endTurn": * playerCharacter.EndTurn(); * break; * * default: * Log.Warning("Unknown command {0}", arguments); * break; * } * }*/ void CC_CreateWindow(string arguments) { if (hudControl == null || hudControl.selectedUnit == null) { return; } RTSUnitAI intellect = hudControl.selectedUnit.Intellect as RTSUnitAI; if (intellect == null) { return; } switch (arguments) { case "inv": if (hudControl.selectedUnit.CanOpenInventory()) { if (intellect.CurrentTask.Entity != null) { if (!(intellect.CurrentTask.Entity as InventoryObject).Disabled) { Controls.Add(new ObjectInventoryWindow(hudControl.selectedUnit, intellect.CurrentTask.Entity as InventoryObject)); } else { Log.Info((intellect.CurrentTask.Entity as InventoryObject).Type.disabledMessage); } } else { Controls.Add(new TESTinventory(hudControl.selectedUnit)); } } break; case "chat": if (hudControl.selectedUnit != null) { VBCharacter partner = (hudControl.selectedUnit.Intellect as RTSUnitAI).CurrentTask.Entity as VBCharacter; ChatWindow tmpchat = new ChatWindow(); tmpchat.SetPartners(hudControl.selectedUnit, partner); Controls.Add(tmpchat); tmpchat.LoadConversation(partner.Name, partner); cameraPosition = partner.Position; } break; default: Controls.Add(ControlDeclarationManager.Instance.CreateControl(arguments)); break; } }
void FocusOnPlayer() { Map.Instance.GetObjects(Map.Instance.InitialCollisionBounds, MapObjectSceneGraphGroups.UnitGroupMask, delegate(MapObject mapObject) { VBCharacter unit = mapObject as VBCharacter; if (unit != null && unit.InitialFaction != null && unit.InitialFaction.Name == "PlayerFaction") { availableUnits.Add(unit); } }); hudControl.selectedUnit = availableUnits[0]; }
public void LoadConversation(string selectedBot, VBCharacter tmpent) { BotName = selectedBot; convPartner = tmpent; ConversationalItem ci = Conversational.Instance.GetBotFirstConversationItem(selectedBot); if (ci != null) { ChangeConversation(ci); } else { // Bot Not Found In File! } }
protected override void OnAttach() { base.OnAttach(); window = ControlDeclarationManager.Instance.CreateControl("VB\\GUI\\HUD\\playerInventory.gui"); (window.Controls["inv"] as Inventory).FillItems(owner); //set owners for any slots foreach (Control c in window.Controls) { SlotHolder tmpHolder = c as SlotHolder; if (tmpHolder != null && tmpHolder.holderType > SlotHolder.HolderType.Inventory) { tmpHolder.owner = owner; VBCharacter rtsOwner = owner as VBCharacter; if (rtsOwner != null) { switch (tmpHolder.holderType) { case SlotHolder.HolderType.Slot1: if (rtsOwner.ActiveItems[0] > 0) { tmpHolder.Controls.Add(new TestSlot(owner.Inventory[rtsOwner.ActiveItems[0] - 1])); } break; case SlotHolder.HolderType.Slot2: if (rtsOwner.ActiveItems[1] > 0) { tmpHolder.Controls.Add(new TestSlot(owner.Inventory[rtsOwner.ActiveItems[1] - 1])); } break; default: break; } } } } Controls.Add(window); }
protected override void OnTick(float delta) { base.OnTick(delta); VBCharacter owner = Owner; if (owner != null) { //dont update if i dont need bool checkVisible = CombatManager.IsEnabled; if (Visible != checkVisible) { SetVisible(checkVisible); } if (Visible && ActionPointsBar != null) { ActionPointsBar.UpdateAPTextures(owner.ActionPts); } } }
public void FillItems(InventoryObject obj) { owner = obj; foreach (InventoryObject.InventoryObjectItem itm in obj.Inventory) { VBCharacter rtsOwner = owner as VBCharacter; if (rtsOwner != null) { if (rtsOwner.Inventory.IndexOf(itm) + 1 == rtsOwner.ActiveItems[0] || rtsOwner.Inventory.IndexOf(itm) + 1 == rtsOwner.ActiveItems[1]) { continue; } } if (!FoundAndUpdatedEntry(itm)) { Controls.Add(new TestSlot(itm)); } } RefreshItemsPosition(); }
public void SetPartners(VBCharacter Starter, VBCharacter Partner) { starter = Starter; convPartner = Partner; }
void SetSlot(SlotHolder _sender, SlotHolder _receiver) { if (_receiver.holderType > SlotHolder.HolderType.Inventory) { //TODO: SWAP ITEMS IN INVENTORY if (_receiver.Controls.Count != 0) { return; } //TODO: MAKE RECEIVER CHECK FOR ITEM TYPE VBCharacter chSnd = _sender.owner as VBCharacter; switch (_receiver.holderType) { case SlotHolder.HolderType.Armor: //set player armor break; case SlotHolder.HolderType.Slot1: if (chSnd != null) { chSnd.SetItem(assignedItem, true); } break; case SlotHolder.HolderType.Slot2: if (chSnd != null) { chSnd.SetItem(assignedItem, false); } break; case SlotHolder.HolderType.Drop: _sender.owner.DropItem(assignedItem); break; } } else { if (_sender.holderType == SlotHolder.HolderType.Inventory) { if (_receiver.owner.CanHoldItem(assignedItem.ItemType)) { _sender.owner.Inventory.Remove(assignedItem); _receiver.owner.Inventory.Add(assignedItem); } else { return; //full stop } } } //TODO: THE PROBLEM WITH THIS SYSTEM IS THAT OBJECTS CANNOT BE SWAPPED BETWEEN SLOTS, INSTEAD OF NOT ACCEPTING THE NEW HOLDER REMOVE THE PREVIOUS ONE //if my sender is on primary or secondary reset its slot VBCharacter chRec = _receiver.owner as VBCharacter; if (chRec != null) { if (_sender.holderType == SlotHolder.HolderType.Slot1) { chRec.ResetSlot(true); } if (_sender.holderType == SlotHolder.HolderType.Slot2) { chRec.ResetSlot(false); } } //if my quantity is > 1, then instead of swapping the slot, add a new identical one to the receiver //and decrease the quntity to the initial one while strring the new one to 0 if (quantity > 1 && (assignedItem.ItemType as AmmoItemType) == null) { if (_receiver.holderType != SlotHolder.HolderType.Drop) { //create a new and identical slot but with the assigned item of the other object TestSlot stmp = new TestSlot(_sender.GetFirstOfTypeUnassignedItem(assignedItem.ItemType)); _receiver.Controls.Add(stmp); } SetQuantity(quantity - 1); } else { Position = new ScaleValue(ScaleType.ScaleByResolution, Vec2.Zero); Parent.Controls.Remove(this); if (_receiver.holderType != SlotHolder.HolderType.Drop && !_receiver.FoundAndUpdatedEntry(assignedItem)) { _receiver.Controls.Add(this); } } }
protected override bool OnMouseUp(EMouseButtons button) { //If atop openly any window to not process if (Controls.Count != 1) { return(base.OnMouseUp(button)); } //GameControlsManager GameControlsManager.Instance.DoMouseUp(button); if (IsMouseInControlArea() && button == EMouseButtons.Left) { Dynamic curObj = GetObject(); switch (CursorState) { case State.Target: if (curObj != null) { CursorState = State.HUDDefault; //PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.InteractWithItem); } break; case State.Use: if (curObj as Unit == null) { /* * if (curObj as InventoryObject != null) * PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Loot); * else if (curObj as Item != null) * PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Take); * else * PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Interact); * */ } break; case State.HUDDefault: if (curObj != null) { /*PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Interact); * RTSCharacter ch = curObj as RTSCharacter; * if (ch != null) * { * string msg = "{0} has {1} hit points and is armed with {2}"; * Log.Info(msg + ".", ch.GetName(), (int)ch.Life, ch.ActiveHeldItem.Type.Name); * } */ } break; case State.Walk: //PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Move); break; default: if (curObj != null && curObj != hudControl.selectedUnit) { VBCharacter tmpEnt = curObj as VBCharacter; if (tmpEnt != null) { /* * switch (tmpEnt.ConvType) * { * case RTSCharacter.ConversationType.BubbleChat: * tmpEnt.BubbleChat("I NEVER HAD MY ONE CHILD!"); * break; * case RTSCharacter.ConversationType.Conversation: * PlayerIntellect.Instance.SetTask(tmpEnt, PlayerIntellect.TaskType.Chat); * break; * * default: * break; * }*/ } } break; } } return(base.OnMouseUp(button)); }
protected override bool OnMouseDown(EMouseButtons button) { //If atop openly any window to not process if (Controls.Count != 1) { return(base.OnMouseDown(button)); } if (IsMouseInControlArea()) { if (button == EMouseButtons.Left) { if (hudControl.selectedUnit != null) { Dynamic curObj = GetObject(); RTSUnitAI intellect = hudControl.selectedUnit.Intellect as RTSUnitAI; switch (CursorState) { case State.Target: if (curObj != null) { CursorState = State.HUDDefault; intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.Attack, curObj), false); } break; case State.Use: if (curObj as Unit == null) { //inventory item? intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.Use, curObj), false); /* * //PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Loot); * intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.Stop), false); * else if (curObj as VBItem != null) * intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.PickUp, curObj), false); * else * intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.Stop), false); * //PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Interact); */ } break; case State.HUDDefault: if (curObj != null) { /*PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Interact); * RTSCharacter ch = curObj as RTSCharacter; * if (ch != null) * { * string msg = "{0} has {1} hit points and is armed with {2}"; * Log.Info(msg + ".", ch.GetName(), (int)ch.Life, ch.ActiveHeldItem.Type.Name); * } */ } break; case State.Walk: intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.Move, MapPos()), false); //PlayerIntellect.Instance.SetTask(curObj, PlayerIntellect.TaskType.Move); break; default: if (curObj != null /*&& curObj != PlayerIntellect.Instance.ControlledObject*/) { VBCharacter tmpEnt = curObj as VBCharacter; if (tmpEnt != null) { intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.Talk, tmpEnt), false); /* * switch (tmpEnt.ConvType) * { * case RTSCharacter.ConversationType.BubbleChat: * tmpEnt.BubbleChat("I NEVER HAD MY ONE CHILD!"); * break; * case RTSCharacter.ConversationType.Conversation: * PlayerIntellect.Instance.SetTask(tmpEnt, PlayerIntellect.TaskType.Chat); * break; * * default: * break; * }*/ } } break; } } else { Dynamic obj = GetObject(); if (obj != null && obj as VBCharacter != null) { hudControl.selectedUnit = obj as VBCharacter; } } } else if (button == EMouseButtons.Right) { Dynamic obj = GetObject(); if (obj != null && cursorState > State.Walk) { hudControl.Controls.Add(new ObjectMenu(obj)); } else { ToggleCursor(); } } } return(base.OnMouseDown(button)); }