Exemplo n.º 1
0
    public void onAvatarEnterWorld(UInt64 rndUUID, Int32 eid, KBEngine.Avatar avatar)
    {
        if(!avatar.isPlayer())
        {
            return;
        }

        UI.inst.info("loading scene...(加载场景中...)");
        Debug.Log("loading scene...");

        object speed = avatar.getDefinedPropterty("moveSpeed");
        if(speed != null)
            set_moveSpeed(avatar, speed);

        object state = avatar.getDefinedPropterty("state");
        if(state != null)
            set_state(avatar, state);

        object modelScale = avatar.getDefinedPropterty("modelScale");
        if(modelScale != null)
            set_modelScale(avatar, modelScale);

        object name = avatar.getDefinedPropterty("name");
        if(name != null)
            set_entityName(avatar, (string)name);

        object hp = avatar.getDefinedPropterty("HP");
        if(hp != null)
            set_HP(avatar, hp);
    }
    public void onEnterWorld(KBEngine.Entity entity)
    {
        if(enterSpace == false)
        {
            pendingEnterEntityIDs.Add(entity.id);
            return;
        }

        Asset newasset = Scene.findAsset(entity.getDefinedPropterty("modelID") + ".unity3d", true, "");
        newasset.createAtScene = loader.inst.currentSceneName;

        SceneEntityObject obj = new SceneEntityObject();
        obj.kbentity = entity;

        if(entity.isPlayer())
            obj.createPlayer();
        else
            obj.create();

        entity.renderObj = obj;

        Scene scene = null;
        if(!loader.inst.scenes.TryGetValue(loader.inst.currentSceneName, out scene))
        {
            Common.ERROR_MSG("KBEEventProc::onEnterWorld: not found scene(" + loader.inst.currentSceneName + ")!");
            return;
        }

        newasset.loadLevel = Asset.LOAD_LEVEL.LEVEL_IDLE;
        obj.asset = newasset;
        obj.idkey = "_entity_" + entity.id;

        Vector3 pos = obj.position;
        Common.calcPositionY(pos, out pos.y, false);
        if(entity.getDefinedPropterty("modelID") == "20002001")
            pos.y += 15.0f;

        obj.position = pos;

        obj.position = entity.position;
        obj.eulerAngles = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x);
        obj.destDirection = obj.eulerAngles;

        object name = entity.getDefinedPropterty("name");
        if(name != null)
            obj.setName((string)name);

        object hp = entity.getDefinedPropterty("HP");
        if(hp != null)
            obj.updateHPBar((Int32)hp, (Int32)entity.getDefinedPropterty("HP_Max"));

        object state = entity.getDefinedPropterty("state");
        if(state != null)
            set_state(entity, state);

        object modelScale = entity.getDefinedPropterty("modelScale");
        if(modelScale != null)
            set_modelScale(entity, modelScale);

        object speed = entity.getDefinedPropterty("moveSpeed");
        if(speed != null)
        {
            set_moveSpeed(entity, speed);
        }

        if(entity.className == "Avatar")
            newasset.unloadLevel = Asset.UNLOAD_LEVEL.LEVEL_FORBID;

        newasset.refs.Add(obj.idkey);
        scene.addSceneObject(obj.idkey, obj);

        if(newasset.isLoaded || newasset.bundle != null)
        {
            obj.Instantiate();
            newasset.refs.Remove(obj.idkey);
        }
        else
        {
            loader.inst.loadPool.addLoad(newasset);
            loader.inst.loadPool.start();
        }
    }
    public void set_position(KBEngine.Entity entity)
    {
        if(entity.renderObj != null)
        {
            Common.calcPositionY(entity.position, out entity.position.y, false);
            ((SceneObject)entity.renderObj).position = entity.position;
            ((SceneEntityObject)entity.renderObj).destPosition = entity.position;
        }

        if(entity.isPlayer() == false)
            return;

        entity.position = (Vector3)entity.getDefinedPropterty("position");

        RPG_Controller.initPos.x = entity.position.x;
        RPG_Controller.initPos.y = entity.position.y;
        RPG_Controller.initPos.z = entity.position.z;

        if(RPG_Controller.instance != null)
        {
            RPG_Controller.instance.transform.position = RPG_Controller.initPos;
            Common.DEBUG_MSG("KBEEventProc::set_position: entity.position=" + entity.position + " " + entity.getDefinedPropterty("position") + ", RPG_Controller.position=" + RPG_Controller.instance.transform.position);
        }
    }
 public void set_MP_Max(KBEngine.Entity entity, object v)
 {
     object vv = entity.getDefinedPropterty("MP");
     if(entity.isPlayer())
     {
         game_ui_autopos.updatePlayerBar_MP(vv, v);
     }
     else
     {
         game_ui_autopos.updateTargetBar_MP(vv, v);
     }
 }
    public void set_MP(KBEngine.Entity entity, object v)
    {
        object vv = entity.getDefinedPropterty("MP_Max");

        if(entity.renderObj != null)
        {
            object oldvv = entity.getDefinedPropterty("old_MP");
            if(oldvv != null)
            {
                Int32 diff = (Int32)vv - (Int32)oldvv;

                if(diff > 0)
                {
                    ((SceneEntityObject)entity.renderObj).addMP(diff);
                }

                entity.setDefinedPropterty("old_MP", vv);
            }
            else
                entity.addDefinedPropterty("old_MP", vv);
        }

        if(entity.isPlayer())
        {
            game_ui_autopos.updatePlayerBar_MP(v, vv);
        }
        else
        {
            game_ui_autopos.updateTargetBar_MP(v, vv);
        }
    }
Exemplo n.º 6
0
 public void set_HP_Max(KBEngine.Entity entity, object v)
 {
     if(entity.renderObj != null)
     {
         ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().hp = (Int32)entity.getDefinedPropterty("HP") + "/" + (Int32)v;
     }
 }
Exemplo n.º 7
0
    public void onEnterWorld(KBEngine.Entity entity)
    {
        if(entity.isPlayer())
            return;

        float y = entity.position.y;
        if(entity.isOnGound)
            y = 1.3f;

        entity.renderObj = Instantiate(entityPerfab, new Vector3(entity.position.x, y, entity.position.z),
            Quaternion.Euler(new Vector3(entity.direction.y, entity.direction.z, entity.direction.x))) as UnityEngine.GameObject;

        ((UnityEngine.GameObject)entity.renderObj).name = entity.classtype + entity.id;

        object speed = entity.getDefinedPropterty("moveSpeed");
        if(speed != null)
            set_moveSpeed(entity, speed);

        object state = entity.getDefinedPropterty("state");
        if(state != null)
            set_state(entity, state);

        object modelScale = entity.getDefinedPropterty("modelScale");
        if(modelScale != null)
            set_modelScale(entity, modelScale);

        object name = entity.getDefinedPropterty("name");
        if(name != null)
            set_entityName(entity, (string)name);

        object hp = entity.getDefinedPropterty("HP");
        if(hp != null)
            set_HP(entity, hp);
    }
Exemplo n.º 8
0
    public void SyncEntityPropertity(KBEngine.Entity entity)
    {
        object name = entity.getDefinedPropterty("name");
        if (name != null)
            onSetEntityName(entity, (string)name);

        object speed = entity.getDefinedPropterty("moveSpeed");
        if (speed != null)
            onSetMoveSpeed(entity, speed);

        object state = entity.getDefinedPropterty("state");
        if (state != null)
            onSetState(entity, state);

        object modelScale = entity.getDefinedPropterty("modelScale");
        if (modelScale != null)
            onSetModelScale(entity, modelScale);

        object hp = entity.getDefinedPropterty("HP");
        if (hp != null)
            onSetHP(entity, hp);
    }
Exemplo n.º 9
0
    public void onSetHPMax(KBEngine.Entity entity, object v)
    {
        Dbg.DEBUG_MSG(String.Format("[World set_HP_Max] entity id: {0}, hp max: {1}, name: {2}", entity.id, (Int32)v, ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().entityName));

        if (((UnityEngine.GameObject)entity.renderObj) == null || ((UnityEngine.GameObject)entity.renderObj).gameObject == null)
            return;

        GameEntity gameEntity = ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>();
        if (gameEntity == null)
            return;

        gameEntity.hp = (Int32)entity.getDefinedPropterty("HP") + "/" + (Int32)v;
    }