Exemplo n.º 1
0
    public bool AddConstraint(BTypedConstraint c)
    {
        if (!isDisposed)
        {
            if (physicWorldParameters.worldType < WorldType.RigidBodyDynamics)
            {
                Debug.LogError("World type must not be collision only");
                return(false);
            }

            if (physicWorldParameters.debugType >= BDebug.DebugType.Debug)
            {
                Debug.LogFormat("Adding constraint {0} to world", c);
            }

            if (c._BuildConstraint())
            {
                DWorld.AddConstraint(c.GetConstraint(), c.disableCollisionsBetweenConstrainedBodies);
                c.m_isInWorld = true;
            }

            return(true);
        }

        return(false);
    }
Exemplo n.º 2
0
    public bool RemoveRigidBody(RigidBody rb)
    {
        if (!isDisposed)
        {
            if (physicWorldParameters.worldType < WorldType.RigidBodyDynamics)
            {
                Debug.LogError("World type must not be collision only");
                return(false);
            }

            if (physicWorldParameters.debugType >= BDebug.DebugType.Debug)
            {
                Debug.LogFormat("Removing rigidbody {0} from world", rb.UserObject);
            }

            DWorld.RemoveRigidBody(rb);

            if (rb.UserObject is BCollisionObject)
            {
                ((BCollisionObject)rb.UserObject).isInWorld = false;
            }

            return(true);
        }

        return(false);
    }
Exemplo n.º 3
0
    public void TryReceiveReward(ECopyType copyType, int chapter, int awardIndex)
    {
        if (awardIndex < 0 || awardIndex > 2)
        {
            GTItemHelper.ShowTip("非法AwardIndex" + awardIndex);
            return;
        }
        int rewardState = RaidModule.Instance.GetChapterRewardStateByAwardIndex(chapter, awardIndex);

        switch (rewardState)
        {
        case ERewardState.NOT_RECEIVE:
            GTItemHelper.ShowTip("未达成条件");
            return;

        case ERewardState.HAS_RECEIVE:
            GTItemHelper.ShowTip("奖励已领取");
            return;
        }
        DWorld chapterDB = ReadCfgWorld.GetDataById(chapter);
        DAward awardDB   = ReadCfgAward.GetDataById(chapterDB.Awards[awardIndex]);

        if (GTItemHelper.CheckBagFull(awardDB.MaxDropNum))
        {
            return;
        }

        ReqGetChapterAward req = new ReqGetChapterAward();

        req.CopyType = (int)copyType;
        req.Chapter  = chapter;
        req.Index    = awardIndex;
        NetworkManager.Instance.Send <ReqGetChapterAward>(MessageID.MSG_REQ_GET_CHAPTERAWARD, req);
    }
Exemplo n.º 4
0
    public bool RemoveConstraint(TypedConstraint c)
    {
        if (!isDisposed)
        {
            if (physicWorldParameters.worldType < WorldType.RigidBodyDynamics)
            {
                Debug.LogError("World type must not be collision only");
                return(false);
            }

            if (physicWorldParameters.debugType >= BDebug.DebugType.Debug)
            {
                Debug.LogFormat("Removing constraint {0} from world", c.Userobject);
            }

            DWorld.RemoveConstraint(c);

            if (c.Userobject is BTypedConstraint)
            {
                ((BTypedConstraint)c.Userobject).m_isInWorld = false;
            }

            return(true);
        }

        return(false);
    }
Exemplo n.º 5
0
    public bool CheckCopy(ECopyType copyType, int chapter, int copyID)
    {
        int    key = (int)copyType;
        DWorld db  = ReadCfgWorld.GetDataById(chapter);

        if (DataDBSRaid.ContainsKey(key))
        {
            XRaid raid = DataDBSRaid.GetDataById(key);
            if (chapter > raid.MaxChapter)
            {
                if (chapter != raid.MaxChapter + 1)
                {
                    GTItemHelper.ShowTip(string.Format("章节超出限制:{0}/{1}", chapter, raid.MaxChapter));
                    return(false);
                }
                if (copyID != db.Copys[0])
                {
                    GTItemHelper.ShowTip("非法CopyID" + copyID);
                    return(false);
                }
            }
            else if (chapter == raid.MaxChapter)
            {
                if (copyID > raid.MaxCopyId + 1)
                {
                    GTItemHelper.ShowTip("非法CopyID" + copyID);
                    return(false);
                }
            }
        }
        return(true);
    }
Exemplo n.º 6
0
    public int GetChapterRewardStateByAwardIndex(int chapter, int index)
    {
        if (!DataDBSMainChapter.ContainsKey(chapter))
        {
            return(ERewardState.NOT_RECEIVE);
        }
        XMainChapter vo      = DataDBSMainChapter.GetDataById(chapter);
        DWorld       db      = ReadCfgWorld.GetDataById(chapter);
        int          starNum = GetChapterStarNumByChapter(chapter);

        if (starNum < db.Stars[index])
        {
            return(ERewardState.NOT_RECEIVE);
        }
        int s = 0;

        switch (index)
        {
        case 0:
            s = vo.Award1;
            break;

        case 1:
            s = vo.Award2;
            break;

        case 2:
            s = vo.Award3;
            break;
        }
        return(s == 1 ? ERewardState.HAS_RECEIVE : ERewardState.CAN_RECEIVE);
    }
Exemplo n.º 7
0
    public bool AddRigidBody(BRigidBody rb)
    {
        if (!isDisposed)
        {
            if (physicWorldParameters.worldType < WorldType.RigidBodyDynamics)
            {
                Debug.LogError("World type must not be collision only");
                return(false);
            }

            if (physicWorldParameters.debugType >= BDebug.DebugType.Debug)
            {
                Debug.LogFormat("Adding rigidbody {0} to world", rb);
            }

            if (rb._BuildCollisionObject())
            {
                DWorld.AddRigidBody((RigidBody)rb.GetCollisionObject(), rb.groupsIBelongTo, rb.collisionMask);
                rb.isInWorld = true;
            }

            return(true);
        }

        return(false);
    }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes the engine and sets the instance value.
 /// </summary>
 void Awake()
 {
     instance   = this;
     bodyCount  = 0;
     bodies     = new List <DBody>();
     detector   = new SimpleDetector();
     integrator = new EulerImplicit();
     contacts   = new HashSet <Manifold>();
     simulate   = false;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes the engine and sets the instance value.
 /// </summary>
 void Awake()
 {
     instance   = this;
     bodyCount  = 0;
     bodies     = new List <DBody>();
     detector   = new HashGridDetector(cellSize, sceneWidth, sceneHeight);
     integrator = new EulerImplicit();
     contacts   = new HashSet <Manifold>();
     simulate   = false;
 }
Exemplo n.º 10
0
    private void ShowDialogueContent(DDialogue db)
    {
        string replaceName = string.Empty;

        switch (db.ContentType)
        {
        case EDialogueContentType.TYPE_NONE:
        {
            replaceName = string.Empty;
        }
        break;

        case EDialogueContentType.TYPE_PLAYER:
        {
            Character c = CharacterManager.Main;
            replaceName = c == null ? string.Empty : c.Name;
        }
        break;

        case EDialogueContentType.TYPE_ACTOR:
        {
            DActor actorDB = ReadCfgActor.GetDataById(db.ContentID);
            replaceName = actorDB == null ? string.Empty : actorDB.Name;
        }
        break;

        case EDialogueContentType.TYPE_ITEM:
        {
            DItem itemDB = ReadCfgItem.GetDataById(db.ContentID);
            replaceName = itemDB == null ? string.Empty : itemDB.Name;
        }
        break;

        case EDialogueContentType.TYPE_MAP:
        {
            DWorld worldDB = ReadCfgWorld.GetDataById(db.ContentID);
            replaceName = worldDB == null ? string.Empty : worldDB.Name;
        }
        break;
        }
        dlgContent.text = db.Content.Replace("%p%", replaceName);

        switch (db.ContentShowType)
        {
        case EDialogueContentShowType.Normal:
            dlgContent.GetComponent <TypewriterEffect>().enabled = false;
            break;

        case EDialogueContentShowType.Effect:
            dlgContent.GetComponent <TypewriterEffect>().enabled = true;
            dlgContent.GetComponent <TypewriterEffect>().ResetToBeginning();
            break;
        }
    }
Exemplo n.º 11
0
    public void ShowViewByChapter(int chapterID)
    {
        mChapter = chapterID;
        DWorld chapterDB = ReadCfgWorld.GetDataById(chapterID);

        for (int i = 0; i < 3; i++)
        {
            mBoxStarNums[i].text = chapterDB.Stars[i].ToString();
            int rewardState = RaidModule.Instance.GetChapterRewardStateByAwardIndex(chapterID, i);
            switch (rewardState)
            {
            case ERewardState.NOT_RECEIVE:
            case ERewardState.CAN_RECEIVE:
                mBoxStates[i].spriteName = "613";
                break;

            case ERewardState.HAS_RECEIVE:
                mBoxStates[i].spriteName = "614";
                break;
            }
        }

        int copysNum = chapterDB.Copys.Length;

        mChapterName.text = chapterDB.Name;
        GTItemHelper.ShowTexture(mMapTexture, chapterDB.Map);
        int enterIndex = RaidModule.Instance.GetMaxCanEnterCopyIndex(mCurCopyType, chapterID);

        for (int i = 0; i < mCopyItems.Count; i++)
        {
            ItemCopy item = mCopyItems[i];
            if (i < copysNum)
            {
                item.item.SetActive(true);
                item.Show(i < enterIndex);
                int   copyID  = chapterDB.Copys[i];
                DCopy db      = ReadCfgCopy.GetDataById(copyID);
                int   starNum = RaidModule.Instance.GetCopyStarNumById(copyID);
                item.copyName.text = db.Name;
                item.item.transform.localPosition = chapterDB.CopyPosArray[i];
                GTItemHelper.ShowStarNum(item.stars, starNum);
            }
            else
            {
                mCopyItems[i].item.SetActive(false);
            }
            if (i == enterIndex - 1)
            {
                mLight.gameObject.SetActive(false);
                mLight.transform.parent        = item.item.transform;
                mLight.transform.localPosition = Vector3.zero;
            }
        }
    }
Exemplo n.º 12
0
    public int GetChapterStarNumByChapter(int chapter)
    {
        int starNum = 0;

        if (DataDBSMainChapter.ContainsKey(chapter))
        {
            DWorld db = ReadCfgWorld.GetDataById(chapter);
            for (int i = 0; i < db.Copys.Length; i++)
            {
                starNum += GetCopyStarNumById(db.Copys[i]);
            }
        }
        return(starNum);
    }
Exemplo n.º 13
0
    private void OnBoxClick(GameObject go)
    {
        GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK);
        int    index = go.name.ToInt32() - 1;
        DWorld db    = ReadCfgWorld.GetDataById(mChapter);

        GTWindowManager.Instance.OpenWindow(EWindowID.UIAwardBox);
        UIAwardBox window = (UIAwardBox)GTWindowManager.Instance.GetWindow(EWindowID.UIAwardBox);
        int        state  = RaidModule.Instance.GetChapterRewardStateByAwardIndex(mChapter, index);

        UIEventListener.VoidDelegate doReceive = delegate(GameObject w)
        {
            RaidService.Instance.TryReceiveReward(mCurCopyType, mChapter, index);
        };
        window.ShowAwardById(db.Awards[index], state, doReceive);
    }
Exemplo n.º 14
0
    private void OnAck_GetChapterAward(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckGetChapterAward     ack = Serializer.Deserialize <AckGetChapterAward>(ms);
        int chapter    = ack.Chapter;
        int awardIndex = ack.Index;

        DWorld       db = ReadCfgWorld.GetDataById(chapter);
        XMainChapter xc;

        if (!DataDBSMainChapter.ContainsKey(chapter))
        {
            xc    = new XMainChapter();
            xc.Id = chapter;
        }
        else
        {
            xc = DataDBSMainChapter.GetDataById(chapter);
        }

        switch (awardIndex)
        {
        case 0:
            xc.Award1 = 1;
            break;

        case 1:
            xc.Award2 = 1;
            break;

        case 3:
            xc.Award3 = 1;
            break;
        }

        DataDBSMainChapter.Update(chapter, xc);

        int            awardID = db.Awards[awardIndex];
        List <KStruct> list    = AwardModule.Instance.GetAwardDataByID(awardID);

        for (int i = 0; i < list.Count; i++)
        {
            GTDataManager.Instance.AddNewItem(list[i].Id, list[i].Num);
        }

        GTEventCenter.FireEvent(GTEventID.TYPE_GET_CHAPTERAWARD);
    }
Exemplo n.º 15
0
    private void OnCopyClick(GameObject go)
    {
        GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK);
        DWorld chapterDB  = ReadCfgWorld.GetDataById(mChapter);
        int    enterIndex = RaidModule.Instance.GetMaxCanEnterCopyIndex(mCurCopyType, mChapter);
        int    index      = go.name.ToInt32();

        if (index > enterIndex)
        {
            GTItemHelper.ShowTip("未通关前置关卡");
            return;
        }
        GTWindowManager.Instance.OpenWindow(EWindowID.UIMainGate);
        UIMainGate window = (UIMainGate)GTWindowManager.Instance.GetWindow(EWindowID.UIMainGate);

        window.ShowViewById(mCurCopyType, mChapter, chapterDB.Copys[index - 1]);
    }
Exemplo n.º 16
0
    public bool AddAction(IAction action)
    {
        if (!isDisposed)
        {
            if (physicWorldParameters.worldType < WorldType.RigidBodyDynamics)
            {
                Debug.LogError("World type must not be collision only");
            }
            else
            {
                DWorld.AddAction(action);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 17
0
    private void ShowInitView()
    {
        transform.Find("Center").gameObject.SetActive(true);
        mapColor.gameObject.SetActive(true);
        background.gameObject.SetActive(true);
        int   pChapter          = RaidModule.Instance.GetMaxChapterByCopyType(ECopyType.TYPE_WORLD);
        Color pOpenNameColor    = new Color32(246, 139, 4, 255);
        Color pOpenChapterColor = new Color32(246, 209, 4, 255);

        for (int i = 0; i < mAreas.Count; i++)
        {
            WorldArea tab = mAreas[i];
            tab.areaIcon1.gameObject.SetActive(true);
            GTItemHelper.ShowImageBlack(tab.areaIcon1, !tab.isOpen);
            int    chapter = DWorld.WORLD_ST_CHAPTER_ID + i;
            DWorld db      = ReadCfgWorld.GetDataById(chapter);
            tab.areaName.text     = db.Name;
            tab.areaName.color    = tab.isOpen ? pOpenNameColor : Color.gray;
            tab.areaChapter.text  = GTTools.Format("第 {0} 章", chapter);
            tab.areaChapter.color = tab.isOpen ? pOpenChapterColor : Color.gray;
        }
    }
Exemplo n.º 18
0
    public int GetMaxCanEnterChapter(ECopyType copyType)
    {
        int key     = (int)copyType;
        int chapter = 0;

        if (DataDBSRaid.ContainsKey(key))
        {
            XRaid  raid      = DataDBSRaid.GetDataById(key);
            DWorld chapterDB = ReadCfgWorld.GetDataById(raid.MaxChapter);
            if (chapterDB.Copys[chapterDB.Copys.Length - 1] == raid.MaxCopyId)
            {
                chapter = GetNextChapter(raid.MaxChapter);
            }
            else
            {
                chapter = raid.MaxChapter;
            }
        }
        else
        {
            chapter = DWorld.WORLD_ST_CHAPTER_ID;
        }
        return(chapter);
    }
Exemplo n.º 19
0
    public int GetMaxCanEnterCopyIndex(ECopyType copyType, int chapterID)
    {
        int    maxCopyID  = GetMaxCopyIdByCopyType(copyType);
        int    maxChapter = GetMaxChapterByCopyType(copyType);
        DWorld db         = ReadCfgWorld.GetDataById(chapterID);

        if (maxChapter == 0 && chapterID == DWorld.WORLD_ST_CHAPTER_ID)
        {
            return(1);
        }
        if (maxChapter > chapterID)
        {
            return(db.Copys.Length);
        }
        if (maxChapter == chapterID)
        {
            if (maxCopyID >= 0)
            {
                int index = 1;
                for (int i = 0; i < db.Copys.Length; i++)
                {
                    if (db.Copys[i] <= maxCopyID)
                    {
                        index++;
                    }
                    else
                    {
                        break;
                    }
                }
                index = index > db.Copys.Length ? db.Copys.Length : index;
                return(index);
            }
        }
        return(0);
    }
Exemplo n.º 20
0
 private void StepSimulation_SubStep_and_TimeStep()
 {
     DWorld.StepSimulation(physicWorldParameters.fixedDeltaTime, physicWorldParameters.maxSubsteps, physicWorldParameters.subFixedTimeStep);
 }
Exemplo n.º 21
0
 void Start()
 {
     this.physics = DWorld.Instance;
 }
Exemplo n.º 22
0
 private void StepSimulation_OneStep()
 {
     DWorld.StepSimulation(physicWorldParameters.fixedDeltaTime);
 }
Exemplo n.º 23
0
 private void StepSimulation_SubStep()
 {
     DWorld.StepSimulation(physicWorldParameters.fixedDeltaTime, physicWorldParameters.maxSubsteps);
 }