Esempio n. 1
0
        private static void ItemGetSelector(int index)
        {
            playerNowHp   += Item.lstItemData[index].nowLife;
            playerNowMana += Item.lstItemData[index].nowMana;

            if (Item.lstItemData[index].attribute == ItemAttribute.Equipment)
            {
                equipWeapon = EquipWeaponName.TreeBranch;
                MainWeapon.SetMainWeapon();
            }
        }
//inits
        private void InitGame()
        {
            this.GetNowTime();
            lastTime = nowTime;

            ImageData.SpriteReading();                                          //cropped image data

            StageManager.stageNum = 0;
            StageOrder.OrderListInit();                                 //stage order
            StageDataSetting.DataBaseReading();                         //database


            ImageData.SystemImagesReading();
            Sound.SoundEffectLoad(Canvas);

            SplashLogoOpen();


            //controlls maked
            mainCanvas = this.FindName("Canvas") as Canvas;
            lblMode    = FindName("lblGameMode") as Label;

            ctlDatabaseButton = btnViewDatabaseWindow;
            ctlMaterialButton = btnViewMaterialBrowser;
            ctlImageButton    = btnViewImageManager;

            CollisionCheck.ColliderCheckMaskGenerater(Canvas);
            MainWeapon.InitMainWeapon(Canvas);

            BalloonMessage.GenerateBalloon(Canvas);
            stpPlayerStatus            = Canvas.FindName("spPlayerStatus") as StackPanel;
            stpPlayerStatus.Visibility = Visibility.Hidden;
            Canvas.SetZIndex(spPlayerStatus, ImageZindex.status);

            var _popcantalk = new Image
            {
                Source     = ImageData.cbSystem,
                Width      = 64, Height = 32,
                Visibility = Visibility.Hidden,
            };

            ImageData.imgPopCanTalk = _popcantalk;
            Canvas.Children.Add(ImageData.imgPopCanTalk);
            Canvas.SetZIndex(ImageData.imgPopCanTalk, ImageZindex.status);


            ImageData.imgHandCursor = new Image
            {
                Source     = ImageData.cbHandCursor,
                Width      = 32, Height = 32,
                Visibility = Visibility.Hidden,
            };

            Canvas.Children.Add(ImageData.imgHandCursor);
            Canvas.SetZIndex(ImageData.imgHandCursor, ImageZindex.handCursor);

            canScreenFade.Width      = 1024;
            canScreenFade.Height     = 768;
            canScreenFade.Visibility = Visibility.Hidden;
            Canvas.Children.Add(canScreenFade);
            Canvas.SetLeft(canScreenFade, 0);
            Canvas.SetTop(canScreenFade, 0);
            Canvas.SetZIndex(canScreenFade, ImageZindex.fade);

            StageInit.InitPlayer(Canvas);
            StageInit.InitPlayerStatus(CaLife, CaMana);
        }
//frameupdate
        protected void FrameUpdateTimer_Update(object sender, ElapsedEventArgs e)
        {
            try
            {
                this.Dispatcher.Invoke(() =>
                {
                    //TimeManagement
                    this.GetNowTime();
                    elapsedTime = nowTime - lastTime;

                    //debug
                    lblDebugA.Content = PlayerStatus.playerPos.X + "," + PlayerStatus.playerPos.Y;
                    lblDebugB.Content = SystemOperator.PixelPerSecond(PlayerStatus.weight);

                    if (elapsedTime < 0)
                    {
                        elapsedTime += 59999;
                    }


                    KeyController.KeyInterval();

                    //GameTransition
                    if (!GameTransition.duringTransition)
                    {
                        GameTransition.GameTransitionController(Canvas, CaLife, CaMana);
                    }

                    //EventAction



                    if (GameTransition.eventStart)
                    {
                        if (GameTransition.lstEventTask.Count > 0)
                        {
                            GameTransition.EventTaskCommander();
                        }


                        if (GameTransition.charaRenderStart)
                        {
                            GameTransition.CharaRender();
                        }

                        if (GameTransition.screenFadeStart)
                        {
                            GameTransition.ScreenFade(Canvas);
                        }

                        if (!GameTransition.eventBalloonIsOpen)
                        {
                            if (GameTransition.eventCount < StageEvent.listEvent.Count)
                            {
                                GameTransition.EventController(Canvas);
                            }
                        }
                        else
                        {
                            if (KeyController.keyReturn)
                            {
                                EnterKeyAction(Canvas);
                            }
                        }
                    }

                    if (KeyController.keyReturn)
                    {
                        EnterKeyAction(Canvas);
                    }

                    //got to Edit Mode
                    if (GameTransition.gameTransition == GameTransitionType.Title)
                    {
                        if (KeyController.keyE)
                        {
                            mainCanvas.Children.Remove(ImageData.imgTitle[0]); mainCanvas.Children.Remove(ImageData.imgTitle[1]);
                            countTime = 0;
                            GameTransition.gameTransition = GameTransitionType.EditMode;
                            timerFrameUpdate.Stop();
                            btnViewStageEditorWindow.IsEnabled = true;
                            btnViewMaterialBrowser.IsEnabled   = true;
                            btnViewImageManager.IsEnabled      = true;
                            btnViewDatabaseWindow.IsEnabled    = true;

                            lblMode.Content = "ゲームモード:エディット";
                        }
                    }

                    //StageDuring game play
                    if (GameTransition.gameTransition == GameTransitionType.StageDuring &&
                        !isDeactivated)
                    {
                        Animator.AnimationItem();
                        Animator.AnimationObject();

                        if (ObjectChecker.isTrigger && !TalkCommander.isTalk)
                        {
                            ObjectBehavior.OnTriggerTouchEvent();
                        }

                        if (TalkCommander.isTalk && !TalkCommander.isTalkOpenBalloon)
                        {
                            TalkCommander.TalkWithNpc(Canvas);
                        }

                        if (TalkCommander.isTalkSelecting)
                        {
                            TalkCommander.TalkSelecting(Canvas);
                        }

                        //first action,last Processing including deletion of list
                        SystemOperator.moveCommonAmountX = 0;
                        SystemOperator.moveCommonAmountY = 0;

                        ObjectChecker.CollisionPtoActionCollider();
                        PlayerBehavior.CollisionPtoE();

                        PlayerBehavior.MovePlayer(Canvas);
                        PlayerBehavior.FallingPlayer();

                        Item.FallingItems();

                        EnemyBehavior.EnemyAction();
                        Animator.AnimationEnemy();

                        SubWeapon.SubWeaponPosUpdate(Canvas);

                        if (PlayerStatus.isMainAttack)
                        {
                            MainWeapon.MainWeaponAttack(Canvas);
                            MainWeapon.MainWeaponCollision(Canvas);
                        }


                        SubWeapon.CollisionSubWeapon(Canvas);

                        PlayerStatus.PlayerStatusUpdate();
                        PlayerBehavior.DamageInvinsibleTimer();

                        SpawnEnemy.RemoveEnemy(Canvas);
                        SpawnEnemy.ReSpawnEnemy(Canvas);
                    }

                    if (Sound.seStop)
                    {
                        if (Sound.sePlayTime < 60)
                        {
                            Sound.sePlayTime++;
                        }
                        else
                        {
                            Sound.sePlayTime = 0;
                            Sound.seStop     = false;
                        }
                    }

                    lastTime = nowTime;
                });
            }
            catch (TaskCanceledException)
            {
            }
        }