예제 #1
0
 public void Die()
 {
     HealthLevel          = 0;
     pauseController.pane = "/Dead";
     Time.timeScale       = 0;
     print("You have died of " + lastCOD.ToString());
 }
예제 #2
0
    void kill(DamageCause COD = DamageCause.Default)
    {
        print (gameObject.name + " suffered a death by " + COD.ToString());

        if (GetComponent<ShootingEnemy>() != null) {
            GetComponent<ShootingEnemy>().weapon.Drop ();
            GameObject ammo = GameObject.CreatePrimitive(PrimitiveType.Cube);
            ammo.name = "DroppedAmmo";
            ammo.transform.Translate(transform.position);
            ammo.transform.Translate(0f,0.5f,0f);
            ammo.AddComponent(typeof(AmmoPickup));
            ammo.GetComponent<AmmoPickup>().ammoType = GetComponent<ShootingEnemy>().ammoType;//GetComponent<ShootingEnemy>().ammo
            ammo.GetComponent<AmmoPickup>().Bullets = GetComponent<ShootingEnemy>().ammo[(int)GetComponent<ShootingEnemy>().ammoType];
        }

        List<Enemy> es = PathfindingEnemy.listEnemies();
        es.Remove(thisEnemy);
        PathfindingEnemy.setTargets(PathfindingEnemy.listEnemies());
        foreach (Enemy e in PathfindingEnemy.targets) {
            if (e is PathfindingEnemy || e is ShootingEnemy) {
                (e as PathfindingEnemy).checkTarget();
                print ("Calling checkTarget on " + e.name);
            }
        }
        Complete();
        gameObject.SetActive(false);
    }
예제 #3
0
    void kill(DamageCause COD = DamageCause.Default)
    {
        print(gameObject.name + " suffered a death by " + COD.ToString());

        if (GetComponent <ShootingEnemy>() != null)
        {
            GetComponent <ShootingEnemy>().weapon.Drop();
            GameObject ammo = GameObject.CreatePrimitive(PrimitiveType.Cube);
            ammo.name = "DroppedAmmo";
            ammo.transform.Translate(transform.position);
            ammo.transform.Translate(0f, 0.5f, 0f);
            ammo.AddComponent(typeof(AmmoPickup));
            ammo.GetComponent <AmmoPickup>().ammoType = GetComponent <ShootingEnemy>().ammoType;          //GetComponent<ShootingEnemy>().ammo
            ammo.GetComponent <AmmoPickup>().Bullets  = GetComponent <ShootingEnemy>().ammo[(int)GetComponent <ShootingEnemy>().ammoType];
        }

        List <Enemy> es = PathfindingEnemy.listEnemies();

        es.Remove(thisEnemy);
        PathfindingEnemy.setTargets(PathfindingEnemy.listEnemies());
        foreach (Enemy e in PathfindingEnemy.targets)
        {
            if (e is PathfindingEnemy || e is ShootingEnemy)
            {
                (e as PathfindingEnemy).checkTarget();
                print("Calling checkTarget on " + e.name);
            }
        }
        Complete();
        gameObject.SetActive(false);
    }
예제 #4
0
    private void TakeDamage(float amount, DamageCause cause)
    {
        _enemyData.Health = _enemyData.Health - amount;
        _eventAggregator.Publish(new EnemyTakeDamageEvent(_enemyData.Health));

        if (_enemyData.Health <= 0)
        {
            Debug.Log(cause.ToString());
            Die(cause);
        }
    }
    /// <summary>
    /// Called This when player Die Logic
    /// </summary>
    void Die(string killer, bool isHeat, DamageCause cause, int gunID, Vector3 hitPos, Player sender)
    {
        dead = true;
        m_CharacterController.enabled = false;
        if (!isMine)
        {
            BodyManager.Ragdolled(hitPos);// convert into ragdoll the remote player
        }
        else
        {
            Transform ngr = (bl_GameData.Instance.DropGunOnDeath) ? null : PlayerSync.NetGunsRoot;
            BodyManager.SetLocalRagdoll(hitPos, ngr, m_CharacterController.velocity);
        }
        for (int i = 0; i < transform.childCount; i++)
        {
            transform.GetChild(i).gameObject.SetActive(false);
        }
        string weapon = cause.ToString();

        if (cause == DamageCause.Player || cause == DamageCause.Bot || cause == DamageCause.Explosion)
        {
            weapon = bl_GameData.Instance.GetWeapon(gunID).Name;
        }
        //Spawn ragdoll
        if (!isMine)// when player is not ours
        {
            if (m_LastShot == LocalName)
            {
                AddKill(isHeat, weapon, gunID);
            }
            if (!isOneTeamMode)
            {
                if (photonView.Owner.GetPlayerTeam() == PhotonNetwork.LocalPlayer.GetPlayerTeam())
                {
                    GameObject di = bl_ObjectPooling.Instance.Instantiate("deathicon", transform.position, transform.rotation);
                    di.GetComponent <bl_ClampIcon>().SetTempIcon(DeathIcon, DeathIconShowTime, 20);
                }
            }
        }
        else//when is our
        {
            AddDeath();
            //show kill cam
            BodyManager.gameObject.name = "YOU";
            GameObject kc = Instantiate(KillCamPrefab, transform.position, transform.rotation) as GameObject;
            kc.GetComponent <bl_KillCam>().SetTarget(sender, cause, killer, BodyManager.PelvisBone);
            bl_UIReferences.Instance.OnKillCam(true, killer, gunID);
            BodyManager.KillCameraCache = kc;
#if ELIM
            bl_Elimination.Instance.OnLocalDeath(kc.GetComponent <bl_KillCam>());
#endif
            if (killer == LocalName)
            {
#if LOCALIZATION
                if (cause == DamageCause.FallDamage)
                {
                    bl_EventHandler.KillEvent(LocalName, string.Empty, bl_Localization.Instance.GetText(20), myTeam, 5, 20);
                }
                else
                {
                    bl_EventHandler.KillEvent(LocalName, string.Empty, bl_Localization.Instance.GetText(19), myTeam, 5, 20);
                }
#else
                if (cause == DamageCause.FallDamage)
                {
                    bl_EventHandler.KillEvent(LocalName, string.Empty, bl_GameTexts.DeathByFall, myTeam, 5, 20);
                }
                else
                {
                    bl_EventHandler.KillEvent(LocalName, string.Empty, bl_GameTexts.CommittedSuicide, myTeam, 5, 20);
                }
#endif
            }
            if (bl_GameData.Instance.DropGunOnDeath)
            {
                GunManager.ThrwoCurrent(true);
            }
            if (cause == DamageCause.Bot)
            {
                bl_EventHandler.KillEvent(killer, gameObject.name, weapon, myTeam, 5, 20);
                bl_AIMananger.Instance.SetBotKill(killer);
            }
            StartCoroutine(DestroyThis());
        }
    }