Beispiel #1
0
 public void SendCommand(ProxyMessageData commandData)
 {
     foreach (var player in Players)
     {
         player.SendCommand(commandData);
     }
 }
Beispiel #2
0
        public override void Execute(MessageData data)
        {
            var game = data.GetTargetAs <Game>();

            game.SendCommand(ProxyMessageData.Create("gameSync", new GameSyncParams(game.Map, game.Players)));
            game.Start();
        }
Beispiel #3
0
        public void MoveEnity(SourceReference Id, Direction direction)
        {
            var entity = GetEntity(Id);

            entity.Direction = direction;

            var newPosition = DetermineNewPosition(entity.Position, direction);

            if (!Map.IsFree(newPosition))
            {
                entity.HitWall(direction);
                return;
            }


            // is there another entity?
            if (Entities.Values.Where(e => e.Position == newPosition).Any())
            {
                // we have a collision ladies and gentleman
                var opponent = Entities.Values.Where(e => e.Position == newPosition).First();

                // both die now
                opponent.Collision(entity);
                entity.Collision(opponent);
            }

            entity.Position = newPosition;
            SendCommand(ProxyMessageData.Create("moveTo", new MoveToParams(entity.Id, newPosition, entity.Direction)));
        }
Beispiel #4
0
        public void Spawn(Entity entity)
        {
            entity.Game = this;
            entity.Id   = SourceReference.NextLocalId;

            SendCommand(ProxyMessageData.Create("spawn", entity));
            Entities.Add(entity.Id, entity);
        }
Beispiel #5
0
 public static async Task<TRes> ExecuteCommandWithCache<TReq, TRes>(string command, TReq reqdata)
 {
     var source = new TaskCompletionSource<TRes>();
     var data = new ProxyMessageData<TReq, TRes>(command, reqdata, source);
     if (!(await CacheService.Instance.TryFromCacheAsync(data)).HasFlag(CacheStatus.VALID))
         await SkyblockBackEnd.Commands[command].Execute(data);
     return source.Task.Result;
 }
Beispiel #6
0
 public void Kill(SourceReference id)
 {
     SendCommand(ProxyMessageData.Create("kill", new IdContainer(id)));
     Entities[id].IsDead = true;
 }
Beispiel #7
0
 public void SendCommand(ProxyMessageData data)
 {
     Connection.SendBack(data);
 }
Beispiel #8
0
 public void AddPoints(int amount)
 {
     Points += amount;
     Game.SendCommand(ProxyMessageData.Create("setPoints", new PointCommandParams(this.Id, Points)));
 }
Beispiel #9
0
 public override void Collision(Entity opponent)
 {
     Game.SendCommand(ProxyMessageData.Create("respawn", new RespawnCommandParams(this.Id, Game.GetRespawnPos(), 3)));
     // dang it, we are dead
     // Todo: count up deaths to perma death on 3
 }