NSZombieApocalypse sample ported to 64-bits

This commit is contained in:
Paola Villarreal 2014-06-26 14:41:36 -05:00
Родитель 79b93b6f0e
Коммит d941e67358
14 изменённых файлов: 186 добавлений и 181 удалений

Просмотреть файл

@ -2,8 +2,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace NSZombieApocalypse

Просмотреть файл

@ -1,12 +1,12 @@
using System;
using System.Drawing;
using MonoTouch.UIKit;
using CoreGraphics;
using UIKit;
namespace NSZombieApocalypse
{
public class BodyPart : UIView
{
public BodyPart (RectangleF frame) : base (frame)
public BodyPart (CGRect frame) : base (frame)
{
BackgroundColor = UIColor.Clear;
ClipsToBounds = false;

Просмотреть файл

@ -1,8 +1,8 @@
using System;
using System.Drawing;
using MonoTouch.CoreGraphics;
using MonoTouch.CoreLocation;
using MonoTouch.UIKit;
using CoreGraphics;
using CoreLocation;
using UIKit;
namespace NSZombieApocalypse
{
@ -31,7 +31,7 @@ namespace NSZombieApocalypse
}
public ButtonCollectionView (RectangleF frame) : base(frame)
public ButtonCollectionView (CGRect frame) : base(frame)
{
Layer.BorderColor = UIColor.Black.CGColor;
Layer.BorderWidth = 1;
@ -39,7 +39,7 @@ namespace NSZombieApocalypse
BackgroundColor = UIColor.White.ColorWithAlpha (0.75f);
for (int k = 0; k < (int) ButtonType.Count; k++) {
var button = new ButtonView (RectangleF.Empty);
var button = new ButtonView (CGRect.Empty);
AddSubview (button);
button.TrackingStartedEvent += TrackingStarted;
button.TrackingContinuedEvent += TrackingContinued;
@ -86,15 +86,15 @@ namespace NSZombieApocalypse
UIGraphics.EndImageContext ();
if (trackingImageView == null) {
trackingImageView = new UIImageView (RectangleF.Empty);
trackingImageView = new UIImageView (CGRect.Empty);
Superview.AddSubview (trackingImageView);
trackingImageView.Alpha = 0.5f;
}
trackingImageView.Image = image;
trackingImageView.SizeToFit ();
RectangleF frame = trackingImageView.Frame;
var newFrame = new RectangleF (Superview.ConvertPointFromView (button.Frame.Location, this), frame.Size);
CGRect frame = trackingImageView.Frame;
var newFrame = new CGRect (Superview.ConvertPointFromView (button.Frame.Location, this), frame.Size);
trackingImageView.Frame = newFrame;
if (ButtonSelectedEvent != null)
ButtonSelectedEvent (button);
@ -102,10 +102,10 @@ namespace NSZombieApocalypse
public void TrackingContinued (ButtonView button, UITouch location)
{
PointF point = location.LocationInView (Superview);
RectangleF frame = trackingImageView.Frame;
var newPoint = new PointF (point.X - button.Frame.Size.Width / 2, point.Y - button.Frame.Size.Height / 2);
var newFrame = new RectangleF (newPoint, frame.Size);
CGPoint point = location.LocationInView (Superview);
CGRect frame = trackingImageView.Frame;
var newPoint = new CGPoint (point.X - button.Frame.Size.Width / 2, point.Y - button.Frame.Size.Height / 2);
var newFrame = new CGRect (newPoint, frame.Size);
trackingImageView.Frame = newFrame;
if (ButtonDraggedEvent != null)
ButtonDraggedEvent (button, location);
@ -124,11 +124,11 @@ namespace NSZombieApocalypse
UIView[] subviews = this.Subviews;
int count = 0;
RectangleF bounds = Bounds;
SizeF buttonSize = ButtonView.ButtonSize;
float xPad = (bounds.Size.Width - (buttonSize.Width * 3)) / 4;
float yPad = (bounds.Size.Height - (buttonSize.Height * 2)) / 3;
float x = xPad, y = 5;
CGRect bounds = Bounds;
CGSize buttonSize = ButtonView.ButtonSize;
nfloat xPad = (bounds.Size.Width - (buttonSize.Width * 3)) / 4;
nfloat yPad = (bounds.Size.Height - (buttonSize.Height * 2)) / 3;
nfloat x = xPad, y = 5;
foreach (var subview in subviews) {
if (count > 0 && count % 3 == 0) {
x = xPad;
@ -136,7 +136,7 @@ namespace NSZombieApocalypse
}
count++;
var frame = new RectangleF (x, y, buttonSize.Width, buttonSize.Height);
var frame = new CGRect (x, y, buttonSize.Width, buttonSize.Height);
subview.Frame = frame.Integral ();
x += buttonSize.Width + xPad;

Просмотреть файл

@ -1,7 +1,7 @@
using System;
using System.Drawing;
using MonoTouch.CoreGraphics;
using MonoTouch.UIKit;
using CoreGraphics;
using UIKit;
namespace NSZombieApocalypse
{
@ -14,7 +14,7 @@ namespace NSZombieApocalypse
public event TrackingContinuedEventHandler TrackingContinuedEvent;
public event TrackingEndedEventHandler TrackingEndedEvent;
public ButtonView (RectangleF frame):base (frame)
public ButtonView (CGRect frame):base (frame)
{
imageView = new UIImageView (UIImage.FromBundle ("buttonView.png"));
AddSubview (imageView);
@ -24,9 +24,9 @@ namespace NSZombieApocalypse
MultipleTouchEnabled = true;
}
public static SizeF ButtonSize {
public static CGSize ButtonSize {
get {
SizeF size = UIImage.FromBundle ("buttonView.png").Size;
CGSize size = UIImage.FromBundle ("buttonView.png").Size;
size.Height += 20;
size.Width += 60;
return size;
@ -101,10 +101,10 @@ namespace NSZombieApocalypse
public override void LayoutSubviews ()
{
RectangleF frame = Bounds;
var newFrame = new RectangleF (Bounds.X, frame.Size.Height - 20, Bounds.Width, 20);
CGRect frame = Bounds;
var newFrame = new CGRect (Bounds.X, frame.Size.Height - 20, Bounds.Width, 20);
labelView.Frame = newFrame.Integral ();
RectangleF imageFrame = imageView.Frame;
CGRect imageFrame = imageView.Frame;
imageFrame.X = (newFrame.Size.Width - imageFrame.Size.Width) / 2;
imageView.Frame = imageFrame.Integral ();
}
@ -113,7 +113,7 @@ namespace NSZombieApocalypse
{
if (labelView == null) {
labelView = new UILabel (RectangleF.Empty);
labelView = new UILabel (CGRect.Empty);
labelView.BackgroundColor = UIColor.Clear;
labelView.Font = UIFont.FromName ("HelveticaNeue", 18);
labelView.TextColor = UIColor.Black;

Просмотреть файл

@ -1,9 +1,9 @@
using System;
using System.Drawing;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using MonoTouch.CoreGraphics;
using MonoTouch.ObjCRuntime;
using CoreGraphics;
using UIKit;
using Foundation;
using ObjCRuntime;
using System.Threading.Tasks;
namespace NSZombieApocalypse
@ -15,19 +15,19 @@ namespace NSZombieApocalypse
public event HelpDidCloseHandler HelpDidClose;
public HelpView (RectangleF frame): base(frame)
public HelpView (CGRect frame): base(frame)
{
BackgroundColor = UIColor.Clear;
Layer.CornerRadius = 8;
var closeFrame = new RectangleF (20, frame.Size.Height - 140, 80, 80);
var closeFrame = new CGRect (20, frame.Size.Height - 140, 80, 80);
var closeView = new SymbolMarkView (closeFrame);
closeView.TouchUpInside += async (s, e) => await Hide ();
AddSubview (closeView);
closeView.Symbol = "X";
closeView.AccessibilityLabel = "Close";
var label = new UILabel (new RectangleF (0, 20, frame.Size.Width, 40));
var label = new UILabel (new CGRect (0, 20, frame.Size.Width, 40));
label.Font = UIFont.FromName ("HelveticaNeue-Italic", 82);
label.Text = "NSZombieApocalypse";
label.BackgroundColor = UIColor.Clear;
@ -39,15 +39,15 @@ namespace NSZombieApocalypse
AddSubview (label);
label.AccessibilityTraits = UIAccessibilityTrait.Header;
var nextFrame = new RectangleF (frame.Size.Width - 100, frame.Size.Height - 140, 80, 80);
var nextFrame = new CGRect (frame.Size.Width - 100, frame.Size.Height - 140, 80, 80);
nextButton = new SymbolMarkView (nextFrame);
nextButton.TouchUpInside += (s, e) => NextSlide ();
AddSubview (nextButton);
nextButton.Symbol = "->";
nextButton.AccessibilityLabel = "Next";
float width = frame.Size.Width * 0.6f;
var textViewFrame = new RectangleF (
nfloat width = frame.Size.Width * 0.6f;
var textViewFrame = new CGRect (
200 + ((frame.Size.Width - 200) - width) / 2,
label.Frame.GetMaxY () + 30,
width,
@ -60,7 +60,7 @@ namespace NSZombieApocalypse
textView.Text = NSBundle.MainBundle.LocalizedString ("helpText1", null, "Strings");
var imageView = new UIImageView (UIImage.FromBundle ("smaller-zombie1.png"));
var imageFrame = new RectangleF (label.Frame.X - 20, textViewFrame.Y, imageView.Frame.Width, imageView.Frame.Height);
var imageFrame = new CGRect (label.Frame.X - 20, textViewFrame.Y, imageView.Frame.Width, imageView.Frame.Height);
imageView.Frame = imageFrame;
AddSubview (imageView);
@ -87,7 +87,7 @@ namespace NSZombieApocalypse
public async Task Hide ()
{
RectangleF frame = Frame;
CGRect frame = Frame;
frame.Y = -frame.Size.Height;
await UIView.AnimateAsync (.35, () => {
Frame = frame;
@ -95,17 +95,17 @@ namespace NSZombieApocalypse
HelpDidClose (this);
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
rect.Height -= 40;
UIColor.White.SetFill ();
var path = UIBezierPath.FromRoundedRect (rect, UIRectCorner.BottomRight | UIRectCorner.BottomLeft, new SizeF (8, 8));
var path = UIBezierPath.FromRoundedRect (rect, UIRectCorner.BottomRight | UIRectCorner.BottomLeft, new CGSize (8, 8));
path.Fill ();
}
public void Show ()
{
RectangleF frame = Frame;
CGRect frame = Frame;
frame.Y = 0;
UIView.Animate (.35, () => {
Frame = frame;});

Просмотреть файл

@ -2,8 +2,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace NSZombieApocalypse
{

Просмотреть файл

@ -1,15 +1,15 @@
using System;
using System.Drawing;
using CoreGraphics;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using MonoTouch.UIKit;
using MonoTouch.AudioToolbox;
using MonoTouch.CoreGraphics;
using MonoTouch.CoreFoundation;
using MonoTouch.AudioUnit;
using MonoTouch.Foundation;
using UIKit;
using AudioToolbox;
using CoreFoundation;
using AudioUnit;
using Foundation;
using MonoTouch.Dialog;
using MonoTouch.AVFoundation;
using AVFoundation;
using System.Linq;
using System.Threading.Tasks;
@ -20,10 +20,10 @@ namespace NSZombieApocalypse
AVAudioPlayer newZombieSound, removeZombieSound;
List <WalkingDead> zombies;
public MiniPadView (RectangleF frame): base(frame)
public MiniPadView (CGRect frame): base(frame)
{
var image = UIImage.FromBundle ("iPadImage.png");
Frame = new RectangleF (Frame.Location, image.Size);
Frame = new CGRect (Frame.Location, image.Size);
ClipsToBounds = false;
var imageView = new UIImageView (image);
@ -58,7 +58,7 @@ namespace NSZombieApocalypse
public void AddZombie ()
{
float chrome = 50;
var frame = new RectangleF (chrome, Frame.Size.Height - 160 - chrome, 80, 200);
var frame = new CGRect (chrome, Frame.Size.Height - 160 - chrome, 80, 200);
var dead = new WalkingDead (frame);
dead.WalkingDeadDidDisassemble += WalkingDeadDidDisassemble;
zombies.Add (dead);

Просмотреть файл

@ -26,6 +26,7 @@
<MtouchI18n>
</MtouchI18n>
<MtouchArch>ARMv7</MtouchArch>
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
@ -87,8 +88,12 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="MonoTouch.Dialog-1" />
<Reference Include="Xamarin.iOS">
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
</Reference>
<Reference Include="MonoTouch.Dialog-1">
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\MonoTouch.Dialog-1.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
@ -140,4 +145,4 @@
<ItemGroup>
<InterfaceDefinition Include="ZBEViewController.xib" />
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -1,6 +1,6 @@
using System;
using System.Drawing;
using MonoTouch.UIKit;
using CoreGraphics;
using UIKit;
namespace NSZombieApocalypse
{
@ -16,7 +16,7 @@ namespace NSZombieApocalypse
}
}
public StatusView (RectangleF frame) : base (frame)
public StatusView (CGRect frame) : base (frame)
{
Layer.BorderColor = UIColor.Black.CGColor;
@ -24,7 +24,7 @@ namespace NSZombieApocalypse
Layer.CornerRadius = 8;
BackgroundColor = UIColor.White.ColorWithAlpha (0.75f);
label = new UILabel (new RectangleF (0, 0, frame.Size.Width, frame.Size.Height));
label = new UILabel (new CGRect (0, 0, frame.Size.Width, frame.Size.Height));
label.Lines = 0;
label.TextAlignment = UITextAlignment.Center;
AddSubview (label);

Просмотреть файл

@ -1,7 +1,7 @@
using System;
using System.Drawing;
using MonoTouch.CoreGraphics;
using MonoTouch.UIKit;
using CoreGraphics;
using UIKit;
namespace NSZombieApocalypse
{
@ -18,19 +18,19 @@ namespace NSZombieApocalypse
}
}
public SymbolMarkView (RectangleF frame): base (frame)
public SymbolMarkView (CGRect frame): base (frame)
{
label = new UILabel (new RectangleF (0, 0, frame.Size.Width, frame.Size.Height));
label = new UILabel (new CGRect (0, 0, frame.Size.Width, frame.Size.Height));
label.TextAlignment = UITextAlignment.Center;
label.Font = UIFont.FromName ("HelveticaNeue-Bold", 48);
label.BackgroundColor = UIColor.Clear;
AddSubview (label);
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
rect = rect.Inset (4, 4);
UIBezierPath path = UIBezierPath.FromArc (new PointF (rect.GetMidX (), rect.GetMidY ()), rect.Size.Width / 2, 0, 180, true);
UIBezierPath path = UIBezierPath.FromArc (new CGPoint (rect.GetMidX (), rect.GetMidY ()), rect.Size.Width / 2, 0, 180, true);
path.LineWidth = 8;
UIColor.White.SetFill ();

Просмотреть файл

@ -1,16 +1,16 @@
using System;
using System.Timers;
using System.Threading;
using System.Drawing;
using CoreGraphics;
using System.Collections.Generic;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using MonoTouch.CoreFoundation;
using MonoTouch.Foundation;
using MonoTouch.CoreAnimation;
using MonoTouch.CoreImage;
using UIKit;
using CoreFoundation;
using Foundation;
using CoreAnimation;
using CoreImage;
using System.Threading.Tasks;
using MonoTouch.ObjCRuntime;
using ObjCRuntime;
namespace NSZombieApocalypse
{
@ -53,8 +53,8 @@ namespace NSZombieApocalypse
public override void ViewWillAppear (bool animated)
{
RectangleF frame = View.Frame;
frame = new RectangleF (frame.X, frame.Y, frame.Size.Height + 20, frame.Size.Width);
CGRect frame = View.Frame;
frame = new CGRect (frame.X, frame.Y, frame.Size.Height + 20, frame.Size.Width);
View.Frame = frame;
frame = View.Frame;
@ -63,20 +63,20 @@ namespace NSZombieApocalypse
backGround.Alpha = 0.34f;
View.AddSubview (backGround);
var miniPadFrame = new RectangleF (350, 50, 0, 0);
var miniPadFrame = new CGRect (350, 50, 0, 0);
miniPadView = new MiniPadView (miniPadFrame);
View.AddSubview (miniPadView);
var meterFrame = new RectangleF (miniPadView.Frame.GetMaxX (), miniPadFrame.Y, 200, miniPadView.Frame.Size.Height);
var meterFrame = new CGRect (miniPadView.Frame.GetMaxX (), miniPadFrame.Y, 200, miniPadView.Frame.Size.Height);
meterView = new ZombieMeter (meterFrame);
View.AddSubview (meterView);
var statusFrame = new RectangleF (100, frame.Size.Height - 350, frame.Size.Width - 100, 100);
var statusFrame = new CGRect (100, frame.Size.Height - 350, frame.Size.Width - 100, 100);
statusView = new StatusView (statusFrame);
View.AddSubview (statusView);
statusView.Status = "Loading";
var buttonsFrame = new RectangleF (100, statusFrame.GetMaxY () + 20, frame.Size.Width - 100, 230);
var buttonsFrame = new CGRect (100, statusFrame.GetMaxY () + 20, frame.Size.Width - 100, 230);
buttonsView = new ButtonCollectionView (buttonsFrame) {
ShouldGroupAccessibilityChildren = true
};
@ -85,7 +85,7 @@ namespace NSZombieApocalypse
buttonsView.ButtonFinishedEvent += ButtonFinished;
View.AddSubview (buttonsView);
var questionFrame = new RectangleF (10, statusFrame.GetMaxY () + 110, 80, 80);
var questionFrame = new CGRect (10, statusFrame.GetMaxY () + 110, 80, 80);
var questionView = new SymbolMarkView (questionFrame) {
AccessibilityLabel = "Help"
};
@ -260,7 +260,7 @@ namespace NSZombieApocalypse
void updateScoreForDroppedButton (ButtonView button)
{
ButtonType buttonType = (ButtonType)button.Tag;
ButtonType buttonType = (ButtonType)(float)button.Tag;
float change = 0;
switch (buttonType) {
case ButtonType.Free:
@ -298,7 +298,7 @@ namespace NSZombieApocalypse
public void ButtonDragged (ButtonView button, UITouch location)
{
PointF point = location.LocationInView (miniPadView);
CGPoint point = location.LocationInView (miniPadView);
if (miniPadView.PointInside (point, null)) {
if (!buttonDraggedToPad) {
CATransaction.Begin ();
@ -333,7 +333,7 @@ namespace NSZombieApocalypse
buttonDraggedToPad = false;
miniPadView.Layer.BorderWidth = 0;
PointF point = location.LocationInView (miniPadView);
CGPoint point = location.LocationInView (miniPadView);
if (miniPadView.PointInside (point, null)) {
updateScoreForDroppedButton (button);
UIView.Animate (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (10f * (float)Math.PI / 180), async () => {
@ -349,8 +349,8 @@ namespace NSZombieApocalypse
var popTime = new DispatchTime (DispatchTime.Now, (long)(delayInSeconds * NSEC_PER_SEC));
DispatchQueue.MainQueue.DispatchAfter (popTime, async () => {
await UIView.AnimateAsync (0.35f, () => {
RectangleF bounds = trackingView.Bounds;
bounds.Size = new SizeF (10, 10);
CGRect bounds = trackingView.Bounds;
bounds.Size = new CGSize (10, 10);
trackingView.Bounds = bounds;
});
trackingView.RemoveFromSuperview ();

Просмотреть файл

@ -4,7 +4,7 @@
// actions made in the Xcode designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoTouch.Foundation;
using Foundation;
namespace NSZombieApocalypse
{

Просмотреть файл

@ -1,8 +1,8 @@
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.CoreGraphics;
using MonoTouch.UIKit;
using CoreGraphics;
using Foundation;
using UIKit;
using System.Threading.Tasks;
namespace NSZombieApocalypse
@ -17,22 +17,22 @@ namespace NSZombieApocalypse
LeftLeg leftLeg;
double startedWalking;
float startedWalkingX;
nfloat startedWalkingX;
bool animated;
bool walkingForward;
class Head : BodyPart
{
public Head (RectangleF rect) : base (rect)
public Head (CGRect rect) : base (rect)
{
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
rect = rect.Inset (4, 4);
rect = new RectangleF ((rect.Size.Width - rect.Size.Height) / 2 + 4, 8, rect.Size.Height, rect.Size.Height);
rect = new CGRect ((rect.Size.Width - rect.Size.Height) / 2 + 4, 8, rect.Size.Height, rect.Size.Height);
UIBezierPath path = UIBezierPath.FromOval (rect);
UIColor.Black.SetStroke ();
UIColor.White.SetFill ();
@ -42,17 +42,17 @@ namespace NSZombieApocalypse
UIBezierPath rightEye, leftEye, mouth = new UIBezierPath ();
if (MovingRight) {
rightEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true);
leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true);
rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true);
leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true);
mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30));
mouth.AddLineTo (new PointF (rect.GetMidX () + 13, rect.Y + 30));
mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30));
mouth.AddLineTo (new CGPoint (rect.GetMidX () + 13, rect.Y + 30));
} else {
rightEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true);
leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () + 5, rect.Y + 15), 4, 0, 180, true);
rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true);
leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 5, rect.Y + 15), 4, 0, 180, true);
mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30));
mouth.AddLineTo (new PointF (rect.GetMidX () - 13, rect.Y + 30));
mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30));
mouth.AddLineTo (new CGPoint (rect.GetMidX () - 13, rect.Y + 30));
}
rightEye.LineWidth = 2;
@ -68,15 +68,15 @@ namespace NSZombieApocalypse
class Body : BodyPart
{
public Body (RectangleF rect) : base (rect)
public Body (CGRect rect) : base (rect)
{
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
rect = rect.Inset (2, 2);
float bodyWidth = rect.Size.Width / 2;
UIBezierPath path = UIBezierPath.FromRoundedRect (new RectangleF ((rect.Size.Width - bodyWidth) / 2, 0, bodyWidth, rect.Size.Height), UIRectCorner.TopLeft | UIRectCorner.TopRight, new SizeF (8, 8));
nfloat bodyWidth = rect.Size.Width / 2;
UIBezierPath path = UIBezierPath.FromRoundedRect (new CGRect ((rect.Size.Width - bodyWidth) / 2, 0, bodyWidth, rect.Size.Height), UIRectCorner.TopLeft | UIRectCorner.TopRight, new CGSize (8, 8));
UIColor.Black.SetStroke ();
UIColor.White.SetFill ();
path.Fill ();
@ -87,16 +87,16 @@ namespace NSZombieApocalypse
class RightLeg : BodyPart
{
public RightLeg (RectangleF rect) : base (rect)
public RightLeg (CGRect rect) : base (rect)
{
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
UIView body = ((WalkingDead)Superview).body;
RectangleF bodyFrame = body.Frame;
float legWidth = rect.Size.Width / 3;
UIBezierPath path = UIBezierPath.FromRoundedRect (new RectangleF (20, bodyFrame.GetMaxY () - 5, legWidth, rect.Size.Height * .25f), UIRectCorner.TopRight | UIRectCorner.BottomRight, new SizeF (3, 3));
CGRect bodyFrame = body.Frame;
nfloat legWidth = rect.Size.Width / 3;
UIBezierPath path = UIBezierPath.FromRoundedRect (new CGRect (20, bodyFrame.GetMaxY () - 5, legWidth, rect.Size.Height * .25f), UIRectCorner.TopRight | UIRectCorner.BottomRight, new CGSize (3, 3));
path.LineWidth = 2;
UIColor.White.SetFill ();
path.Fill ();
@ -106,16 +106,16 @@ namespace NSZombieApocalypse
class LeftLeg : BodyPart
{
public LeftLeg (RectangleF rect) : base (rect)
public LeftLeg (CGRect rect) : base (rect)
{
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
UIView body = ((WalkingDead)Superview).body;
RectangleF bodyFrame = body.Frame;
float legWidth = rect.Size.Width / 3;
UIBezierPath path = UIBezierPath.FromRoundedRect (new RectangleF (30, bodyFrame.GetMaxY () - 5, legWidth, (rect.Size.Height) * .25f), UIRectCorner.TopRight | UIRectCorner.BottomRight, new SizeF (3, 3));
CGRect bodyFrame = body.Frame;
nfloat legWidth = rect.Size.Width / 3;
UIBezierPath path = UIBezierPath.FromRoundedRect (new CGRect (30, bodyFrame.GetMaxY () - 5, legWidth, (rect.Size.Height) * .25f), UIRectCorner.TopRight | UIRectCorner.BottomRight, new CGSize (3, 3));
UIColor.Black.SetColor ();
path.LineWidth = 2;
@ -127,25 +127,25 @@ namespace NSZombieApocalypse
class RightArm : BodyPart
{
public RightArm (RectangleF rect) : base (rect)
public RightArm (CGRect rect) : base (rect)
{
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
UIView head = ((WalkingDead)Superview).head;
var path = new UIBezierPath ();
path.LineCapStyle = CGLineCap.Round;
RectangleF headFrame = head.Frame;
CGRect headFrame = head.Frame;
if (!MovingRight) {
path.MoveTo (new PointF (rect.GetMidX () - 10, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () - 10 + rect.Size.Width / 4, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () - 10 + rect.Size.Width / 2, headFrame.GetMaxY () + 10 + rect.Size.Height / 10));
path.MoveTo (new CGPoint (rect.GetMidX () - 10, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () - 10 + rect.Size.Width / 4, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () - 10 + rect.Size.Width / 2, headFrame.GetMaxY () + 10 + rect.Size.Height / 10));
} else {
path.MoveTo (new PointF (rect.GetMidX () + 10, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () + 10 - rect.Size.Width / 4, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () + 10 - rect.Size.Width / 2, headFrame.GetMaxY () + 10 + rect.Size.Height / 10));
path.MoveTo (new CGPoint (rect.GetMidX () + 10, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () + 10 - rect.Size.Width / 4, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () + 10 - rect.Size.Width / 2, headFrame.GetMaxY () + 10 + rect.Size.Height / 10));
}
UIColor.Black.SetStroke ();
@ -160,26 +160,26 @@ namespace NSZombieApocalypse
class LeftArm : BodyPart
{
public LeftArm (RectangleF rect) : base (rect)
public LeftArm (CGRect rect) : base (rect)
{
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
UIView head = ((WalkingDead)Superview).head;
UIBezierPath path = new UIBezierPath ();
path.LineCapStyle = CGLineCap.Round;
RectangleF headFrame = head.Frame;
CGRect headFrame = head.Frame;
if (!MovingRight) {
rect.X -= 20;
path.MoveTo (new PointF (rect.GetMidX () + 20, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () + 20 + rect.Size.Width / 6, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () + 20 + rect.Size.Width / 6 + 10, headFrame.GetMaxY () + 10 + 20));
path.MoveTo (new CGPoint (rect.GetMidX () + 20, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () + 20 + rect.Size.Width / 6, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () + 20 + rect.Size.Width / 6 + 10, headFrame.GetMaxY () + 10 + 20));
} else {
path.MoveTo (new PointF (rect.GetMidX () - 20, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () - 20 - rect.Size.Width / 6, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () - 20 - rect.Size.Width / 6 - 10, headFrame.GetMaxY () + 10 + 20));
path.MoveTo (new CGPoint (rect.GetMidX () - 20, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () - 20 - rect.Size.Width / 6, headFrame.GetMaxY () + 10));
path.AddLineTo (new CGPoint (rect.GetMidX () - 20 - rect.Size.Width / 6 - 10, headFrame.GetMaxY () + 10 + 20));
}
UIColor.Black.SetStroke ();
@ -194,27 +194,27 @@ namespace NSZombieApocalypse
public event DidDisassembleHandler WalkingDeadDidDisassemble;
public WalkingDead (RectangleF frame) :base (frame)
public WalkingDead (CGRect frame) :base (frame)
{
BackgroundColor = UIColor.Clear;
ClipsToBounds = false;
head = new Head (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height * .25f));
head = new Head (new CGRect (0, 0, Frame.Size.Width, Frame.Size.Height * .25f));
AddSubview (head);
body = new Body (new RectangleF (0, head.Frame.GetMaxY (), Frame.Size.Width, Frame.Size.Height * .375f));
body = new Body (new CGRect (0, head.Frame.GetMaxY (), Frame.Size.Width, Frame.Size.Height * .375f));
AddSubview (body);
leftArm = new LeftArm (new RectangleF (0, 0, Frame.Size.Width + 20, Frame.Size.Height));
leftArm = new LeftArm (new CGRect (0, 0, Frame.Size.Width + 20, Frame.Size.Height));
AddSubview (leftArm);
rightArm = new RightArm (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height));
rightArm = new RightArm (new CGRect (0, 0, Frame.Size.Width, Frame.Size.Height));
AddSubview (rightArm);
rightLeg = new RightLeg (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height));
rightLeg = new RightLeg (new CGRect (0, 0, Frame.Size.Width, Frame.Size.Height));
AddSubview (rightLeg);
leftLeg = new LeftLeg (new RectangleF (0, 0, Frame.Size.Width, Frame.Size.Height));
leftLeg = new LeftLeg (new CGRect (0, 0, Frame.Size.Width, Frame.Size.Height));
AddSubview (leftLeg);
TurnAround ();
@ -248,7 +248,7 @@ namespace NSZombieApocalypse
if (!animated)
return;
RectangleF superviewFrame = Superview.Frame;
CGRect superviewFrame = Superview.Frame;
startedWalking = NSDate.Now.SecondsSinceReferenceDate;
startedWalkingX = Frame.X;
UIView.Animate (10, 0, UIViewAnimationOptions.AllowUserInteraction, () => {
@ -258,7 +258,7 @@ namespace NSZombieApocalypse
if (!walkingForward)
TurnAround ();
RectangleF frame = Frame;
CGRect frame = Frame;
frame.X = superviewFrame.Size.Width - frame.Size.Width - 50;
Frame = frame;
}, () => {
@ -269,7 +269,7 @@ namespace NSZombieApocalypse
startedWalking = NSDate.Now.SecondsSinceReferenceDate;
startedWalkingX = Frame.X;
RectangleF frame = Frame;
CGRect frame = Frame;
frame.X = 50;
UIView.Animate (10, 0, UIViewAnimationOptions.AllowUserInteraction, () => {
Frame = frame;},
@ -284,19 +284,19 @@ namespace NSZombieApocalypse
animated = false;
UIView.Animate (.75, () => {
var frame = new RectangleF (head.Frame.X, -100, head.Frame.Width, head.Frame.Height);
var frame = new CGRect (head.Frame.X, -100, head.Frame.Width, head.Frame.Height);
head.Frame = frame;
frame = new RectangleF (-100, leftArm.Frame.Y, leftArm.Frame.Width, leftArm.Frame.Height);
frame = new CGRect (-100, leftArm.Frame.Y, leftArm.Frame.Width, leftArm.Frame.Height);
leftArm.Frame = frame;
frame = new RectangleF (rightArm.Frame.Size.Width + 100, rightArm.Frame.Y, rightArm.Frame.Width, rightArm.Frame.Height);
frame = new CGRect (rightArm.Frame.Size.Width + 100, rightArm.Frame.Y, rightArm.Frame.Width, rightArm.Frame.Height);
rightArm.Frame = frame;
frame = new RectangleF (leftLeg.Frame.X - 50, leftLeg.Frame.Size.Height, leftLeg.Frame.Width, leftLeg.Frame.Height);
frame = new CGRect (leftLeg.Frame.X - 50, leftLeg.Frame.Size.Height, leftLeg.Frame.Width, leftLeg.Frame.Height);
leftLeg.Frame = frame;
frame = new RectangleF (rightLeg.Frame.X + 50, rightLeg.Frame.Size.Height, rightLeg.Frame.Width, rightLeg.Frame.Height);
frame = new CGRect (rightLeg.Frame.X + 50, rightLeg.Frame.Size.Height, rightLeg.Frame.Width, rightLeg.Frame.Height);
rightLeg.Frame = frame;
}, async () => {
await UIView.AnimateAsync (.5, () => {
@ -367,10 +367,10 @@ namespace NSZombieApocalypse
rightLeg.Layer.RemoveAllAnimations ();
leftLeg.Layer.RemoveAllAnimations ();
float percentage = (float)(NSDate.Now.SecondsSinceReferenceDate - startedWalking / 10);
float xNow = Math.Abs (Frame.X - startedWalkingX) * percentage;
RectangleF frame = Frame;
Frame = new RectangleF (xNow + (frame.Size.Width / 2), frame.Y, frame.Height, frame.Width);
nfloat percentage = (float)(NSDate.Now.SecondsSinceReferenceDate - startedWalking / 10);
nfloat xNow = (nfloat)Math.Abs (Frame.X - startedWalkingX) * percentage;
CGRect frame = Frame;
Frame = new CGRect (xNow + (frame.Size.Width / 2), frame.Y, frame.Height, frame.Width);
}
public delegate void DidDisassembleHandler (WalkingDead walkingdead);

Просмотреть файл

@ -1,8 +1,8 @@
using System;
using System.Drawing;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using MonoTouch.CoreGraphics;
using CoreGraphics;
using UIKit;
using Foundation;
namespace NSZombieApocalypse
{
@ -21,13 +21,13 @@ namespace NSZombieApocalypse
UILabel label;
public ZombieMeter (RectangleF frame) : base (frame)
public ZombieMeter (CGRect frame) : base (frame)
{
BackgroundColor = UIColor.Clear;
Layer.CornerRadius = 8;
ZombieLevel = 0;
label = new UILabel (new RectangleF (0, 0, frame.Size.Width, 0));
label = new UILabel (new CGRect (0, 0, frame.Size.Width, 0));
label.TextAlignment = UITextAlignment.Center;
label.Text = "Zombie Meter";
label.Font = UIFont.FromName ("Helvetica", 24);
@ -35,7 +35,7 @@ namespace NSZombieApocalypse
AddSubview (label);
label.SizeToFit ();
var labelFrame = label.Frame;
label.Frame = new RectangleF (labelFrame.X, labelFrame.Y, frame.Size.Width, labelFrame.Size.Height);
label.Frame = new CGRect (labelFrame.X, labelFrame.Y, frame.Size.Width, labelFrame.Size.Height);
}
@ -57,12 +57,12 @@ namespace NSZombieApocalypse
}
}
public override void Draw (RectangleF rect)
public override void Draw (CGRect rect)
{
float pad = 20;
float numberOfMeters = 10;
float meterSpacing = 5;
float yOrigin = label.Frame.GetMaxY () + 10;
nfloat pad = 20;
nfloat numberOfMeters = 10;
nfloat meterSpacing = 5;
nfloat yOrigin = label.Frame.GetMaxY () + 10;
UIBezierPath background = UIBezierPath.FromRoundedRect (rect, 8);
UIColor.White.SetFill ();
@ -70,7 +70,7 @@ namespace NSZombieApocalypse
UIColor.Black.SetStroke ();
RectangleF meter = new RectangleF (
CGRect meter = new CGRect (
pad,
yOrigin,
rect.Size.Width - pad * 2,
@ -96,14 +96,14 @@ namespace NSZombieApocalypse
float diff = (level - k);
if (diff > 0 && diff < 1) {
RectangleF smallerRect = meter;
smallerRect = new RectangleF (
CGRect smallerRect = meter;
smallerRect = new CGRect (
smallerRect.X,
smallerRect.Y + smallerRect.Size.Height - ((smallerRect.Size.Height) * diff),
smallerRect.Size.Width,
(smallerRect.Size.Height) * diff
);
var smallerPath = UIBezierPath.FromRoundedRect (smallerRect, UIRectCorner.BottomLeft | UIRectCorner.BottomRight, new SizeF (2, 2));
var smallerPath = UIBezierPath.FromRoundedRect (smallerRect, UIRectCorner.BottomLeft | UIRectCorner.BottomRight, new CGSize (2, 2));
smallerPath.Fill ();
} else {