Esempio n. 1
0
    private void Update()
    {
        if (curInterObj == null)
        {
            curInterObjScript = null;
            curInterUIScript  = null;
        }
        if (Input.GetButtonDown("Interact") && curInterObj)
        {
            if (curInterUIScript)
            {
                curInterUIScript.DoInter();
            }
            //Check to see if this object is to be stored in inventory


            else if (curInterObjScript)
            {
                if (curInterObjScript.inventory)
                {
                    inventory.AddItem(curInterObj);
                    curInterObj = null;
                }
                else if (curInterObjScript.talks)
                {
                    curInterObjScript.Talk();
                }
            }
        }
    }
Esempio n. 2
0
        IEnumerator StartHapticUntilUnused(GameObject usingObj)
        {
            VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(usingObj);

            while (InterObject.IsUsing())
            {
                VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, hapticPulseStrength, hapticPulseDuration, hapticPulseInterval);
                yield return(waitForJudgeIfBeingUsed);
            }

            var lastTime = 5;

            for (int i = 0; i <= lastTime; i++)
            {
                float currentStrengh = Mathf.Lerp(hapticPulseStrength, 2 * hapticPulseStrength / 3, (float)i / lastTime);
                VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, currentStrengh, hapticPulseDuration, hapticPulseInterval);
                yield return(new WaitForSeconds(0.05f));
            }
            //--------------------------------------------
            for (int i = 0; i <= lastTime; i++)
            {
                float currentStrengh = Mathf.Lerp(2 * hapticPulseStrength / 3, 0, (float)i / lastTime);
                VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, currentStrengh, hapticPulseDuration, hapticPulseInterval);
                yield return(new WaitForSeconds(0.05f));
            }
        }
Esempio n. 3
0
 private void InitEvent()
 {
     InterObject.InteractableObjectUsed += (sender, e) => {
         StopAllCoroutines();
         GameObject usingObj = InterObject.GetUsingObject();
         // print(usingObj);
     };
 }
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Item")
     {
         Debug.Log(other.name);
         currentInteractiveObject = other.gameObject;
         currentInterObjectScript = currentInteractiveObject.GetComponent <InterObject>();
     }
 }
Esempio n. 5
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("interObject"))
     {
         Debug.Log(other.name);
         curInterObj       = other.gameObject;
         curInterObjScript = curInterObj.GetComponent <InterObject>();
     }
 }
Esempio n. 6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("door"))
     {
         interCode = 1;
         d         = collision.GetComponent <Doorway>();
     }
     if (collision.CompareTag("interactable"))
     {
         currentObject = collision.gameObject;
         interCode     = 2;
         inter         = collision.GetComponent <InterObject>();
     }
     if (collision.CompareTag("star"))
     {
         stars++;
     }
 }
Esempio n. 7
0
    public void AddObject(InterObject interObject)
    {
        List <InterObject> listInterObject = null;
        eTeamType          teamType        = interObject.TEAM_TYPE;

        // 리스트 생성 또는 로드
        if (DicInterObject.ContainsKey(teamType) == false)
        {
            listInterObject = new List <InterObject>();
            DicInterObject.Add(teamType, listInterObject);
        }
        else
        {
            DicInterObject.TryGetValue(teamType, out listInterObject);
        }

        listInterObject.Add(interObject);
    }
Esempio n. 8
0
                public void Update()
                {
                    UpdateExchangeModel();
                    if (m_pkgBossInfo == null || m_pkgBossInfo.state == 1)
                    {
                        return;
                    }

                    //刷新墓碑状态下的名字倒计时
                    InterObject inter_object = InterObjectManager.Instance.GetObject(m_uid);

                    if (inter_object != null)
                    {
                        // 查询特殊怪物表
                        var data_mon_attr = DBManager.Instance.GetDB <DBSpecialMon>().GetData(m_pkgBossInfo.id);
                        if (data_mon_attr == null)
                        {
                            GameDebug.LogError("Cannot find special monster info,id:" + m_pkgBossInfo.id);
                            return;
                        }

                        var  actor_id   = data_mon_attr.ActorId;
                        uint leave_time = 0;
                        if (m_pkgBossInfo.refresh_time > Game.GetInstance().ServerTime)
                        {
                            leave_time = (m_pkgBossInfo.refresh_time - Game.GetInstance().ServerTime);
                        }

                        string time_format = CommonTool.SecondsToStr((int)leave_time);

                        string fmt = xc.DBConstText.GetText("BOSS_REFRESH_TXT_NAME");
                        if (ActorHelper.IsHomeBoss(actor_id) || // boss之家
                            ActorHelper.IsSouthLandBoss(actor_id) ||   // 南天圣地
                            ActorHelper.IsElementAreaBoss(actor_id) || // 元素禁地
                            ActorHelper.IsServerBoss(actor_id)         // 跨服boss
                            )
                        {
                            fmt = xc.DBConstText.GetText("BOSS_REFRESH_TXT_NAME_2");
                        }

                        string name_str = string.Format(fmt, m_monster_name, time_format);
                        inter_object.SetNameLabel(name_str);
                    }
                }
Esempio n. 9
0
 private void OnTriggerExit2D(Collider2D other)
 {
     if (other.CompareTag("interUI"))
     {
         if (other.gameObject == curInterObj)
         {
             curInterObj      = null;
             curInterUIScript = null;
         }
     }
     if (other.CompareTag("interObject"))
     {
         if (other.gameObject == curInterObj)
         {
             curInterObj       = null;
             curInterObjScript = null;
         }
     }
 }
Esempio n. 10
0
    public void RemoveObject(InterObject interObject, bool bDelete = false)
    {
        eTeamType teamType = interObject.TEAM_TYPE;

        if (DicInterObject.ContainsKey(teamType) == true)
        {
            List <InterObject> listInterObject = null;
            DicInterObject.TryGetValue(teamType, out listInterObject);
            listInterObject.Remove(interObject);
        }
        else
        {
            Debug.LogError("존재 하지 않는 엑터를 삭제하려고 합니다.");
        }

        if (bDelete)
        {
            Destroy(interObject.gameObject);
        }
    }
Esempio n. 11
0
                public void UpdateExchangeModel()
                {
                    if (m_need_update_exchange_model == false)
                    {
                        return;
                    }

                    if (m_pkgBossInfo == null)
                    {
                        return;
                    }

                    if (m_pkgBossInfo.state == 1)//世界BOSS处于存活状态,删除墓碑
                    {
                        if (m_uid != null)
                        {
                            InterObjectManager.Instance.DestroyObject(m_uid);
                            m_uid = null;
                        }
                        m_need_update_exchange_model = false;
                    }
                    else//BOSS已经死亡; BOSS播放完死亡动画=>删除BOSS怪物=>创建墓碑
                    {
                        // 查询特殊怪物表
                        var data_mon_attr = DBManager.Instance.GetDB <DBSpecialMon>().GetData(m_pkgBossInfo.id);
                        if (data_mon_attr == null)
                        {
                            GameDebug.LogError("Cannot find special monster info,id:" + m_pkgBossInfo.id);
                            return;
                        }

                        var actor_id = data_mon_attr.ActorId;

                        Dictionary <UnitID, Actor> boss_actor_dict = ActorManager.Instance.GetMonsterSetByActorId(actor_id);
                        bool can_destroy_model = true;
                        foreach (var item in boss_actor_dict)
                        {
                            Actor death_boss_actor = item.Value;
                            if (death_boss_actor != null && death_boss_actor.transform != null)
                            {
                                m_model_Quaternion = death_boss_actor.transform.rotation;
                                Vector3 new_pos = death_boss_actor.transform.position;
                                if (new_pos.y < -500)
                                {
                                    GameDebug.LogError(string.Format("boss_actor pos maybe is error new_pos = {0}, {1}, {2}",
                                                                     new_pos.x, new_pos.y, new_pos.z));
                                }
                                else
                                {
                                    m_pos = death_boss_actor.transform.position;
                                }
                            }

                            if (death_boss_actor != null)
                            {
                                AnimationOptions op = death_boss_actor.GetAnimationOptions(Actor.EAnimation.death);
                                if (op != null && can_destroy_model)
                                {
                                    if (death_boss_actor.IsPlaying())
                                    {
                                        can_destroy_model = false;
                                    }
                                }
                            }
                        }

                        if (has_created_inter_object == false)
                        {
                            has_created_inter_object = true;
                            m_monster_name           = RoleHelp.GetActorName(actor_id);
                            string      prefab = string.Format("Assets/Res/{0}.prefab", RoleHelp.GetPrefabName(actor_id));
                            InterObject create_inter_object = InterObjectManager.Instance.CreateObject <InterObject>(m_uid, prefab, m_pos, m_model_Quaternion, RoleHelp.GetPrefabScale(actor_id));
                            if (create_inter_object != null)
                            {
                                create_inter_object.m_StyleInfo.Offset       = new Vector3(0, 2.8f, 0);
                                create_inter_object.m_StyleInfo.HeadOffset   = new Vector3(0, 2.0f, 0);
                                create_inter_object.m_StyleInfo.ScreenOffset = UI3DText.NameTextScreenOffset;
                                create_inter_object.m_StyleInfo.Scale        = Vector3.one;
                                create_inter_object.m_StyleInfo.IsShowBg     = false;
                                create_inter_object.m_StyleInfo.SpritName    = "";

                                create_inter_object.IsVisible = false;
                                DBWorldBoss.DBWorldBossItem boss_item = DBManager.Instance.GetDB <DBWorldBoss>().GetData(m_pkgBossInfo.id);
                                if (boss_item != null)
                                {
                                    create_inter_object.SetCollider(boss_item.DeathModelCenter, boss_item.DeathModelRadius);
                                }
                            }
                        }

                        if (can_destroy_model)
                        {
                            InterObject create_inter_object = InterObjectManager.Instance.GetObject(m_uid);
                            if (create_inter_object != null)
                            {
                                create_inter_object.IsVisible = true;
                                create_inter_object.SetPosAndQuaternion(m_pos, m_model_Quaternion);
                            }
                            m_need_update_exchange_model = false;
                        }
                    }
                }
Esempio n. 12
0
 // Start is called before the first frame update
 private void Start()
 {
     io = this.GetComponent <InterObject>();
 }