public virtual void ToggleCursor() { //stop any task in progress if (cursorState != State.Walk && hudControl.selectedUnit != null) { RTSUnitAI intellect = hudControl.selectedUnit.Intellect as RTSUnitAI; intellect.DoTask(new RTSUnitAI.Task(RTSUnitAI.Task.Types.Stop), false); } switch (CursorState) { case State.Target: CursorState = State.Walk; break; case State.HUDDefault: if (CombatManager.Instance != null) { CursorState = State.Target; } else { CursorState = State.Walk; } break; case State.Walk: CursorState = State.HUDDefault; break; default: break; } }
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)); }