Exemplo n.º 1
0
    static void init()
    {
        if (!EditorApplication.isPlaying)
        {
            EditorApplication.isPlaying = true;
        }

        ActorViewer window = (ActorViewer)GetWindow(typeof(ActorViewer));

        window.Show();
        if (!Directory.Exists(AssertBundleCreator.ActorAssetbundlePath))
        {
            Directory.CreateDirectory(AssertBundleCreator.ActorAssetbundlePath);
        }
        DirectoryInfo actorInfo = new DirectoryInfo(AssertBundleCreator.ActorAssetbundlePath);

        FileInfo[] actorFiles     = actorInfo.GetFiles();
        string     assetBundleExt = ".assetbundle";

        window.AllActors.Add("none");
        window.BodyEquips.Add("none");
        window.HairEquips.Add("none");
        window.FaceEquips.Add("none");
        window.ShoulderEquips.Add("none");
        window.AllWeapons.Add("none");
        window.AllEffects.Add("none");
        window.AnimNames.Add("none");

        window.AllActors.Add("wplayer");
        window.AllActors.Add("mplayer");
        foreach (FileInfo fileInfo in actorFiles)
        {
            string actorFileName = fileInfo.Name;
            if (actorFileName.Contains(assetBundleExt))
            {
                string actorName = actorFileName.Substring(0, actorFileName.Length - assetBundleExt.Length);
                window.AllActors.Add(actorName);
                window.AllWeapons.Add(actorName);
                window.AllEffects.Add(actorName);
            }
        }

        if (!Directory.Exists(AssertBundleCreator.EquipAssetbundlePath))
        {
            Directory.CreateDirectory(AssertBundleCreator.EquipAssetbundlePath);
        }
        DirectoryInfo equipInfo = new DirectoryInfo(AssertBundleCreator.EquipAssetbundlePath);

        FileInfo[] equipFiles = equipInfo.GetFiles();

        foreach (FileInfo fileInfo in equipFiles)
        {
            string equipFileName = fileInfo.Name;
            if (equipFileName.Contains(assetBundleExt))
            {
                string equipName = equipFileName.Substring(0, equipFileName.Length - assetBundleExt.Length);
                window.BodyEquips.Add(equipName);
                window.HairEquips.Add(equipName);
                window.FaceEquips.Add(equipName);
                window.ShoulderEquips.Add(equipName);
            }
        }


        string skillFileExt = ".txt";

        if (!Directory.Exists(AssertBundleCreator.SkillAssetbundlePath))
        {
            Directory.CreateDirectory(AssertBundleCreator.SkillAssetbundlePath);
        }
        DirectoryInfo skillInfo = new DirectoryInfo(AssertBundleCreator.SkillAssetbundlePath);

        FileInfo[] skillFiles = skillInfo.GetFiles();
        window.SkillNames.Add("none");
        foreach (FileInfo fileInfo in skillFiles)
        {
            string skillFileName = fileInfo.Name;
            if (skillFileName.Contains(skillFileExt))
            {
                string SkillName = skillFileName.Substring(0, skillFileName.Length - skillFileExt.Length);
                window.SkillNames.Add(SkillName);
            }
        }
        window.LocatorNames.Add("none");
        //创建game object用于每帧更新
        //		GameObject frameGO = new GameObject();
        //	frameGO.AddComponent("FrameUpdateScript");
    }
Exemplo n.º 2
0
        protected override void Initialize()
        {
            gameMode   = Settings.UserSettings.LastGameMode;
            FullScreen = true;
            Background = Contents.Sprites.Game_Background;

            GameObject lastObj;

            var playingArenaPadding = 16;

            hider = new ObjectHider(this)
            {
                HideTimePeriod = 350
            };
            Objects.Add(hider);

            // ADDING FIRST PANEL
            // PANEL BACKGROUND
            Objects.Add(new GameObject(this)
            {
                Size        = new Vector2(712, 132),
                Position    = new Vector2(4, 4),
                SpriteImage = Contents.Sprites.GameUI_top_background,
                LayerDepth  = 0.02f
            });
            lastObj = Objects.Last();
            hider.HideObject(Objects.Last(), HidePlace.Top);

            var playingArenaStart = lastObj.Position.Y + lastObj.Size.Y + playingArenaPadding;

            // ACTOR VIEWER
            var viewerPos  = new Vector2(lastObj.Position.X + 16, lastObj.Position.Y + 16);
            var viewerSize = new Vector2(116, 100);

            Objects.Add(new DynamicBackgroundObject(this, Contents.Sprites.Dialog_inside, 4)
            {
                Size       = viewerSize,
                Position   = viewerPos,
                LayerDepth = 0.045f
            });
            hider.HideObject(Objects.Last(), HidePlace.Top);

            actorViewer = new ActorViewer(this, viewerSize, Contents.Colors.ActorViewerBackgroundColor)
            {
                Position   = viewerPos,
                LayerDepth = 0.05f
            };
            Objects.Add(actorViewer);
            hider.HideObject(Objects.Last(), HidePlace.Top);

            var btnPauseSize = new Vector2(116, 100);

            // PAUSE BUTTON
            btnPause             = Bank.Buttons.GetPlainButton(this);
            btnPause.SpriteImage = Contents.Sprites.Button_pause;
            btnPause.Size        = btnPauseSize;
            btnPause.Position    = new Vector2(lastObj.Position.X + lastObj.Size.X - btnPauseSize.X - 16, lastObj.Position.Y + 16);
            btnPause.Click      += btnPause_Click;
            Objects.Add(btnPause);
            hider.HideObject(Objects.Last(), HidePlace.Top);

            // SETTINGS
            var lblScoreSize  = new Vector2(416, 40);
            var lblLevelSize  = new Vector2(416, 24);
            var scoreLineSize = new Vector2(284, 4);

            // SCORE
            lblScore = new BreathingObject(this)
            {
                Size           = lblScoreSize,
                Position       = new Vector2(148, lastObj.Position.Y + 24),
                TextSpriteFont = Contents.Fonts.PixelArtTextFont,
                Text           = Constants.Texts.Score,
                TextHeight     = (int)lblScoreSize.Y,
                TextAlignment  = TextAlignment.Center,
                TextColor      = Color.White,
                ShowText       = true,
                LayerDepth     = 0.05f,
                MaxScale       = 1.1f,
                MinScale       = 1f,
                TimerLimit     = 200,
                Timer          = 0,
                Loop           = false,
                IsPaused       = true,
                StartTextColor = Color.White,
                EndTextColor   = Color.Red
            };
            Objects.Add(lblScore);
            hider.HideObject(Objects.Last(), HidePlace.Top);

            // LINE BETWEEN SCORE AND LEVEL
            Objects.Add(new GameObject(this)
            {
                SpriteImage = Contents.Sprites.Pix,
                BaseColor   = Color.White,
                Size        = scoreLineSize,
                Position    = new Vector2(148 + (416 - scoreLineSize.X) / 2, lastObj.Position.Y + 72),
                LayerDepth  = 0.05f
            });
            hider.HideObject(Objects.Last(), HidePlace.Top);

            // LEVEL
            lblLevel = new BreathingObject(this)
            {
                Size           = lblLevelSize,
                Position       = new Vector2(148, lastObj.Position.Y + 88),
                TextSpriteFont = Contents.Fonts.PixelArtTextFont,
                Text           = Constants.Texts.Level,
                TextHeight     = (int)lblLevelSize.Y,
                TextAlignment  = TextAlignment.Center,
                TextColor      = Color.White,
                ShowText       = true,
                LayerDepth     = 0.05f,
                MaxScale       = 1.1f,
                MinScale       = 1f,
                TimerLimit     = 500,
                Timer          = 0,
                Loop           = false,
                IsPaused       = true,
                StartTextColor = Color.White,
                EndTextColor   = Color.Red
            };
            Objects.Add(lblLevel);
            hider.HideObject(Objects.Last(), HidePlace.Top);

            // ADDING SECOND PANEL
            // SETTINGS
            var btnSize = new Vector2(152, 112);

            // PANEL BACKGROUND
            float playingArenaEndY     = 0;
            float controlButtonsStartY = 0;

            if (gameMode == SettingOptions.GameMode.Classic)
            {
                Objects.Add(new GameObject(this)
                {
                    Size        = new Vector2(712, 144),
                    Position    = new Vector2(4, Size.Y - 144 - 4),
                    SpriteImage = Contents.Sprites.GameUI_bottom_classic_background,
                    LayerDepth  = 0.02f
                });
                lastObj = Objects.Last();
                hider.HideObject(Objects.Last(), HidePlace.Bottom);

                playingArenaEndY     = lastObj.Position.Y - playingArenaPadding;
                controlButtonsStartY = lastObj.Position.Y + 16;
            }
            else
            {
                Objects.Add(new GameObject(this)
                {
                    Size        = new Vector2(712, 224),
                    Position    = new Vector2(4, Size.Y - 224 - 4),
                    SpriteImage = Contents.Sprites.GameUI_bottom_normal_background,
                    LayerDepth  = 0.02f
                });
                lastObj = Objects.Last();
                hider.HideObject(Objects.Last(), HidePlace.Bottom);

                playingArenaEndY     = lastObj.Position.Y - playingArenaPadding;
                controlButtonsStartY = lastObj.Position.Y + 96;

                // ADDING BONUS PANEL
                pnlBonusBtns = new GameObject(this)
                {
                    Size       = new Vector2(680, 60),
                    Position   = new Vector2(lastObj.Position.X + 16, lastObj.Position.Y + 16),
                    LayerDepth = 0.02f,
                    //SpriteImage = Contents.Sprites.Pix,
                    //BaseColor = Color.Red
                };
                Objects.Add(pnlBonusBtns);
                hider.HideObject(Objects.Last(), HidePlace.Bottom);

                bonusObjs = new List <GameObject>();
            }

            // CONTROL BUTTON LEFT
            btnControlLeft             = Bank.Buttons.GetPlainButton(this);
            btnControlLeft.SpriteImage = Contents.Sprites.ControlButton_left;
            btnControlLeft.Size        = btnSize;
            btnControlLeft.Position    = new Vector2(lastObj.Position.X + 16, controlButtonsStartY);
            btnControlLeft.Release    += btnLeft_Release;
            btnControlLeft.Hover      += btnLeft_Hover;
            Objects.Add(btnControlLeft);
            hider.HideObject(Objects.Last(), HidePlace.Bottom);

            // CONTROL BUTTON FALL
            btnControlFall             = Bank.Buttons.GetPlainButton(this);
            btnControlFall.SpriteImage = Contents.Sprites.ControlButton_fall;
            btnControlFall.Size        = btnSize;
            btnControlFall.Position    = new Vector2(lastObj.Position.X + 192, controlButtonsStartY);
            btnControlFall.Click      += btnDown_Click;
            btnControlFall.Hover      += btnDown_Hover;
            btnControlFall.Release    += btnDown_Release;
            Objects.Add(btnControlFall);
            hider.HideObject(Objects.Last(), HidePlace.Bottom);

            // CONTROL BUTTON ROTATE
            btnControlRotate             = Bank.Buttons.GetPlainButton(this);
            btnControlRotate.SpriteImage = Contents.Sprites.ControlButton_rotate;
            btnControlRotate.Size        = btnSize;
            btnControlRotate.Position    = new Vector2(lastObj.Position.X + 368, controlButtonsStartY);
            btnControlRotate.Click      += btnRotate_Click;
            Objects.Add(btnControlRotate);
            hider.HideObject(Objects.Last(), HidePlace.Bottom);

            // CONTROL BUTTON RIGHT
            btnControlRight             = Bank.Buttons.GetPlainButton(this);
            btnControlRight.SpriteImage = Contents.Sprites.ControlButton_right;
            btnControlRight.Size        = btnSize;
            btnControlRight.Position    = new Vector2(lastObj.Position.X + 544, controlButtonsStartY);
            btnControlRight.Release    += btnRight_Release;
            btnControlRight.Hover      += btnRight_Hover;
            Objects.Add(btnControlRight);
            hider.HideObject(Objects.Last(), HidePlace.Bottom);

            // ADDING PLAYING ARENA
            var arenaSize     = new Vector2(Size.X - 2 * playingArenaPadding, playingArenaEndY - playingArenaStart);
            var arenaPosition = new Vector2(playingArenaPadding, playingArenaStart);

            switch (gameMode)
            {
            case GameMode.Classic:
            {
                arena = new PlayingArena_Classic(this, arenaSize, arenaPosition);
            } break;

            case GameMode.Normal:
            {
                arena = new PlayingArena_Normal(this, arenaSize, arenaPosition);
                (arena as PlayingArena_Normal).AvailableBonusesChanged += Arena_AvailableBonusesChanged;
                (arena as PlayingArena_Normal).ActiveBonusChanged      += Arena_ActiveBonusChanged;
            } break;

            case GameMode.Extreme:
            {
                arena = new PlayingArena_Extreme(this, arenaSize, arenaPosition);
                (arena as PlayingArena_Extreme).AvailableBonusesChanged += Arena_AvailableBonusesChanged;
                (arena as PlayingArena_Extreme).ActiveBonusChanged      += Arena_ActiveBonusChanged;
            } break;
            }

            arena.LayerDepth          = 0.05f;
            arena.ActorsQueueChanged += Arena_ActorsQueueChanged;
            arena.ScoreChanged       += Arena_ScoreChanged;
            arena.GameEnded          += Arena_GameEnded;
            arena.StartNewGame();
            Objects.Add(arena);
            hider.HideObject(Objects.Last(), HidePlace.Bottom);

            // adding border for arena
            var borderOffset = new Vector2(12);

            Objects.Add(new DynamicBackgroundObject(this, Contents.Sprites.GameUI_playingArena_border, 4)
            {
                Position   = new Vector2(arena.Position.X - borderOffset.X, arena.Position.Y - borderOffset.Y),
                Size       = new Vector2(arena.Size.X + 2 * borderOffset.X, arena.Size.Y + 2 * borderOffset.Y),
                LayerDepth = 0.051f
            });
            hider.HideObject(Objects.Last(), HidePlace.Bottom);

            //// ADDING STAR SYSTEM ////
            Objects.Add(new StarSystem(this, new Vector2(680, 1200), new Vector2(20, 40)));
            lastObj            = Objects.Last();
            lastObj.LayerDepth = 0.019f;
            (lastObj as StarSystem).Start(218884, 1, 3, 3, 5, 15);
            (lastObj as StarSystem).MaxTimer = 5000;
            (lastObj as StarSystem).Alpha    = 0.8f;

            hider.AllHidden += Hider_AllHidden;
            hider.AllShown  += Hider_AllShown;
            hider.Hide(false);
        }