コード例 #1
0
    override protected void doSth(myEvent toDo)
    {
        switch (toDo.type)
        {
        case eventType.text:
            if (npc != null)
            {
                npc.changeTurn(-player.GetComponent <Player>().turn);
            }
            string _name = gameManager.instance.hat.find(toDo.str1, gameManager.instance.setting.nowlang);
            string text  = gameManager.instance.hat.find(toDo.str2, gameManager.instance.setting.nowlang);
            if (toDo.bool1)
            {
                showTextPanel(_name, text, gameManager.instance.hat.findImg(toDo.str3), gameManager.instance.hat.findAudio(toDo.str4), gameManager.instance.hat.findPitch(toDo.str4));
            }
            else
            {
                showTextPanel(_name, text, null, gameManager.instance.hat.findAudio(toDo.str4), gameManager.instance.hat.findPitch(toDo.str4));
            }
            break;

        case eventType.changeIndependentSwitch:
            setIndependentSwitch(toDo.bool1, (int)toDo.independentSwitch);
            pushNow(true); break;

        case eventType.If:
            if (eventListDefine.checkCondition(toDo.condition, eventLists[nowList].events.eventList.independentSwitchs))
            {
                pushNow(true);
            }
            else
            {
                eventLists[nowList].events.thisNow += (toDo.int1 + 1);
            }
            break;

        default: break;
        }
    }
コード例 #2
0
ファイル: tools.cs プロジェクト: cafel176/RPGFrameWork
    // 公用的写在这里,各自个性化的写在dosth里
    protected void toolsDoSth(myEvent toDo)
    {
        switch (toDo.type)
        {
        case eventType.beBlack: beBlack(toDo.float1); break;

        case eventType.beWhite: beWhite(toDo.float1); break;

        case eventType.wait: waitForTime(toDo.float1); break;

        case eventType.startUserControl: pushNow(true); startUserControl(); break;

        case eventType.stopUserControl: pushNow(true); stopUserControl(); break;

        case eventType.changeGlobalInt:
            calValue cal = toDo.howToCal;
            int      u   = dataManager.instance.getInt(toDo.str1);
            if (cal == calValue.add)
            {
                dataManager.instance.setInt(toDo.str1, u + toDo.int1);
            }
            else if (cal == calValue.minus)
            {
                dataManager.instance.setInt(toDo.str1, u - toDo.int1);
            }
            else if (cal == calValue.multiply)
            {
                dataManager.instance.setInt(toDo.str1, u * toDo.int1);
            }
            else if (cal == calValue.divide)
            {
                dataManager.instance.setInt(toDo.str1, u / toDo.int1);
            }
            else
            {
                dataManager.instance.setInt(toDo.str1, toDo.int1);
            }
            pushNow(true); break;

        case eventType.changeGlobalFloat:
            cal = toDo.howToCal;
            float y = dataManager.instance.getFloat(toDo.str1);
            if (cal == calValue.add)
            {
                dataManager.instance.setFloat(toDo.str1, y + toDo.float1);
            }
            else if (cal == calValue.minus)
            {
                dataManager.instance.setFloat(toDo.str1, y - toDo.float1);
            }
            else if (cal == calValue.multiply)
            {
                dataManager.instance.setFloat(toDo.str1, y * toDo.float1);
            }
            else if (cal == calValue.divide)
            {
                dataManager.instance.setFloat(toDo.str1, y / toDo.float1);
            }
            else
            {
                dataManager.instance.setFloat(toDo.str1, toDo.float1);
            }
            pushNow(true); break;

        case eventType.changeGlobalSwith:
            dataManager.instance.setSwitch(toDo.str1, toDo.bool1);
            pushNow(true); break;

        case eventType.debugLog:
            Debug.Log(toDo.str1);
            pushNow(true); break;

        case eventType.playBgm:
            playMusic(gameManager.instance.hat.findAudio(toDo.str1));
            pushNow(true); break;

        case eventType.stopBgm:
            finishBgm = false;
            pushNow(true); break;

        case eventType.playBgs:
            playBGS(gameManager.instance.hat.findAudio(toDo.str1));
            pushNow(true); break;

        case eventType.stopBgs:
            finishBgs = false;
            pushNow(true); break;

        case eventType.playSE:
            playSE(gameManager.instance.hat.findAudio(toDo.str1), gameManager.instance.hat.findPitch(toDo.str1));
            pushNow(true); break;

        case eventType.showPic:
            UIManager.instance.showPicPanel(toDo.str1, toDo.vec2_1, gameManager.instance.hat.findImg(toDo.str2), toDo.float1 / 255.0f);
            pushNow(true); break;

        case eventType.movePic:
            UIManager.instance.movePicPanel(toDo.str1, toDo.vec2_1, toDo.float1 / 255.0f, toDo.float2);
            if (toDo.bool1)
            {
                waitForTime(toDo.float2);
            }
            else
            {
                pushNow(true);
            }
            break;

        case eventType.hidePic: pushNow(true);
            UIManager.instance.hidePicPanel(toDo.str1); break;

        case eventType.textSpecial:
            string text = gameManager.instance.hat.find(toDo.str1, gameManager.instance.setting.nowlang);
            showSpecialTextPanel(text, toDo.vec2_1, gameManager.instance.hat.findAudio(toDo.str2), gameManager.instance.hat.findPitch(toDo.str2));
            break;

        case eventType.changeScene:
            pushNow(true);
            Vector2 t = new Vector2(0, 1);
            if (toDo.turn == turn.down)
            {
                t = new Vector2(0, -1);
            }
            else if (toDo.turn == turn.left)
            {
                t = new Vector2(-1, 0);
            }
            else if (toDo.turn == turn.right)
            {
                t = new Vector2(1, 0);
            }
            loadLevel(toDo.str1, dataManager.instance.team[0], toDo.vec2_1, t);
            break;

        case eventType.playAnima:
            var           a        = spawnPrefab(toDo.str1, toDo.vec2_1);
            var           animator = a.GetComponent <Animator>();
            AnimationClip clip     = animator.runtimeAnimatorController.animationClips[0];
            var           speed    = animator.GetCurrentAnimatorStateInfo(0).speed;
            var           time     = clip.length / (speed * speed);
            if (toDo.bool1)
            {
                waitForTime(time);
            }
            else
            {
                pushNow(true);
            }
            break;

        case eventType.moveCamera:
            CameraMoveToSw(toDo.vec2_1, toDo.float1);
            break;

        case eventType.sbMoveToSw:
            GameObject g = null;
            if (toDo.findType == findType.tag)
            {
                g = GameObject.FindGameObjectWithTag(toDo.str1);
            }
            else if (toDo.findType == findType.name)
            {
                g = GameObject.Find(toDo.str1);
            }
            t = new Vector2(0, 1);
            if (toDo.turn == turn.down)
            {
                t = new Vector2(0, -1);
            }
            else if (toDo.turn == turn.left)
            {
                t = new Vector2(-1, 0);
            }
            else if (toDo.turn == turn.right)
            {
                t = new Vector2(1, 0);
            }
            if (g.GetComponent <Player>() == null)
            {
                g = g.transform.GetChild(0).gameObject;
            }
            SbMoveToSw(g, toDo.vec2_1, t);
            break;

        case eventType.changeThingPos:
            pushNow(true); g = null;
            if (toDo.findType == findType.tag)
            {
                g = GameObject.FindGameObjectWithTag(toDo.str1);
            }
            else if (toDo.findType == findType.name)
            {
                g = GameObject.Find(toDo.str1);
            }
            changeThingPos(g, toDo.vec2_1);
            break;

        case eventType.changeTurn:
            g = null;
            if (toDo.findType == findType.tag)
            {
                g = GameObject.FindGameObjectWithTag(toDo.str1);
            }
            else if (toDo.findType == findType.name)
            {
                g = GameObject.Find(toDo.str1);
            }
            t = new Vector2(0, 1); pushNow(true);
            if (toDo.turn == turn.down)
            {
                t = new Vector2(0, -1);
            }
            else if (toDo.turn == turn.left)
            {
                t = new Vector2(-1, 0);
            }
            else if (toDo.turn == turn.right)
            {
                t = new Vector2(1, 0);
            }
            if (g.GetComponent <Player>() == null)
            {
                g = g.transform.GetChild(0).gameObject;
            }
            changePlayerTurn(g, t);
            break;

        case eventType.changeThingActive:
            pushNow(true); g = null;     // 注意find函数无法查找隐藏的物体,需要给物体添加父物体以设置其可见性,且父子物体不可重名
            if (toDo.findType == findType.tag)
            {
                if (toDo.str1 == gameManager.instance.hat.player)
                {
                    g = player;
                }
                else
                {
                    g = GameObject.FindGameObjectWithTag(toDo.str1).transform.GetChild(0).gameObject;
                }
            }
            else if (toDo.findType == findType.name)
            {
                g = GameObject.Find(toDo.str1).transform.GetChild(0).gameObject;
            }
            if (g != null)
            {
                g.SetActive(toDo.bool1);
            }
            break;

        case eventType.showSavePanel:
            pushNow();
            UIManager.instance.showSavePanel();
            break;

        case eventType.changeItem:
            getItem(toDo.int1, toDo.int2);
            var n = dataManager.instance.itemlist.getItemInfo(toDo.int1)._name;
            showHint("获得道具:" + gameManager.instance.hat.find(n, gameManager.instance.setting.nowlang) + " x" + toDo.int2, true);
            break;

        case eventType.flashScreen:
            UIManager.instance.showFlash(toDo.color1, toDo.float1);
            if (toDo.bool1)
            {
                waitForTime(toDo.float1);
            }
            else
            {
                pushNow(true);
            }
            break;

        case eventType.shakeScreen:
            ShakeCamera(toDo.float2, toDo.float1);
            if (toDo.bool1)
            {
                waitForTime(toDo.float1);
            }
            else
            {
                pushNow(true);
            }
            break;

        case eventType.startQuest:
            dataManager.instance.addQuest(toDo.int1);
            pushNow(true);
            break;

        case eventType.changeQuest:
            dataManager.instance.changeQuest(toDo.int1, toDo.questStatus);
            pushNow(true);
            break;

        case eventType.changeWeather:

            pushNow(true);
            break;


        default: break;
        }

        doSth(toDo);// 子类实现各自的操作
    }
コード例 #3
0
ファイル: tools.cs プロジェクト: cafel176/RPGFrameWork
 virtual protected void doSth(myEvent toDo)
 {
 }
コード例 #4
0
ファイル: publicEvent.cs プロジェクト: cafel176/RPGFrameWork
    override protected void doSth(myEvent toDo)
    {
        // 公共事件默认不阻塞进程,需要阻塞进程的事件需要在这里手动设置
        // 阻塞进程的事件由协程实现,这些事件在执行时,自动执行事件执行频率会被影响
        switch (toDo.type)
        {
        case eventType.beBlack:
            if (player)
            {
                stopUserControl();
                player.GetComponent <Player>().Move(Vector2.zero);
            }
            afterTime = delegate { startUserControl(); }; timer = toDo.float1; break;

        case eventType.beWhite:
            if (player)
            {
                stopUserControl();
                player.GetComponent <Player>().Move(Vector2.zero);
            }
            afterTime = delegate { startUserControl(); }; timer = toDo.float1; break;

        case eventType.wait:
            if (player)
            {
                stopUserControl();
                player.GetComponent <Player>().Move(Vector2.zero);
            }
            afterTime = delegate { startUserControl(); }; timer = toDo.float1; break;

        case eventType.text:
            if (player)
            {
                stopUserControl();
                player.GetComponent <Player>().Move(Vector2.zero);
            }
            string _name = gameManager.instance.hat.find(toDo.str1, gameManager.instance.setting.nowlang);
            string text  = gameManager.instance.hat.find(toDo.str2, gameManager.instance.setting.nowlang);
            if (toDo.bool1)
            {
                showTextPanel(_name, text, gameManager.instance.hat.findImg(toDo.str3), gameManager.instance.hat.findAudio(toDo.str4), gameManager.instance.hat.findPitch(toDo.str4));
            }
            else
            {
                showTextPanel(_name, text, null, gameManager.instance.hat.findAudio(toDo.str4), gameManager.instance.hat.findPitch(toDo.str4));
            }
            break;

        case eventType.If:
            if (eventListDefine.checkCondition(toDo.condition, null))
            {
                pushNow(true);
            }
            else
            {
                nowList.thisNow += (toDo.int1 + 1);
            }
            break;


        default: break;
        }
    }