public void LevelUpHeroThenKillHim_ResultsInClassesAndRacesUnchanged_Test()
        {
            // Arrange
            var dwarf  = "Dwarf";
            var priest = "Priest";
            var quest  = QuestFactory.CreateStartedWithMaleHero(
                out var gameStore,
                out var gameId,
                out var playerId,
                out var sequence);

            var raceMessage  = RaceMessage.CreateAdd(sequence.Next, playerId, new[] { dwarf });
            var classMessage = ClassMessage.CreateAdd(sequence.Next, playerId, new[] { priest });
            var deathMsg     = DeathMessage.Create(sequence.Next, playerId);

            // Act
            quest.AddMessage(gameId, raceMessage);
            quest.AddMessage(gameId, classMessage);
            var game = quest.AddMessage(gameId, deathMsg);

            // Assert
            var hero = game.GetHero(playerId);

            Assert.Single(hero.Races);
            Assert.Single(hero.Classes);
        }
        private void OnClientReceiveMessage(DeathMessage message)
        {
            var playerName   = PlayerJoin.PlayerNames.TryGetValue(message.SenderId, out var n) ? n : message.PlayerName;
            var deathMessage = Necronomicon.GetPhrase(message.DeathType);

            DebugLog.All(string.Format(deathMessage, playerName));
        }
    // Server
    private IEnumerator CheckDeathRoutine()
    {
        yield return(new WaitUntil(() => this.isPlayingGame == true));

        Debug.Log("Check death routine");

        while (this.isPlayingGame)
        {
            for (int i = 0; i < this.maxConnections; i++)
            {
                if (this.playerHealthList[i] <= 0)
                {
                    Debug.Log(this.playerInfoList[i].name + " has died");

                    // Send death msg to all clients
                    DeathMessage msg = new DeathMessage();
                    msg.objectId          = (int)this.playerInfoList[i].playerObjectId;
                    msg.nextSpawnPosition = this.spawnTransforms[Random.Range(0, this.spawnTransforms.Count)].position;
                    NetworkServer.SendToAll(CustomMsgType.Death, msg);

                    this.StartCoroutine(this.RespawnPlayer(i));
                    break;
                }
            }
            yield return(null);
        }
    }
示例#4
0
    private void Die()
    {
        DeathMessage message = deathMessages[Random.Range(0, deathMessages.Count)];

        newDayButton.SetActive(false);
        messageManager.CreateCustomMessage(message.title, message.description, diePrefab);
        PlayerPrefs.SetInt("HighScore", daysPassed);
    }
示例#5
0
 public virtual void Awake()
 {
     shotDirection     = GetComponentInChildren <ShotDirection>();
     deathMessage      = GetComponentInChildren <DeathMessage>();
     healthBar         = GetComponentInChildren <HealthBar>();
     weaponStatCompare = GetComponentInChildren <WeaponStatCompare>();
     aimUi             = GetComponentInChildren <AimUi>();
 }
        public void LetHeroDieThatIsNotInTheGame_ThrowsException_Test()
        {
            // Arrange
            var quest    = QuestFactory.CreateStarted(out var gameStore, out var gameId, out var sequence);
            var deathMsg = DeathMessage.Create(sequence.Next, Guid.NewGuid());

            // Act & Assert
            Assert.Throws <InvalidActionException>(() => quest.AddMessage(gameId, deathMsg));
        }
        public void LetHeroDieBeforeGameStarted_ThrowsException_Test()
        {
            // Arrange
            var quest     = QuestFactory.CreateStored(out var gameStore, out var gameId);
            var playerMsg = PlayerMessage.CreateAdd(1, new[] { someDude });
            var deathMsg  = DeathMessage.Create(2, someDude.Id);

            // Act & Assert
            quest.AddMessage(gameId, playerMsg);
            Assert.Throws <InvalidActionException>(() => quest.AddMessage(gameId, deathMsg));
        }
            public static void BroadcastDeath(DeathType deathType)
            {
                var message = new DeathMessage
                {
                    PlayerName = PlayerJoin.MyName,
                    SenderId   = PlayerTransformSync.LocalInstance.netId.Value,
                    DeathType  = deathType
                };

                _instance._deathHandler.SendToServer(message);
            }
    // Client
    public void OnDeathMessage(NetworkMessage _networkMessage)
    {
        DeathMessage msg = _networkMessage.ReadMessage <DeathMessage>();

        // Send msg to player object
        PlayerManager tempPlayer = NetworkHelper.GetObjectByNetIdValue <PlayerManager>((uint)msg.objectId, false);

        tempPlayer.OnDeath(msg.nextSpawnPosition);

        // Run respawn coroutine
        tempPlayer.StartCoroutine(tempPlayer.OnRespawn(this.respawnTime));
    }
示例#10
0
 public static void OnPKDeath(Player killer, Player victim, DeathMessage deathMessage)
 {
     try
     {
         if (killer != null && victim != null)
         {
             string msg = string.Format(deathMessage.Broadcast, victim.Name, killer.Name);
             foreach (var player in PlayerManager.GetAllOnline())
             {
                 if (player != killer && player != victim)
                 {
                     player.Session.WorldBroadcast(msg);
                 }
             }
             //GlobalWorldBroadcast(msg);
         }
     } catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
        public void LevelUpHeroThenKillHim_ResultsInBonusReset_Test()
        {
            // Arrange
            var quest = QuestFactory.CreateStartedWithMaleHero(
                out var gameStore,
                out var gameId,
                out var playerId,
                out var sequence);

            var bonusMsg = BonusMessage.Create(sequence.Next, playerId, 1);
            var deathMsg = DeathMessage.Create(sequence.Next, playerId);

            // Act
            quest.AddMessage(gameId, bonusMsg);
            var game = quest.AddMessage(gameId, deathMsg);

            // Assert
            var hero = game.GetHero(playerId);

            Assert.Equal(0, hero.Bonus);
        }
 public override void InitializeStates(out BaseState default_state)
 {
     default_state     = alive;
     base.serializable = true;
     alive.ParamTransition(death, dying_duplicant, (Instance smi, Death p) => p != null && smi.IsDuplicant).ParamTransition(death, dying_creature, (Instance smi, Death p) => p != null && !smi.IsDuplicant);
     dying_duplicant.ToggleAnims("anim_emotes_default_kanim", 0f).ToggleTag(GameTags.Dying).ToggleChore((Instance smi) => new DieChore(smi.master, death.Get(smi)), die);
     dying_creature.ToggleBehaviour(GameTags.Creatures.Die, (Instance smi) => true, delegate(Instance smi)
     {
         smi.GoTo(dead);
     });
     die.ToggleTag(GameTags.Dying).Enter("Die", delegate(Instance smi)
     {
         Death death2 = death.Get(smi);
         if (smi.IsDuplicant)
         {
             DeathMessage message = new DeathMessage(smi.gameObject, death2);
             KFMOD.PlayOneShot(GlobalAssets.GetSound("Death_Notification_localized", false), smi.master.transform.GetPosition());
             KFMOD.PlayOneShot(GlobalAssets.GetSound("Death_Notification_ST", false));
             Messenger.Instance.QueueMessage(message);
         }
     }).GoTo(dead);
     dead.ToggleAnims("anim_emotes_default_kanim", 0f).defaultState = dead.ground.TriggerOnEnter(GameHashes.Died, null).ToggleTag(GameTags.Dead).Enter(delegate(Instance smi)
     {
         smi.ApplyDeath();
         Game.Instance.Trigger(282337316, smi.gameObject);
     });
     dead.ground.Enter(delegate(Instance smi)
     {
         Death death = this.death.Get(smi);
         if (death == null)
         {
             death = Db.Get().Deaths.Generic;
         }
         if (smi.IsDuplicant)
         {
             smi.GetComponent <KAnimControllerBase>().Play(death.loopAnim, KAnim.PlayMode.Loop, 1f, 0f);
         }
     }).EventTransition(GameHashes.OnStore, dead.carried, (Instance smi) => smi.IsDuplicant && smi.HasTag(GameTags.Stored));
     dead.carried.ToggleAnims("anim_dead_carried_kanim", 0f).PlayAnim("idle_default", KAnim.PlayMode.Loop).EventTransition(GameHashes.OnStore, dead.ground, (Instance smi) => !smi.HasTag(GameTags.Stored));
 }
示例#13
0
    public void OnGUI()
    {
        GUI.Box(new Rect(Screen.width - 320, 20, 300, 20), "");
        if (HealthLevel >= 4)
        {
            GUI.Box(new Rect(Screen.width - 320, 20, 300 * (HealthLevel / statistics.acualMaxHealth), 20), "");
        }
        if (Time.timeScale == 0 && pauseController.pane.Equals("/Dead"))
        {
            GUI.Label(new Rect((Screen.width / 2) - 200, (Screen.height / 2) - 20, 400, 40), "YOU ARE DEAD!");
            GUI.Label(new Rect((Screen.width / 2) - 200, (Screen.height / 2) - 00, 400, 40), DeathMessage.getMsg(lastCOD));

            return;
        }                                                                                                                                                               //MAYBE

        /*if (HealthLevel < 1) {
         * //	GUI.Box(new Rect(0, 0, Screen.width, Screen.height), DeathScreen);
         * //}*/
        //style. color = new Color (0,0,0,(HealthLevel/statistics.acualMaxHealth)*255);
        //style.normal.background.
        if (HealthLevel < (0.25 * statistics.acualMaxHealth) && drawTextures)
        {
            //GUI.Box(new Rect(0,0, Screen.width, Screen.height), bloodSplatter, style);
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), bloodSplatter);
        }
    }
示例#14
0
 protected bool Equals(DeathMessage other) => string.Equals(KillerType, other.KillerType) &&
 string.Equals(VictimType, other.VictimType) &&
 string.Equals(DamageType, other.DamageType);
 private void OnServerReceiveMessage(DeathMessage message)
 {
     _deathHandler.SendToAll(message);
 }