protected override void Die() { GameController.AddScore(scorePrice); EnemyHitEffect.Display(); StopCoroutine(runAICoroutine); StartCoroutine(EnemyDisappear()); }
// Start is called before the first frame update void Start() { // エネミー情報取得 enemy = this.gameObject; // エネミーヒットエフェクト eh = GetComponent <EnemyHitEffect>(); DamageNumPrefab = Resources.Load("DamageNum") as GameObject; // FeedOutFlg = false; // AlphaTime = 1.0f; }
public override void onAddedToEntity() { base.onAddedToEntity(); PlayerPunchEffect = entity.scene.content.Load <SoundEffect>("Sound/playerPunch"); //Yes EnemyPunchEffect = entity.scene.content.Load <SoundEffect>("Sound/enemyPunch"); //yes EnemyShootEffect = entity.scene.content.Load <SoundEffect>("Sound/enemyShoot"); //Yes EnemyDieEffect = entity.scene.content.Load <SoundEffect>("Sound/enemyDie"); //Yes BackgroundMusic = entity.scene.content.Load <Song>("Sound/backgroundMusic"); //yes PlayBackgroundMusic(); EnemyHitEffect = entity.scene.content.Load <SoundEffect>("Sound/enemyHit"); //Yes PlayerPunch = PlayerPunchEffect.CreateInstance(); EnemyPunch = EnemyPunchEffect.CreateInstance(); EnemyShoot = EnemyShootEffect.CreateInstance(); EnemyDie = EnemyDieEffect.CreateInstance(); EnemyHit = EnemyHitEffect.CreateInstance(); }
void Start() { // プレイヤー情報取得 player = GameObject.Find("FPSController"); //GetComponentを用いてコンポーネントを取り出す. // アニメータ animator = this.gameObject.GetComponent <Animator>(); // マテリアル material = this.gameObject.GetComponent <SpriteRenderer>().material; // エネミーパラメータ ep = this.gameObject.GetComponent <EnemyParameter>(); // エネミーヒットエフェクト eh = this.gameObject.GetComponent <EnemyHitEffect>(); // ダメージナンバーエフェクト dn = this.gameObject.GetComponent <DamageNumEffect>(); // ライト plight = this.gameObject.GetComponent <Light>(); // レベル情報取得 AILevel = ep.GetLevel(); // レベル処理 propID_h = Shader.PropertyToID("_Hue"); propID_s = Shader.PropertyToID("_Saturation"); propID_c = Shader.PropertyToID("_Contrast"); if (AILevel == 1) { // マテリアル material.SetFloat(propID_h, 0.0f); material.SetFloat(propID_s, 0.5f); material.SetFloat(propID_c, 0.5f); // パラメータ ep.hp = 20; ep.atk = 10; ep.def = 0; ep.speed = 0; ep.startrot = 60; // ポイントライト plight.color = new Color(0.5f, 0.5f, 1.0f, 1.0f); // 弾取得 bullet = Resources.Load("GhostBulletRed") as GameObject; } else if (AILevel == 2) { material.SetFloat(propID_h, 0.45f); material.SetFloat(propID_s, 1.0f); material.SetFloat(propID_c, 0.7f); ep.hp = 30; ep.atk = 15; ep.def = 10; ep.speed = 0; ep.startrot = 60; plight.color = new Color(1.0f, 0.5f, 0.5f, 1.0f); bullet = Resources.Load("GhostBulletBlue") as GameObject; } else if (AILevel == 3) { material.SetFloat(propID_h, 0.3f); material.SetFloat(propID_s, 0.4f); material.SetFloat(propID_c, 1.0f); ep.hp = 40; ep.atk = 25; ep.def = 20; ep.speed = 0; ep.startrot = 60; plight.color = new Color(1.0f, 0.5f, 1.0f, 1.0f); bullet = Resources.Load("GhostBulletGreen") as GameObject; } }
private void Awake() { enemyHitEffect = this; }
public virtual void TakeDamage(float damage) { //////////////////////////////////////////////////////////// if (player == null) { Debug.LogError("Player is null "); return; } if (enemyHitEffects == null) { Debug.LogError("Hiteffects is null "); return; } if (levelManager == null) { Debug.LogError("levelManager is null "); return; } health -= damage; player.RefillHealth(lifestealPercentage * damage); AlertRoom(); // "Spawn" hit effect EnemyHitEffect hitEffect = enemyHitEffects.GetEffect().GetComponent <EnemyHitEffect>(); hitEffect.Play(transform); hitSound.start(); if (health <= 0.0f) { deadSound.start(); //////////////////////////////////////////////////////////// // CHANGE MATERIALS TO DISSOLVE //////////////////////////////////////////////////////////// // Materials returned by renderer is a copy, not a reference if (materialParents.Count != 0) { int materialParentIndex = 0; int deathMaterialIndex = 0; try { foreach (GameObject materialParent in materialParents) { Material[] materials = new Material[originalMaterials[materialParentIndex].Length]; for (int materialIndex = 0; materialIndex < originalMaterials[materialParentIndex].Length; materialIndex++) { Texture originalTexture = originalMaterials[materialParentIndex][materialIndex].GetTexture("_BaseColorMap"); if (originalTexture == null) { Debug.LogError("Error: Enemy original texture is null. GO: " + gameObject.name); navAgent.enabled = false; gameManager.KillEnemy(); Destroy(gameObject); break; } materials[materialIndex] = deathMaterials[deathMaterialIndex]; materials[materialIndex].SetTexture("_DissolveAlbedo", originalTexture); deathMaterialIndex++; } materialParents[materialParentIndex].GetComponent <Renderer>().materials = materials; isDissolving = true; disappearsSound.start(); materialParentIndex++; } } catch { Debug.LogError("Error: Enemy dissolve fail. GO: " + gameObject.name); navAgent.enabled = false; gameManager.KillEnemy(); Destroy(gameObject); } } else { Debug.LogError("Error: No material parents on enemy. GO: " + gameObject.name); navAgent.enabled = false; gameManager.KillEnemy(); Destroy(gameObject); } //////////////////////////////////////////////////////////// // PROPERLY KILL ENEMY FROM GAME //////////////////////////////////////////////////////////// navAgent.enabled = false; foreach (Collider collider in colliders) { collider.enabled = false; } gameManager.KillEnemy(); //////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////// else { //StartCoroutine( FlashColor() ); } //////////////////////////////////////////////////////////// }
void Start() { // プレイヤー情報取得 player = GameObject.Find("FPSController"); //GetComponentを用いてコンポーネントを取り出す. // アニメータ animator = this.gameObject.GetComponent <Animator>(); // マテリアル material = this.gameObject.GetComponent <SpriteRenderer>().material; // カラー color = this.gameObject.GetComponent <SpriteRenderer>().color; // エネミーパラメータ ep = this.gameObject.GetComponent <EnemyParameter>(); // エネミーヒットエフェクト eh = this.gameObject.GetComponent <EnemyHitEffect>(); // ダメージナンバーエフェクト dn = this.gameObject.GetComponent <DamageNumEffect>(); // ライト //plight = this.gameObject.GetComponent<Light>(); // レベル情報取得 AILevel = ep.GetLevel(); // 行動時間調整 ActionTime = 120; // レベル処理 propID_h = Shader.PropertyToID("_Hue"); propID_s = Shader.PropertyToID("_Saturation"); propID_c = Shader.PropertyToID("_Contrast"); if (AILevel == 1) { // マテリアル material.SetFloat(propID_h, 0.0f); material.SetFloat(propID_s, 0.5f); material.SetFloat(propID_c, 0.5f); // パラメータ ep.hp = 20; ep.atk = 10; ep.def = 0; //ep.speed = 1.0f; ep.startrot = 60; // ポイントライト //plight.color = new Color(0.5f,0.5f,1.0f,1.0f); SquidHp = ep.hp; } else if (AILevel == 2) { material.SetFloat(propID_h, 0.45f); material.SetFloat(propID_s, 1.0f); material.SetFloat(propID_c, 0.7f); //ep.hp = 10; ep.atk = 20; ep.def = 10; //ep.speed = 1.3f; ep.startrot = 60; //plight.color = new Color(1.0f,0.5f,0.5f,1.0f); } }