Skip to content

Commit

Permalink
hiding controls on first step of tutorial. Showing text
Browse files Browse the repository at this point in the history
  • Loading branch information
seanhess committed Aug 24, 2013
1 parent 6081974 commit c1f2f99
Show file tree
Hide file tree
Showing 44 changed files with 565 additions and 126 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
all: sprites
all: install

sprites:
cd WizardWar && bash images/packTextures.sh
cd WizardWar && bash images/packTextures.sh

install: sprites

2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
platform :ios, '5.0'
pod 'ReactiveCocoa', '1.8.1'
pod 'ReactiveCocoa', '~> 1.9.7'
pod 'BButton', '~> 2.0.0'
pod 'WEPopover', '~> 0.0.1'
pod 'SDWebImage', '~> 3.3'
Expand Down
70 changes: 57 additions & 13 deletions WizardWar.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions WizardWar/AIService.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

@protocol AIService <NSObject, Simulated>
@property (nonatomic, strong) Wizard*wizard;
@property (nonatomic, strong) Wizard*opponent;
@property (nonatomic, weak) id<AIDelegate> delegate;

// for tutorials, they can hide the controls
@property (nonatomic) BOOL hideControls;

-(void)tutorialDidTap;
-(void)opponent:(Wizard*)wizard didCastSpell:(Spell*)spell atTick:(NSInteger)tick;
-(BOOL)shouldPreventSpellCast:(Spell*)spell atTick:(NSInteger)tick;

@end
2 changes: 1 addition & 1 deletion WizardWar/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#import "ConnectionService.h"
#import <ReactiveCocoa.h>
#import "AnalyticsService.h"
#import <TestFlight.h>
#import "TestFlight.h"
#import <FacebookSDK/FacebookSDK.h>
#import "OLUnitsService.h"
#import "InfoService.h"
Expand Down
13 changes: 13 additions & 0 deletions WizardWar/ChatBubbleSprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ChatBubbleSprite.h
// WizardWar
//
// Created by Sean Hess on 8/24/13.
// Copyright (c) 2013 Orbital Labs. All rights reserved.
//

#import "CCSprite.h"

@interface ChatBubbleSprite : CCSprite
@property (nonatomic, strong) NSString * message;
@end
44 changes: 44 additions & 0 deletions WizardWar/ChatBubbleSprite.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// ChatBubbleSprite.m
// WizardWar
//
// Created by Sean Hess on 8/24/13.
// Copyright (c) 2013 Orbital Labs. All rights reserved.
//

#import "ChatBubbleSprite.h"
#import "cocos2d.h"
#import "AppStyle.h"

@interface ChatBubbleSprite ()
@property (nonatomic, strong) CCSprite * background;
@property (nonatomic, strong) CCLabelTTF * label;
@end


@implementation ChatBubbleSprite

-(id)init {
if ((self = [super init])) {
self.background = [CCSprite spriteWithSpriteFrameName:@"chat-bubble.png"];
self.background.scale = 0.5;
[self addChild:self.background];

self.label = [CCLabelTTF labelWithString:@"hello" fontName:FONT_LOVEYA fontSize:12.0];
self.label.color = ccc3(0, 0, 0);
[self addChild:self.label];
}
return self;
}

-(void)setMessage:(NSString *)message {
_message = message;
if (!message) message = @"";
[self.label setString:message];
}

-(void)setFlipX:(BOOL)flipX {
self.background.flipX = flipX;
}

@end
2 changes: 1 addition & 1 deletion WizardWar/Data/DataModel.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>DataModel v0.14.xcdatamodel</string>
<string>DataModel 4.xcdatamodel</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<attribute name="level" optional="YES" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="passed" optional="YES" attributeType="Boolean" syncable="YES"/>
<attribute name="wizardLevel" optional="YES" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
</entity>
<entity name="SpellRecord" representedClassName="SpellRecord" syncable="YES">
<attribute name="castTotal" optional="YES" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
Expand Down Expand Up @@ -54,7 +55,7 @@
<elements>
<element name="Challenge" positionX="0" positionY="0" width="128" height="105"/>
<element name="FacebookUser" positionX="0" positionY="0" width="128" height="135"/>
<element name="QuestLevel" positionX="160" positionY="192" width="128" height="120"/>
<element name="QuestLevel" positionX="160" positionY="192" width="128" height="135"/>
<element name="SpellRecord" positionX="160" positionY="192" width="128" height="120"/>
<element name="User" positionX="0" positionY="0" width="128" height="360"/>
</elements>
Expand Down
2 changes: 1 addition & 1 deletion WizardWar/FeedbackLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "FeedbackLayer.h"
#import <cocos2d.h>
#import "cocos2d.h"
#import "AppStyle.h"
#import <ReactiveCocoa.h>
#import "Spell.h"
Expand Down
20 changes: 20 additions & 0 deletions WizardWar/Library/RACHelpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// RACHelpers.h
// WizardWar
//
// Created by Sean Hess on 8/24/13.
// Copyright (c) 2013 Orbital Labs. All rights reserved.
//

#import <Foundation/Foundation.h>


#define RACMapExists ^id(id value) { return @(value != nil); }
#define RACFilterExists ^BOOL(id value) { return value != nil; }

#define RACMapNot ^id(NSNumber* value) { return @(!value.intValue); }


@interface RACHelpers : NSObject

@end
13 changes: 13 additions & 0 deletions WizardWar/Library/RACHelpers.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// RACHelpers.m
// WizardWar
//
// Created by Sean Hess on 8/24/13.
// Copyright (c) 2013 Orbital Labs. All rights reserved.
//

#import "RACHelpers.h"

@implementation RACHelpers

@end
1 change: 0 additions & 1 deletion WizardWar/LifeIndicatorNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@

@interface LifeIndicatorNode : CCNode
@property (nonatomic, strong) Wizard * player;
@property (nonatomic, strong) Match * match;
-(id)initWithUnits:(Units*)units;
@end
8 changes: 0 additions & 8 deletions WizardWar/LifeIndicatorNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ -(id)initWithUnits:(Units *)units {
[[RACAble(self.player.effect) distinctUntilChanged] subscribeNext:^(id value) {
[self renderEffect];
}];

[[RACAble(self.match.status) distinctUntilChanged] subscribeNext:^(id value) {
[self renderMatchStatus];
}];
}
return self;
}
Expand Down Expand Up @@ -112,8 +108,4 @@ -(void)renderEffect {
}
}

-(void)renderMatchStatus {
self.visible = self.match.status == MatchStatusPlaying;
}

@end
1 change: 1 addition & 0 deletions WizardWar/Match.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef enum MatchStatus {

@property (nonatomic, strong) NSMutableArray * sortedPlayers;
@property (nonatomic) MatchStatus status;
@property (nonatomic, strong) id<AIService>ai;

-(id)initWithMatchId:(NSString*)matchId hostName:(NSString*)hostName currentWizard:(Wizard*)wizard withAI:(id<AIService>)ai multiplayer:(id<Multiplayer>)multiplayer sync:(TimerSyncService*)sync;
-(void)update:(NSTimeInterval)dt;
Expand Down
1 change: 0 additions & 1 deletion WizardWar/Match.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ @interface Match () <GameTimerDelegate, MultiplayerDelegate, TimerSyncDelegate,
@property (nonatomic, strong) GameTimerService * timer;
@property (nonatomic, strong) id<Multiplayer> multiplayer;
@property (nonatomic, strong) TimerSyncService * sync;
@property (nonatomic, strong) id<AIService> ai;

@property (nonatomic, strong) NSMutableDictionary * players;
@property (nonatomic, strong) NSMutableDictionary * spells;
Expand Down
5 changes: 5 additions & 0 deletions WizardWar/MatchLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
#import "Combos.h"
#import "Units.h"
#import "DrawingLayer.h"
#import <ReactiveCocoa.h>

@interface MatchLayer : CCLayer
@property (nonatomic, strong) DrawingLayer * drawingLayer;
@property (nonatomic, strong) RACSignal * showControlsSignal;
@property (nonatomic, strong) RACSignal * matchStatusSignal;


-(id)initWithMatch:(Match*)match size:(CGSize)size combos:(Combos*)combos units:(Units*)units;
@end
32 changes: 18 additions & 14 deletions WizardWar/MatchLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "SpellsLayer.h"

#import <ReactiveCocoa.h>
#import "RACHelpers.h"

#define INDICATOR_PADDING_Y 40

Expand All @@ -43,6 +44,9 @@ @interface MatchLayer () <CCTouchOneByOneDelegate, MatchDelegate>
@property (nonatomic, strong) UIButton * backButton;
@property (nonatomic, strong) CCSprite * background;

@property (nonatomic) MatchStatus matchStatus;
@property (nonatomic, strong) RACSignal * aiHideControlsSignal;

@end

@implementation MatchLayer
Expand All @@ -55,9 +59,6 @@ -(id)initWithMatch:(Match*)match size:(CGSize)size combos:(Combos *)combos units

[self addChild:[CCLayerColor layerWithColor:ccc4(66, 66, 66, 255)]];

__weak MatchLayer * wself = self;


// Manually use the suffix, because fallbacks conflict for other stuff
NSString * backgroundName = @[@"cave", @"icecave", @"evilforest", @"castle"].randomItem;
NSInteger device = [[CCConfiguration sharedConfiguration] runningDevice];
Expand Down Expand Up @@ -96,9 +97,6 @@ -(id)initWithMatch:(Match*)match size:(CGSize)size combos:(Combos *)combos units
LifeIndicatorNode * player1Indicator = [[LifeIndicatorNode alloc] initWithUnits:units];
LifeIndicatorNode * player2Indicator = [[LifeIndicatorNode alloc] initWithUnits:units];

player1Indicator.match = self.match;
player2Indicator.match = self.match;

player1Indicator.position = ccp(self.units.min, self.units.maxY - INDICATOR_PADDING_Y*units.spriteScaleModifier);
player2Indicator.position = ccp(self.units.max, self.units.maxY - INDICATOR_PADDING_Y*units.spriteScaleModifier);

Expand All @@ -107,9 +105,15 @@ -(id)initWithMatch:(Match*)match size:(CGSize)size combos:(Combos *)combos units

[self scheduleUpdate];

[[RACAble(self.match.status) distinctUntilChanged] subscribeNext:^(id value) {
[wself renderMatchStatus];
}];
self.matchStatusSignal = [[RACAbleWithStart(self.match.status) distinctUntilChanged] filter:RACFilterExists];
self.aiHideControlsSignal = [RACAbleWithStart(self.match.ai.hideControls) distinctUntilChanged];
self.showControlsSignal = [RACSignal combineLatest:@[self.matchStatusSignal, self.aiHideControlsSignal]
reduce:^(NSNumber* status, NSNumber* hideControls) {
return @((status.intValue == MatchStatusPlaying) && !hideControls.intValue);
}];

RAC(self.matchStatus) = self.matchStatusSignal;
RAC(self.indicators.visible) = self.showControlsSignal;

// DEBUG THING
// self.debug = [CCLabelTTF labelWithString:@"0" fontName:@"Marker Felt" fontSize:120];
Expand Down Expand Up @@ -153,9 +157,9 @@ -(void)didAddSpell:(Spell *)spell {
[[SimpleAudioEngine sharedEngine] playEffect:@"fireball.mp3"];
}
else if([spell isType:Earthwall]) {
[[SimpleAudioEngine sharedEngine] playEffect:@"eart®hwall.mp3"];
[[SimpleAudioEngine sharedEngine] playEffect:@"earthwall.mp3"];
}
else if ([spell isType:Icewall]) {
else if ([spell isAnyType:@[Icewall, Firewall]]) {
[[SimpleAudioEngine sharedEngine] playEffect:@"icewall.mp3"];
}
else if([spell isType:Vine]) {
Expand All @@ -166,7 +170,7 @@ -(void)didAddSpell:(Spell *)spell {
}
else if([spell isType:Monster]) {
[[SimpleAudioEngine sharedEngine] playEffect:@"monster.mp3"];
}
}
else if([spell isType:Windblast]) {
[[SimpleAudioEngine sharedEngine] playEffect:@"windblast.mp3"];
}
Expand All @@ -190,7 +194,7 @@ -(void)didAddSpell:(Spell *)spell {

- (void)didAddPlayer:(Wizard *)wizard {
BOOL isCurrentWizard = (wizard == self.match.currentWizard);
WizardSprite * sprite = [[WizardSprite alloc] initWithWizard:wizard units:self.units match:self.match isCurrentWizard:isCurrentWizard];
WizardSprite * sprite = [[WizardSprite alloc] initWithWizard:wizard units:self.units match:self.match isCurrentWizard:isCurrentWizard hideControls:self.aiHideControlsSignal];

[self.wizards addChild:sprite];
}
Expand All @@ -207,7 +211,7 @@ - (void)didTick:(NSInteger)currentTick {
self.debug.string = [NSString stringWithFormat:@"%i", (int)(currentTick * TICK_INTERVAL)];
}

- (void)renderMatchStatus {
- (void)setMatchStatus:(MatchStatus)status {
self.spells.visible = (self.match.status == MatchStatusPlaying);

if (self.match.status == MatchStatusPlaying) {
Expand Down
Loading

0 comments on commit c1f2f99

Please sign in to comment.