Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
842b791
Model: multiplayer init method implemented, turn class added. Also ad…
Igor-Tukh Nov 30, 2017
06c1cd4
Merge branch 'model' into dev
dkaznacheev Dec 8, 2017
35b6dec
Model: simple multiplayer implemented (not tested), Minotaur is unsop…
Igor-Tukh Dec 8, 2017
cda7a79
Model: multiplayer javadocs added
Igor-Tukh Dec 8, 2017
a369e0d
Added background and Start Activity
dkaznacheev Dec 8, 2017
83698dc
Merge branch 'model' into dev
dkaznacheev Dec 8, 2017
1a30232
Added multiplayer visuals
dkaznacheev Dec 8, 2017
7adf598
Added field centering
dkaznacheev Dec 9, 2017
9df5708
Added icons and InitActivity for local game
dkaznacheev Dec 9, 2017
c7d1b12
Updated icons and added a nice little move direction arrow in FieldView
dkaznacheev Dec 9, 2017
3470c97
Added basic serialization for Field and Turn
dkaznacheev Dec 11, 2017
095da14
Added simple level editor, repackaged custom views, split FieldView t…
dkaznacheev Dec 11, 2017
1a3a3ae
Added choosing cell in editor
dkaznacheev Dec 11, 2017
70f0782
Network: play games sign in implemented, (doesn't work)
Igor-Tukh Dec 15, 2017
b124f2c
xml
Igor-Tukh Dec 25, 2017
b398cd8
Network: all need files added
Igor-Tukh Dec 25, 2017
8142367
Model: big update. Shoots, minotaurs, hospitals implemented. Game win…
Igor-Tukh Dec 26, 2017
3f24e61
Manual merge model to dev
dkaznacheev Dec 27, 2017
705d856
Fixed model, added winning game screen
dkaznacheev Dec 27, 2017
04d56d3
Manual dev pull
dkaznacheev Dec 27, 2017
6729042
DB: game redactor saving with database
Igor-Tukh Dec 27, 2017
eb0b4e5
DB: game redactor saving with database. First saving loading is imple…
Igor-Tukh Dec 27, 2017
3ba9696
Merge branch 'db' into dev
dkaznacheev Dec 27, 2017
fe92259
Upgraded level editor
dkaznacheev Dec 27, 2017
82af18c
Implemented Log
dkaznacheev Dec 27, 2017
dccd482
DB: level selecting from list of mazes implemented.
Igor-Tukh Jan 1, 2018
72ef0b0
Network: opponents select UI added
Igor-Tukh Feb 5, 2018
9bd6304
Network: new match cancel implemented
Igor-Tukh Feb 5, 2018
3e79f4f
Merge remote-tracking branch 'origin/network' into dev
Feb 6, 2018
b2fef95
Merge remote-tracking branch 'origin/db' into dev
Feb 6, 2018
fc1bb9f
Merged everything together
Feb 6, 2018
ec0a1b0
Network: match config file creating implemented
Igor-Tukh Feb 6, 2018
ff67308
Dev: minor updates & refactoring
Igor-Tukh Feb 6, 2018
de83746
Added game saving
Feb 6, 2018
3c0105c
Added GameState for single/multiplayer, refactored MainActivity
Feb 7, 2018
bf2cfc1
GameState serialization naming changed for consistency
Feb 7, 2018
ff2a93a
Model: fixed bug with showing dead minotaur.
Igor-Tukh Feb 8, 2018
b827225
Network: implemented showWarning and updateMatch methods.
Igor-Tukh Feb 8, 2018
f89dc4c
Split MainActivity to parent GameActivity andchild LocalGameActivity,…
Feb 9, 2018
7a00cd0
Added deleting levels in editor
Feb 9, 2018
07f3e5c
Merge branch 'dev' of https://github.com/dkaznacheev/labyrinth into dev
Feb 9, 2018
9ec5397
Network: some GPGS updates.
Igor-Tukh Feb 9, 2018
32a5872
merged network into dev
Feb 9, 2018
1198633
added OnlineGameActivity
Feb 10, 2018
4e7f316
Network on dev: base network multiplayer implemented, works very stra…
Igor-Tukh Feb 10, 2018
53e2738
Big cleanup
dkaznacheev Feb 19, 2018
3b36d4b
Network on dev: huge update, background thread updating.
Igor-Tukh Feb 20, 2018
900d58b
cleaned and fixed
Feb 20, 2018
65572de
Manual merge
Feb 20, 2018
1db15bc
Added editor correctness check
Feb 21, 2018
539458b
Added level loading to local
Feb 21, 2018
79d6bab
xml updated
Feb 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions Labyrinth/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Labyrinth/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
Expand All @@ -26,6 +27,11 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
testCompile 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-games:11.6.0'
implementation 'com.google.android.gms:play-services-auth:11.6.0'
}
apply plugin: 'com.android.application'
1 change: 1 addition & 0 deletions Labyrinth/app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"ru.spbau.labyrinth","split":"","minSdkVersion":"16"}}]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Instrumentation test, which will execute on an Android device.
Expand Down
48 changes: 33 additions & 15 deletions Labyrinth/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,39 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.spbau.labyrinth">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity
android:name=".LocalGameActivity"
android:screenOrientation="portrait" />
<activity
android:name=".OnlineGameActivity"
android:screenOrientation="portrait" />
<activity android:name=".LogActivity" />
<activity android:name=".StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LogActivity"></activity>
</application>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".InitActivity" />
<activity
android:name=".EditorActivity"
android:screenOrientation="portrait" />
<activity android:name=".LevelSelectActivity"/>
<activity android:name=".EndGameActivity"
android:screenOrientation="portrait"/>
<activity android:name=".networkMultiplayer.MultiplayerActivity"/>
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
</application>

</manifest>
Binary file added Labyrinth/app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 140 additions & 0 deletions Labyrinth/app/src/main/java/ru/spbau/labyrinth/EditorActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package ru.spbau.labyrinth;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import ru.spbau.labyrinth.customviews.EditFieldView;
import ru.spbau.labyrinth.customviews.OuterScrollView;
import ru.spbau.labyrinth.db.DBHelper;
import ru.spbau.labyrinth.model.field.Field;

public class EditorActivity extends AppCompatActivity implements View.OnClickListener {
private static final int MAZE_REQUEST = 2;
static DBHelper dbHelper;
static EditFieldView editFieldView;

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == MAZE_REQUEST) {
if (data == null || resultCode != RESULT_OK) {
return;
}
String maze = data.getStringExtra("maze");
if (maze != null) {
setEditFieldView(maze);
checkField();
}
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_editor);

final OuterScrollView outerScrollView = findViewById(R.id.outerScroll);
final HorizontalScrollView horizontalScrollView = findViewById(R.id.horizontalScroll);
editFieldView = findViewById(R.id.fieldView);

outerScrollView.post(new Runnable() {
public void run() {
outerScrollView.scrollTo(0, 650);
}
});
horizontalScrollView.post(new Runnable() {
public void run() {
horizontalScrollView.scrollTo(650, 0);
}
});

Button saveButton = findViewById(R.id.saveButton);
Button loadButton = findViewById(R.id.loadButton);
Button checkButton = findViewById(R.id.checkButton);

saveButton.setOnClickListener(this);
loadButton.setOnClickListener(this);
checkButton.setOnClickListener(this);

dbHelper = new DBHelper(this);
}

private void saveMaze(final Field field) {
if (!checkField())
return;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final EditText input = new EditText(this);
input.setHint("Maze name...");
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
builder.setView(input);
builder.setPositiveButton("SAVE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
String name = input.getText().toString();
if (!name.equals("")) {
dbHelper.saveField(field, name);
}
}
});
builder.show();
}

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.saveButton: {
saveMaze(editFieldView.getField());
break;
}
case R.id.loadButton: {
Intent intent = new Intent(EditorActivity.this, LevelSelectActivity.class);
startActivityForResult(intent, MAZE_REQUEST);
break;
}
case R.id.checkButton: {
checkField();
break;
}
}
dbHelper.close();
}

@Override
protected void onResume() {
super.onResume();
checkField();
}

public boolean checkField() {
editFieldView = findViewById(R.id.fieldView);
final ImageView backgroundImageView = findViewById(R.id.background);

Field.ErrorType error = editFieldView.getField().isCorrect();
if (error == Field.ErrorType.NO_ERROR) {
backgroundImageView.setImageResource(R.drawable.labyrinth_green);
return true;
} else {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
backgroundImageView.setImageResource(R.drawable.labyrinth_red);
return false;
}
}

public static void setEditFieldView(String json) {
editFieldView.setField(Field.deserialize(json));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ru.spbau.labyrinth;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class EndGameActivity extends AppCompatActivity {
private final int[] backgrounds = {
R.drawable.labyrinth_red,
R.drawable.labyrinth_blue,
R.drawable.labyrinth_green,
R.drawable.labyrinth_yellow};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_endgame);
Intent intent = getIntent();
int winner = intent.getIntExtra("winnerId", 0);
String name = intent.getStringExtra("winnerName");

ImageView background = findViewById(R.id.background);
background.setImageResource(backgrounds[winner]);
TextView endTextView = findViewById(R.id.endTextView);

endTextView.setText("GAME OVER\nWinner:\n" + name);

Button menuButton = findViewById(R.id.menuButton);
menuButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}

}
Loading