-
Notifications
You must be signed in to change notification settings - Fork 1
/
Delete.cpp
53 lines (43 loc) · 1.43 KB
/
Delete.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Delete.h"
#include "Input.h"
#include "Output.h"
#include "GameObject.h"
Delete::Delete(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
pManager = pApp;
}
Delete::~Delete()
{
}
void Delete::ReadActionParameters()
{
// Get a Pointer to the Input / Output Interfaces
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
// Read the GameObjCell parameter
pOut->PrintMessage("Deleting GameObject: Click on its Cell ...");
GameObjCell = pIn->GetCellClicked();
bool HasGameObj = pGrid->getobject(GameObjCell);
///Make the needed validations on the read parameters
if (GameObjCell.IsValidCell() == 0 || HasGameObj==0)
{
pGrid->PrintErrorMessage("Error: Invalid Cell/ Cell does not have game object...");
return;
}
// Clear messages
pOut->ClearStatusBar();
}
// Execute the action
void Delete::Execute()
{
// The first line of any Action Execution is to read its parameter first
// and hence initializes its data members
ReadActionParameters();
Grid* pGrid = pManager->GetGrid(); // We get a pointer to the Grid from the ApplicationManager
//Remove the game object from the cell
pGrid->RemoveObjectFromCell(GameObjCell);
// Here, the gameobject is successfull removed from the cell, so we finished executing the DeleteGameObject
pGrid->UpdateInterface();
}