public void ShowEndScreen() { // Congratulation title var congratulationsNode = SKSpriteNode.FromImageNamed("Overlays/congratulations.png"); // Max image var characterNode = SKSpriteNode.FromImageNamed("Overlays/congratulations_pandaMax.png"); characterNode.Position = new CGPoint(0f, -220f); characterNode.AnchorPoint = new CGPoint(0.5f, 0f); this.congratulationsGroupNode = new SKNode(); this.congratulationsGroupNode.AddChild(characterNode); this.congratulationsGroupNode.AddChild(congratulationsNode); this.AddChild(this.congratulationsGroupNode); // Layout the overlay this.Layout2DOverlay(); // Animate congratulationsNode.Alpha = 0f; congratulationsNode.XScale = 0f; congratulationsNode.YScale = 0f; congratulationsNode.RunAction(SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.25), SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25), SKAction.ScaleTo(1f, 0.1) }) })); characterNode.Alpha = 0f; characterNode.XScale = 0f; characterNode.YScale = 0f; characterNode.RunAction(SKAction.Sequence(new SKAction[] { SKAction.WaitForDuration(0.5), SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.5), SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25), SKAction.ScaleTo(1f, 0.1) }) }) })); }
public Sprite[,,] Getmap(nfloat Height, nfloat Width, int mapnum) { block_setup setup = new block_setup(); fetch_data fetch = new fetch_data(); Sprite[,,] sprites = new Sprite[10, 10, 3]; StreamReader maps = null; try { maps = new StreamReader(fetch.Get_path_map() + "maps.csv"); Debug.WriteLine("No error for map path"); } catch (Exception ex) { Debug.WriteLine(ex); } string[] row; do { row = maps.ReadLine().Split(','); if (int.Parse(row[0]) == mapnum) { Sprite.Block block = new Sprite.Block(setup.b(row[3])); block.xPos = int.Parse(row[1]); block.yPos = int.Parse(row[2]); block.zPos = 0; block.spriteNode = SKSpriteNode.FromImageNamed(block.path); setup.setPos(ref block, ref sprites, Height, Width); } }while (int.Parse(row[0]) <= mapnum); maps.Close(); return(sprites); }
/// <summary> /// Renders the logo. /// </summary> void RenderLogo() { var logo = SKSpriteNode.FromImageNamed(LOGO_IMAGE); logo.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY() * 1.75); AddChild(logo); }
public void ShowScanAction() { var size = base.Size; _scanText1 = new SKLabelNode("AppleSDGothicNeo-Regular") { Text = "Move your phone", FontSize = 30, Position = new CGPoint(size.Width / 2, 100), Color = UIColor.White, }; AddChild(_scanText1); _scanText2 = new SKLabelNode("AppleSDGothicNeo-Regular") { Text = "to find a surface", FontSize = 30, Position = new CGPoint(size.Width / 2, 70), Color = UIColor.White, }; AddChild(_scanText2); _phone = SKSpriteNode.FromImageNamed("phone_scaled"); _phone.Position = new CGPoint(size.Width / 2, 190); var circle = UIBezierPath.FromRoundedRect(new CGRect(new CGPoint(size.Width / 2 - 20, 190), new CGSize(40, 40)), 20); var moveAlongPath = SKAction.RepeatActionForever(SKAction.FollowPath(circle.CGPath, false, false, 2.0)); _phone.RunAction(moveAlongPath); AddChild(_phone); ScanActionShowing = true; ScanActionFinished = false; }
public void ShowActionPlacement() { var size = base.Size; _check = SKSpriteNode.FromImageNamed("check_scaled"); _check.Position = new CGPoint(size.Width / 2, 190); AddChild(_check); }
/// <summary> /// Renders the background. /// </summary> void RenderBackground() { var background = SKSpriteNode.FromImageNamed(BACKGROUND_IMAGE); background.AnchorPoint = new CGPoint(0, 0); background.ZPosition = -1; background.Size = Frame.Size; AddChild(background); }
void ShowEndScreen() { gameIsComplete = true; // Add confettis SCNMatrix4 particlePosition = SCNMatrix4.CreateTranslation(0f, 8f, 0f); GameView.Scene.AddParticleSystem(confetti, particlePosition); // Congratulation title SKSpriteNode congrat = SKSpriteNode.FromImageNamed("Images/congratulations.png"); congrat.Position = new CGPoint(GameView.Bounds.Width / 2, GameView.Bounds.Height / 2); SKScene overlay = GameView.OverlayScene; congrat.XScale = congrat.YScale = 0; congrat.Alpha = 0; congrat.RunAction(SKAction.Group(new [] { SKAction.FadeInWithDuration(0.25), SKAction.Sequence(new [] { SKAction.ScaleTo(.55f, 0.25), SKAction.ScaleTo(.3f, 0.1), }) })); // Panda Image SKSpriteNode congratPanda = SKSpriteNode.FromImageNamed("Images/congratulations_pandaMax.png"); congratPanda.Position = new CGPoint(GameView.Bounds.Width / 2f, GameView.Bounds.Height / 2f - 90f); congratPanda.AnchorPoint = new CGPoint(.5f, 0f); congratPanda.XScale = congratPanda.YScale = 0f; congratPanda.Alpha = 0; congratPanda.RunAction(SKAction.Sequence(new [] { SKAction.WaitForDuration(.5f), SKAction.Sequence(new [] { SKAction.ScaleTo(.5f, 0.25), SKAction.ScaleTo(.4f, 0.1) }) })); overlay.AddChild(congratPanda); overlay.AddChild(congrat); // Stop music GameView.Scene.RootNode.RemoveAllAudioPlayers(); // Play the congrat sound. GameView.Scene.RootNode.AddAudioPlayer(SCNAudioPlayer.FromSource(victoryMusic)); // Animate the camera forever DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 1 * NanoSecondsPerSeond), () => { cameraYHandle.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0f, -1f, 0f, 3.0))); cameraXHandle.RunAction(SCNAction.RotateTo(-(float)Math.PI / 4f, 0f, 0f, 5.0)); }); }
public void GiveToProcess(Process process, string picName) { busy = true; this.process = process; sprite = SKSpriteNode.FromImageNamed(picName); sprite.Position = new CoreGraphics.CGPoint((nfloat)Constants.DrawingStartVerticalOffset, (nfloat)Constants.WindowHeight - (nfloat)address / GameScene.memorySize * Constants.MemoryDrawingWidth); sprite.YScale = 1.0f * Constants.MemoryDrawingWidth / (GameScene.memorySize * sprite.Size.Height); sprite.ZPosition = 50; sprite.AnchorPoint = new CGPoint(0, sprite.CenterRect.Height); }
public void CreateSprite(CGPoint location) { var sprite = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("Spaceship", "png")); sprite.Position = location; sprite.SetScale(0.5f); var action = SKAction.RotateByAngle(NMath.PI, 1.0); sprite.RunAction(SKAction.RepeatActionForever(action)); AddChild(sprite); }
public override void MouseDown(NSEvent theEvent) { // Called when a mouse click occurs var location = theEvent.LocationInNode(this); var sprite = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("Spaceship", "png")); sprite.Position = location; sprite.SetScale(0.2f); AddChild(sprite); }
public override void DidMoveToView(SKView view) { //Load in the "table top" SKSpriteNode background = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("bg_1", "jpg")); background.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY()); background.ScaleTo(Frame.Size); background.ZPosition = -1000; AddChild(background); DealCards(); }
public void ShowActionControls() { var size = base.Size; _actuatorLeft = SKSpriteNode.FromImageNamed("piston_scaled"); _actuatorLeft.Position = new CGPoint(size.Width / 2 - ActuatorCenterOffset, ActuatorEdgeOffset); AddChild(_actuatorLeft); _actuatorRight = SKSpriteNode.FromImageNamed("piston_scaled"); _actuatorRight.Position = new CGPoint(size.Width / 2 + ActuatorCenterOffset, ActuatorEdgeOffset); AddChild(_actuatorRight); }
protected GameScene(IntPtr handle) : base(handle) { fetch = new setup1(); data = new fetch_data(); move = new movements(); player1 = new Sprite.Entity(fetch.p1()); sprites = new Sprite[10, 10, 3]; Nextmove = false; //accelx = 0; //accely = 0; Height = Frame.Size.Height; Width = Frame.Size.Width; bg = SKSpriteNode.FromImageNamed("background/background"); player1.spriteNode = SKSpriteNode.FromImageNamed(player1.spritef); //p1 = SKSpriteNode.FromImageNamed("sprites/player/p1front"); }
/// <summary> /// Draws scene background /// </summary> void DrawBackground() { // TODO: optimize background rendering SKSpriteNode background = new SKSpriteNode(); for (nfloat i = 0; i < GameMap.Width; i += _windowWidth) { var bgpart = SKSpriteNode.FromImageNamed("GameStage.png"); bgpart.AnchorPoint = new CGPoint(0, 0); bgpart.ZPosition = -1; bgpart.Size = new CGSize(_windowWidth, _windowHeight); bgpart.Position = new CGPoint(i, 0); AddChild(bgpart); } }
public override void MouseDown(NSEvent theEvent) { // Called when a mouse click occurs var location = theEvent.LocationInNode(this); var sprite = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("Spaceship", "png")); sprite.Position = location; sprite.SetScale(0.5f); var action = SKAction.RotateByAngle(NMath.PI, 1.0); sprite.RunAction(SKAction.RepeatActionForever(action)); AddChild(sprite); }
public override void MouseDown(NSEvent theEvent) { // Called when a mouse click occurs var location = theEvent.LocationInNode(this); SKSpriteNode sprite = SKSpriteNode.FromImageNamed("person"); //var sprite = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("Spaceship", "png")); sprite.Position = location; sprite.SetScale(10); var action = SKAction.MoveBy(2, 2, 0.1); sprite.RunAction(SKAction.RepeatActionForever(action)); //sprite.RunAction(SKAction.RepeatActionForever(action)); AddChild(sprite); }
/// <summary> /// Анимация бонуса Бомба /// </summary> /// <param name="bomb">Бомба.</param> public void AnimateBomb(Gem bomb) { CGSize initialSize = new CGSize(gemCellWidth, gemCellHeight); CGSize newSize = new CGSize(gemCellWidth * (Properties.BombBlastRadius * 2 + 1), gemCellHeight * (Properties.BombBlastRadius * 2 + 1)); CGPoint initialPosition = GetPositionFromRowAndColumn(bomb.Row, bomb.Column); SKSpriteNode sprite = SKSpriteNode.FromImageNamed("bomb_blast"); sprite.Size = initialSize; sprite.Position = initialPosition; sprite.ZPosition = 110; SKAction resizeSprite = SKAction.ResizeTo(newSize, Properties.LineDestructionDuration / 1000f); gemLayer.AddChild(sprite); sprite.RunAction(SKAction.Sequence(resizeSprite, SKAction.RemoveFromParent())); }
public override void DidMoveToView(SKView view) { var bgNode = SKSpriteNode.FromImageNamed("bg.jpg"); var scale = Size.Width / bgNode.Size.Width; bgNode.SetScale(scale * 2); bgNode.Position = new CGPoint(Size.Width / 2, Size.Height / 2); AddChild(bgNode); bgNode.ZPosition = -1; PhysicsWorld.Gravity = new CGVector(0, 0); GC = new GameController(this); GC.SpawnPlayer(); var colDelegate = new CollisionDelegate(); colDelegate.Callbacks += NodesCollided; PhysicsWorld.ContactDelegate = colDelegate; }
/// <summary> /// Добававляем его спрайт на нод для камешка, с расчетом размера и позиции /// </summary> /// <param name="gem">Камешек которому добавляется спрайт.</param> private void AttachSpriteTo(Gem gem) { SKSpriteNode sprite; // Если разрушитель - открепляем старый спрайт на этом месте от слоя камешков if ((gem.IsALineDestroyer || gem.IsABomb) && Level.GemArray[gem.Row, gem.Column] != null) { sprite = Level.GemArray[gem.Row, gem.Column].Sprite; if (sprite != null && sprite.Parent != null) { sprite.RemoveFromParent(); } } // подготовка спрайта sprite = SKSpriteNode.FromImageNamed(gem.GetSpriteName()); sprite.Size = new CGSize(gemCellWidth, gemCellHeight); sprite.Position = GetPositionFromRowAndColumn(gem.Row, gem.Column); gemLayer.AddChild(sprite); gem.Sprite = sprite; // подготовка к анимации sprite.Alpha = 0; sprite.XScale = 0.5f; sprite.YScale = 0.5f; // Анимация появления камешка sprite.RunAction( SKAction.Sequence( SKAction.WaitForDuration(0.25, 0.5), SKAction.Group( SKAction.FadeInWithDuration(0.25), SKAction.ScaleTo(1.0f, 0.25) ) )); // если разрушитель - заменяем в массиве камешек if (gem.IsALineDestroyer || gem.IsABomb) { Level.GemArray[gem.Row, gem.Column] = gem; } }
/// <summary> /// Анимация разрушителей. создает спрайт, на месте бонуса, которому придает анимацию /// перемещения к центру (зависит от активированного бонуса - вертикально /// или горизонтально), с одновременным растягиванием, иммитируя лазерныйй луч /// затем удаляет спрайт со сцены /// </summary> /// <param name="destroyer">Активированный онус.</param> public void AnimateLineDestroyer(Gem destroyer) { SKSpriteNode sprite; CGPoint centerPoint; SKAction resizeSprite; // инициализация спрайта, подготовка координат для анимации, размеров if (destroyer.IsHorizontal) { float newWidth = gemCellWidth * Level.ColumnsNumber; sprite = SKSpriteNode.FromImageNamed("destroyer_ray_horisontal"); centerPoint = new CGPoint(gemCellWidth * Level.ColumnsNumber / 2, destroyer.Sprite.Position.Y); resizeSprite = SKAction.ResizeToWidth(newWidth, Properties.LineDestructionDuration / 1000f); } else { float newHeight = gemCellHeight * Level.RowsNumber; sprite = SKSpriteNode.FromImageNamed("destroyer_ray_vertical"); centerPoint = new CGPoint(destroyer.Sprite.Position.X, gemCellHeight * Level.RowsNumber / 2); resizeSprite = SKAction.ResizeToHeight(newHeight, Properties.LineDestructionDuration / 1000f); } SKAction moveToCenter = SKAction.MoveTo(centerPoint, Properties.LineDestructionDuration / 1000f); CGPoint initialPosition = GetPositionFromRowAndColumn(destroyer.Row, destroyer.Column); CGSize initialSize = new CGSize(gemCellWidth, gemCellHeight); sprite.Size = initialSize; sprite.Position = initialPosition; sprite.ZPosition = 110; gemLayer.AddChild(sprite); sprite.RunAction(moveToCenter); sprite.RunAction(SKAction.Sequence(resizeSprite, SKAction.RemoveFromParent())); }
//*****MouseDown(NsEvent theEvent){}************************************ //*****is an event that takes places the player on the board or screen** public override void MouseDown(NSEvent theEvent) { // Called when a mouse click occurs if (game == 0x000F) { return; } var location = theEvent.LocationInNode(this); //initiliazint the Sprite object (SKSSpriteNode is the type) var sprite = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("SideNW", "png")); sprite.Name = "BlakePlayer"; //naming the sprite node for lookup sprite.Position = location; // sprite.SetScale(0.25f); //setting the scale of the helo PlayerRide.SetPlayer(sprite); //placing the sprite into the helo object AddChild(sprite); //adding a child places sprite object onto the screen game = 0x000F; }
public SpriteKitOverlayScene(CGSize size) { Size = size; AnchorPoint = new CGPoint(0.5f, 0.5f); ScaleMode = SKSceneScaleMode.ResizeFill; //buttons NextButton = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("images/next", "png")); var marginY = 60.0f; var maringX = -60.0f; #if __IOS__ if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { marginY = 30; } #endif NextButton.Position = new CGPoint(size.Width * 0.5f + maringX, -size.Height * 0.5f + marginY); NextButton.Name = "next"; NextButton.Alpha = 0.01f; #if __IOS__ if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { NextButton.XScale = NextButton.YScale = 0.5f; } #endif AddChild(NextButton); #if __IOS__ PreviousButton = SKSpriteNode.FromColor(UIColor.Clear, NextButton.Frame.Size); #else PreviousButton = SKSpriteNode.FromColor(NSColor.Clear, NextButton.Frame.Size); #endif PreviousButton.Position = new CGPoint(-(size.Width * 0.5f + maringX), -size.Height * 0.5f + marginY); PreviousButton.Name = "back"; PreviousButton.Alpha = 0.01f; AddChild(PreviousButton); }
// Gets the map from the table and returns it in a Sprite array public Sprite[,,] Getmap(nfloat Height, nfloat Width, int mapnum) { block_setup setup = new block_setup(); Sprite[,,] sprites = new Sprite[10, 10, 3]; StreamReader maps = null; try { maps = new StreamReader(path_map + "maps.csv"); Debug.WriteLine("No error for map path"); } catch (Exception ex) { Debug.WriteLine("Failed to access maps directory: {0}", ex); } string[] row; maps.ReadLine(); try { do { row = maps.ReadLine().Split(','); if (int.TryParse(row[0], out int z) && int.Parse(row[0]) == mapnum) { Sprite.Block block = new Sprite.Block(setup.b(row[3])); block.xPos = int.Parse(row[1]); block.yPos = int.Parse(row[2]); block.zPos = 0; block.spriteNode = SKSpriteNode.FromImageNamed(block.path); setup.setPos(ref block, ref sprites, Height, Width); } }while (int.Parse(row[0]) <= mapnum); Debug.WriteLine("Fetched map from maps table without problem"); } catch (Exception ex) { Debug.WriteLine("Failed to fetch from maps table: {0}", ex); } maps.Close(); return(sprites); }
public override void KeyUp(NSEvent theEvent) { // Called when a key is var location = theEvent.LocationInNode(this); //SKSpriteNode sprite = SKSpriteNode.FromImageNamed("p1front"); var sprite = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("p1front", "png")); sprite.Position = location; sprite.SetScale(1f); var action = SKAction.MoveBy(2, 2, 0.1); //SKAction OutofBounds = SKAction.RemoveFromParent(); //sprite. sprite.RunAction(SKAction.RepeatActionForever(action)); AddChild(sprite); }
// Fetches a map file and imports it into a 3 dimensional array while instantiating the values public Sprite[,,] fetchMap(nfloat Height, nfloat Width, string mapID) { block_setup setup = new block_setup(); Sprite[,,] sprites = new Sprite[10, 10, 3]; StreamReader map1 = null; try { map1 = new StreamReader(path_map + mapID + ".csv"); Debug.WriteLine("No error for map path"); } catch (Exception ex) { Debug.WriteLine("Error whilst trying to access map: {0}", ex); } string[] row; for (int y = 9; y >= 0; y--) { row = map1.ReadLine().Split(','); for (int x = 0; x < row.Length; x++) { if (row[x] != "0") { Sprite.Block block = new Sprite.Block(setup.b(row[x])); block.xPos = x; block.yPos = y; block.zPos = 0; block.spriteNode = SKSpriteNode.FromImageNamed(block.path); setup.setPos(ref block, ref sprites, Height, Width); } } } map1.Close(); return(sprites); }
public OverlayScene(CGSize size) : base(size) { AnchorPoint = new CGPoint(0.5f, 0.5f); ScaleMode = SKSceneScaleMode.ResizeFill; float scale = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 1.5f : 1f; var myImage = SKSpriteNode.FromImageNamed(ResourceManager.GetResourcePath("speedGauge.png")); myImage.AnchorPoint = new CGPoint(0.5f, 0f); myImage.Position = new CGPoint(size.Width * 0.33f, -size.Height * 0.5f); myImage.XScale = 0.8f * scale; myImage.YScale = 0.8f * scale; AddChild(myImage); var needleHandle = SKNode.Create(); var needle = SKSpriteNode.FromImageNamed(ResourceManager.GetResourcePath("needle.png")); needleHandle.Position = new CGPoint(0f, 16f); needle.AnchorPoint = new CGPoint(0.5f, 0f); needle.XScale = 0.7f; needle.YScale = 0.7f; needle.ZRotation = (float)Math.PI / 2f; needleHandle.AddChild(needle); myImage.AddChild(needleHandle); SpeedNeedle = needleHandle; var cameraImage = SKSpriteNode.FromImageNamed(ResourceManager.GetResourcePath("video_camera.png")); cameraImage.Position = new CGPoint(-size.Width * 0.4f, -size.Height * 0.4f); cameraImage.Name = "camera"; cameraImage.XScale = 0.6f * scale; cameraImage.YScale = 0.6f * scale; AddChild(cameraImage); }
public Overlay(CGSize size, GameController controller) : base(size) { this.overlayNode = new SKNode(); var width = size.Width; var height = size.Height; this.collectedGemsSprites = new List <SKSpriteNode>(); // Setup the game overlays using SpriteKit. this.ScaleMode = SKSceneScaleMode.ResizeFill; this.AddChild(this.overlayNode); this.overlayNode.Position = new CGPoint(0f, height); // The Max icon. var characterNode = SKSpriteNode.FromImageNamed("Overlays/MaxIcon.png"); var menuButton = new Button(characterNode) { Position = new CGPoint(50f, -50f), XScale = 0.5f, YScale = 0.5f, }; this.overlayNode.AddChild(menuButton); menuButton.SetClickedTarget(this.ToggleMenu); // The Gems for (int i = 0; i < 1; i++) { var gemNode = SKSpriteNode.FromImageNamed("Overlays/collectableBIG_empty.png"); gemNode.Position = new CGPoint(125f + i * 80f, -50f); gemNode.XScale = 0.25f; gemNode.YScale = 0.25f; this.overlayNode.AddChild(gemNode); this.collectedGemsSprites.Add(gemNode); } // The key this.collectedKeySprite = SKSpriteNode.FromImageNamed("Overlays/key_empty.png"); this.collectedKeySprite.Position = new CGPoint(195f, -50f); this.collectedKeySprite.XScale = 0.4f; this.collectedKeySprite.YScale = 0.4f; this.overlayNode.AddChild(this.collectedKeySprite); // The virtual D-pad #if __IOS__ this.ControlOverlay = new ControlOverlay(new CGRect(0f, 0f, width, height)); this.ControlOverlay.LeftPad.Delegate = controller; this.ControlOverlay.RightPad.Delegate = controller; this.ControlOverlay.ButtonA.Delegate = controller; this.ControlOverlay.ButtonB.Delegate = controller; this.AddChild(this.ControlOverlay); #endif // the demo UI this.demoMenu = new Menu(size) { Hidden = true, Delegate = controller, }; this.overlayNode.AddChild(this.demoMenu); // Assign the SpriteKit overlay to the SceneKit view. base.UserInteractionEnabled = false; }
public override void Update(double currentTime) { // Called before each frame is rendered time = currentTime; if (memoryInputConfirmed) { RemoveAllChildren(); processes.Clear(); if (memorySize != 0) { memorySprite = SKSpriteNode.FromImageNamed("rect.png"); memorySprite.AnchorPoint = new CGPoint(0, memorySprite.CenterRect.Height); memorySprite.Position = new CGPoint(Constants.DrawingStartVerticalOffset, Constants.WindowHeight); memorySprite.YScale = 1; memory = new Memory(memorySize); AddChild(memorySprite); } } if (processInputConfirmed) { if (memory != null) { if (processSize > 0) { Process process = new Process(currentProcessId, processName, processSize); if (process.AddIntoMemory(processes, memory, GetRandomPicName(), algorithm)) { currentProcessId++; } else { NSAlert alert = new NSAlert(); alert.MessageText = "内存空间不足,尝试:\n" + "\t1 等待现有进程执行结束后再次新建进程\n" + "\t2 新建一个占内存较小的进程\n" + "\t3 重新建立一个空间较大的内存"; alert.RunModal(); } } else { NSAlert alert = new NSAlert(); alert.MessageText = "进程所占空间必须为大于零的整数,请重新输入。"; alert.RunModal(); } memory.Draw(this); } else { NSAlert alert = new NSAlert(); alert.MessageText = "请先确定内存大小。"; alert.RunModal(); } } memoryInputConfirmed = false; processInputConfirmed = false; if (memory != null) { GetCurrentStatus(); } }
public void Setup() { nfloat w = Bounds.Width; nfloat h = Bounds.Height; if (w < h) { nfloat wTmp = w; w = h; h = wTmp; } // Setup the game overlays using SpriteKit SKScene skScene = SKScene.FromSize(new CGSize(w, h)); skScene.ScaleMode = SKSceneScaleMode.ResizeFill; overlayGroup = SKNode.Create(); skScene.AddChild(overlayGroup); overlayGroup.Position = new CGPoint(0f, h); // The Max icon SKSpriteNode sprite = SKSpriteNode.FromImageNamed("Images/MaxIcon.png"); sprite.Position = new CGPoint(50f, -50f); overlayGroup.AddChild(sprite); sprite.XScale = sprite.YScale = 0.5f; for (int i = 0; i < 3; i++) { flowers [i] = SKSpriteNode.FromImageNamed("Images/FlowerEmpty.png"); flowers [i].Position = new CGPoint(110f + i * 40f, -50f); flowers [i].XScale = flowers [i].YScale = 0.25f; overlayGroup.AddChild(flowers[i]); } // The peal icon and count. sprite = SKSpriteNode.FromImageNamed("Images/ItemsPearl.png"); sprite.Position = new CGPoint(110f, -100f); sprite.XScale = sprite.YScale = 0.5f; overlayGroup.AddChild(sprite); pearlLabel = SKLabelNode.FromFont("Chalkduster"); pearlLabel.Text = "x0"; pearlLabel.Position = new CGPoint(152f, -113f); overlayGroup.AddChild(pearlLabel); // The D-Pad sprite = SKSpriteNode.FromImageNamed("Images/dpad.png"); sprite.Position = new CGPoint(100f, 100f); sprite.XScale = sprite.YScale = 0.5f; skScene.AddChild(sprite); padRect = new CGRect( (sprite.Position.Y - DPAD_RADIUS) / w, 1f - (sprite.Position.Y + DPAD_RADIUS) / h, 2f * DPAD_RADIUS / w, 2f * DPAD_RADIUS / h ); // Assign the SpriteKit overlay to the SceneKit view. OverlayScene = skScene; // Setup the pinch gesture defaultFov = PointOfView.Camera.XFov; var pinch = new UIPinchGestureRecognizer { Delegate = this, CancelsTouchesInView = false }; pinch.AddTarget(() => PinchWithGestureRecognizer(pinch)); AddGestureRecognizer(pinch); }
public override void DidMoveToView(SKView view) { // Setup your scene here var myLabel = new SKLabelNode("Chalkduster") { Text = "Helicopter Destroyers \n**COMING SOON**!", FontSize = 45, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2) }; var myLabel1 = new SKLabelNode("Black") { Text = "BDD copyright 2017", FontSize = 35, Position = new CGPoint(Frame.Width / 2, Frame.Height / 3), Name = "myLabel1" }; var ScoreLabel = new SKLabelNode("Comicsans") { Text = "Score: ", FontSize = 42, Position = new CGPoint(Frame.Width - 100, 100), Name = "ScoreLabel" }; var NavArrow = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("NavArrow", "png")); var Compass = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("compassgauge_small", "png")); var Image1 = SKSpriteNode.FromImageNamed(NSBundle.MainBundle.PathForResource("SideS", "png")); Image1.Position = new CGPoint(Frame.Width / 2, Frame.Height / 4); Compass.Position = new CGPoint(Frame.Width - 50, 50); Compass.Name = "Compass"; NavArrow.Position = new CGPoint(Frame.Width - 50, 50); NavArrow.Name = "NavArrow"; NavArrow.SetScale((nfloat)1.5); //INITIALIZE PLAYER BULLET MAGAZINE for (int j = 0; j < PlayerMagazine.Length; j += 1) { PlayerMagazine[j] = new Bullets(); } //INITIALIZE TOWER ARRAY for (int i = 0; i < EnemyTowers.Length; i += 1) { EnemyTowers[i] = new Towers(5);//towers with 5 guards //for now the number of guards means 2 bullets per guard } for (int i = 0; i < EnemyTanks.Length; i += 1) { EnemyTanks[i] = new Tanks(); } //PLACE TOWERS RANDOMLY THROUGHOUT THE FRAME Random randx = new Random((int)Frame.Width); Random randy = new Random((int)Frame.Height); for (int i = 0; i < EnemyTowers.Length; i += 1) { nfloat randomx = (nfloat)randx.Next() % Frame.Width; nfloat randomy = (nfloat)randy.Next() % Frame.Height; EnemyTowers[i].tower.Position = new CGPoint(randomx, randomy); EnemyTowers[i].tower.Name = "Tower_" + i.ToString(); } for (int i = 0; i < EnemyTanks.Length; i += 1) { nfloat randomx = (nfloat)randx.Next() % Frame.Width; nfloat randomy = (nfloat)randy.Next() % Frame.Height; EnemyTanks[i].enemySprite.Position = new CGPoint(randomx, randomy); EnemyTanks[i].enemySprite.Name = "EnemyTank_" + i.ToString(); } //ADD THE TOWERS TO THE GAMESCENE (PARENT) for (int i = 0; i < EnemyTowers.Length; i += 1) { AddChild(EnemyTowers[i].tower); } //ADD THE TANKS TO THE GAMESENE (PARENT) for (int i = 0; i < EnemyTanks.Length; i += 1) { AddChild(EnemyTanks[i].enemySprite); } //ADD THE LABELS TO THE GAMESCENE (PARENT) AddChild(myLabel); AddChild(myLabel1); AddChild(ScoreLabel); //ADD THE GAUGES TO THE GAMESCENE AddChild(Compass); AddChild(NavArrow); //ESTABLISH AND RUN AN ACTION FOR myLabel and ScoreLabel var fadeout1 = SKAction.FadeOutWithDuration(5); var fadeout2 = SKAction.FadeOutWithDuration(5); myLabel.RunAction(fadeout2); myLabel1.RunAction(fadeout1); }