예제 #1
0
        async Task <string> Go(string direction)
        {
            IRoomGrain destination = await this.State.roomGrain.ExitTo(direction, this.State.gameState);

            StringBuilder description = new StringBuilder();

            if (destination != null)
            {
                await this.State.roomGrain.Exit(this);

                await destination.Enter(this);

                this.State.roomGrain = destination;
                var desc = await destination.Description(State.myInfo, this.State.gameState);

                if (desc != null)
                {
                    description.Append(desc);
                }
            }
            else
            {
                description.Append("You cannot go in that direction.");
            }
            await State.WriteStateAsync();

            return(description.ToString());
        }
예제 #2
0
        async Task SetRoomGrain(IRoomGrain room)
        {
            this.State.roomGrain = room;
            await room.Enter(this);

            await State.WriteStateAsync();
        }
예제 #3
0
        async Task Move()
        {
            var directions = new string [] { "north", "south", "west", "east" };

            var        rand     = new Random().Next(0, 4);
            IRoomGrain nextRoom = await this.roomGrain.ExitTo(directions[rand]);

            if (null == nextRoom)
            {
                return;
            }

            await this.roomGrain.Exit(this.monsterInfo);

            await nextRoom.Enter(this.monsterInfo);

            this.roomGrain = nextRoom;
        }
예제 #4
0
        async Task Move()
        {
            var        directions = new string[] { "north", "south", "west", "east" };
            var        rand       = new Random().Next(0, 4);
            IRoomGrain nextRoom   = await this.State.roomGrain.ExitTo(directions[rand], this);

            if (null == nextRoom)
            {
                return;
            }
            await this.State.roomGrain.Exit(this);

            await nextRoom.Enter(this);

            //Get Push grain
            var notifier = PushNotifierGrainFactory.GetGrain(0);
            //loop through players in the room grain
            var playersInRoom = await this.State.roomGrain.GetPlayersInRoom();

            for (int i = 0; i < playersInRoom.Length; i++)
            {
                Guid playerId = playersInRoom[i].GetPrimaryKey();
                await notifier.SendMessage(this.State.npcInfo.Name + " has left the room", playerId.ToString());
            }

            this.State.roomGrain = nextRoom;
            //Send messages to players in new room
            playersInRoom = await this.State.roomGrain.GetPlayersInRoom();

            for (int i = 0; i < playersInRoom.Length; i++)
            {
                Guid playerId = playersInRoom[i].GetPrimaryKey();
                await notifier.SendMessage(this.State.npcInfo.Name + " has entered room", playerId.ToString());
            }

            await State.WriteStateAsync();
        }
예제 #5
0
        async Task <string> Go(string direction)
        {
            IRoomGrain destination = await this.roomGrain.ExitTo(direction);

            StringBuilder description = new StringBuilder();

            if (destination != null)
            {
                await this.roomGrain.Exit(myInfo);

                await destination.Enter(myInfo);

                this.roomGrain = destination;
                var desc = await destination.Description(myInfo);

                if (desc != null)
                {
                    description.Append(desc);
                }
            }
            else
            {
                description.Append("You cannot go in that direction.");
            }

            if (things.Count > 0)
            {
                description.AppendLine("You are holding the following items:");
                foreach (var thing in things)
                {
                    description.AppendLine(thing.Name);
                }
            }

            return(description.ToString());
        }
예제 #6
0
 Task IPlayerGrain.SetRoomGrain(IRoomGrain room)
 {
     this.roomGrain = room;
     return room.Enter(myInfo);
 }
예제 #7
0
 Task IPlayerGrain.SetRoomGrain(IRoomGrain room)
 {
     this.roomGrain = room;
     return(room.Enter(myInfo));
 }