Exemplo n.º 1
0
    void loadMEVT(int stage)
    {
        string path    = stage < 10 ? "0" + stage.ToString() : stage.ToString();
        string pathDir = Application.dataPath + "/Objects/DAT/Stage/Stage" + path + "/";

        string pathMEVT = pathDir + "MEVT_" + path + ".DAT";

        FileStream fs = File.OpenRead(pathMEVT);

        byte[] bytes = new byte[fs.Length];
        fs.Read(bytes, 0, (int)fs.Length);
        fs.Close();

        int index = 0;
        int count = bytes.Length / 14;

        data[stage].MEVT = new GameBattleMEVT[count];

        for (int i = 0; i < count; i++)
        {
            GameBattleMEVT p = new GameBattleMEVT();
            p.EventType  = (GameBattleMapEventType)BitConverter.ToInt16(bytes, index); index += 2;
            p.EventParm1 = BitConverter.ToInt16(bytes, index); index += 2;
            p.EventParm2 = BitConverter.ToInt16(bytes, index); index += 2;

            p.ItemGetType  = (GameBattleMapEventType)BitConverter.ToInt16(bytes, index); index += 2;
            p.ItemGetParm1 = BitConverter.ToInt16(bytes, index); index += 2;
            p.ItemGetParm2 = BitConverter.ToInt16(bytes, index); index += 2;

            p.MapShow = BitConverter.ToInt16(bytes, index); index += 2;

            data[stage].MEVT[i] = p;

            if (p.EventType == GameBattleMapEventType.Event)
            {
                Debug.LogWarning("stage EventType " + stage + " " + p.EventParm1 + " " + p.EventParm2);
            }
        }
    }
Exemplo n.º 2
0
    public void checkMapEvent1(GameBattleUnit unit, OnEventOver over)
    {
        onEventOver = over;

        GameBattleDTL.Point point = getPoint(unit.PosX, unit.PosY);

        if (!mapEvent.ContainsKey(point.MapEvent))
        {
            onCheckMapEvent();
            return;
        }

        GameBattleMEVT evt = mapEvent[point.MapEvent];

        switch (evt.EventType)
        {
        case GameBattleMapEventType.Event:
        {
            switch (evt.EventParm1)
            {
            // what ghost !?

            case 0:
                break;

            case 1:
                break;

            case 2:
                if (unit.IsEnemy)
                {
                    onCheckMapEvent();
                    return;
                }
                break;

            case 4:
                if (GameUserData.instance.Stage == 31)
                {
                    if (unit.UnitID > 1)
                    {
                        onCheckMapEvent();
                        return;
                    }
                }
                break;

            case 3:
            case 5:
            {
                if (unit.BattleAIType != GameBattleAIType.AIMoveToPos)
                {
                    onCheckMapEvent();
                    return;
                }

                if (!checkMapEvent(unit.AIMoveToX, unit.AIMoveToY, point.MapEvent))
                {
                    onCheckMapEvent();
                    return;
                }
            }
            break;

            case 6:
                break;
            }

            GameUserData.instance.setGameData((int)GameUserDataType.MapEvent6, unit.BattleManID);

            GameBattleEventManager.instance.showEvent(evt.EventParm2, 0, onCheckMapEvent1);
        }
        break;

        default:
            onCheckMapEvent1();
            break;
        }
    }
Exemplo n.º 3
0
    public void checkMapEvent(GameBattleUnit unit, OnEventOver over)
    {
        onEventOver = over;

        GameBattleDTL.Point point = getPoint(unit.PosX, unit.PosY);

        if (!mapEvent.ContainsKey(point.MapEvent))
        {
            onCheckMapEvent();
            return;
        }

        GameBattleMEVT evt = mapEvent[point.MapEvent];

        switch (evt.EventType)
        {
        case GameBattleMapEventType.Event:
        {
            switch (evt.EventParm1)
            {
            // what ghost !?

            case 0:
                break;

            case 1:
                break;

            case 2:
                break;

            case 3:
                onCheckMapEvent();
                return;

            case 4:
                if (GameUserData.instance.Stage == 31)
                {
                    // fix stage 30 bug. so many bugs.

                    if (GameUserData.instance.getGameData(10) == 0)
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID > 1)
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID == 0 && unit.WeaponID != 14)
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID == 0 && GameUserData.instance.Proficiency < 25 - PlayerPrefs.GetInt("review", 0))
                    {
                        onCheckMapEvent();
                        return;
                    }

                    if (unit.UnitID == 1 && unit.BattleAIType == GameBattleAIType.None)
                    {
                        onCheckMapEvent();
                        return;
                    }
                }
                break;

            case 5:
                onCheckMapEvent();
                return;

            case 6:
                break;
            }

            GameUserData.instance.setGameData((int)GameUserDataType.MapEvent6, unit.BattleManID);

            GameBattleEventManager.instance.showEvent(evt.EventParm2, 0, onCheckMapEvent);
        }
        break;

        case GameBattleMapEventType.Item:
        {
            switch (evt.ItemGetType)
            {
            case GameBattleMapEventType.Item:
            {
                if (unit.canAddItem())
                {
                    unit.addItem(evt.ItemGetParm1);
                }
                else
                {
                    GameUserData.instance.addItem(evt.ItemGetParm1);
                }

                GameBattleGetItemUI.instance.show(evt.ItemGetParm1, 0, null);
                onCheckMapEvent();
            }
            break;

            case GameBattleMapEventType.Gold:
            {
                GameUserData.instance.addGold(evt.ItemGetParm1);

                GameBattleGetItemUI.instance.show(GameDefine.INVALID_ID, evt.ItemGetParm1, null);
                onCheckMapEvent();
            }
            break;
            }

            mapEvent.Remove(point.MapEvent);
        }
        break;
        }



        for (int i = 0; i < transTreasures.childCount; ++i)
        {
            if (transTreasures.GetChild(i).gameObject.name == point.MapEvent.ToString())
            {
                Destroy(transTreasures.transform.GetChild(i).gameObject);
            }
        }

        //         clearTreasures();
        //         updateTreasures();
    }