void Init() { var gesture = CCEventListenerGesture.Create(); gesture.SetSwipeThreshouldDistance(80); gesture.OnSwipeEnded = (swipe) => { isSwiped = false; switch (swipe) { case CCEventListenerGesture.SwipeDirection.NONE: break; case CCEventListenerGesture.SwipeDirection.UP: case CCEventListenerGesture.SwipeDirection.DOWN: case CCEventListenerGesture.SwipeDirection.LEFT: //ふぉーるするー case CCEventListenerGesture.SwipeDirection.RIGHT: CCLog.Log($"[OreOreLog]:{nameof(TestLayer)}{this.ZOrder}"); var goGame = new CCMenuItemLabel(new CCLabel("ゲームであそぶ", "Arial", 40), _ => { ChangeScene(new Loading(new GameAssetsLoader(new GameAssets()))); var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dig.Close(); }); var goTitle = new CCMenuItemLabel(new CCLabel("タイトルにもどる", "Arial", 40), _ => { ChangeScene(new Loading(new TitleAssetsLoader())); var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dig.Close(); }); var cancel = new CCMenuItemLabel(new CCLabel("キャンセル", "Arial", 40), _ => { var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dig.Close(); RemoveChild(dig); isSwiped = false; }); var sns_share = new CCMenuItemLabel(new CCLabel("ランキングのシェア", "Arial", 40), _ => { var dig = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dig.Close(); RemoveChild(dig); void Share(CCLayer layer) { CCRenderTexture rt = new CCRenderTexture(VisibleBoundsWorldspace.Size, VisibleBoundsWorldspace.Size, CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8); rt.BeginWithClear(CCColor4B.Black); layer.Visit(); rt.End(); rt.Sprite.Position = VisibleBoundsWorldspace.Center; CCRenderCommand shareCommand = new CCCustomCommand( () => { using (MemoryStream ms = new MemoryStream()) { //rt.Texture.SaveAsPng(ms, (int)layer.VisibleBoundsWorldspace.Size.Width, (int)layer.VisibleBoundsWorldspace.Size.Height); //ShareControl.ShareImage(ms); rt.SaveToStream(ms, CCImageFormat.Png); var _share = Xamarin.Forms.DependencyService.Get <IShareSNS>(); string text = ""; if (_rankingData.IsRankinCurrentPlayData) { int score = _rankingData.Ranks[_rankingData.RankinIndex].Score; if (_rankingData.RankinIndex == 0) { text = $"わたしのスコア:{score}点" + $"\n" + $"ハイスコア更新しました!"; } else { text = $"わたしのスコア:{score}点" + $"\n" + $"ランキング更新しました!"; } } else { text = "今のランキングです!"; } string hashTag = "#撃ち続けろ"; text = text + "\n" + hashTag; _share.Post(text, ms); } }); Renderer.AddCommand(shareCommand); } Share(this); isSwiped = false; return; }); var menuItems = new[] { goGame, goTitle, sns_share, cancel }; var menu = new ModalMenu(menuItems) { Position = new CCPoint(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y - 30), }; menu.AlignItemsVertically(30); var dialog = new ModalMenuDialog(menu); AddChild(dialog, 1, ModalMenuDialog.TAG); isSwiped = true; break; default: break; } }; AddEventListener(gesture, this.Point.First()); var touch = new CCEventListenerTouchOneByOne(); touch.OnTouchBegan = (_, __) => { foreach (var label in _rankPointsLabel) { if (label.Label.BoundingBoxTransformedToWorld.ContainsPoint(_.Location)) { selectedMenuItem = label; label.Selected = true; return(true); } } return(false); }; touch.OnTouchMoved = (_, __) => { CCMenuItem current = null; foreach (var label in _rankPointsLabel) { if (label.Label.BoundingBoxTransformedToWorld.ContainsPoint(_.Location)) { current = label; break; } } if (current != selectedMenuItem) { if (selectedMenuItem != null) { selectedMenuItem.Selected = false; } if (current != null) { current.Selected = true; } selectedMenuItem = current; } }; touch.OnTouchEnded = /*EventListener_TouchEnded*/ (_, __) => { if (selectedMenuItem != null) { selectedMenuItem.Selected = false; selectedMenuItem.Activate(); } }; AddEventListener(touch, this); if (_rankingData.CurrentPlayData != null) { var currentScoreLabel = new CCLabel($"あなたのスコア:{_rankingData.CurrentPlayData.Score}点", "arial", 20) { Position = new CCPoint(20, GlobalGameData.Window_Height - 20), AnchorPoint = CCPoint.AnchorMiddleLeft }; AddChild(currentScoreLabel); if (_rankingData.IsRankinCurrentPlayData) { var omedetoLabel = new CCLabel("ランクインおめでとう!", "arial", 20) { Position = new CCPoint(380, GlobalGameData.Window_Height - 20) }; AddChild(omedetoLabel); } } systemLabel = new CCLabel("スワイプ:メニューを開く スコアを選ぶ:リプレイ", "arial", 20) { Position = new CCPoint(20, 20), AnchorPoint = CCPoint.AnchorMiddleLeft, Visible = false }; AddChild(systemLabel); }
protected override void AddedToScene() { base.AddedToScene(); var title = new CCSprite("Images/Title/title_old") { Position = new CCPoint(ContentSize.Center.X, /*380-150/2*/ ContentSize.Center.Y) }; AddChild(title); CCAudioEngine.SharedEngine.PlayBackgroundMusic("Music/Title/bgm_maoudamashii_8bit24", true); var gameMenuItem = new CCMenuItemLabel(new CCLabel("はじめる", "Arial", 50), _ => { ChangeScene(new Loading(new GameAssetsLoader(new GameAssets()))); } ); var rankingMenuItem = new CCMenuItemLabel(new CCLabel("らんきんぐ", "Arial", 50), _ => { ChangeScene(new Loading(new RankingAssetsLoader())); } ); var helpMenuItem = new CCMenuItemLabel(new CCLabel("へるぷ", "Arial", 50), _ => { var osiItem = new CCMenuItemLabel(new CCLabel("おーぷんそーすらいぶらり", "Arial", 40), __ => { NavigateToWebView("OpenSourceLibrary.html"); }) ; var sozaiItem = new CCMenuItemLabel(new CCLabel("つかったそざい", "Arial", 40), __ => { NavigateToWebView("UsingMaterial.html"); }); var closeItem = new CCMenuItemLabel(new CCLabel("とじる", "Arial", 40), __ => { var dialog = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dialog.Close(); RemoveChild(dialog); }); var menu = new ModalMenu(osiItem, sozaiItem, closeItem) { Position = ContentSize.Center, }; menu.AlignItemsVertically(40); var modalDialog = new ModalMenuDialog(menu); AddChild(modalDialog, 1, ModalMenuDialog.TAG); }); var titleMenuItems = new[] { gameMenuItem, rankingMenuItem, helpMenuItem }; var titleMenu = new CCMenu(titleMenuItems) { Position = new CCPoint(GlobalGameData.Window_Center_X, GlobalGameData.Window_Height / 4), }; titleMenu.AlignItemsVertically(30); AddChild(titleMenu); }
protected override void AddedToScene() { base.AddedToScene(); var backGround = new CCSprite("Images/BackGround/space", null) { Position = ContentSize.Center }; AddChild(backGround); if (_mode == GameMode.Replay) { playerPoint = _playData.PlayerPositions; enemyPopPointX = new Queue <int>(_playData.EnemyPopPoints_X); enemyTypes = new Queue <MoverType>(_playData.MoverTypes); var modeLabel = new CCLabel("リプレイモード", "arial", 30) { Color = new CCColor3B(255, 100, 100), Position = new CCPoint(380, GlobalGameData.Window_Height - 20) }; AddChild(modeLabel); } player = _mode == GameMode.Normal ? new Player() : new ReplayPlayer(playerPoint); AddChild(player.Node); enemys = new List <Enemy>(100); playerBullets = new List <IBullet <IShot> >(50); enemyBullets = new List <IBullet <IShot> >(100); if (_mode == GameMode.Normal) { playerPoint = new List <Point>(10000); enemyPopPointX = new Queue <int>(100); enemyTypes = new Queue <MoverType>(100); } brokenMovers = new BrokenMover[2]; brokenMovers[0] = new BrokenMover(new CCPoint(0, 650), (new NormalEnemySkin()).ImgPath, MoverType.NormalEnemy); brokenMovers[1] = new BrokenMover(new CCPoint(0, 620), (new StrongEnemySkin()).ImgPath, MoverType.StrongEnemy); AddChild(brokenMovers[0].Image); AddChild(brokenMovers[1].Image); AddChild(brokenMovers[0].Nodes[1]); AddChild(brokenMovers[1].Nodes[1]); var count3 = new CCSprite("Images/System/Count3"); var count2 = new CCSprite("Images/System/Count2"); var count1 = new CCSprite("Images/System/Count1"); var countGo = new CCSprite("Images/System/CountGo") { Tag = 0x1919 }; var counts = new[] { count3, count2, count1, countGo }; var countAction = new CCMoveTo(1, ContentSize.Center); var countsQueue = new Queue <CCNode>(counts); var remove = new CCRemoveSelf(); foreach (var count in counts) { count.Position = new CCPoint(1000, GlobalGameData.Window_Center_Y); AddChild(count); } void s(float f) { if (!countsQueue.Any()) { CCAudioEngine.SharedEngine.PlayBackgroundMusic(randomBGM, true); Unschedule(s); Schedule(RunGameLogic); Schedule((_) => { if (_mode == GameMode.Normal) { Enemy enemy = new Enemy(new EnemySkinFactory(), this); enemyPopPointX.Enqueue(enemy.InitXPoint); enemyTypes.Enqueue(enemy.Type); AddEnemy(enemy); } else if (_mode == GameMode.Replay) { if (!enemyPopPointX.Any() || !enemyTypes.Any()) { return; } AddEnemy(new ReplayEnemy(this, enemyPopPointX.Dequeue(), enemyTypes.Dequeue())); } }, 1.0f); Schedule((_) => { if (!player.IsEnable) { return; } AddBullets(playerBullets, player.Fire(playerBullets)); }, (1.0f / 6.0f)); Schedule(_ => { if (!player.IsEnable) { return; } Score++; }, 1.0f); AddEventListener(player.TouchListener, this); } else { var count = countsQueue.Dequeue(); count.RunActions(countAction, remove); if (count.Tag == 0x1919) { CCAudioEngine.SharedEngine.PlayEffect("SE/Countdown01-6"); } else { CCAudioEngine.SharedEngine.PlayEffect("SE/Countdown01-5"); } } }; Schedule(s, 1, 4, 1); var button = new CCSprite("Images/System/gear") { Position = new CCPoint(30, 30), }; var buttontouch = new CCEventListenerTouchOneByOne() { IsSwallowTouches = true, OnTouchBegan = (touch, _) => { if (button.BoundingBox.ContainsPoint(touch.Location)) { isbuttontouch = true; return(true); } return(false); }, OnTouchMoved = (touch, _) => { if (!isbuttontouch) { return; } isbuttontouch = false; if (button.BoundingBox.ContainsPoint(touch.Location)) { isbuttontouch = true; } }, OnTouchEnded = (touch, _) => { if (!isbuttontouch) { return; } if (button.BoundingBox.ContainsPoint(touch.Location)) { this.Pause(); //var dialog = new YesNoDialog("停止なう", "再開しますか", // ___ => // { // var _dialog = GetChildByTag(YesNoDialog.TAG) as YesNoDialog; // _dialog.Close(); // RemoveChild(_dialog); // this.Resume(); // }, null); //AddChild(dialog, 1, YesNoDialog.TAG); var pauseMenu = new ModalMenu() { Position = ContentSize.Center, }; var retryGame = new CCMenuItemLabel(new CCLabel("ゲームをやりなおす", "Arials", 50), A => { ChangeScene(new Game(randomBGM)); var dialog = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dialog.Close(); }); var goRanking = new CCMenuItemLabel(new CCLabel("ランキングにもどる", "Arial", 50), A => { ChangeScene(new Loading(new RankingAssetsLoader())); var dialog = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dialog.Close(); }); var goTitle = new CCMenuItemLabel(new CCLabel("タイトルにもどる", "Arial", 50), A => { ChangeScene(new Loading(new TitleAssetsLoader())); var dialog = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dialog.Close(); }); var resumeGame = new CCMenuItemLabel(new CCLabel("ゲームをつづける", "Arial", 50), A => { this.Resume(); var dialog = GetChildByTag(ModalMenuDialog.TAG) as ModalMenuDialog; dialog.Close(); RemoveChild(dialog); }); var menuItems = new[] { retryGame, goTitle, resumeGame }; foreach (var menuItem in menuItems) { pauseMenu.AddChild(menuItem); } pauseMenu.AlignItemsVertically(20); var modalMenuDialog = new ModalMenuDialog(pauseMenu); AddChild(modalMenuDialog, 1, ModalMenuDialog.TAG); } } }; AddChild(button); AddEventListener(buttontouch); }