Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OriginalGladiator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Ryan Hoppe (rmh898)
OriginalGladiator
Commits
0f703872
Commit
0f703872
authored
8 years ago
by
Ryan Hoppe (rmh898)
Browse files
Options
Downloads
Patches
Plain Diff
A few proposed weapon stats tossed in the arena control script
parent
120eb803
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ArenaCombatControl.cs
+153
-0
153 additions, 0 deletions
ArenaCombatControl.cs
with
153 additions
and
0 deletions
ArenaCombatControl.cs
0 → 100644
+
153
−
0
View file @
0f703872
using
UnityEngine
;
using
System.Collections
;
public
class
ArenaCombatControl
:
MonoBehaviour
{
private
Rigidbody2D
Player
;
private
Animator
myAnimator
;
[
SerializeField
]
private
float
speed
;
private
bool
LookRight
=
true
;
private
bool
canMove
=
true
;
private
float
attackSpeedCooldown
;
// fields to modify player stats based on weapons
public
WeaponStats
[]
weapons
;
public
int
currentWeapon
=
0
;
// Use this for initialization
void
Start
()
{
weapons
[
currentWeapon
].
attackSpeed
=
1f
;
Player
=
GetComponent
<
Rigidbody2D
>();
myAnimator
=
GetComponent
<
Animator
>();
//required for animation *******
SetWeaponStats
();
}
// Update is called once per frame
void
Update
()
{
float
h
=
Input
.
GetAxis
(
"Horizontal"
);
float
i
=
Input
.
GetAxis
(
"Vertical"
);
Movement
(
h
);
FlipPlayer
(
h
);
RotatePlayerZaxis
(
h
);
Attack
();
Block
();
Jump
();
}
//controlling the characters movement
private
void
Movement
(
float
horizontal
)
{
if
(
canMove
)
{
Player
.
velocity
=
new
Vector2
(
speed
*
horizontal
,
Player
.
velocity
.
y
);
myAnimator
.
SetFloat
(
"speed"
,
(
Mathf
.
Abs
(
horizontal
)));
//required for animation *******
}
}
private
void
Attack
()
{
attackSpeedCooldown
-=
Time
.
deltaTime
;
if
(
Input
.
GetKeyDown
(
KeyCode
.
Space
)
&&
attackSpeedCooldown
<=
0
)
{
attackSpeedCooldown
=
weapons
[
currentWeapon
].
attackSpeed
;
myAnimator
.
SetBool
(
"attack"
,
true
);
}
else
{
myAnimator
.
SetBool
(
"attack"
,
false
);
}
}
private
void
Block
()
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
E
))
{
myAnimator
.
SetBool
(
"block"
,
true
);
Player
.
velocity
=
Vector2
.
zero
;
canMove
=
false
;
}
if
(
Input
.
GetKeyUp
(
KeyCode
.
E
))
{
myAnimator
.
SetBool
(
"block"
,
false
);
canMove
=
true
;
}
}
private
void
Jump
()
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
W
))
{
Player
.
AddForce
(
new
Vector2
(
0
,
500
));
}
}
//faces the characters body in the appropriate direction
private
void
FlipPlayer
(
float
horizontal
)
{
if
(
horizontal
>
0
&&
!
LookRight
||
horizontal
<
0
&&
LookRight
)
{
LookRight
=
!
LookRight
;
Vector3
theScale
=
transform
.
localScale
;
theScale
.
x
*=
-
1
;
transform
.
localScale
=
theScale
;
}
}
//keeps the character from falling over
private
void
RotatePlayerZaxis
(
float
horizonal
)
{
Vector3
myRotation
=
gameObject
.
transform
.
rotation
.
eulerAngles
;
Vector3
Pos
=
transform
.
localPosition
;
//if the player does not need to be climbing up an angle, the character will be fixed upright
if
(
Pos
.
x
<
-
4f
||
Pos
.
x
>
5f
)
{
transform
.
localRotation
=
Quaternion
.
Euler
(
0
,
0
,
0
);
}
else
{
//allows the character to rotate but not past 90 degrees either direction when climbing
if
(
myRotation
.
z
>
90
)
{
myRotation
.
z
=
Mathf
.
Clamp
(
0
,
0
,
0
);
transform
.
rotation
=
Quaternion
.
Euler
(
myRotation
);
}
if
(
myRotation
.
z
<
-
90
)
{
myRotation
.
z
=
Mathf
.
Clamp
(
0
,
0
,
0
);
transform
.
rotation
=
Quaternion
.
Euler
(
myRotation
);
}
}
}
//a few proposed weapon stats
private
void
SetWeaponStats
()
{
weapons
[
1
].
damageMin
=
1
;
weapons
[
1
].
damageMax
=
5
;
weapons
[
1
].
attackSpeed
=
1
;
weapons
[
2
].
damageMin
=
2
;
weapons
[
2
].
damageMax
=
5
;
weapons
[
2
].
attackSpeed
=
2
;
weapons
[
3
].
damageMin
=
3
;
weapons
[
3
].
damageMax
=
6
;
weapons
[
3
].
attackSpeed
=
2
;
weapons
[
4
].
damageMin
=
3
;
weapons
[
4
].
damageMax
=
4
;
weapons
[
4
].
attackSpeed
=
4
;
weapons
[
5
].
damageMin
=
6
;
weapons
[
5
].
damageMax
=
12
;
weapons
[
5
].
attackSpeed
=
1
;
weapons
[
6
].
damageMin
=
5
;
weapons
[
6
].
damageMax
=
10
;
weapons
[
6
].
attackSpeed
=
3
;
}
}
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