add new feature:

show position , health ,weather and food
This commit is contained in:
shugen002
2016-02-01 17:38:35 +08:00
parent b34486b603
commit fdc031e660
8 changed files with 107 additions and 1 deletions
@@ -1,6 +1,8 @@
module.exports = function($scope, socket) {
$scope.players = [];
$scope.food=0;
$scope.health=0;
// request player list every 5000ms
setInterval(function() {
@@ -26,6 +28,11 @@ module.exports = function($scope, socket) {
socket.on('disconnect', function() {
$scope.$apply(function() {
$scope.players = [];
$scope.posx = 'no';
$scope.posy = 'no';
$scope.posz = 'no';
$scope.food=0;
$scope.health=0;
});
});
@@ -33,7 +40,34 @@ module.exports = function($scope, socket) {
socket.on('bot:disconnect', function() {
$scope.$apply(function() {
$scope.players = [];
$scope.posx = 'no';
$scope.posy = 'no';
$scope.posz = 'no';
$scope.food=0;
$scope.health=0;
});
});
socket.on('bot:move', function(data) {
$scope.$apply(function() {
$scope.posx=data.x;
$scope.posy=data.y;
$scope.posz=data.z;
});
});
socket.on('bot:forcedMove', function(data) {
$scope.$apply(function() {
$scope.posx=data.x;
$scope.posy=data.y;
$scope.posz=data.z;
});
});
socket.on('bot:health',function(data){
$scope.$apply(function() {
$scope.health=data.health;
$scope.food=data.food;
});
})
};