Skip to content

Instantly share code, notes, and snippets.

@hcarreras
Created November 24, 2013 16:54
Show Gist options
  • Save hcarreras/7629340 to your computer and use it in GitHub Desktop.
Save hcarreras/7629340 to your computer and use it in GitHub Desktop.
//
// Level1.m
// VeoVeo
//
// Created by Alberto Quesada Aranda on 23/11/13.
// Copyright (c) 2013 VV Company. All rights reserved.
//
#import "Level1.h"
#import "Level2.h"
@interface Level1 ()
@end
@implementation Level1
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
_buttonPlane.tag = 1;
_buttonTree.tag = 2;
_buttonCow.tag = 3;
_buttonBee.tag = 4;
_buttonAvestruz.tag = 5;
//tengo que crear todos los demas objetos del nivel
_cow = [[Cow alloc] init];
_plane = [[Plane alloc] init];
_tree = [[Arbol alloc] init];
_bee = [[Bee alloc] init];
_avestruz = [[Avestruz alloc] init];
_objetos = [NSMutableArray alloc];
_objetos = [NSMutableArray arrayWithObjects: _cow, _plane, _tree, _bee, nil];
_buscado = [[Avestruz alloc] init];
//sé que objeto estoy buscando asi que tengo que preparar la primera pista:
//_label1.text = aleatorio(_cow.pistas);
_showPista.text = [Control aleatorio: [_buscado clues] : [_buscado asked_clues]];
_pistas_actuales = [[NSMutableString alloc] initWithString: _showPista.text];
_primera_ronda = true;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)fallo:(UIButton *)sender
{
NSString *respuesta;
if (sender.tag == 1 && _plane.nombre != [_buscado nombre]) {
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _plane.nombre : _plane.clues];
}
else if (sender.tag == 2 && _tree.nombre != [_buscado nombre]){
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _tree.nombre : _tree.clues];
}
else if (sender.tag == 3 && _cow.nombre == [_buscado nombre]){
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _cow.nombre : _cow.clues];
}
else if (sender.tag == 4 && _bee.nombre == [_buscado nombre]){
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _bee.nombre : _bee.clues];
}
else if (sender.tag == 5 && _avestruz.nombre == [_buscado nombre]){
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _avestruz.nombre : _avestruz.clues];
}
else if (sender.tag == 1 or sender.tag == 2{
_buscado = [Control ganaste: _showPista : _buscado : _objetos];
_primera_ronda = true;
[_pistas_actuales setString:@""];
}
/*
if (sender.tag == 1) {
if (_plane.nombre == [_buscado nombre]) {
_buscado = [Control ganaste: _showPista : _buscado : _objetos];
_primera_ronda = true;
[_pistas_actuales setString:@""];
}
else {
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _plane.nombre : _plane.clues];
}
}
else if (sender.tag == 2){
if (_tree.nombre == [_buscado nombre]) {
_buscado = [Control ganaste: _showPista : _buscado : _objetos];
_primera_ronda = true;
[_pistas_actuales setString:@""];
}
else {
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _tree.nombre : _tree.clues];
}
}
else if (sender.tag == 3){
if (_cow.nombre == [_buscado nombre]) {
_buscado = [Control ganaste: _showPista : _buscado : _objetos];
_primera_ronda = true;
[_pistas_actuales setString:@""];
}
else {
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _cow.nombre : _cow.clues];
}
}
else if (sender.tag == 4){
if (_bee.nombre == [_buscado nombre]) {
_buscado = [Control ganaste: _showPista : _buscado : _objetos];
_primera_ronda = true;
[_pistas_actuales setString:@""];
}
else {
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _bee.nombre : _bee.clues];
}
}
else if (sender.tag == 5){
if (_avestruz.nombre == [_buscado nombre]) {
_buscado = [Control ganaste: _showPista : _buscado : _objetos];
_primera_ronda = true;
[_pistas_actuales setString:@""];
}
else {
respuesta = [Control compara: [_buscado nombre] : [_buscado asked_clues] : _avestruz.nombre : _avestruz.clues];
}
}
*/
if(_buscado == nil) {
//cargar siguiente nivel!!
Level2 *lev2 = [[Level2 alloc] init];
[self presentViewController:lev2 animated:YES completion:nil];
}
if (respuesta == nil) {
_showPista.text = [Control aleatorio: [_buscado clues] : [_buscado asked_clues]];
}
else {
UIAlertView *helloWorldAlert = [[UIAlertView alloc]
initWithTitle:@"Fallaste" message:respuesta delegate:nil cancelButtonTitle:@"Continuar" otherButtonTitles:nil];
// Display the Hello World Message
[helloWorldAlert show];
}
if (respuesta == nil && _primera_ronda && _buscado != nil) {
[_pistas_actuales appendString: @"\n"];
[_pistas_actuales appendString: _showPista.text];
}
if ([[_buscado clues] count] == 0){
_buscado = [_buscado init];
[Control aleatorio: [_buscado clues] : [_buscado asked_clues]];
_primera_ronda = false;
}
}
- (IBAction)Pistas:(id)sender {
UIAlertView *helloWorldAlert = [[UIAlertView alloc]
initWithTitle:@"Pistas actuales:" message:_pistas_actuales delegate:nil cancelButtonTitle:@"Continuar" otherButtonTitles:nil];
// Display the Hello World Message
[helloWorldAlert show];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment