Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
four
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
31
Issues
31
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
gadig
four
Commits
781857a8
Commit
781857a8
authored
Nov 17, 2016
by
tmorga18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged the fireball and watershield actions into one script
parent
0b883507
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
46 deletions
+120
-46
Assets/Prefabs/Ability - Water Shield Projectile.prefab
Assets/Prefabs/Ability - Water Shield Projectile.prefab
+0
-0
Assets/Prefabs/Ability - Water Shield Projectile.prefab.meta
Assets/Prefabs/Ability - Water Shield Projectile.prefab.meta
+8
-0
Assets/Prefabs/Ability - Water Shield.prefab
Assets/Prefabs/Ability - Water Shield.prefab
+0
-0
Assets/Prefabs/Ability - Water Shield.prefab.meta
Assets/Prefabs/Ability - Water Shield.prefab.meta
+8
-0
Assets/script/Actions.cs
Assets/script/Actions.cs
+47
-46
Assets/sprite/Gadic_Four_WaterShieldSprite.png
Assets/sprite/Gadic_Four_WaterShieldSprite.png
+0
-0
Assets/sprite/Gadic_Four_WaterShieldSprite.png.meta
Assets/sprite/Gadic_Four_WaterShieldSprite.png.meta
+57
-0
No files found.
Assets/Prefabs/Ability - Water Shield Projectile.prefab
0 → 100644
View file @
781857a8
File added
Assets/Prefabs/Ability - Water Shield Projectile.prefab.meta
0 → 100644
View file @
781857a8
fileFormatVersion: 2
guid: 20fb6f28ca90a4a9492d76f7f0042220
timeCreated: 1478844848
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Assets/Prefabs/Ability - Water Shield.prefab
0 → 100644
View file @
781857a8
File added
Assets/Prefabs/Ability - Water Shield.prefab.meta
0 → 100644
View file @
781857a8
fileFormatVersion: 2
guid: afa3b25f0de7541cb9c01e694f6778e1
timeCreated: 1477008989
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Assets/script/Actions.cs
View file @
781857a8
...
...
@@ -4,34 +4,24 @@ using UnityEngine.UI;
public
class
Actions
:
MonoBehaviour
{
// The array full of the character's abilities
public
GameObject
[]
abilities
=
new
GameObject
[
4
];
public
GameObject
[]
abilities
=
new
GameObject
[
4
];
// The array full of the character's abilities
public
GameObject
currentAbility
=
null
;
// Which ability is currently active
private
int
abilitiesCounter
=
0
;
// A counter which lets you cycle through the abilities
public
Image
abilitiesImage
;
// Picture which shows which ability it active
// *** Choose Ability ***
// Which ability is currently active
public
GameObject
currentAbility
=
null
;
// A counter which lets you cycle through the abilities
public
int
abilitiesCounter
=
0
;
// Picture which shows which ability it active
public
Image
abilitiesImage
;
private
Color
abilityUnusable
;
private
Color
abilityUsable
;
// *** RotateAbilities ***
// The axis around which the abilities rotate
private
Vector3
zAxis
=
new
Vector3
(
0
,
0
,
1
);
// The point around which the abilities rotate
public
GameObject
center
;
public
int
fireballSpeed
=
5
;
public
GameObject
waterShieldPrefab
;
public
bool
waterShieldUsable
=
true
;
private
float
waterShieldTimer
=
0.0f
;
public
float
waterShieldCooldown
=
5.0f
;
private
Color
abilityUnusable
;
private
Color
abilityUsable
;
private
Vector3
LastInput
;
void
Start
()
{
// Set the initial ability to something so that it's not null
CycleAbility
();
...
...
@@ -43,6 +33,12 @@ public class Actions : MonoBehaviour {
void
Update
()
{
RaycastHit2D
hit
=
Physics2D
.
Raycast
(
transform
.
position
,
GetLastDirection
());
Debug
.
DrawRay
(
transform
.
position
,
GetLastDirection
(),
Color
.
red
);
// Constantly check where the player is facing
GetLastDirection
();
if
(
Input
.
GetButtonDown
(
"Fire1"
))
{
UseAbility
(
currentAbility
.
name
);
}
...
...
@@ -61,15 +57,12 @@ public class Actions : MonoBehaviour {
// If the player presses the button to choose an ability...
if
(
Input
.
GetButtonDown
(
"Fire2"
))
{
// Increment the counter
abilitiesCounter
++;
// Call the ChooseAbility() function
CycleAbility
();
// A loop which will rotate each of the abilities in the array
foreach
(
GameObject
ability
in
abilities
)
{
StartCoroutine
(
RotateAbility
(
ability
));
}
}
}
...
...
@@ -81,51 +74,59 @@ public class Actions : MonoBehaviour {
if
(
abilitiesCounter
>
abilities
.
Length
-
1
)
{
abilitiesCounter
=
0
;
}
// Set the currentAbility to the one chosen by the abilitiesCounter
currentAbility
=
abilities
[
abilitiesCounter
];
// Set the image of the gameObject of the ability equal to the picture of the currentAbility
abilitiesImage
.
GetComponent
<
Image
>().
sprite
=
currentAbility
.
GetComponent
<
SpriteRenderer
>().
sprite
;
}
IEnumerator
RotateAbility
(
GameObject
ability
)
{
// Initially set the rotationCounter to 0
float
rotationCounter
=
0
;
// This loop will rotate each element around a center pivot point
while
(
rotationCounter
<=
8
)
{
ability
.
transform
.
RotateAround
(
center
.
transform
.
position
,
zAxis
,
10f
);
rotationCounter
++;
yield
return
new
WaitForSeconds
(
0.000000001f
);
}
}
public
void
UseAbility
(
string
myCurrentAbility
)
{
Debug
.
Log
(
myCurrentAbility
);
switch
(
myCurrentAbility
)
{
case
"Fireball"
:
Debug
.
Log
(
"Casting fireball!"
);
case
"Ability - Fireball"
:
GameObject
clone
=
Instantiate
(
currentAbility
,
this
.
transform
.
position
,
Quaternion
.
identity
)
as
GameObject
;
clone
.
GetComponent
<
FireballProjectile
>().
move
=
LastInput
;
clone
.
GetComponent
<
FireballProjectile
>().
speed
=
fireballSpeed
;
break
;
case
"Water Shield"
:
case
"Ability - Water Shield"
:
if
(
waterShieldUsable
==
true
)
{
GameObject
myShield
=
(
GameObject
)
Instantiate
(
waterShieldPrefab
,
transform
.
position
,
Quaternion
.
identity
);
GameObject
myShield
=
(
GameObject
)
Instantiate
(
currentAbility
,
transform
.
position
,
Quaternion
.
identity
);
WaterShield
waterShield
=
myShield
.
GetComponent
<
WaterShield
>();
waterShield
.
mainCharacter
=
this
.
gameObject
.
transform
;
waterShieldUsable
=
false
;
}
break
;
case
"Rock"
:
case
"Ability - Rock"
:
Debug
.
Log
(
"Throwing a rock!"
);
break
;
case
"Breath of Air"
:
case
"Ability - Breath of Air"
:
Debug
.
Log
(
"Casting breath of air!"
);
break
;
}
}
public
Vector3
GetLastDirection
()
{
Vector3
input
=
new
Vector3
(
Input
.
GetAxisRaw
(
"Horizontal"
),
Input
.
GetAxisRaw
(
"Vertical"
),
0
);
if
(
input
.
x
==
0
&&
input
.
y
==
0
)
{
//do nothing
}
else
if
(
input
.
y
!=
0
)
{
LastInput
=
new
Vector3
(
0
,
input
.
y
,
0
);
}
else
{
LastInput
=
new
Vector3
(
input
.
x
,
0
,
0
);
}
return
LastInput
;
}
}
Assets/sprite/Gadic_Four_WaterShieldSprite.png
0 → 100644
View file @
781857a8
555 Bytes
Assets/sprite/Gadic_Four_WaterShieldSprite.png.meta
0 → 100644
View file @
781857a8
fileFormatVersion: 2
guid: aa31553023d864160985ca0e82b9ae15
timeCreated: 1478832493
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 10
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment