상속: HaxxitGameState
예제 #1
0
 public void OnProgramClick(DrawableRectangle rectangle)
 {
     Haxxit.Maps.Point haxxit_location = display_map_state.XnaPointToHaxxitPoint(rectangle.Area.Center);
     if (display_map_state.Map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(haxxit_location)
         && !display_map_state.Map.GetNode<Haxxit.Maps.ProgramHeadNode>(haxxit_location).Program.AlreadyRanCommand())
     {
         MapMovementGameState new_state = new MapMovementGameState(this, haxxit_location);
         _mediator_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
     }
 }
예제 #2
0
        // Sends all of the planned AI actions to the engine
        private void SendActions()
        {
            if (waitingToSend)
            {
                if (System.Environment.TickCount > departureTime)
                {
                    // We're ready to send an action to the engine
                    waitingToSend = false;
                    NotifyArgs args = turnActions.Peek();

                    // If we have an AI move, we need to push the MapMovementGameState so that the player has an indication before the actual move is issued
                    if (!pushedState && args.ArgsType == NotifyArgs.ArgType.Move)
                    {
                        pushedState = true;
                        Haxxit.Maps.MoveEventArgs moveEventArgs = (Haxxit.Maps.MoveEventArgs)args.EventArgsItem;
                        GameStates.MapMovementGameState new_state = new GameStates.MapMovementGameState(backgroundState, moveEventArgs.Start);
                        new_state.MoveAI = true;
                        _notifiable_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                    }

                    // If we have an AI command, we need to push the MapAttackGameState so that the player has an indication before the actual command is issued
                    else if (!pushedState && args.ArgsType == NotifyArgs.ArgType.Command)
                    {
                        pushedState = true;
                        Haxxit.Maps.CommandEventArgs commandEventArgs = (Haxxit.Maps.CommandEventArgs)args.EventArgsItem;
                        GameStates.MapAttackGameState new_state = new GameStates.MapAttackGameState(backgroundState, commandEventArgs.AttackerPoint, commandEventArgs.Command);
                        new_state.CommandAI = true;
                        _notifiable_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                    }

                    // We're either following up an overlayed state push with the actual event (move or command) or we're signalying the end of the AI's turn
                    else
                    {
                        pushedState = false;
                        args = turnActions.Dequeue();
                        _notifiable_manager.Notify(args.EventItem, args.ObjectItem, args.EventArgsItem);
                    }
                }
            }
            else if (turnActions.Any())
            {
                // We're ready to retrieve the next action
                waitingToSend = true;

                // Now handled A.S.A.P. since ACTIONSTALLTIME is used in move/command states
                departureTime = System.Environment.TickCount + 0;
            }
            else
            {
                // We've sent all the actions
                state = AIState.Waiting;
            }
        }
예제 #3
0
 public void OnMoveClick(DrawableRectangle rectangle)
 {
     Haxxit.Maps.Map map = user_map_state.display_map_state.Map;
     Haxxit.Maps.Point haxxit_location = user_map_state.display_map_state.XnaPointToHaxxitPoint(rectangle.Area.Center);
     Haxxit.Maps.Point direction = haxxit_location - selected_program;
     if (map.CanMoveProgram(selected_program, direction))
     {
         _mediator_manager.Notify("haxxit.map.move", this, new Haxxit.Maps.MoveEventArgs(selected_program, direction));
         if (map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(haxxit_location)
             && !map.GetNode<Haxxit.Maps.ProgramHeadNode>(haxxit_location).Program.AlreadyRanCommand())
         {
             MapMovementGameState new_state = new MapMovementGameState(user_map_state, haxxit_location);
             _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
         }
         else
         {
             _mediator_manager.Notify("haxxit.engine.state.pop", this, new EventArgs());
         }
     }
 }