Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        /*
         * 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;
            }
        }
Esempio n. 3
0
        protected override bool OnMouseDoubleClick(EMouseButtons button)
        {
            if (IsMouseInControlArea() && button == EMouseButtons.Left && hudControl.selectedUnit != null)
            {
                RTSUnitAI intellect = hudControl.selectedUnit.Intellect as RTSUnitAI;

                hudControl.selectedUnit.IsRunning = true;
                return(true);
            }


            return(base.OnMouseDoubleClick(button));
        }
Esempio n. 4
0
        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));
        }