示例#1
0
    public void showLayer(int id, bool b)
    {
//        clearAnimations();

        layerList.Add(id);

        string path = GameDefine.getString2(GameUserData.instance.Stage);

        if (objsLayer0 == null ||
            objsLayer0.Length != activeBattleStage.Layer.L0.Length)
        {
            objsLayer0 = new GameObject[activeBattleStage.Layer.L0.Length];
        }

        int lastLayer = 0;

        float lastWidth  = 0.0f;
        float lastHeight = 0.0f;

        for (int j = 0; j < activeBattleStage.Layer.L0.Length; j++)
        {
            if (activeBattleStage.Layer.L0[j].ID == id)
            {
                if (objsLayer0[j] != null)
                {
                    continue;
                }

                lastLayer   = activeBattleStage.Layer.L0[j].Lyaer;
                layerHeight = id * 5000;

                if (id > 1 && GameUserData.instance.Stage == 34)
                {
                    // fix stage 34 bug.
                    layerHeight = 5000;
                }

                if (layerList.Count == 1)
                {
                    GameBattleSceneMovement.instance.moveToEvent(0, 0);
                }

                if (activeBattleStage.Layer.L0[j].Name.Contains(".saf"))
                {
                    string pathDir     = "Prefab/Stage/Stage" + path + "/";
                    string pathTexture = pathDir + activeBattleStage.Layer.L0[j].Name.Replace(".saf", "");

                    GameObject imgObject = Resources.Load <GameObject>(pathTexture);
                    GameObject obj       = Instantiate(imgObject, GameCameraManager.instance.transform);
                    obj.name = activeBattleStage.Layer.L0[j].Name;

                    float z = GameDefine.getZ(activeBattleStage.Layer.L0[j].Unknow0);

                    Transform trans = obj.transform;
                    trans.localPosition = new Vector3(-GameCameraManager.instance.sceneWidthHalf,
                                                      GameCameraManager.instance.sceneHeightHalf
                                                      , z + 20);
                    trans.localScale = new Vector3(1.0f, 1.0f, 1.0f);

                    GameAnimation animation = obj.GetComponent <GameAnimation>();

                    animation.playAnimation();

                    objsLayer0[j] = obj;
                }
                else
                {
                    string pathDir     = "Texture/Map/Stage" + path + "/";
                    string pathTexture = pathDir + activeBattleStage.Layer.L0[j].Name;

                    GameObject imgObject = Resources.Load <GameObject>("Prefab/Map");
                    GameObject obj       = Instantiate(imgObject, transBackground);
                    obj.name = activeBattleStage.Layer.L0[j].Name;

                    float z = GameDefine.getZ(activeBattleStage.Layer.L0[j].Unknow0);

                    Transform trans = obj.transform;
                    trans.localPosition = new Vector3(0.0f, layerHeight, z);
                    trans.localScale    = new Vector3(1.0f, 1.0f, 1.0f);

                    SpriteRenderer sprite = obj.GetComponent <SpriteRenderer>();
                    sprite.sprite = Resources.Load <Sprite>(pathTexture);

                    float w = activeBattleStage.Layer.L0[j].Width * GameDefine.TEXTURE_WIDTH;
                    float h = activeBattleStage.Layer.L0[j].Height * GameDefine.TEXTURE_HEIGHT;

                    if (w > 4096 || h > 4096)
                    {
                        w = w / activeBattleStage.DTL.Width * GameDefine.TEXTURE_WIDTH;
                        h = w / activeBattleStage.DTL.Height * GameDefine.TEXTURE_HEIGHT;

                        trans.localScale = new Vector3(w, h, 1.0f);
                    }

                    if (activeBattleStage.Layer.L0[j].Unknow4 != 10 &&
                        activeBattleStage.Layer.L0[j].Unknow5 != 8)
                    {
                        if (GameUserData.instance.Stage == 18)
                        {
                            // fix stage 18 bug
                            trans.localPosition = new Vector3(0.0f, layerHeight, 10.0f);
                        }

                        trans.localScale = new Vector3(lastWidth / w, lastHeight / h, 1.0f);
                    }
                    else
                    {
                        lastWidth  = w;
                        lastHeight = h;
                    }

                    objsLayer0[j] = obj;
                }
            }
        }


        if (objsLayer1 == null ||
            objsLayer1.Length != activeBattleStage.Layer.L1.Length)
        {
            objsLayer1 = new GameObject[activeBattleStage.Layer.L1.Length];
        }

        for (int j = 0; j < activeBattleStage.Layer.L1.Length; j++)
        {
            if (activeBattleStage.Layer.L1[j].ID != id)
            {
                continue;
            }

            string pathDir     = "Prefab/Stage/Stage" + path + "/";
            string pathTexture = pathDir + activeBattleStage.Layer.L1[j].Name;

            GameObject imgObject = Resources.Load <GameObject>(pathTexture);
            GameObject obj       = Instantiate(imgObject, transBackground);
            obj.name = activeBattleStage.Layer.L1[j].Name;

            Transform trans = obj.transform;
            trans.localPosition = new Vector3(activeBattleStage.Layer.L1[j].OffsetX,
                                              -activeBattleStage.Layer.L1[j].OffsetY + layerHeight,
                                              -1000 - j);


            trans.localScale = new Vector3(1.0f, 1.0f, 1.0f);

            GameAnimation animation = obj.GetComponent <GameAnimation>();

            if (activeBattleStage.Layer.L1[j].VisibleBattle == 0)
            {
                bool bVisible = true;

                if (activeBattleStage.Layer.L1[j].ParmEffect != GameDefine.INVALID_ID)
                {
                    bVisible = GameUserData.instance.getGameData(activeBattleStage.Layer.L1[j].ParmEffect) > 0;
                }

                if (bVisible)
                {
                    switch (activeBattleStage.Layer.L1[j].Pause)
                    {
                    case 0:
                        animation.playAnimation();
                        break;

                    case 1:
                        animation.playAnimation();
                        //                                Debug.LogError( "activeBattleStage.Layer.L1[ j ].Pause" + j );
                        break;

                    case 2:
                        animation.playSound = false;
                        animation.showFrame(0);
                        animation.playSound = true;
                        break;
                    }
                }
            }



//             // 夏侯婴加入?
//             if ( GameUserData.instance.Stage == 28 &&
//                 activeBattleStage.Layer.L1[ j ].Parm == 7 ) // 8
//             {
//                 continue;
//             }
//             if ( GameUserData.instance.Stage == 29 &&
//                 activeBattleStage.Layer.L1[ j ].Parm == 1 ) // 3
//             {
//                 continue;
//             }

            objsLayer1[j] = obj;
        }


#if UNITY_EDITOR
        if (id == 1)
        {
            GameBattleDTL dtl = activeBattleStage.DTL;
            int           ii  = 0;

            Sprite spriteObject = Resources.Load <Sprite>("White");

            for (int i = 0; i < dtl.Height; i++)
            {
                for (int j = 0; j < dtl.Width; j++)
                {
                    // editor test

                    //                    return;

                    GameObject imgObject = Resources.Load <GameObject>("Prefab/Sprite");
                    GameObject obj       = Instantiate(imgObject, transCell);
                    obj.name = i + "-" + j;

                    Transform trans = obj.transform;
                    trans.localPosition = new Vector3(j * 30, -i * 24 + layerHeight, 0.0f);
//                    trans.localScale = new Vector3( 1.0f , 1.0f , 1.0f );

                    SpriteRenderer sprite = obj.GetComponent <SpriteRenderer>();
                    float          c      = (dtl.Points[ii].Move * 25) / 255.0f;
                    sprite.color  = new Color(c, c, c, (c > 0.25f ? 0.25f : c));
                    sprite.sprite = spriteObject;

                    if (dtl.Points[ii].MapEvent != -1 &&
                        activeBattleStage.MEVT.Length > dtl.Points[ii].MapEvent)
                    {
                        if (activeBattleStage.MEVT[dtl.Points[ii].MapEvent].EventType == GameBattleMapEventType.Event)
                        {
                            sprite.color = new Color(0.0f, 1.0f, 0.0f, 0.25f);
                        }
                        else if (activeBattleStage.MEVT[dtl.Points[ii].MapEvent].EventType == GameBattleMapEventType.Item)
                        {
                            sprite.color = new Color(1.0f, 1.0f, 0.0f, 0.25f);
                        }
                    }

                    GamePointTset test = obj.AddComponent <GamePointTset>();
                    test.Value0 = dtl.Points[ii].Move;
                    test.Value1 = dtl.Points[ii].Floor;
                    test.Value2 = dtl.Points[ii].MapEvent;

//                     obj = Instantiate( imgObject , transUnit );
//                     obj.name = i + "-" + j;
//
//                     trans = obj.GetComponent<RectTransform>();
//                     trans.localPosition = new Vector3( j * 30 , -i * 24 , 0.0f );
//                     trans.localScale = new Vector3( 1.0f , 1.0f , 1.0f );
//                     trans.sizeDelta = new Vector2( 30 , 24 );
//
//                     image = obj.GetComponent<Image>();
//                     image.enabled = false;

                    ii++;
                }
            }
        }
#endif
    }
示例#2
0
    public void showLayer(int id)
    {
        string path = GameDefine.getString2(activeID);

        if (objsLayer0 == null ||
            objsLayer0.Length != activeRPGStage.Layer.L0.Length)
        {
            objsLayer0 = new GameObject[activeRPGStage.Layer.L0.Length];
        }

        for (int j = 0; j < activeRPGStage.Layer.L0.Length; j++)
        {
            if (activeRPGStage.Layer.L0[j].ID == id)
            {
                if (objsLayer0[j] != null)
                {
                    continue;
                }

                if (activeRPGStage.Layer.L0[j].Unknow4 == 10 &&
                    activeRPGStage.Layer.L0[j].Unknow5 == 8)
                {
                    layerHeight = id * 5000;
                }

                if (activeRPGStage.Layer.L0[j].Name.Contains(".saf"))
                {
                    string pathDir     = "Prefab/RPG/RPG" + path + "/";
                    string pathTexture = pathDir + activeRPGStage.Layer.L0[j].Name.Replace(".saf", "");

                    GameObject imgObject = Resources.Load <GameObject>(pathTexture);
                    GameObject obj       = Instantiate(imgObject, transBackground);
                    obj.name = activeRPGStage.Layer.L0[j].Name;

                    float z = GameDefine.getZ(activeRPGStage.Layer.L0[j].Unknow0);

                    Transform trans = obj.transform;
                    trans.localPosition = new Vector3(0.0f, layerHeight, z);
                    trans.localScale    = new Vector3(5.0f, 5.0f, 5.0f);

                    GameAnimation animation = obj.GetComponent <GameAnimation>();

                    animation.playAnimation();

                    objsLayer0[j] = obj;
                }
                else
                {
                    string pathDir     = "Texture/RPG/";
                    string pathTexture = pathDir + activeRPGStage.Layer.L0[j].Name;

                    GameObject imgObject = Resources.Load <GameObject>("Prefab/Sprite");
                    GameObject obj       = Instantiate(imgObject, transBackground);
                    obj.name = activeRPGStage.Layer.L0[j].Name;

                    float z = GameDefine.getZ(activeRPGStage.Layer.L0[j].Unknow0);

                    Transform trans = obj.transform;
                    trans.localPosition = new Vector3(0.0f, layerHeight, z);
                    trans.localScale    = new Vector3(1.0f, 1.0f, 1.0f);

                    if (activeRPGStage.Layer.L0[j].Unknow4 != 10 &&
                        activeRPGStage.Layer.L0[j].Unknow5 != 8)
                    {
                        trans.localScale = new Vector3(2.0f, 2.0f, 1.0f);
                    }

                    transUnit.localPosition = new Vector3(0.0f, 0.0f, -1100);

                    SpriteRenderer sprite = obj.GetComponent <SpriteRenderer>();
                    sprite.sprite = Resources.Load <Sprite>(pathTexture);

                    float w = activeRPGStage.DTL.Width * GameDefine.TEXTURE_WIDTH;
                    float h = activeRPGStage.DTL.Height * GameDefine.TEXTURE_HEIGHT;

                    if (w == 4096 || h == 4096)
                    {
                        w = w / activeRPGStage.DTL.Width * GameDefine.TEXTURE_WIDTH;
                        h = w / activeRPGStage.DTL.Height * GameDefine.TEXTURE_HEIGHT;

                        trans.localScale = new Vector3(w, h, 1.0f);
                    }

                    objsLayer0[j] = obj;
                }
            }
        }


        if (objsLayer1 == null ||
            objsLayer1.Length != activeRPGStage.Layer.L1.Length)
        {
            objsLayer1 = new GameObject[activeRPGStage.Layer.L1.Length];
        }

        for (int j = 0; j < activeRPGStage.Layer.L1.Length; j++)
        {
            if (activeRPGStage.Layer.L1[j].ID == id)
            {
                string pathDir     = "Prefab/RPG/RPG" + path + "/";
                string pathTexture = pathDir + activeRPGStage.Layer.L1[j].Name;

                GameObject imgObject = Resources.Load <GameObject>(pathTexture);
                GameObject obj       = Instantiate(imgObject, transBackground);
                obj.name = activeRPGStage.Layer.L1[j].Name;

                Transform trans = obj.transform;
                trans.localPosition = new Vector3(activeRPGStage.Layer.L1[j].OffsetX,
                                                  -activeRPGStage.Layer.L1[j].OffsetY + layerHeight,
                                                  -1000 - j);

                trans.localScale = new Vector3(1.0f, 1.0f, 1.0f);

                GameAnimation animation = obj.GetComponent <GameAnimation>();

                if (activeRPGStage.Layer.L1[j].Unknow5 == 0)
                {
                    if (activeRPGStage.Layer.L1[j].Unknow3 == GameDefine.INVALID_ID)
                    {
                        animation.playAnimation();
                    }
                    else
                    {
                    }
                }
                else
                {
                }

                objsLayer1[j] = obj;
            }
        }



#if UNITY_EDITOR
        if (id == 1)
        {
            GameRPGDTL dtl = activeRPGStage.DTL;
            int        ii  = 0;

            Sprite spriteObject = Resources.Load <Sprite>("White");

            for (int i = 0; i < dtl.Height; i++)
            {
                for (int j = 0; j < dtl.Width; j++)
                {
                    // editor test

                    GameObject imgObject = Resources.Load <GameObject>("Prefab/Sprite");
                    GameObject obj       = Instantiate(imgObject, transCell);
                    obj.name = i + "-" + j;

                    Transform trans = obj.transform;
                    trans.localPosition = new Vector3(j * 30, -i * 24 + layerHeight, 0.0f);
                    //                    trans.localScale = new Vector3( 1.0f , 1.0f , 1.0f );

                    SpriteRenderer sprite = obj.GetComponent <SpriteRenderer>();
                    sprite.color  = new Color(1.0f, 1.0f, 1.0f, (dtl.Points[ii].Move == 1 ? 0.2f : 0.0f));
                    sprite.sprite = spriteObject;

                    GamePointTset test = obj.AddComponent <GamePointTset>();
                    test.Value0 = dtl.Points[ii].Move;
                    test.Value1 = dtl.Points[ii].MapEvent;
                    test.Value2 = dtl.Points[ii].RPGEvent;

                    if (dtl.Points[ii].MapEvent > 0)
                    {
                        sprite.color = new Color(0.0f, 1.0f, 0.0f, 0.25f);
                    }
                    else if (dtl.Points[ii].RPGEvent > 0)
                    {
                        sprite.color = new Color(1.0f, 0.0f, 0.0f, 0.25f);
                    }

                    ii++;
                }
            }
        }
#endif
    }
示例#3
0
    public void playAnimation(int id, int id2, int frame, int endFrame, OnEventOver over)
    {
        if (!animations.ContainsKey(id))
        {
            return;
        }

#if UNITY_EDITOR
        Debug.Log("playAnimation " + animations[id].gameObject.name);
#endif

        onEventOver = over;

        GameAnimation animation = animations[id];

        int height = layerHeight;

        bool bUpdateHeight = false;

        if (id2 >= 10000500 && GameUserData.instance.Stage == 19)
        {
            // fix stage 7 19 bug
            height        = 2 * 5000;
            bUpdateHeight = true;

            GameAnimation ani = objsLayer0[1].GetComponent <GameAnimation>();
            ani.stopAnimation();
            ani.clearAnimation();
        }

        if ((id2 >= 20000000 && GameUserData.instance.Stage == 7) ||
            (id2 >= 20000000 && GameUserData.instance.Stage == 14))
        {
            // fix stage 7 14 bug

            height        = 2 * 5000;
            bUpdateHeight = true;
        }

        float z = GameDefine.getZ(id2);

        if (id2 >= 20000000)
        {
            z -= 3000;
        }

        Transform trans = animation.transform;

        if (animation.lastUnitID != GameDefine.INVALID_ID)
        {
            GameBattleUnit unit = GameBattleUnitManager.instance.getUnit(animation.lastUnitID);

            GameBattleSceneMovement.instance.moveToEvent(unit.PosX - GameCameraManager.instance.xCell,
                                                         unit.PosY - GameCameraManager.instance.yCell);

            trans.localPosition = new Vector3(GameBattleSceneMovement.instance.PosXReal,
                                              GameBattleSceneMovement.instance.PosYReal + height, z);
        }
        else
        {
            trans.localPosition = new Vector3(GameBattleSceneMovement.instance.AnimationPosX,
                                              GameBattleSceneMovement.instance.AnimationPosY + height,
                                              z);
        }


        if (id2 >= 20000000 &&
            GameUserData.instance.Stage == 23)
        {
            // fix stage 23 bug

            trans.localPosition = new Vector3(GameBattleSceneMovement.instance.PosXReal,
                                              GameBattleSceneMovement.instance.PosYReal + height, z);

            trans.localScale = new Vector3(GameCameraManager.instance.sceneWidth / 320.0f, 1.0f, 1.0f);
        }

        if (id2 == 10000500 &&
            GameUserData.instance.Stage == 24)
        {
            // fix stage 24 bug

            trans.localPosition = new Vector3(260.0f,
                                              -620.0f + height, z);
        }

        if (frame == GameDefine.INVALID_ID)
        {
            animation.playAnimation(0, GameDefine.INVALID_ID, false, onEffectPlayOver);
        }
        else
        {
            if (frame == endFrame)
            {
                animation.stopAnimation();
                animation.showFrame(endFrame);

                if (onEventOver != null)
                {
                    onEventOver();
                }
            }
            else
            {
                animation.playAnimation(frame, endFrame + 1, false, onEffectPlayOver);
            }

            //                animation.stopAnimation();
            //               animation.showFrame( frame );
        }

        if (bUpdateHeight)
        {
            GameCameraManager.instance.setPos(GameBattleSceneMovement.instance.PosXReal,
                                              GameBattleSceneMovement.instance.PosYReal + height);
        }
    }