Exemplo n.º 1
0
    void DoGameEvent(int eventID, object param)
    {
        if (eventID == (int)GameEventID.SYSTEM_LOADSCENECOMPELETE)
        {
            Client.stLoadSceneComplete pa = (Client.stLoadSceneComplete)param;
            int homeID = GameTableManager.Instance.GetGlobalConfig <int>("HomeSceneID");
            if (pa.nMapID == homeID)
            {
                IPlayer player = ClientGlobal.Instance().MainPlayer;
                if (player != null)
                {
                    //stRequestAllHomeUserCmd_C cmd = new stRequestAllHomeUserCmd_C();
                    //cmd.char_id = player.GetID();
                    //NetService.Instance.Send(cmd);
                    ReqAllUserHomeData(player.GetID());

                    ReqHomeTradePrice();
                }
            }
        }
        else if (eventID == (int)GameEventID.PLAYER_LOGIN_SUCCESS)
        {
        }
        else if (eventID == (int)GameEventID.HOMELAND_CLICKENTITY)
        {
            stClickEntity ce = (stClickEntity)param;
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es != null)
            {
                IEntity et = es.FindEntity(ce.uid);
                if (et != null)
                {
                    if (IsMyHome()) //只有自己家园才可以点击实体
                    {
                        if (et.GetEntityType() == EntityType.EntityType_Plant || et.GetEntityType() == EntityType.EntityType_Soil)
                        {//农场点击响应
                            OnClickPlantEntity(et);
                        }
                        else if (et.GetEntityType() == EntityType.EntityType_Animal)
                        {
                            OnClickAnimalEntity(et);
                        }
                        else if (et.GetEntityType() == EntityType.EntityType_Tree)
                        {
                            OnClickTreeEntity(et);
                        }
                        else if (et.GetEntityType() == EntityType.EntityType_Minerals)
                        {
                            OnClickMineEntity(et);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public void OnClickEntity(IEntity entity)
    {
        if (entity == null)
        {
            return;
        }

        stClickEntity clickEntity = new stClickEntity();

        clickEntity.uid = entity.GetUID();
        Engine.Utility.EventEngine.Instance().DispatchEvent((int)(int)GameEventID.HOMELAND_CLICKENTITY, clickEntity);
    }