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

        if (player != null)
            return;

        Dbg.DEBUG_MSG("[World createPlayer] create palyer success...");

        if (avatar.isOnGround)
            avatar.position.y = 1.3f;

        if (!AttachEntityGameObject(avatar, true))
        {
            Dbg.ERROR_MSG(String.Format("[World onAvatarEnterWorld] AttachEntityGameObject failed, entity id: {0}, entity type: {1}", avatar.id, avatar.className));
            return;
        }

        player = (UnityEngine.GameObject)avatar.renderObj;
        player.GetComponent<GameEntity>().entityEnabled = false;

        UI.inst.info("loading scene...(加载场景中...)");
        Dbg.DEBUG_MSG("[World onAvatarEnterWorld] loading scene...");

        SyncEntityPropertity(avatar);
        //((UnityEngine.GameObject)avatar.renderObj).GetComponent<GameEntity>().OnEnterWorld();
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
0
    public void onAvatarEnterWorld(UInt64 rndUUID, Int32 eid, KBEngine.Avatar avatar)
    {
        if(!avatar.isPlayer())
        {
            return;
        }

        UI.inst.info("loading scene...(加载场景中...)");
        Debug.Log("loading scene...");
    }
 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_moveSpeed(KBEngine.Entity entity, object v)
    {
        if(enterSpace == false)
            return;

        float fspeed = ((float)(Byte)v) / 10f;

        if(entity.isPlayer())
        {
            if(RPG_Controller.instance != null)
                RPG_Controller.instance.walkSpeed = fspeed;
        }

        if(entity.renderObj != null)
        {
            ((SceneEntityObject)entity.renderObj).set_moveSpeed(fspeed);
        }
    }
    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);
        }
    }
    public void set_direction(KBEngine.Entity entity)
    {
        if(enterSpace == false)
            return;

        if(entity.isPlayer() == false)
        {
            if(entity.renderObj != null)
            {
                ((SceneEntityObject)entity.renderObj).destDirection = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x);
                //((SceneObject)entity.renderObj).rotation = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x);
            }
            return;
        }

        RPG_Controller.initRot = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x);
        if(RPG_Controller.instance != null)
        {
            RPG_Controller.instance.transform.Rotate(RPG_Controller.rotation);
            Common.DEBUG_MSG("KBEEventProc::set_direction: RPG_Controller.rotation=" + RPG_Controller.instance.transform.rotation);
        }
    }
    public void set_level(KBEngine.Entity entity, object v)
    {
        if(game_ui_autopos.level_label == null)
            return;

        if(entity.isPlayer())
        {
            game_ui_autopos.level_label.text = "lv: " + v;
        }
        else
        {
            game_ui_autopos.target_level_label.text = "lv:" + v;
        }
    }
Exemplo n.º 9
0
    public void onEnterWorld(KBEngine.Entity entity)
    {
        Dbg.DEBUG_MSG(String.Format("[World onEnterWorld] entity id: {0}, entity type: {1}", entity.id, entity.className));
        if(entity.isPlayer())
            return;

        if(entity.isOnGround)
            entity.position.y = 1.3f;

        if(!AttachEntityGameObject(entity, false))
        {
            Dbg.ERROR_MSG(String.Format("[World onEnterWorld] AttachEntityGameObject failed, entity id: {0}, entity type: {1}", entity.id, entity.className));
            return;
        }

        PlayerController playerController = ((UnityEngine.GameObject)entity.renderObj).GetComponent<PlayerController>();
        if (playerController)
            playerController.enabled = false;

        GameObjectMoveState moveState = ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameObjectMoveState>();
        if (moveState)
            moveState.enabled = false;

        onSetPosition(entity);
        onSetDirection(entity);

        SyncEntityPropertity(entity);
        ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().OnEnterWorld();
    }
    public void recvDamage(KBEngine.Entity entity, KBEngine.Entity attacker, Int32 skillID, Int32 damageType, Int32 damage)
    {
        if(enterSpace == false)
            return;

        if(attacker != null)
        {
            if(attacker.renderObj != null)
            {
                ((SceneEntityObject)attacker.renderObj).attack(skillID, damageType, ((SceneEntityObject)entity.renderObj));
            }
        }

        if(entity.renderObj != null)
        {
            if(CameraTargeting.inst != null && CameraTargeting.inst.lasttargetTransform == null && entity.isPlayer())
            {
                CameraTargeting.inst.setTarget(((SceneEntityObject)attacker.renderObj).gameEntity.transform);
                TargetManger.setTarget((SceneEntityObject)attacker.renderObj);
            }

            ((SceneEntityObject)entity.renderObj).recvDamage(skillID, damageType, damage);
        }
    }
    public void set_state(KBEngine.Entity entity, object v)
    {
        if(enterSpace == false)
            return;

        if(entity.renderObj != null)
        {
            ((SceneEntityObject)entity.renderObj).set_state((SByte)v);
        }

        if(entity.isPlayer())
        {
            RPG_Controller.enabled = ((SByte)v) != 1;

            if(RPG_Controller.enabled == false)
                game_ui_autopos.showRelivePanel();
            else
                game_ui_autopos.hideRelivePanel();
        }
    }
Exemplo n.º 12
0
	public void onEnterWorld(KBEngine.Entity entity)
	{
		if(entity.isPlayer())
			return;
		
		float y = entity.position.y;
		if(entity.isOnGround)
			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.className + "_" + entity.id;
	}
Exemplo n.º 13
0
    public void set_position(KBEngine.Entity entity)
    {
        if (entity.renderObj == null)
            return;

        Vector3 v = (Vector3)entity.getDefinedProperty("position");
        ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().destPosition = v;
        ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().position = v;

        if (entity.isPlayer())//第一次主角获取位置时,调整摄像头
        {
            Camera.main.GetComponent<SmoothFollow>().FollowUpdate();
            if (isFirstPos)
            {
                Camera.main.GetComponent<SmoothFollow>().ResetView();
                isFirstPos = false;
            }
        }
    }
Exemplo n.º 14
0
    public void set_state(KBEngine.Entity entity, object v)
    {
        if (entity.renderObj != null)
        {
            if (((SByte)v) == 1)//死亡
            {
                ((UnityEngine.GameObject)(entity.renderObj)).GetComponent<Animator>().Play("Dead");
            }
            else
            {
                ((UnityEngine.GameObject)(entity.renderObj)).GetComponent<Animator>().Play("Idle");
            }
        }

        if (entity.isPlayer())
        {
            Debug.Log("player->set_state: " + v);

            UnityEngine.GameObject UIGame = UnityEngine.GameObject.FindGameObjectWithTag("UIGame");

            if (((SByte)v) == 1)
            {
                UIGame.GetComponent<UI_Game>().tran_relive.gameObject.SetActive(true);

            }
            else
                UIGame.GetComponent<UI_Game>().tran_relive.gameObject.SetActive(false);

            return;
        }
    }
Exemplo n.º 15
0
    public void recvDamage(KBEngine.Entity entity, KBEngine.Entity attacker, Int32 skillID, Int32 damageType, Int32 damage)
    {
        Skill sk = SkillBox.inst.get(skillID);
        if (sk != null)
        {
            Vector3 dir = entity.position - attacker.position;

            UnityEngine.GameObject renderEntity = (UnityEngine.GameObject)attacker.renderObj;
            renderEntity.GetComponent<Animator>().Play("Punch");
            //显示技能效果
            sk.displaySkill(attacker, entity);

            if (attacker.isPlayer())
            {
                renderEntity.transform.LookAt(new Vector3(renderEntity.transform.position.x + dir.x, renderEntity.transform.position.y, renderEntity.transform.position.z + dir.z));
            }
        }
    }
Exemplo n.º 16
0
    public void onEnterWorld(KBEngine.Entity entity)
    {
        if (entity.isPlayer())
            return;

        float y = entity.position.y;
        if (entity.isOnGround)
            y = 0.0f;

        if (entity.className == "Gate")
        {
            entity.renderObj = Instantiate(gatePerfab, 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)).GetComponent<GameEntity>().entityDisable();
        }
        else if (entity.className == "Monster")
        {
            entity.renderObj = Instantiate(otherPlayerPerfab, 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;

        }
        else if (entity.className == "DroppedItem")
        {
            entity.renderObj = Instantiate(droppedItemPerfab, 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;
        }
        else if (entity.className == "Avatar")
        {
            entity.renderObj = Instantiate(otherPlayerPerfab, 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;
        }
        else if (entity.className == "NPC")
        {
            entity.renderObj = Instantiate(otherPlayerPerfab, 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.className + "_" + entity.id;

        set_position(entity);
        set_direction(entity);

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

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

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

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

        object hp = entity.getDefinedProperty("HP");
        if (hp != null)
            set_HP(entity, hp);

        object hpMax = entity.getDefinedProperty("HP_Max");
        if (hpMax != null)
            set_HP_Max(entity, hpMax);

        object equipWeapon = entity.getDefinedProperty("equipWeapon");
        if (equipWeapon != null)
            set_equipWeapon(entity, (Int32)equipWeapon);
    }
Exemplo n.º 17
0
    public void onAvatarEnterWorld(UInt64 rndUUID, Int32 eid, KBEngine.Avatar avatar)
    {
        if (!avatar.isPlayer())
        {
            return;
        }
        createPlayer();
        //UI.inst.info("loading scene...(加载场景中...)");
        Debug.Log("loading scene...");

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

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

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

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

        object hp = avatar.getDefinedProperty("HP");
        if (hp != null)
            set_HP(avatar, hp);

        object hpMax = avatar.getDefinedProperty("HP_Max");
        if (hpMax != null)
            set_HP_Max(avatar, hpMax);

        //设置头像属性
        UnityEngine.GameObject ptarget = UnityEngine.GameObject.FindGameObjectWithTag("TargetPlayer");

        if (ptarget)
        {
            ui_targetPlayer = ptarget.GetComponent<UI_Target>();
        }
        if (ui_targetPlayer)
        {
            ui_targetPlayer.GE_target = player.GetComponent<GameEntity>();
            ui_targetPlayer.UpdateTargetUI();
        }
        //end
        UnityEngine.GameObject canvas = UnityEngine.GameObject.FindGameObjectWithTag("Canvas");
        UnityEngine.GameObject panel_state = null;
        if (canvas.transform.Find("Panel - State") != null)
            panel_state = canvas.transform.Find("Panel - State").gameObject;
        if (panel_state != null)
        {
            UI_AvatarState avaterState = panel_state.GetComponent<UI_AvatarState>();
            object attack_max = avatar.getDefinedProperty("attack_Max");
            if (attack_max != null)
                avaterState.setAttackMax((Int32)attack_max);

            object attack_min = avatar.getDefinedProperty("attack_Min");
            if (attack_min != null)
                avaterState.setAttackMin((Int32)attack_min);

            object defence = avatar.getDefinedProperty("defence");
            if (defence != null)
                avaterState.setDefence((Int32)defence);

            object rating = avatar.getDefinedProperty("rating");
            if (rating != null)
                avaterState.setRating((Int32)rating);

            object dodge = avatar.getDefinedProperty("dodge");
            if (dodge != null)
                avaterState.setDodge((Int32)dodge);

            object strength = avatar.getDefinedProperty("strength");
            if (strength != null)
                avaterState.setStrength((Int32)strength);

            object dexterity = avatar.getDefinedProperty("dexterity");
            if (dexterity != null)
                avaterState.setDexterity((Int32)dexterity);

            object stamina = avatar.getDefinedProperty("stamina");
            if (stamina != null)
                avaterState.setStamina((Int32)stamina);

            object exp = avatar.getDefinedProperty("exp");
            if (exp != null)
                avaterState.setExp((UInt64)exp);

            object level = avatar.getDefinedProperty("level");
            if (level != null)
                avaterState.setLevel((UInt16)level);
        }

        object equipWeapon = avatar.getDefinedProperty("equipWeapon");
        if (equipWeapon != null)
            set_equipWeapon(avatar, (Int32)equipWeapon);

        SkillBox.inst.initSkillDisplay();
    }
    public void set_name(KBEngine.Entity entity, object v)
    {
        if(entity.isPlayer())
        {
            if(game_ui_autopos.name_label == null)
                return;

            game_ui_autopos.name_label.text = (string)v;
        }
        else
        {
            if(entity.renderObj != null)
            {
                ((SceneEntityObject)entity.renderObj).setName((string)v);
            }
        }
    }
Exemplo n.º 19
0
    public void set_state(KBEngine.Entity entity, object v)
    {
        if(entity.renderObj != null)
        {
            ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().set_state((SByte)v);
        }

        if(entity.isPlayer())
        {
            Debug.Log("player->set_state: " + v);

            if(((SByte)v) == 1)
                showReliveGUI = true;
            else
                showReliveGUI = false;

            return;
        }
    }
    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);
        }
    }
Exemplo n.º 21
0
    public void onSetState(KBEngine.Entity entity, object v)
    {
        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.set_state((SByte)v);

        if(entity.isPlayer())
        {
            Dbg.DEBUG_MSG("[World set_state] player->set_state: " + v);

            if(((SByte)v) == 1)
                UI.inst.showReliveGUI = true;
            else
                UI.inst.showReliveGUI = false;

            return;
        }
    }
    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();
        }
    }
Exemplo n.º 23
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);
    }