C# Game Programming Cookbook for Unity 3D / Программирование игр на Unity 3D C#. Книга готовых решений.: 6.1.2.1 Разбор скрипта
| Английский оригинал | Перевод на русский | |
|---|---|---|
Сожалеем, но текст оригинала доступен только зарегистрированным пользователям. |
The BaseWeaponScript class derives from MonoBehavior: ilia1395 25.10.14 в 22:10 |
|
|
using UnityEngine; ilia1395 25.10.14 в 22:10 |
||
|
public virtual void Init() ilia1395 25.10.14 в 22:10 |
||
|
public virtual void Enable() ilia1395 25.10.14 в 22:11 |
||
|
public virtual void Reloaded() ilia1395 25.10.14 в 22:11 |
||
|
public virtual void SetCollider( Collider aCollider ) ilia1395 25.10.14 в 22:11 |
||
|
public virtual void Fire( Vector3 aDirection, int ownerID ) ilia1395 25.10.14 в 22:11 |
||
|
// be sure to check canFire so that the weapon can be ilia1395 25.10.14 в 22:11 |
||
|
// if we’re out of ammo and we do not have infinite ammo, ilia1395 25.10.14 в 22:11 |
||
|
// decrease ammo ilia1395 25.10.14 в 22:11 |
||
|
// we need to reload before we can fire again ilia1395 25.10.14 в 22:12 |
||
|
// schedule a completion of reloading in <reloadTime> ilia1395 25.10.14 в 22:12 |
||
|
public virtual void FireProjectile( Vector3 fireDirection, int ilia1395 25.10.14 в 22:12 |
||
|
// make our first projectile theProjectile= MakeProjectile( ownerID ); ilia1395 25.10.14 в 22:12 |
||
|
// direct the projectile toward the direction of fire theProjectile.LookAt( theProjectile.position + fireDirection ); ilia1395 25.10.14 в 22:12 |
||
|
// add some force to move our projectile ilia1395 25.10.14 в 22:12 |
||
