Пример #1
0
 public void AddAction(PBEventAction success, PBEventAction fail)
 {
     successAction = success;
     failAction    = fail;
     actions.Add(success);
     actions.Add(fail);
 }
Пример #2
0
    private IEnumerator MoveNextState(PBEventAction action)
    {
        // Select action
        currentEvent.SelectAction(action);

        // Here only normal state will update ui
        // Battle state has its own ui behaviors
        if (currentEvent.current.GetType() != typeof(PBBattleState))
        {
            UpdateUI();
        }

        // Check battle state
        // If it's a battle state, start a coroutine for battle
        // Then if will wait unitl battle end and check the result
        while (currentEvent.current.GetType() == typeof(PBBattleState))
        {
            yield return(StartCoroutine(BattleManager.instance.Battle(Data.player, currentEvent.owner)));

            PBBattleState state = currentEvent.current as PBBattleState;
            switch (BattleManager.instance.ending)
            {
            case BattleEnding.Character1Win:
                yield return(StartCoroutine(MoveNextState(state.successAction)));

                break;

            case BattleEnding.Character2Win:
                yield return(StartCoroutine(MoveNextState(state.failAction)));

                break;
            }
        }

        // Check final state
        // If it's a final state, there will be only one button which allows player to exit the event
        if (currentEvent.current.actions.Count == 0)
        {
            uim.SetEventBtnText(0, "离开");
            uim.RemoveEventBtnListeners(0);
            uim.AddEventBtnListener(0, (delegate { EndEvent(); }));
            for (int i = 1; i < uim.GetEventBtnsNumber(); i += 1)
            {
                uim.SetEventBtnText(i, "");
                uim.RemoveEventBtnListeners(i);
            }
        }
    }
Пример #3
0
    private void InitZombie(SmallMapObject zombie)
    {
        zombie.character = new Character("僵尸");

        Weapon sword = new Weapon(777, WeaponType.Melee);

        sword.name = "【美工刀】";
        zombie.character.weapon = sword;

        foreach (Attack atk in Data.AllAttacks.Values)
        {
            foreach (ActionType atkType in atk.types)
            {
                if (atkType == ActionType.MeleeWeapon || atkType == ActionType.Magic)
                {
                    zombie.character.attackPool.Add(atk);
                    break;
                }
            }
        }

        PBEventState  s1 = new PBEventState("你遭遇了" + zombie.character.name);
        PBBattleState s2 = new PBBattleState();
        PBEventState  s3 = new PBEventState("你把" + zombie.character.name + "砍死了");

        s3.exitJobs = new PBJob[] { delegate { BattleWin(zombie); } };
        PBEventState s4 = new PBEventState("你被" + zombie.character.name + "啃死了");

        s4.exitJobs = new PBJob[] { delegate { BattleFail(zombie); } };

        PBEventAction a1 = new PBEventAction("战斗");

        a1.AddTransition(s2, 1);
        PBEventAction a2 = new PBEventAction("");

        a2.AddTransition(s3, 1);
        PBEventAction a3 = new PBEventAction("");

        a3.AddTransition(s4, 1);

        s1.AddAction(a1);
        s2.AddAction(a2, a3);

        zombie.pBEvent = new PBEvent(s1, "僵尸事件", zombie.character);
        zombie.ai      = new ZombieAI(4f, 1f, 2f, 1f);
    }
Пример #4
0
 public void SelectAction(PBEventAction action)
 {
     current.Exit();
     current = action.NextState();
     current.Enter();
 }
Пример #5
0
    private void InitGamblingMachine(SmallMapObject gm)
    {
        gm.character = new Character("赌博机");

        Weapon wand = new Weapon(999, WeaponType.Magic);

        wand.name           = "【无用大棒】";
        gm.character.weapon = wand;

        foreach (Attack atk in Data.AllAttacks.Values)
        {
            foreach (ActionType atkType in atk.types)
            {
                if (atkType == ActionType.Magic)
                {
                    gm.character.attackPool.Add(atk);
                    break;
                }
            }
        }

        PBEventState s1 = new PBEventState("遇到一个赌博机。");
        PBEventState s2 = new PBEventState("看起来这台老虎机还能用。");
        PBEventState s3 = new PBEventState("你离开了。");

        s3.exitJobs = new PBJob[] { delegate { Leave(gm); } };
        PBEventState s4 = new PBEventState("获得资源。");
        PBEventState s5 = new PBEventState("颗粒无收。");
        PBEventState s6 = new PBEventState("获得大笔金钱。");
        PBEventState s7 = new PBEventState("中了超级大乐透。");
        PBEventState s8 = new PBEventState("赌博机活了,并向你冲了过来");
        PBEventState s9 = new PBEventState("你摧毁了赌博机,获得了里面所有奖品");

        s9.exitJobs = new PBJob[] { delegate { BattleWin(gm); } };
        PBEventState s10 = new PBEventState("你被赌博机吃了");

        s10.exitJobs = new PBJob[] { delegate { BattleFail(gm); } };
        PBBattleState s11 = new PBBattleState();

        PBEventAction a1 = new PBEventAction("检查一下");

        a1.AddTransition(s2, 1);
        PBEventAction a2 = new PBEventAction("远离黄赌毒");

        a2.AddTransition(s3, 1);
        PBEventAction a3 = new PBEventAction("溜了溜了");

        a3.AddTransition(s3, 1);
        PBEventAction a4 = new PBEventAction("感觉手气爆表,有点膨胀");

        a4.AddTransition(s4, 0.3f);
        a4.AddTransition(s5, 0.3f);
        a4.AddTransition(s6, 0.3f);
        a4.AddTransition(s7, 0.1f);
        PBEventAction a5 = new PBEventAction("...");

        a5.AddTransition(s2, 1);
        PBEventAction a6 = new PBEventAction("踹一脚");

        a6.AddTransition(s8, 1);
        PBEventAction a7 = new PBEventAction();
        PBEventAction a8 = new PBEventAction();

        a7.AddTransition(s9, 1);
        a8.AddTransition(s10, 1);
        PBEventAction a9 = new PBEventAction("战斗");

        a9.AddTransition(s11, 1);

        s1.AddAction(a1, a2);
        s2.AddAction(a3, a4, a6);
        s4.AddAction(a5);
        s5.AddAction(a5);
        s6.AddAction(a5);
        s7.AddAction(a5);
        s8.AddAction(a9);
        s11.AddAction(a7, a8);

        gm.interaction = new InteractionEvent("赌博机事件", new PBEvent(s1, "赌博机事件", gm.character), true);
        gm.ai          = new StaticAI();
    }