• 大小: 9.53MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-05
  • 语言: 其他
  • 标签: as3.0  源码  

资源简介

《as大型网页游戏开发》实例electroserver可运行,实例3-8

资源截图

代码片段和文件信息

package com.gamebook.digging;

import com.electrotank.electroserver4.extensions.basePlugin;
import com.electrotank.electroserver4.extensions.ChainAction;
import com.electrotank.electroserver4.extensions.api.ScheduledCallback;
import com.electrotank.electroserver4.extensions.api.value.Esobject;
import com.electrotank.electroserver4.extensions.api.value.EsobjectRO;
import com.electrotank.electroserver4.extensions.api.value.UserEnterContext;
import java.util.AbstractMap;
import java.util.AbstractQueue;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentlinkedQueue;

public class DiggingPlugin extends basePlugin {
    // variables
    private AbstractMapyerInfo> playerInfoMap;
    private AbstractQueueyerInfo> delayQueue;
    private Grid grid;
    
    @Override
    public void init( EsobjectRO ignored ) {
        grid = new Grid();
        playerInfoMap = new ConcurrentHashMapyerInfo>();
        delayQueue = new ConcurrentlinkedQueueyerInfo>();
    }

    @Override
    public ChainAction userEnter(UserEnterContext context) {
        String playerName = context.getUserName();
        getApi().getLogger().debug(“userEnter: “ + playerName);
        return ChainAction.OkAndContinue;
    }

    @Override
    public void request(String playerName EsobjectRO requestParameters) {
        Esobject messageIn = new Esobject();
        messageIn.addAll(requestParameters);
        getApi().getLogger().debug(playerName + “ requests: “ + messageIn.toString());
        String action = messageIn.getString(PluginConstants.ACTION);

        if (action.equals(PluginConstants.INIT_ME)) {
            handlePlayerInitRequest(playerName);
        } else if (action.equals(PluginConstants.DIG_HERE)) {
            handleDigHereRequest(playerName messageIn);
        } else if (action.equals(PluginConstants.POSITION_UPDATE)) {
            relayMessage(playerName messageIn);
        }
    }

    @Override
    public void userExit(String playerName) {
        if (playerInfoMap.containsKey(playerName)) {
            playerInfoMap.remove(playerName);
        }
        Esobject message = new Esobject();
        message.setString(PluginConstants.ACTION PluginConstants.REMOVE_Player);
        message.setString(PluginConstants.NAME playerName);
        sendAndLog(“userExit“ message);
    }

    @Override
    public void destroy() {
        while (!delayQueue.isEmpty()) {
            PlayerInfo pInfo = delayQueue.poll();
            if (pInfo != null) {
                pInfo.cancelCallback(getApi());
            }
        }
        getApi().getLogger().debug(“room destroyed“);
    }

    private synchronized Esobject[] getFullPlayerList() {
        Esobject[] list = new Esobject[playerInfoMap.size()];
        int ptr = 0;
        for (PlayerInfo pInfo : playerInfoMap.values()) {
            list[ptr] = pInfo.toEsobject();
            ptr++;
        }
        return

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     245299  2011-12-26 08:36  chapter5\chat_room\bin\ChatRoom.swf

     文件         66  2011-10-20 21:08  chapter5\chat_room\bin\server.xml

     文件       2636  2011-10-12 17:09  chapter5\chat_room\Chat Room.as3proj

     文件     152946  2009-06-25 08:58  chapter5\chat_room\lib\as3-client-4.0.6a.swc

     文件      86692  2009-06-25 08:58  chapter5\chat_room\lib\chat_assets.swc

     文件       1307  2009-06-25 08:59  chapter5\chat_room\obj\Chat-RoomConfig.old

     文件       1307  2009-06-25 08:59  chapter5\chat_room\obj\Chat-RoomConfig.xml

     文件       1019  2011-12-01 13:04  chapter5\chat_room\obj\ChatRoomConfig.old

     文件       1019  2011-12-26 08:36  chapter5\chat_room\obj\ChatRoomConfig.xml

     文件    2210816  2011-10-21 07:48  chapter5\chat_room\src\assets\chat_assets.fla

     文件     106830  2009-06-25 08:59  chapter5\chat_room\src\assets\chat_assets.swc

     文件     107732  2009-06-25 08:59  chapter5\chat_room\src\assets\chat_assets.swf

     文件       4489  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ChatFlow.as

     文件      11977  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ChatRoom.as

     文件        426  2011-10-20 21:07  chapter5\chat_room\src\com\gamebook\chatroom\Main.as

     文件        591  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ui\ConnectingScreen.as

     文件       1430  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ui\CreateRoomScreen.as

     文件       1020  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ui\ErrorScreen.as

     文件       1420  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ui\LoginScreen.as

     文件        288  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ui\PopuupBackground.as

     文件        345  2009-06-25 08:59  chapter5\chat_room\src\com\gamebook\chatroom\ui\TextLabel.as

     文件     340862  2011-12-01 13:20  chapter6\dig_game\client\bin\DigGame.swf

     文件         66  2009-06-25 08:59  chapter6\dig_game\client\bin\server.xml

     文件       2636  2009-06-25 08:59  chapter6\dig_game\client\Dig Game.as3proj

     文件     152946  2009-06-25 08:59  chapter6\dig_game\client\lib\as3-client-4.0.6a.swc

     文件      86692  2009-06-25 08:59  chapter6\dig_game\client\lib\chat_assets.swc

     文件       1509  2009-06-25 08:59  chapter6\dig_game\client\obj\Dig-GameConfig.old

     文件       1509  2009-06-25 08:59  chapter6\dig_game\client\obj\Dig-GameConfig.xml

     文件       1149  2011-12-01 13:05  chapter6\dig_game\client\obj\DigGameConfig.old

     文件       1149  2011-12-01 13:05  chapter6\dig_game\client\obj\DigGameConfig.xml

............此处省略307个文件信息

评论

共有 条评论