Example #1
0
 void drawP4Slot()
 {
     if (GUI.Button(P4SlotRect, ControllerSlotTexture, ""))
     {
         if (errorState == ErrorState.None)             // if it's not in an error state
         {
             // Toggle selecting for the slot
             if (CurrentlySelecting == SelectingState.None)
             {
                 if (Slot4Selection == ControllerSelectionState.None)
                 {
                     CurrentlySelecting = SelectingState.P4;                         // toggle
                 }
                 else
                 {
                     Slot4Selection = ControllerSelectionState.None;                         // reset slot
                 }
             }
             else if (CurrentlySelecting == SelectingState.P4)
             {
                 CurrentlySelecting = SelectingState.None;
             }
         }
     }
 }
 public override void Evaluate(Microsoft.Xna.Framework.GameTime gt)
 {
     if (m_Camera != null && m_SelectionState == SelectingState.Finished)
     {
         foreach (Tantric.World.WorldLayer layer in Orchestra.Layers)
         {
             foreach (Tantric.World.WorldObject obj in layer.Objects.Values)
             {
                 if (obj is World.Objects.Human.HumanAssembler)
                 {
                     if (obj.Position.X > m_SelectionBox.X + m_Camera.Position.X && obj.Position.X < m_SelectionBox.Z + m_Camera.Position.X)
                     {
                         if (obj.Position.Y > m_SelectionBox.Y + m_Camera.Position.Y && obj.Position.Y < m_SelectionBox.W + m_Camera.Position.Y)
                         {
                             if (!m_Selected.Contains(obj as World.Objects.Human.HumanAssembler))
                             {
                                 m_Selected.Add(obj as World.Objects.Human.HumanAssembler);
                             }
                         }
                     }
                 }
             }
         }
         m_SelectionBox.X = m_SelectionBox.Y = m_SelectionBox.Z = m_SelectionBox.W = 0;
         m_SelectionState = SelectingState.Idle;
     }
     if (m_Camera == null && Orchestra != null)
     {
         m_Camera = Orchestra.Camera;
     }
 }
Example #3
0
    void drawC4Icon()
    {
        if (Slot1Selection == ControllerSelectionState.C4)
        {
            GUI.DrawTexture(P1SlotRect, C4Texture);
        }
        else if (Slot2Selection == ControllerSelectionState.C4)
        {
            GUI.DrawTexture(P2SlotRect, C4Texture);
        }
        else if (Slot3Selection == ControllerSelectionState.C4)
        {
            GUI.DrawTexture(P3SlotRect, C4Texture);
        }
        else if (Slot4Selection == ControllerSelectionState.C4)
        {
            GUI.DrawTexture(P4SlotRect, C4Texture);
        }
        else         // Draw it as a button if there's enough controllers, otherwise draw it as a texture
        {
            if (numOfControllers >= 4)
            {
                if (GUI.Button(C4SlotRect, C4Texture, ""))
                {
                    if (errorState == ErrorState.None)                     // if it's not in an error state
                    {
                        if (CurrentlySelecting == SelectingState.P1)
                        {
                            Slot1Selection = ControllerSelectionState.C4;
                        }
                        else if (CurrentlySelecting == SelectingState.P2)
                        {
                            Slot2Selection = ControllerSelectionState.C4;
                        }
                        else if (CurrentlySelecting == SelectingState.P3)
                        {
                            Slot3Selection = ControllerSelectionState.C4;
                        }
                        else if (CurrentlySelecting == SelectingState.P4)
                        {
                            Slot4Selection = ControllerSelectionState.C4;
                        }

                        if (CurrentlySelecting != SelectingState.None)
                        {
                            CurrentlySelecting = SelectingState.None;
                        }
                    }
                }
            }
            else
            {
                GUI.DrawTexture(C4SlotRect, C4DarkTexture);
            }
        }
    }
Example #4
0
        public Order()
        {
            selectingState = new SelectingState(this);
            supplyingDeliveryDetailsState = new SupplyingDeliveryDetailsState(this);
            orderPickingState = new OrderPickingState(this);
            readyForShippingState = new ReadyForShippingState(this);
            shippedState = new ShippedState(this);

            state = selectingState;
        }
Example #5
0
        public Order()
        {
            selectingState = new SelectingState(this);
            supplyingDeliveryDetailsState = new SupplyingDeliveryDetailsState(this);
            orderPickingState             = new OrderPickingState(this);
            readyForShippingState         = new ReadyForShippingState(this);
            shippedState = new ShippedState(this);

            state = selectingState;
        }
Example #6
0
    /*******\
    * START *
    \*******/
    void Start()
    {
        int buttonHeight = (int)(Screen.height * 0.15);
        int buttonWidth  = (int)((float)ControllerSlotTexture.width * ((float)buttonHeight / (float)ControllerSlotTexture.height));        // Set the width based on the height ratio
        int vertSpacing  = (int)(Screen.height * 0.08);
        int horzSpacing  = (int)((Screen.width - (buttonWidth * 4)) / 6);

        //Initialize the rect positions
        P1LabelRect = new Rect(horzSpacing, vertSpacing, buttonWidth, buttonHeight);
        P2LabelRect = new Rect(horzSpacing, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        P3LabelRect = new Rect(horzSpacing, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        P4LabelRect = new Rect(horzSpacing, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        P1SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing, buttonWidth, buttonHeight);
        P2SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        P3SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        P4SlotRect = new Rect(horzSpacing * 2 + buttonWidth, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        KB1SlotRect    = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing, buttonWidth, buttonHeight);
        C1SlotRect     = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        C3SlotRect     = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        SaveButtonRect = new Rect(horzSpacing * 4 + buttonWidth * 2, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        KB2SlotRect      = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing, buttonWidth, buttonHeight);
        C2SlotRect       = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing * 2 + buttonHeight, buttonWidth, buttonHeight);
        C4SlotRect       = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight);
        CancelButtonRect = new Rect(horzSpacing * 5 + buttonWidth * 3, vertSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight);

        int errorHeight = Screen.height / 2;
        int errorWidth  = (int)((float)Error1.width * ((float)errorHeight / (float)Error1.height));

        ErrorRect = new Rect((Screen.width - errorWidth) / 2, (Screen.height - errorHeight) / 2, errorWidth, errorHeight);


        // Initialize the slot states by getting the storage object
        InitializeStorage storage = (InitializeStorage)GameObject.Find("VariableStorage").GetComponent(typeof(InitializeStorage));

        InitializeStorage.ControllerSelection storedP1Controller = storage.P1Controller;
        InitializeStorage.ControllerSelection storedP2Controller = storage.P2Controller;
        InitializeStorage.ControllerSelection storedP3Controller = storage.P3Controller;
        InitializeStorage.ControllerSelection storedP4Controller = storage.P4Controller;

        Slot1Selection = (ControllerSelectionState)((int)storedP1Controller);
        Slot2Selection = (ControllerSelectionState)((int)storedP2Controller);
        Slot3Selection = (ControllerSelectionState)((int)storedP3Controller);
        Slot4Selection = (ControllerSelectionState)((int)storedP4Controller);

        numOfControllers = storage.numOfControllers;

        // Initialize the what the player is currently selecting
        CurrentlySelecting = SelectingState.None;

        errorState = ErrorState.None;
    }
Example #7
0
    void drawKB2Icon()
    {
        if (Slot1Selection == ControllerSelectionState.KB2)
        {
            GUI.DrawTexture(P1SlotRect, KB2Texture);
        }
        else if (Slot2Selection == ControllerSelectionState.KB2)
        {
            GUI.DrawTexture(P2SlotRect, KB2Texture);
        }
        else if (Slot3Selection == ControllerSelectionState.KB2)
        {
            GUI.DrawTexture(P3SlotRect, KB2Texture);
        }
        else if (Slot4Selection == ControllerSelectionState.KB2)
        {
            GUI.DrawTexture(P4SlotRect, KB2Texture);
        }
        else         // Draw it as a button
        {
            if (GUI.Button(KB2SlotRect, KB2Texture, ""))
            {
                if (errorState == ErrorState.None)                 // if it's not in an error state
                {
                    if (CurrentlySelecting == SelectingState.P1)
                    {
                        Slot1Selection = ControllerSelectionState.KB2;
                    }
                    else if (CurrentlySelecting == SelectingState.P2)
                    {
                        Slot2Selection = ControllerSelectionState.KB2;
                    }
                    else if (CurrentlySelecting == SelectingState.P3)
                    {
                        Slot3Selection = ControllerSelectionState.KB2;
                    }
                    else if (CurrentlySelecting == SelectingState.P4)
                    {
                        Slot4Selection = ControllerSelectionState.KB2;
                    }

                    if (CurrentlySelecting != SelectingState.None)
                    {
                        CurrentlySelecting = SelectingState.None;
                    }
                }
            }
        }
    }
        public void Initialize()
        {
            _location         = new Point(1, 1);
            _location2        = new Point(5, 5);
            _selectionManager = new Mock <ISelectionManager>();
            _selectionManager
            .Setup(m => m
                   .CreateSelection(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns((int x, int y, int width, int height) => {
                return(new Selection(new Rectangle(x, y, width, height), ZIndex));
            });
            _buffer = Int32.Parse(ConfigurationManager.AppSettings[Constants.BufferAppSetting]);

            _state = new SelectingState(_selectionManager.Object, _location);
        }
Example #9
0
    public void Initialize(InputSystem input, Board board, Worker.Colour colour)
    {
        _input   = input;
        _board   = board;
        _workers = new List <Worker>();
        _colour  = colour;

        _god = new BaseGod();

        _stateMachine = new StateMachine();
        _stateMachine.Initialize(input, board);

        WaitingState waitingState = new WaitingState();

        _stateMachine.RegisterState(waitingState);

        PlacingState placingState = new PlacingState();

        _stateMachine.RegisterState(placingState);

        SelectingState selectingState = new SelectingState();

        _stateMachine.RegisterState(selectingState);

        MovingState movingState = new MovingState();

        _stateMachine.RegisterState(movingState);

        BuildingState buildingState = new BuildingState();

        _stateMachine.RegisterState(buildingState);

        WaitingOnConfirmationState waitingOnConfirmationState = new WaitingOnConfirmationState();

        _stateMachine.RegisterState(waitingOnConfirmationState);

        DoneTurnState doneTurnState = new DoneTurnState();

        _stateMachine.RegisterState(doneTurnState);

        _stateMachine.SetState((int)StateId.Waiting);
    }
        public override void ProcessInput(string Pressed, Microsoft.Xna.Framework.Vector2 Mouse)
        {
            // TODO: Clean up formation algorithm
            // TODO; Redesign input, it's ugly.
            #region Formation
            if (m_Selected != null && Pressed == "Mouse_Right" && m_Camera != null)
            {
                Microsoft.Xna.Framework.Vector2 offset = new Microsoft.Xna.Framework.Vector2();
                Microsoft.Xna.Framework.Vector2 formationOrientation = new Microsoft.Xna.Framework.Vector2();
                Microsoft.Xna.Framework.Vector2 flippedOrientation   = new Microsoft.Xna.Framework.Vector2();
                Microsoft.Xna.Framework.Vector2 clickedLocation      = (m_Camera.Position + Mouse);
                float averageX    = 0;
                float averageY    = 0;
                int   numberUnits = m_Selected.Count;
                int   rows        = 4;
                int   spacing     = 100;
                float counterX    = -.5f * (Math.Min(numberUnits, rows) - 1);
                if (counterX < rows * -.5f)
                {
                    counterX = rows * -.5f;
                }
                float counterY = 0;
                foreach (Tantric.Logic.Unit unit in m_Selected)
                {
                    averageX += unit.Position.X;
                    averageY += unit.Position.Y;
                }
                averageX /= numberUnits;
                averageY /= numberUnits;

                formationOrientation = clickedLocation - new Microsoft.Xna.Framework.Vector2(averageX, averageY);
                formationOrientation.Normalize();
                flippedOrientation.X = -formationOrientation.Y;
                flippedOrientation.Y = formationOrientation.X;

                foreach (Tantric.Logic.Unit unit in m_Selected)
                {
                    offset  = (flippedOrientation * counterX) * spacing;
                    offset += -formationOrientation * counterY * spacing;
                    unit.AddGoal(new Tantric.Logic.UnitGoal("MoveTo", true, -1, clickedLocation + offset));
                    counterX += 1;
                    if (counterX > (rows - 1) * .5)
                    {
                        numberUnits -= rows;
                        counterX     = -.5f * (Math.Min(numberUnits, rows) - 1);
                        if (counterX < rows * -.5f)
                        {
                            counterX = rows * -.5f;
                        }
                        counterY += 1;
                    }
                }
            }
            #endregion

            if (Pressed == "Mouse_Left" && m_SelectionState == SelectingState.Idle)
            {
                m_SelectionBox.X = Mouse.X;
                m_SelectionBox.Y = Mouse.Y;
                m_SelectionState = SelectingState.Started;
                m_Selected.Clear();
            }
            else if (Pressed == "Mouse_Left" && m_SelectionState == SelectingState.Started)
            {
                m_SelectionBox.Z = Mouse.X;
                m_SelectionBox.W = Mouse.Y;
            }
            else
            {
                m_SelectionState = SelectingState.Finished;
            }
            if (m_Camera != null && Pressed == "Camera_Left")
            {
                m_Camera.Translate(new Microsoft.Xna.Framework.Vector2(-1, 0) * World.Objects.Human.HumanStatistics.GetStatistic("Camera", "Speed"));
            }
            if (m_Camera != null && Pressed == "Camera_Right")
            {
                m_Camera.Translate(new Microsoft.Xna.Framework.Vector2(1, 0) * World.Objects.Human.HumanStatistics.GetStatistic("Camera", "Speed"));
            }
            if (m_Camera != null && Pressed == "Camera_Up")
            {
                m_Camera.Translate(new Microsoft.Xna.Framework.Vector2(0, -1) * World.Objects.Human.HumanStatistics.GetStatistic("Camera", "Speed"));
            }
            if (m_Camera != null && Pressed == "Camera_Down")
            {
                m_Camera.Translate(new Microsoft.Xna.Framework.Vector2(0, 1) * World.Objects.Human.HumanStatistics.GetStatistic("Camera", "Speed"));
            }
        }