本文整理汇总了C#中Enemy.init方法的典型用法代码示例。如果您正苦于以下问题:C# Enemy.init方法的具体用法?C# Enemy.init怎么用?C# Enemy.init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy.init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: init
public void init () {
elementsHolder = transform.Find("ElementsHolder").GetComponent<ElementsHolder>();
iconsHolderRender = elementsHolder.GetComponent<SpriteRenderer>();
fightEffectPlayer = transform.Find("FightEffectPlayer").GetComponent<FightEffectPlayer>();
elementEffectPlayer = transform.Find("ElementEffectPlayer").GetComponent<ElementEffectPlayer>();
fightInterface = transform.Find("FightInterface").GetComponent<FightInterface>();
enemy = transform.Find("Enemy").GetComponent<Enemy>();
resultScreen = transform.Find("FightResultScreen").GetComponent<FightResultScreen>();
enemyDeadAnimator = transform.Find("EnemyDeadAnim").GetComponent<Animator>();
fightProcessor = GetComponent<FightProcessor>();
deadStone = enemyDeadAnimator.transform.Find("DeadStone");
enemyPos = enemy.transform.localPosition;
potionBag = Vars.gameplay.getPotionBag();
elementsHolder.init();
enemy.init();
resultScreen.init(this, potionBag);
fightInterface.init();
elementEffectPlayer.init(this, enemy);
fightProcessor.init(this, elementsHolder, enemy, potionBag);
elementsHolder.gameObject.SetActive(true);
fightInterface.gameObject.SetActive(true);
enemyDeadAnimator.gameObject.SetActive(false);
gameObject.SetActive(false);
}
示例2: create_enemy
public void create_enemy(EnemyAsset asset, Vector3 pos)
{
if (asset.predator && predator_count >= max_predators) return;
//create enemy class and object
Enemy new_enemy = new Enemy();
new_enemy.gobj = GameObject.Instantiate(asset.gobj);
new_enemy.asset = asset;
BoxCollider[] colliders = new_enemy.gobj.GetComponents<BoxCollider>();
if (colliders.Length >= 1) new_enemy.box_collider_body = colliders[0];
if (colliders.Length >= 2) new_enemy.box_collider_head = colliders[1];
//scale enemy
bool blurred_enemy = Random.value < asset.blurred_spawn_rate;
float m = Random.Range(0.0f, .2f);
if (Random.value < .5f) m += Random.Range(.3f, .5f);
if (blurred_enemy) {
float b_scale = Random.Range(10.0f, 12.0f);
if (asset == hammerhead || asset == great_white || asset == jellyfish) b_scale = Random.Range(3.0f, 4.0f);
new_enemy.gobj.transform.localScale = asset.min_scale * b_scale;
}
else new_enemy.gobj.transform.localScale = asset.min_scale + ((asset.max_scale - asset.min_scale) * m);
GameObject mesh_obj = null;
foreach (Transform child in new_enemy.gobj.transform) {
if (child.name.IndexOf("mesh") != -1) { mesh_obj = child.gameObject; break; }
}
new_enemy.mesh = mesh_obj.GetComponent<SkinnedMeshRenderer>().sharedMesh;
new_enemy.mesh_obj = mesh_obj;
Vector3 s = Vector3.Scale(new_enemy.box_collider_body.bounds.size, new_enemy.gobj.transform.localScale);
if (blurred_enemy) { mesh_obj.layer = 8; new_enemy.blurred_enemy = true; }
if (asset.predator) {
++predator_count;
new_enemy.predator = true;
}
//gen 0-1 value in exactly 2 channels
Vector3 colour_vec = Vector3.zero;
float rand = Random.Range(0, 3);
float c_intensity = 1;
if (asset == jellyfish) c_intensity = .4f;
else if (asset == great_white || asset == hammerhead) c_intensity = .4f;
if (rand == 0) colour_vec = new Vector3(0.0f, 0.0f, c_intensity);
else if (rand == 1) colour_vec = new Vector3(0.0f, c_intensity, 0.0f);
else if (rand == 2) colour_vec = new Vector3(c_intensity, c_intensity, 0.0f);
if (!blurred_enemy && asset.predator) colour_vec = new Vector3(c_intensity, 0.0f, 0.0f);
Color colour = new Color(colour_vec.x, colour_vec.y, colour_vec.z);
new_enemy.colour = colour;
new_enemy.set_emission_colour(colour);
//position enemy
float depth = s.y;
if (asset == jellyfish) depth = s.z;
pos.y -= depth + 1;
if (blurred_enemy) pos.y -= 2;
pos.y = Mathf.Max(pos.y, -30.0f);
new_enemy.gobj.transform.position = pos;
//init and apply light
new_enemy.init();
float size = Mathf.Min(Mathf.Max(s.x, s.z), 50.0f);
float intensity = .75f;
if (blurred_enemy) { intensity = .55f; size /= 3.0f; }
Light.lights.Add(new_enemy.light = Light.create(pos.x, pos.z, size, intensity, colour_vec.x, colour_vec.y, colour_vec.z, 1));
enemies.Add(new_enemy);
}