C# Game Programming Cookbook for Unity 3D / Программирование игр на Unity 3D C#. Книга готовых решений.: 9.3.1 Разбор скрипта
| Английский оригинал | Перевод на русский | |
|---|---|---|
Сожалеем, но текст оригинала доступен только зарегистрированным пользователям. |
||
|
using AIAttackStates; ilia1395 25.10.14 в 20:31 |
||
|
public class BaseArmedEnemy : ExtendedCustomMonoBehavior ilia1395 25.10.14 в 20:31 |
||
|
public void Init() ilia1395 25.10.14 в 20:31 |
||
|
if(weaponControl==null) ilia1395 25.10.14 в 20:31 |
||
|
if(rendererToTestAgainst==null) ilia1395 25.10.14 в 20:32 |
||
|
// if a player manager is not set in the editor, let’s try ilia1395 25.10.14 в 20:32 |
||
|
myDataManager= myPlayerManager.DataManager; ilia1395 25.10.14 в 20:32 |
||
|
canFire=true; ilia1395 25.10.14 в 20:32 |
||
|
public virtual void Update () ilia1395 25.10.14 в 20:32 |
||
|
// if we are not allowed to control the weapon, we drop out ilia1395 25.10.14 в 20:32 |
||
|
if(thisGameObjectShouldFire) ilia1395 25.10.14 в 20:33 |
||
|
// we use doFire to determine whether or not to fire ilia1395 25.10.14 в 20:33 |
||
|
if( canFire ) ilia1395 25.10.14 в 20:33 |
||
|
if( currentState==AIAttackState.random_fire ) ilia1395 25.10.14 в 20:33 |
||
|
if( currentState==AIAttackState.look_and_destroy ) ilia1395 25.10.14 в 20:33 |
||
|
doFire=true; ilia1395 25.10.14 в 20:33 |
||
|
// if we’re not set to random fire or look and ilia1395 25.10.14 в 20:33 |
||
|
if( doFire ) ilia1395 25.10.14 в 20:33 |
||
|
if(onlyFireWhenOnscreen && !rendererToTestAgainst. ilia1395 25.10.14 в 20:34 |
||
|
// tell weapon control to fire, if we have a weapon ilia1395 25.10.14 в 20:34 |
||
|
// set a flag to disable firing temporarily (providing a ilia1395 25.10.14 в 20:34 |
||
|
public void ResetFire () ilia1395 25.10.14 в 20:34 |
