예제 #1
0
 public override void OnStateEnter()
 {
     player.Anim.CrossFade("Male Die", 0.2f);
     PlayerDeath.Invoke();
     player.isVulnerable = false;
     DisablePlayer();
 }
예제 #2
0
 /// <summary>
 /// Raises the player death event.
 /// </summary>
 private void OnPlayerDeath()
 {
     if (PlayerDeath != null)
     {
         PlayerDeath.Invoke();
     }
 }
예제 #3
0
 public void TakeDamage()
 {
     PlayerDeath?.Invoke();
     _scriptableEventChannel.ShakeTheCamera?.Invoke(0.5f, 0.2f);
     Instantiate(_onDeathEffects, transform.position, Quaternion.identity);
     FMODUnity.RuntimeManager.PlayOneShot("event:/Character/Death");
     Destroy(gameObject);
 }
예제 #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Enemy"))
     {
         if (PlayerDeath != null)
         {
             PlayerDeath.Invoke();
         }
     }
 }
예제 #5
0
        public static void HandleData(GetDataEventArgs args, MemoryStream data, PvPPlayer player)
        {
            switch (args.MsgID)
            {
            case PacketTypes.PlayerHurtV2:
                if (new PlayerHurtArgs().ExtractData(args, data, player, out var playerhurt))
                {
                    PlayerHurt?.Invoke(typeof(DataHandler), playerhurt);
                }
                return;

            case PacketTypes.TogglePvp:
                if (new TogglePvPArgs().ExtractData(player, out var togglepvp))
                {
                    PvPToggled?.Invoke(typeof(DataHandler), togglepvp);
                }
                return;

            case PacketTypes.PlayerSlot:
                if (new PlayerSlotArgs().ExtractData(data, player, out var playerslot))
                {
                    SlotUpdate?.Invoke(typeof(DataHandler), playerslot);
                }
                return;

            case PacketTypes.PlayerDeathV2:
                if (new PlayerDeathArgs().ExtractData(player, out var playerdeath))
                {
                    PlayerDeath?.Invoke(typeof(DataHandler), playerdeath);
                }
                return;

            case PacketTypes.ProjectileNew:
                if (new ProjectileNewArgs().ExtractData(args, data, player, out var projectilenew))
                {
                    ProjectileNew?.Invoke(typeof(DataHandler), projectilenew);
                }
                return;

            case PacketTypes.ProjectileDestroy:
                if (new ProjectileDestroyArgs().ExtractData(data, out var projectiledestroy))
                {
                    ProjectileDestroyed?.Invoke(typeof(DataHandler), projectiledestroy);
                }
                return;

            case PacketTypes.PlayerUpdate:
                if (new PlayerUpdateArgs().ExtractData(data, player, out var playerupdate))
                {
                    PlayerUpdate?.Invoke(typeof(DataHandler), playerupdate);
                }
                return;
            }
        }
예제 #6
0
파일: Player.cs 프로젝트: waverma/TheRooms
 public void DoDamage(double value)
 {
     Health -= value;
     if (Health <= 0)
     {
         Health = 0;
         PlayerDeath?.Invoke();
     }
     else
     {
         StateChanged?.Invoke();
     }
 }
예제 #7
0
        protected virtual void OnPlayerDeath(PlayerDeath packet)
        {
            System.Diagnostics.Debug.Assert(PlayerId != null, nameof(PlayerId) + " != null");
            if (packet.playerId == PlayerId.Value)
            {
                Players[PlayerId.Value].PlayerObject.Kill();
                Debug.Log("Death!");
            }

            Players[packet.playerId].Deaths = packet.playerDeaths;
            Players[packet.killerId].Kills  = packet.killerKills;

            if (packet.killerId == PlayerId.Value)
            {
                OwnKill?.Invoke(this, Players[packet.playerId]);
            }

            Debug.LogFormat("Player {0} killed Player {1}", packet.killerId, packet.playerId);

            PlayerDeath?.Invoke(this, packet);
        }
예제 #8
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (invulnerableTimeLeft > 0)
        {
            return;
        }

        AudioSource.Play();
        Health--;

        Damage1SpriteRenderer.enabled = false;
        Damage2SpriteRenderer.enabled = Health == 2;
        Damage3SpriteRenderer.enabled = Health == 1;

        if (Health <= 0)
        {
            PlayerDeath?.Invoke();
        }
        else
        {
            StartInvulerability();
        }
    }
예제 #9
0
        public static void InvokePlayerDeath(PlayerStats stats, ref PlayerStats.HitInfo info, GameObject obj, int pid = 0)
        {
            PlayerDeath playerDeath = PlayerDeathEvent;

            if (playerDeath == null)
            {
                return;
            }

            PlayerDeathEvent ev = new PlayerDeathEvent()
            {
                Killer = pid == 0 ? stats.gameObject.GetPlayer() : Player.GetPlayer(pid),
                Player = Player.GetPlayer(obj),
                Info   = info
            };

            if (string.IsNullOrEmpty(ev.Player.characterClassManager.UserId))
            {
                return;
            }

            playerDeath?.Invoke(ref ev);
            info = ev.Info;
        }
예제 #10
0
 public static void InvokePlayerDeath(PlayerDeathEventArgs e)
 {
     PlayerDeath?.Invoke(e);
 }
예제 #11
0
 // ReSharper disable UnusedParameter.Local
 private void OnPlayerDeath(int oldValue, int newValue)
 {
     PlayerDeath?.Invoke();
 }
예제 #12
0
 public void OnPlayerDeath(int deathCount)
 {
     PlayerDeath?.Invoke(deathCount);
 }
예제 #13
0
 public static void Kill()
 {  //Invokes the playerdeath event
     PlayerDeath?.Invoke(typeof(PlayerLife), System.EventArgs.Empty);
 }
예제 #14
0
 public static void InvokePlayerDeath(Mobile m) => PlayerDeath?.Invoke(m);
예제 #15
0
 protected override IEnumerator Death()
 {
     PlayerDeath.Invoke();
     yield return(null);
 }
예제 #16
0
 public void OnPlayerDeath()
 {
     PlayerDeath?.Invoke();
 }
예제 #17
0
        public void ApplyDamage(DamageMessage data)
        {
            if (currentHitPoints <= 0)
            {//ignore damage if already dead. TODO : may have to change that if we want to detect hit on death...
                return;
            }

            if (isInvulnerable)
            {
                OnHitWhileInvulnerable.Invoke();
                return;
            }

            Vector3 forward = transform.forward;

            forward = Quaternion.AngleAxis(hitForwardRotation, transform.up) * forward;

            //we project the direction to damager to the plane formed by the direction of damage
            Vector3 positionToDamager = data.damageSource - transform.position;

            positionToDamager -= transform.up * Vector3.Dot(transform.up, positionToDamager);

            if (Vector3.Angle(forward, positionToDamager) > hitAngle * 0.5f)
            {
                return;
            }

            isInvulnerable    = true;
            currentHitPoints -= data.amount;

            if (currentHitPoints <= 0)
            {
                schedule += OnDeath.Invoke;     //This avoid race condition when objects kill each other.
                if (this.gameObject.layer == 9) //Player
                {
                    if (data.damager.gameObject.name == "BodyDamager")
                    {
                        PlayerDeathEvent?.Invoke(ENEMY_TYPE.CHOMPER);
                    }

                    else if (data.damager.gameObject.name == "Spit(Clone)")
                    {
                        PlayerDeathEvent?.Invoke(ENEMY_TYPE.SPITTER);
                    }
                }

                else if (this.gameObject.layer == 23) // Enemy
                {
                    if (gameObject.name == "Chomper")
                    {
                        EnemyDeathEvent?.Invoke(gameObject, ENEMY_TYPE.CHOMPER);
                    }

                    else if (gameObject.name == "Spitter")
                    {
                        EnemyDeathEvent?.Invoke(gameObject, ENEMY_TYPE.SPITTER);
                    }
                }
            }

            else
            {
                if (data.damager.gameObject.name == "BodyDamager")
                {
                    PlayerHurtEvent?.Invoke(ENEMY_TYPE.CHOMPER);
                }

                else if (data.damager.gameObject.name == "Spit(Clone)")
                {
                    PlayerHurtEvent?.Invoke(ENEMY_TYPE.SPITTER);
                }

                OnReceiveDamage.Invoke();
            }

            var messageType = currentHitPoints <= 0 ? MessageType.DEAD : MessageType.DAMAGED;

            for (var i = 0; i < onDamageMessageReceivers.Count; ++i)
            {
                var receiver = onDamageMessageReceivers[i] as IMessageReceiver;
                receiver.OnReceiveMessage(messageType, this, data);
            }
        }
예제 #18
0
 //fires event of player loose
 public static void FirePlayerDeath()
 {
     PlayerDeath?.Invoke();
 }
예제 #19
0
 public void OnPlayerDeath()
 {
     Bot.Stats.Deaths++;
     PlayerDeath?.Invoke(Bot);
 }