-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathGraphCell.m
More file actions
91 lines (86 loc) · 2.35 KB
/
GraphCell.m
File metadata and controls
91 lines (86 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// GraphCell.m
// Connect5
//
// Created by Mohammed Eldehairy on 6/21/13.
// Copyright (c) 2013 Mohammed Eldehairy. All rights reserved.
//
#import "GraphCell.h"
@implementation GraphCell
-(id)initWithColor:(GraphCellStatus)color
{
self = [super init];
if(self)
{
self.color = color;
self.temporarilyUnoccupied = NO;
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
if(self)
{
self.color = ((NSNumber*)[aDecoder decodeObjectForKey:@"color"]).intValue;
self.x = ((NSNumber*)[aDecoder decodeObjectForKey:@"x"]).intValue;
self.y = ((NSNumber*)[aDecoder decodeObjectForKey:@"y"]).intValue;
self.index = ((NSNumber*)[aDecoder decodeObjectForKey:@"index"]).intValue;
self.temporarilyUnoccupied = ((NSNumber*)[aDecoder decodeObjectForKey:@"temporarilyUnoccupied"]).intValue;
}
return self;
}
-(void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:[NSNumber numberWithInt:self.color] forKey:@"color"];
[aCoder encodeObject:[NSNumber numberWithInt:self.x] forKey:@"x"];
[aCoder encodeObject:[NSNumber numberWithInt:self.y] forKey:@"y"];
[aCoder encodeObject:[NSNumber numberWithInt:self.index] forKey:@"index"];
[aCoder encodeObject:[NSNumber numberWithInt:self.temporarilyUnoccupied] forKey:@"temporarilyUnoccupied"];
}
-(UIColor*)GetUIColor
{
if(self.color==unOccupied)
{
return [UIColor whiteColor];
}else if (_color==red)
{
return [UIColor redColor];
}else if (_color==blue)
{
return [UIColor blueColor];
}else
{
return [UIColor greenColor];
}
}
-(void)dealloc
{
}
-(CGPoint)getPointWithSize:(MSize*)size
{
CGPoint point = CGPointMake(_index/(size.height), _index%(size.height));
return point;
}
-(void)copySelftoGCell:(GraphCell*)CopyGCell
{
CopyGCell.color = self.color;
CopyGCell.temporarilyUnoccupied = self.temporarilyUnoccupied;
CopyGCell.index = self.index;
CopyGCell.x = self.x;
CopyGCell.y = self.y;
}
-(id)copyWithZone:(NSZone *)zone
{
GraphCell *copy = [[GraphCell alloc] init];
if(copy)
{
[copy setColor:self.color];
[copy setX:self.x];
[copy setY:self.y];
[copy setIndex:self.index];
[copy setTemporarilyUnoccupied:self.temporarilyUnoccupied];
}
return copy;
}
@end