Exemplo n.º 1
0
/*
    Function: vUnitMenu_InitSelect

    Description -
    Initialise the menu to be in the select state. The state where the player can
    select units and change their ai.

    1 argument:
    Unit_Menu *menu - The unit menu to initialise to the select state.
*/
void vUnitMenu_InitSelect(Unit_Menu *menu)
{
    Vent_Game *game = menu->currentGame;
    Camera_2D *camera = &game->camera;
    Vent_Unit *playerUnit = game->playerUnit;

    menu->state = UMENU_STATE_SELECT;

    /*Disable the overlay*/
    uiSpine_OpenTemplate(&menu->spine, "Select", SELECT_ON);

    /*Ensure that the mouse pointer is on*/
    uiPointer_Unclamp(&menu->pointer);
    uiPointer_SetDraw(&menu->pointer, 1);

    /*Force the origin of the state scroll to be the select state*/
    uiButtonScroll_SetOrigin(uiSpine_GetEntity(&menu->spine, "Scroll:State"), 1);

    /*Set the pointer to the player*/
    uiPointer_SetPos(menu->spine.pnt, 1, playerUnit->middlePosition.x - camera->iPosition.x, playerUnit->middlePosition.y - camera->iPosition.y);

    /*Reset the selected unit list*/
    list_Clear(&menu->selectedUnits);
    menu->numSelected = 0;

    control_Stop(&menu->cSelect, 500);

    return;
}
Exemplo n.º 2
0
/*
    Function: vUnitMenu_Select

    Description -
    Select a unit/s in the game at the ui pointers position.

    1 argument:
    Unit_Menu *menu - The unit menu containing the data needed to select units.
*/
static int vUnitMenu_Select(Unit_Menu *menu)
{
    Vent_Game *game = menu->currentGame;
    Vent_Side *playerSide = &game->side[game->playerUnit->team];

    Vent_Unit *u = NULL;
    struct list *unitList = NULL;

    /*Unit select origin*/
    Vector2DInt position = {menu->pntPos.x, menu->pntPos.y};

    /*Set the amount selected to 0*/
    list_Clear(&menu->selectedUnits);
    menu->numSelected = 0;

    /*For all the units in the players side*/
    unitList = playerSide->units;

    while(unitList != NULL)
    {
        u = unitList->data;

        /*If the unit collides with the curser and its not the player*/
        if(u->isPlayer == 0 && collisionStatic_CircRectInt(position.x, position.y, &menu->selectRadius, u->iPosition.x, u->iPosition.y, u->width, u->height) == 1)
        {
            /*Place it into the selected list and update the counter*/
            menu->numSelected ++;
            list_Push(&menu->selectedUnits, u, 0);
        }

        unitList = unitList->next;
    }

    return menu->numSelected;
}
void daemon_compute_render_nodes(struct razer_daemon *daemon)
{
	//struct razer_queue *queue = daemon_create_queue();
	list *queue = list_Create(0,0);
	list_Clear(daemon->render_nodes);
	struct razer_fx_render_node *rn = daemon_get_render_node(daemon,daemon->frame_buffer_linked_uid);
	if(rn)
	{
		list_Queue(queue,rn);
		daemon_compute_append_queue(daemon,queue);
	}
	//daemon_free_queue(&queue);
	list_Close(queue);
	daemon->is_render_nodes_dirty = 0;
}
Exemplo n.º 4
0
/*
    Function: vUnitMenu_Clean

    Description -
    Clean up the unit menu.

    1 arguments:
    Unit_Menu *menu - The unit menu to clean
*/
void vUnitMenu_Clean(Unit_Menu *menu)
{
    int x = 0;

    uiSpine_Clean(&menu->spine);

    uiPointer_Clean(&menu->pointer);

    for(x = 0; x < UNIT_ENDTYPE; x++)
    {
        sprite_Clean(&menu->sUnitBox[x]);
    }

    control_Clean(&menu->cSelect);
    control_Clean(&menu->cChangeAi);
    control_Clean(&menu->cBack);

    list_Clear(&menu->selectedUnits);

    return;
}
Exemplo n.º 5
0
/*
    Function: vUnitMenu_Update

    Description -
    Update the unit menu.

    3 arguments:
    Unit_Menu *menu - The unit menu to update.
    Base_State *bs - The base state of the main game.
    float deltaTime - The delta time of each call to this function.
*/
void vUnitMenu_Update(Unit_Menu *menu, Base_State *bs, float deltaTime)
{
    Vent_GameState *vgs = bs->info;
    Vent_Game *game = menu->currentGame;
    Ui_ButtonScroll *scroll = NULL;

    Vector2D pntPos = {0.0f, 0.0f};

    /*Update the main ui of the menu*/
    uiSpine_Update(&menu->spine, deltaTime);

    /*Update the pointer position*/
    uiPointer_Update(&menu->pointer, deltaTime);
    pntPos = uiPointer_GetPos(&menu->pointer);
    menu->pntPos.x = (int)pntPos.x + game->camera.iPosition.x;
    menu->pntPos.y = (int)pntPos.y + game->camera.iPosition.y;


    if(control_IsActivated(&menu->cChangeAi) == 1)
    {
        scroll = uiSpine_GetEntity(&menu->spine, "Scroll:Ai");
        uiButtonScroll_ForceSelect(scroll, 0);
        uiButtonScroll_IncreaseSelected(scroll);
        uiButtonScroll_ForceSelect(scroll, -1);
    }

    /*Logic depends on which state the menu is in*/
    switch(menu->state)
    {
        case UMENU_STATE_BASE:

        /*Go back to the game*/
        if(control_IsActivated(&menu->cBack) == 1)
        {
            bs->render = Game_Render;
            bs->logic = Game_Logic;

            timer_Resume(&vgs->game.gTimer);
        }

        if(control_IsActivated(&menu->cSelect) == 1)
        {
            switch(menu->subState)
            {
                case UMENU_SUBSTATE_BUY:

                UM_SetState(menu, UMENU_STATE_PLACE);

                break;

                case UMENU_SUBSTATE_SELECT:

                UM_SetState(menu, UMENU_STATE_SELECT);

                break;
            }
        }

        break;

        case UMENU_STATE_PLACE:

        /*Buy a unit*/
        if(control_IsActivated(&menu->cSelect) == 1)
        {
            vUnitMenu_Purchase(menu);
        }

        /*Go back to the base state of the menu*/
        if(control_IsActivated(&menu->cBack) == 1)
        {
            UM_SetState(menu, UMENU_STATE_BASE);
        }

        vUnitMenu_ScrollCamera(menu, &vgs->game.camera, deltaTime);

        break;

        case UMENU_STATE_SELECT:

        /*Select a unit*/
        if(control_IsActivated(&menu->cSelect) == 1)
        {
            /*If no units or selected then collision detect search for them*/
            if(menu->numSelected == 0)
            {
                vUnitMenu_Select(menu);
            }
            else /*Otherwise give the currently selected units ai*/
            {
                /*Give the ai to the selected units*/
                vUnitMenu_GiveAiList(menu, menu->selectedUnits);

                /*Confirm that the selected units have been given an ai*/
                text_Draw_Arg(115, 75, ker_Screen(), font_Get(2, 13), &tColourWhite, VL_HUD + 2, 1000, "Ai set");
            }
        }

        /*Go back to the base state of the menu, or if units are select, unselect them*/
        if(control_IsActivated(&menu->cBack) == 1)
        {
            if(menu->numSelected == 0)
            {
                UM_SetState(menu, UMENU_STATE_BASE);
            }
            else
            {
                menu->numSelected = 0;
                list_Clear(&menu->selectedUnits);
            }
        }

        vUnitMenu_ScrollCamera(menu, &vgs->game.camera, deltaTime);

        break;
    }

    return;
}