Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
240 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using RTS; | ||
|
||
public class Turret : Building { | ||
|
||
private Quaternion aimRotation; | ||
|
||
protected override void Start () { | ||
base.Start (); | ||
detectionRange = weaponRange; | ||
} | ||
|
||
protected override void Update () { | ||
base.Update(); | ||
if(aiming) { | ||
transform.rotation = Quaternion.RotateTowards(transform.rotation, aimRotation, weaponAimSpeed); | ||
CalculateBounds(); | ||
//sometimes it gets stuck exactly 180 degrees out in the calculation and does nothing, this check fixes that | ||
Quaternion inverseAimRotation = new Quaternion(-aimRotation.x, -aimRotation.y, -aimRotation.z, -aimRotation.w); | ||
if(transform.rotation == aimRotation || transform.rotation == inverseAimRotation) { | ||
aiming = false; | ||
} | ||
} | ||
} | ||
|
||
public override bool CanAttack() { | ||
if(UnderConstruction() || hitPoints == 0) return false; | ||
return true; | ||
} | ||
|
||
protected override void UseWeapon () { | ||
base.UseWeapon(); | ||
Vector3 spawnPoint = transform.position; | ||
spawnPoint.x += (2.6f * transform.forward.x); | ||
spawnPoint.y += 1.0f; | ||
spawnPoint.z += (2.6f * transform.forward.z); | ||
GameObject gameObject = (GameObject)Instantiate(ResourceManager.GetWorldObject("TurretProjectile"), spawnPoint, transform.rotation); | ||
Projectile projectile = gameObject.GetComponentInChildren<Projectile>(); | ||
projectile.SetRange(0.9f * weaponRange); | ||
projectile.SetTarget(target); | ||
} | ||
|
||
protected override void AimAtTarget () { | ||
base.AimAtTarget(); | ||
aimRotation = Quaternion.LookRotation (target.transform.position - transform.position); | ||
} | ||
} |
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
RTS Tutorial/Assets/WorldObject/Building/Turret/TurretProjectile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class TurretProjectile : Projectile {} |
Binary file added
BIN
+9.21 KB
RTS Tutorial/Assets/WorldObject/Building/Turret/TurretProjectile.prefab
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file modified
BIN
+2.02 KB
(110%)
RTS Tutorial/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+28 Bytes
(100%)
RTS Tutorial/Library/metadata/b2/b28c4dc01ee837c439f36a14b80f574e
Binary file not shown.
Oops, something went wrong.