getPostInt() public static méthode

public static getPostInt ( string name ) : Int32
name string
Résultat Int32
    void OnItemPick()
    {
        if (_player == null)
        {
            _player = UnityEngine.GameObject.FindGameObjectWithTag("Player");
        }
        if (_inventory == null && _player != null)
        {
            _inventory = _player.GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>();
        }
        if (_inventory != null)
        {
            float distance = Vector3.Distance(this.gameObject.transform.position, _player.transform.position);

            if (distance <= 3)
            {
                //bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);
                //if (check)
                //    Destroy(this.gameObject);
                if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
                {
                    DroppedItem item = (DroppedItem)KBEngineApp.app.findEntity(Utility.getPostInt(gameObject.name));
                    if (item != null)
                    {
                        item.pickUpRequest();
                    }
                    //_inventory.addItemToInventory(item.itemID, item.itemValue);
                    //_inventory.updateItemList();
                    //_inventory.stackableSettings();
                    //Destroy(this.gameObject);
                }
            }
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        KBEngine.Entity entity = KBEngineApp.app.player();
        KBEngine.Avatar avatar = null;
        if (entity != null && entity.className == "Avatar")
        {
            avatar = (KBEngine.Avatar)entity;
        }

        if (avatar != null)
        {
            text_pos.text = avatar.position.x.ToString("#.0") + "," + avatar.position.z.ToString("#.0");

            foreach (Skill sk in SkillBox.inst.skills)
            {
                sk.updateTimer(Time.deltaTime);//更新技能的冷却时间
            }
        }
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 100.0f, 1 << LayerMask.NameToLayer("CanAttack")))
            {
                UI_Target ui_target = World.instance.getUITarget();
                ui_target.GE_target = hit.collider.GetComponent <GameEntity>();
                ui_target.UpdateTargetUI();

                string name = Utility.getPreString(ui_target.GE_target.name);
                if (name == "NPC" && !MenuBox.hasMenu())
                {
                    Int32 id   = Utility.getPostInt(ui_target.GE_target.name);
                    NPC   _npc = (NPC)KBEngineApp.app.findEntity(id);

                    if (_npc != null)
                    {
                        UInt32 dialogID = _npc.dialogID;
                        avatar.dialog(id, dialogID);
                    }
                }
            }
        }
        //更新消耗品计时器
        ConsumeLimitCD.instance.Update(Time.deltaTime);
    }
Exemple #3
0
    public void AttackSkill(int skillId)
    {
        KBEngine.Entity entity = KBEngineApp.app.player();
        KBEngine.Avatar avatar = null;
        if (entity != null && entity.className == "Avatar")
        {
            avatar = (KBEngine.Avatar)entity;
        }
        if (avatar == null)
        {
            return;
        }

        UI_Target ui_target = World.instance.getUITarget();

        if (ui_target != null && ui_target.GE_target != null)
        {
            string name     = ui_target.GE_target.name;
            Int32  entityId = Utility.getPostInt(name);

            if (avatar != null)
            {
                int errorCode = avatar.useTargetSkill(skillId, entityId);
                if (errorCode == 1)
                {
                    UI_ErrorHint._instance.errorShow("目标太远");
                    //逼近目标
                    UnityEngine.GameObject renderEntity = (UnityEngine.GameObject)entity.renderObj;
                    renderEntity.GetComponent <MoveController>().moveTo(ui_target.GE_target.transform, SkillBox.inst.get(skillId).canUseDistMax - 1, skillId);
                }
                if (errorCode == 2)
                {
                    UI_ErrorHint._instance.errorShow("技能冷却");
                }
                if (errorCode == 3)
                {
                    UI_ErrorHint._instance.errorShow("目标已死亡");
                }
            }
        }
        else
        {
            if (skillId == 3)//治疗自己
            {
                if (avatar != null)
                {
                    int errorCode = avatar.useTargetSkill(skillId, avatar.id);
                    if (errorCode == 2)
                    {
                        UI_ErrorHint._instance.errorShow("技能冷却");
                    }
                    if (errorCode == 3)
                    {
                        UI_ErrorHint._instance.errorShow("目标已死亡");
                    }
                }
            }
            else
            {
                UI_ErrorHint._instance.errorShow("未选择目标");
            }
        }
    }