コード例 #1
0
    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);
        }
    }
コード例 #2
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.className + "_" + entity.id;

        set_position(entity);
        set_direction(entity);

        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);
        }
    }
コード例 #3
0
    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);
        }
    }
コード例 #4
0
    public static void showTargetBar(SceneEntityObject seo)
    {
        if (seo == null || seo.kbentity == null || target_bar == null)
        {
            return;
        }

        NGUITools.SetActive(target_bar, true);

        KBEngine.Entity entity = seo.kbentity;
        string          name   = (string)entity.getDefinedPropterty("name");
        object          level  = entity.getDefinedPropterty("level");
        object          hp     = entity.getDefinedPropterty("HP");
        object          hpmax  = entity.getDefinedPropterty("HP_Max");
        object          mp     = entity.getDefinedPropterty("MP");
        object          mpmax  = entity.getDefinedPropterty("MP_Max");

        target_name_label.text = name;
        if (level != null)
        {
            target_level_label.text = "lv:" + level;
        }
        else
        {
            target_level_label.text = "";
        }

        updateTargetBar_HP(hp, hpmax);
        updateTargetBar_MP(mp, mpmax);
    }
コード例 #5
0
    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);
        }
    }
コード例 #6
0
    public void set_HP_Max(KBEngine.Entity entity, object v)
    {
        object vv = entity.getDefinedPropterty("HP");

        if (entity.isPlayer())
        {
            game_ui_autopos.updatePlayerBar_HP(vv, v);
            if (onChangehpmax != null)
            {
                onChangehpmax(v);
            }
        }
        else
        {
            game_ui_autopos.updateTargetBar_HP(vv, v);
        }
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        hp_label        = UnityEngine.GameObject.Find("hp").GetComponent <UILabel>();
        mp_label        = UnityEngine.GameObject.Find("mp").GetComponent <UILabel>();
        target_hp_label = UnityEngine.GameObject.Find("target_hp").GetComponent <UILabel>();
        target_mp_label = UnityEngine.GameObject.Find("target_mp").GetComponent <UILabel>();

        hp_ProgressBar        = UnityEngine.GameObject.Find("hp_ProgressBar").GetComponent <UISlider>();
        target_hp_ProgressBar = UnityEngine.GameObject.Find("target_hp_ProgressBar").GetComponent <UISlider>();
        mp_ProgressBar        = UnityEngine.GameObject.Find("mp_ProgressBar").GetComponent <UISlider>();
        target_mp_ProgressBar = UnityEngine.GameObject.Find("target_mp_ProgressBar").GetComponent <UISlider>();

        name_label         = UnityEngine.GameObject.Find("ename").GetComponent <UILabel>();
        level_label        = UnityEngine.GameObject.Find("elevel").GetComponent <UILabel>();
        target_name_label  = UnityEngine.GameObject.Find("target_ename").GetComponent <UILabel>();
        target_level_label = UnityEngine.GameObject.Find("target_elevel").GetComponent <UILabel>();

        target_bar = UnityEngine.GameObject.Find("target_power_bar");
        hideTargetBar();

        ui_relive = UnityEngine.GameObject.Find("relive");
        UnityEngine.GameObject gobackrelive = UnityEngine.GameObject.Find("gobackrelive");
        UIEventListener.Get(gobackrelive).onClick = on_gobackreliveClick;
        UnityEngine.GameObject localrelive = UnityEngine.GameObject.Find("localrelive");
        UIEventListener.Get(localrelive).onClick = on_localreliveClick;
        hideRelivePanel();

        KBEngine.Entity player = KBEngineApp.app.player();
        if (player != null && KBEEventProc.inst != null)
        {
            KBEEventProc.inst.set_HP(player, player.getDefinedPropterty("HP"));
            KBEEventProc.inst.set_HP_Max(player, player.getDefinedPropterty("HP_Max"));
            KBEEventProc.inst.set_MP(player, player.getDefinedPropterty("MP"));
            KBEEventProc.inst.set_MP_Max(player, player.getDefinedPropterty("MP_Max"));
            KBEEventProc.inst.set_level(player, player.getDefinedPropterty("level"));
            KBEEventProc.inst.set_name(player, player.getDefinedPropterty("name"));

            if ((SByte)player.getDefinedPropterty("state") == 1)
            {
                showRelivePanel();
            }
        }
    }
コード例 #8
0
    public void set_exp(KBEngine.Entity entity, object v)
    {
        //Debug.Log("set Exp ");
        if (!entity.isPlayer())
        {
            return;
        }
        // Debug.Log("set Exp " + v);
        object level = entity.getDefinedPropterty("level");

        Debug.LogWarning("level is " + (UInt16)level);
        object vv = Exp[(UInt16)level];

        //object vv = 2000;
        Debug.LogWarning("vv is " + (float)(Int32)vv);
        if (entity.isPlayer())
        {
            game_ui_autopos.updatePlayerBar_Exp(v, vv);
            if (onChangeexp != null)
            {
                onChangeexp(v);
            }
        }
    }
コード例 #9
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;
     }
 }
コード例 #10
0
    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();
        }
    }
コード例 #11
0
    void Update()
    {
        if (Camera.main == null)
        {
            Common.DEBUG_MSG("RPG_Controller::Update: not ready!");
            return;
        }

        if (characterController == null)
        {
            Common.DEBUG_MSG("Error: No Character Controller component found! Please add one to the GameObject which has this script attached.");
            return;
        }

        if (WorldManager.currinst != null)
        {
            WorldManager.ChunkPos currChunk = WorldManager.currinst.atChunk();
            if (currChunk.x >= 0 && currChunk.y >= 0)
            {
                if (WorldManager.currinst.loadedChunk(currChunk) == false)
                {
                    canControl = 0;
                    showAlert(true);
                    Common.DEBUG_MSG("RPG_Controller::Update: wait for load(" + (currChunk.x + 1) + "," + (currChunk.y + 1) + "), currpos=" + transform.position);
                    return;
                }

                if (WorldManager.currinst.loadedWorldObjsCamera() == false)
                {
                    canControl = 0;
                    showAlert(true);
                    Common.DEBUG_MSG("RPG_Controller::Update: wait for load(worldObject)!");
                    return;
                }

                if (canControl < 5)
                {
                    canControl += 1;
                    return;
                }

                if (enabled == false)
                {
                    // Common.DEBUG_MSG("RPG_Controller::Update: enabled = false!");
                    if (isShowAlert == true)
                    {
                        showAlert(false);
                    }
                    return;
                }

                KBEngine.Entity player = KBEngineApp.app.player();
                if (player == null)
                {
                    return;
                }

                walkSpeed = ((float)(Byte)player.getDefinedPropterty("moveSpeed")) / 10f;                 // 每秒速度
            }
        }

        GetInput();
        StartMotor();

        if (isShowAlert == true)
        {
            showAlert(false);
        }
    }
コード例 #12
0
 void InitAvatorInfo()
 {
     player = KBEngineApp.app.player();
     if (player != null && KBEEventProc.inst != null)
     {
         name.text       = player.getDefinedPropterty("name") + "";
         PhyDef.text     = player.getDefinedPropterty("PhyDef") + "";
         MagicAtack.text = player.getDefinedPropterty("MagicAtack") + "";
         MagicDef.text   = player.getDefinedPropterty("MagicDef") + "";
         PhyAtack.text   = player.getDefinedPropterty("PhyAtack") + "";
         level.text      = player.getDefinedPropterty("level") + "";
         exp.text        = player.getDefinedPropterty("Exp") + "";
         mp.text         = player.getDefinedPropterty("MP") + "/" + player.getDefinedPropterty("MP_Max");
         hp.text         = player.getDefinedPropterty("HP") + "/" + player.getDefinedPropterty("HP_Max");
     }
     //name.text = AvatorInfo.inst.name;
     //PhyDef.text = AvatorInfo.inst.phdef + "";
     //MagicAtack.text = AvatorInfo.inst.magicattack + "";
     //MagicDef.text = AvatorInfo.inst.madef + "";
     //PhyAtack.text = AvatorInfo.inst.phattack + "";
     //level.text = AvatorInfo.inst.level + "";
     //exp.text = AvatorInfo.inst.exp + "";
     //mp.text = AvatorInfo.inst.mp + "/" + AvatorInfo.inst.mpmax;
     //hp.text = AvatorInfo.inst.hp + "/" + AvatorInfo.inst.hpmax;
 }
コード例 #13
0
 void onChangehp(object o)
 {
     hp.text = o + "/" + player.getDefinedPropterty("HP_Max");
 }
コード例 #14
0
    // Use this for initialization
    void Start()
    {
        //信息弹框
        tipsInfo = transform.Find("Tips/popInfo").gameObject;
        name     = tipsInfo.transform.Find("name").GetComponent <UILabel>();
        des      = tipsInfo.transform.Find("des").GetComponent <UILabel>();
        power    = tipsInfo.transform.Find("power").GetComponent <UILabel>();
        price    = tipsInfo.transform.Find("price").GetComponent <UILabel>();
        tipsInfo.SetActive(false);

        //技能
        skillui = transform.Find("skillUI").gameObject;
        skillui.SetActive(false);
        skillUIbtn = transform.Find("sysctrls/Container/Scroll View/Grid/sysctrl_skill").gameObject;
        UIEventListener.Get(skillUIbtn).onClick = ShowSkillUI;

        //人物属性
        avatorUI = transform.Find("avatorUI").gameObject;
        avatorUI.SetActive(false);
        avatorUIbtn = transform.Find("sysctrls/Container/Scroll View/Grid/sysctrl_avatar").gameObject;
        UIEventListener.Get(avatorUIbtn).onClick = ShowAvatorUI;

        //背包
        BagUIbtn = transform.Find("sysctrls/Container/Scroll View/Grid/sysctrl_bag").gameObject;
        BagUI    = transform.Find("knapsackUI").gameObject;
        BagUI.SetActive(false);
        UIEventListener.Get(BagUIbtn).onClick = ShowBagUI;

        F1 = transform.Find("sysitemboxs/ContainerF/sys_itemslotsF/Grid/sys_itemslotF1").GetComponent <UISkillDragDropContainer>();
        F1.keyEventName = KeyCode.F1;
        F2 = transform.Find("sysitemboxs/ContainerF/sys_itemslotsF/Grid/sys_itemslotF2").GetComponent <UISkillDragDropContainer>();
        F2.keyEventName = KeyCode.F2;
        F3 = transform.Find("sysitemboxs/ContainerF/sys_itemslotsF/Grid/sys_itemslotF3").GetComponent <UISkillDragDropContainer>();
        F3.keyEventName = KeyCode.F3;
        F4 = transform.Find("sysitemboxs/ContainerF/sys_itemslotsF/Grid/sys_itemslotF4").GetComponent <UISkillDragDropContainer>();
        F4.keyEventName = KeyCode.F4;
        F5 = transform.Find("sysitemboxs/ContainerF/sys_itemslotsF/Grid/sys_itemslotF5").GetComponent <UISkillDragDropContainer>();
        F5.keyEventName = KeyCode.F5;
        F6 = transform.Find("sysitemboxs/ContainerF/sys_itemslotsF/Grid/sys_itemslotF6").GetComponent <UISkillDragDropContainer>();
        F6.keyEventName = KeyCode.F6;

        minimap         = transform.Find("minimap").gameObject;
        hp_label        = transform.Find("my_power_bar/hp_ProgressBar/Label").GetComponent <UILabel>();
        mp_label        = transform.Find("my_power_bar/mp_ProgressBar/Label").GetComponent <UILabel>();
        target_hp_label = transform.Find("target_power_bar/target_hp_ProgressBar/Label").GetComponent <UILabel>();
        target_mp_label = transform.Find("target_power_bar/target_mp_ProgressBar/Label").GetComponent <UILabel>();

        exp_ProgressBar = transform.Find("exp_ProgressBar").GetComponent <UISlider>();
        exp_label       = exp_ProgressBar.transform.Find("Label").GetComponent <UILabel>();

        hp_ProgressBar        = transform.Find("my_power_bar/hp_ProgressBar").GetComponent <UISlider>();
        target_hp_ProgressBar = transform.Find("target_power_bar/target_hp_ProgressBar").GetComponent <UISlider>();
        mp_ProgressBar        = transform.Find("my_power_bar/mp_ProgressBar").GetComponent <UISlider>();
        target_mp_ProgressBar = transform.Find("target_power_bar/target_mp_ProgressBar").GetComponent <UISlider>();

        name_label         = transform.Find("my_power_bar/ename").GetComponent <UILabel>();
        level_label        = transform.Find("my_power_bar/elevel").GetComponent <UILabel>();
        target_name_label  = transform.Find("target_power_bar/target_ename").GetComponent <UILabel>();
        target_level_label = transform.Find("target_power_bar/target_elevel").GetComponent <UILabel>();

        target_bar = transform.Find("target_power_bar").gameObject;
        hideTargetBar();
        ui_relive = transform.Find("relive").gameObject;
        UnityEngine.GameObject gobackrelive = ui_relive.transform.Find("gobackrelive").gameObject;
        UIEventListener.Get(gobackrelive).onClick = on_gobackreliveClick;
        UnityEngine.GameObject localrelive = ui_relive.transform.Find("localrelive").gameObject;
        UIEventListener.Get(localrelive).onClick = on_localreliveClick;
        hideRelivePanel();

        KBEngine.Entity player = KBEngineApp.app.player();
        if (player != null && KBEEventProc.inst != null)
        {
            KBEEventProc.inst.set_HP(player, player.getDefinedPropterty("HP"));
            KBEEventProc.inst.set_HP_Max(player, player.getDefinedPropterty("HP_Max"));
            KBEEventProc.inst.set_MP(player, player.getDefinedPropterty("MP"));
            KBEEventProc.inst.set_MP_Max(player, player.getDefinedPropterty("MP_Max"));
            KBEEventProc.inst.set_level(player, player.getDefinedPropterty("level"));
            KBEEventProc.inst.set_name(player, player.getDefinedPropterty("name"));
            KBEEventProc.inst.set_exp(player, player.getDefinedPropterty("Exp"));

            if ((SByte)player.getDefinedPropterty("state") == 1)
            {
                showRelivePanel();
            }
        }
    }