예제 #1
0
 public override Task OnActivateAsync()
 {
     this.myInfo = new PlayerInfo { Key = this.GetPrimaryKey(), Name = "nobody" };
     return base.OnActivateAsync();
 }
예제 #2
0
 Task IRoomGrain.Enter(PlayerInfo player)
 {
     players.RemoveAll(x => x.Key == player.Key);
     players.Add(player);
     return TaskDone.Done;
 }
예제 #3
0
 Task IRoomGrain.Exit(PlayerInfo player)
 {
     players.RemoveAll(x => x.Key == player.Key);
     return TaskDone.Done;
 }
예제 #4
0
        Task<string> IRoomGrain.Description(PlayerInfo whoisAsking)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(this.description);

            if (things.Count > 0)
            {
                sb.AppendLine("The following things are present:");
                foreach (var thing in things)
                {
                    sb.Append("  ").AppendLine(thing.Name);
                }
            }

            var others = players.Where(pi => pi.Key != whoisAsking.Key).ToArray();

            if (others.Length > 0 || monsters.Count > 0)
            {
                sb.AppendLine("Beware! These guys are in the room with you:");
                if (others.Length > 0)
                    foreach (var player in others)
                    {
                        sb.Append("  ").AppendLine(player.Name);
                    }
                if (monsters.Count > 0)
                    foreach (var monster in monsters)
                    {
                        sb.Append("  ").AppendLine(monster.Name);
                    }
            }

            return Task.FromResult(sb.ToString());
        }