Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Blaze-Brigade
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Susan Yuen
Blaze-Brigade
Commits
14b751d8
Commit
14b751d8
authored
8 years ago
by
Susan Yuen
Browse files
Options
Downloads
Patches
Plain Diff
Changed screen size. Edited code format a little bit.
parent
c8604e06
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs
+13
-3
13 additions, 3 deletions
src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs
src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
+32
-42
32 additions, 42 deletions
src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
with
45 additions
and
45 deletions
src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs
+
13
−
3
View file @
14b751d8
...
...
@@ -9,13 +9,13 @@ namespace Controller
{
class
GameFunction
{
public
readonly
int
SCREEN_HEIGHT
=
50
0
;
public
readonly
int
SCREEN_WIDTH
=
50
0
;
public
readonly
int
SCREEN_HEIGHT
=
96
0
;
public
readonly
int
SCREEN_WIDTH
=
64
0
;
private
bool
playableUnitSelected
;
private
Unit
selectedUnit
;
private
Player
currentPlayer
;
private
bool
isAnimating
=
false
;
// indicates whether an animation sequence is on screen
// might not need; check if enemyUnitsInRange returns an empty list
public
bool
isAnEnemyUnitInRange
(
Unit
unit
)
...
...
@@ -88,6 +88,16 @@ namespace Controller
selectedUnit
=
unit
;
}
public
bool
getIsAnimating
()
{
return
isAnimating
;
}
public
void
setIsAnimating
(
bool
animating
)
{
isAnimating
=
animating
;
}
// checks if the node is attackable based on the unit's class and position
// I THINK THIS WOULD WORK MUCH SIMPLER BASED ON EQUIPPED WEAPON NOT UNIT TYPE!!
// IF logic < equippedweapon.range or IF logic < weapon with highest range.
...
...
This diff is collapsed.
Click to expand it.
src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
+
32
−
42
View file @
14b751d8
...
...
@@ -13,8 +13,6 @@ namespace Controller
{
class
MouseHandler
{
private
bool
isAnimating
=
false
;
// indicates whether an animation sequence is on screen
MouseState
lastMouseState
;
MouseState
currentMouseState
;
int
turnState
=
0
;
//0= no button selected, 1 = attack selected, 2 = move selected
...
...
@@ -27,14 +25,13 @@ namespace Controller
bool
validX
=
currentMouseState
.
X
<
gameFunction
.
SCREEN_WIDTH
&&
currentMouseState
.
X
>
0
;
bool
validY
=
currentMouseState
.
Y
<
gameFunction
.
SCREEN_HEIGHT
&&
currentMouseState
.
Y
>
0
;
// checks for single mouse click inside the window
if
(
lastMouseState
.
LeftButton
==
ButtonState
.
Released
&&
currentMouseState
.
LeftButton
==
ButtonState
.
Pressed
&&
validX
&&
validY
)
{
// do not react to user input if animation is on screen
if
(
i
sAnimating
)
if
(
gameFunction
.
getI
sAnimating
()
)
{
return
;
}
...
...
@@ -46,8 +43,6 @@ namespace Controller
// if player clicks after unit is already selected ...
if
(
gameFunction
.
isPlayableUnitSelected
())
{
// TODO: PATH FINDING
Node
startNode
=
graph
.
getNode
(
gameFunction
.
getSelectedUnit
().
getPosition
());
Node
endNode
=
graph
.
getNode
(
position
);
...
...
@@ -55,9 +50,9 @@ namespace Controller
{
updateUnitPosition
(
position
,
gameFunction
);
}
gameFunction
.
setPlayableUnitSelected
(
false
);
gameFunction
.
setSelectedUnit
(
null
);
setSelectedUnit
(
gameFunction
,
null
,
false
);
}
// if player clicks when no unit is selected ...
else
{
...
...
@@ -65,15 +60,21 @@ namespace Controller
Unit
unit
=
getPlayableUnitOnNodeClicked
(
graph
.
getNode
(
position
),
position
,
gameFunction
.
playerCurrentlyMoving
());
if
(
unit
!=
null
)
{
unit
.
setClickedOn
(
true
);
unit
.
setMenuOpen
(
true
);
gameFunction
.
setPlayableUnitSelected
(
true
);
gameFunction
.
setSelectedUnit
(
unit
);
setSelectedUnit
(
gameFunction
,
unit
,
true
);
}
}
}
}
// sets selection of unit state inside GameFunction and the unit itself
private
void
setSelectedUnit
(
GameFunction
gameFunction
,
Unit
unit
,
bool
selected
)
{
unit
.
setMenuOpen
(
selected
);
unit
.
setClickedOn
(
selected
);
gameFunction
.
setPlayableUnitSelected
(
selected
);
gameFunction
.
setSelectedUnit
(
unit
);
}
// if playable unit exists where user clicked, return it; else, return null
private
Unit
getPlayableUnitOnNodeClicked
(
Node
clickedNode
,
Vector2
positionClicked
,
Player
currentPlayer
)
{
...
...
@@ -106,23 +107,22 @@ namespace Controller
{
if
(
gameFunction
.
getSelectedUnit
().
getPosition
().
Item1
<
positionX
)
{
for
(
currentX
=
gameFunction
.
getSelectedUnit
().
getPosition
().
Item1
;
currentX
<=
positionX
;
currentX
++)
{
Thread
.
Sleep
(
500
);
gameFunction
.
getSelectedUnit
().
setPosition
(
currentX
,
currentY
);
Debug
.
Write
(
"X is: "
+
currentX
);
for
(
currentX
=
gameFunction
.
getSelectedUnit
().
getPosition
().
Item1
;
currentX
<=
positionX
;
currentX
++)
{
Thread
.
Sleep
(
500
);
gameFunction
.
getSelectedUnit
().
setPosition
(
currentX
,
currentY
);
Debug
.
Write
(
"X is: "
+
currentX
);
}
}
}
else
{
for
(
currentX
=
gameFunction
.
getSelectedUnit
().
getPosition
().
Item1
;
currentX
>=
positionX
;
currentX
--)
else
{
Thread
.
Sleep
(
500
);
gameFunction
.
getSelectedUnit
().
setPosition
(
currentX
,
currentY
);
Debug
.
Write
(
"X is: "
+
currentX
);
for
(
currentX
=
gameFunction
.
getSelectedUnit
().
getPosition
().
Item1
;
currentX
>=
positionX
;
currentX
--)
{
Thread
.
Sleep
(
500
);
gameFunction
.
getSelectedUnit
().
setPosition
(
currentX
,
currentY
);
Debug
.
Write
(
"X is: "
+
currentX
);
}
}
}
if
(
gameFunction
.
getSelectedUnit
().
getPosition
().
Item2
<
positionY
)
{
for
(
currentY
=
gameFunction
.
getSelectedUnit
().
getPosition
().
Item2
;
currentY
<=
positionY
;
currentY
++)
...
...
@@ -147,32 +147,22 @@ namespace Controller
}
}
public
void
Draw
(
GameTime
gametime
)
{
}
public
void
setAnimating
(
bool
animating
)
{
isAnimating
=
animating
;
}
//which dropdownmenu is selected
void
buttonAction
(
int
i
)
private
void
buttonAction
(
int
i
)
{
//take action corresponding to which button was clicked
//
take action corresponding to which button was clicked
switch
(
i
)
{
case
0
:
//if attack clicked
case
0
:
//
if attack clicked
turnState
=
1
;
break
;
case
1
:
//if moved is clicked
case
1
:
//
if moved is clicked
turnState
=
2
;
break
;
case
2
:
//if item is clicked
case
2
:
//
if item is clicked
turnState
=
3
;
break
;
case
3
:
//if wait is clicked
case
3
:
//
if wait is clicked
break
;
default
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment