diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/connections/BulletCreateConnection.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/connections/BulletCreateConnection.java index 16032b6..4ee4826 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/connections/BulletCreateConnection.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/connections/BulletCreateConnection.java @@ -3,7 +3,7 @@ import org.ntlab.radishforandroidstudio.framework.network.HttpAsyncConnection; public class BulletCreateConnection extends HttpAsyncConnection { - public BulletCreateConnection(String instanceId, String playerId) { +public BulletCreateConnection(String instanceId, String playerId) { super("http://nitta-lab-www.is.konan-u.ac.jp/CactusServer/rest/instances/" + instanceId + "/bullets/" + playerId); } } diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/BulletsManager.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/BulletsManager.java index d0e0a76..77a7adf 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/BulletsManager.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/BulletsManager.java @@ -9,12 +9,14 @@ import org.ntlab.radishforandroidstudio.framework.gameMain.GameBaseModel; import org.ntlab.radishforandroidstudio.framework.model3D.ModelFactory; import org.ntlab.radishforandroidstudio.framework.model3D.Object3D; +import org.ntlab.radishforandroidstudio.framework.model3D.Position3D; import org.ntlab.radishforandroidstudio.framework.model3D.Property3D; import org.ntlab.radishforandroidstudio.framework.model3D.Universe; import org.ntlab.radishforandroidstudio.framework.network.CallBack; import org.ntlab.radishforandroidstudio.java3d.Appearance; import org.ntlab.radishforandroidstudio.java3d.Material; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/DummyBullet.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/DummyBullet.java new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/DummyBullet.java diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java index e7b400e..3323298 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java @@ -1,26 +1,13 @@ package org.ntlab.radishforandroidstudio.cactusClient.models; -import android.app.Activity; -import android.app.Fragment; import android.content.res.Resources; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.Toast; import net.arnx.jsonic.JSON; -import org.ntlab.radishforandroidstudio.R; -import org.ntlab.radishforandroidstudio.cactusClient.Cactus; import org.ntlab.radishforandroidstudio.cactusClient.connections.CharacterConnection; -import org.ntlab.radishforandroidstudio.cactusClient.views.PlayerFragment; -import org.ntlab.radishforandroidstudio.framework.RWT.RWTUIFragment; import org.ntlab.radishforandroidstudio.framework.animation.Animation3D; import org.ntlab.radishforandroidstudio.framework.event.PadEvent; import org.ntlab.radishforandroidstudio.framework.gameMain.GameBaseModel; @@ -42,9 +29,14 @@ import java.util.ArrayList; public class OwnPlayer implements PadListener, GameBaseModel, CallBack { - private boolean isTouched = false; - private float touchX = 0.0f; - private float touchY = 0.0f; + private boolean isPadTouched = false; + private float touchPadX = 0.0f; + private float touchPadY = 0.0f; + + + private float eyeX = 0.0f; + private float eyeY = 0.0f; + private OvergroundActor actor; private Camera3D camera; private Player player; @@ -90,6 +82,8 @@ } + + public void setPlayerId(String id) { playerId = id; } @@ -98,22 +92,9 @@ Vector3d charaVector3d = actor.getDirection(); charaVector3d.normalize();//キャラの向きを単位ベクトルに camera.setViewPoint(actor.getPosition() - .add(5.0 * charaVector3d.getX(), charaVector3d.getY() + 5.0, 5.0 * charaVector3d.getZ()));//視点 - camera.setViewLine(new Vector3d(-5.0 * charaVector3d.getX(), charaVector3d.getY() - 2.5, -5.0 * charaVector3d.getZ()));//視線 + .add(5.0 * charaVector3d.getX() , charaVector3d.getY() + 5.0, 5.0 * charaVector3d.getZ() ));//視点 + camera.setViewLine(new Vector3d(-5.0 * charaVector3d.getX(), charaVector3d.getY() - 2.5 , -5.0 * charaVector3d.getZ()+ eyeX));//視線 } -// -// @Override -// public void onClick(View v) { -// if(actor.isOnGround()) { -// Velocity3D vel = actor.getVelocity(); -// vel.setY(vel.getY() + 15); -// actor.setVelocity(vel); -// System.out.print("Jumpしました。"); -// }else{ -// System.out.print("地に足がついてない。"); -// } -// System.out.print("onClick押されましたよ----------------------------------------------------"); -// } /** * パッドを動かしたときのイベント処理 @@ -129,9 +110,9 @@ if (motionEvent.getAction() == MotionEvent.ACTION_DOWN || motionEvent.getAction() == MotionEvent.ACTION_MOVE) { - isTouched = true; - touchX = (float) (Math.cos(event.getAngle()) * event.getLength()); - touchY = (float) (Math.sin(event.getAngle()) * event.getLength()); + isPadTouched = true; + touchPadX = (float) (Math.cos(event.getAngle()) * event.getLength()); + touchPadY = (float) (Math.sin(event.getAngle()) * event.getLength()); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { @@ -139,7 +120,7 @@ vel.setX(0); vel.setY(0); actor.setVelocity(vel); - isTouched = false; + isPadTouched = false; } return false; @@ -153,7 +134,7 @@ bullets.setPosition(actor.getPosition()); bullets.setAngle(((Solid3D)(actor.getBody())).getQuaternion()); - if (isTouched) { + if (isPadTouched) { Vector3d up = new Vector3d(0,1,0); Vector3d total = new Vector3d(); @@ -164,21 +145,13 @@ Vector3d touchXVec = right.clone(); Vector3d touchYVec = actorVec.clone(); - touchXVec.scale(touchX * -5); - touchYVec.scale(touchY * 5); + touchXVec.scale(touchPadX * -5); + touchYVec.scale(touchPadY * 5); total.add(touchXVec); total.add(touchYVec); total.y = vel.getY(); - -// Button jumpButton = (Button) getActivity().findViewById(R.id.Button); -// jumpButton.setOnClickListener(new View.OnClickListener() { -// public void onClick(View v) { -// if(actor.isOnGround()) total.y = vel.getY() + 15; -// } -// }); - vel.setVector3d(total); actor.setVelocity(vel); @@ -237,6 +210,12 @@ } + public void changeViewpoint(float x,float y){ + eyeX = x; + eyeY = y; + actor.rotY(0.05 * (0.5f - eyeX) ); + } + public boolean onTouch(View v, MotionEvent event) { System.out.println("RWTUIFragment touch"); return false; diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/LoginFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/LoginFragment.java index fff180f..e74e5b3 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/LoginFragment.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/LoginFragment.java @@ -102,7 +102,5 @@ if(testFlag == false)connection.doPut(); } }); - - } } diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java index 10dcb22..90aa06d 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java @@ -51,6 +51,10 @@ private ObjectsConnection con; RWTUIFragment f = null; + private boolean isTouched = false; + private float touchX = 0.0f; + private float touchY = 0.0f; + public PlayerFragment() { // Required empty public constructor } @@ -134,8 +138,32 @@ player.jump(); } }); - } + parentView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { + + //画面をどこタッチしたか + float maxX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax(); + float minX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMin(); + float maxY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax(); + float minY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMin(); + touchX = (event.getX() - minX) / (maxX - minX); + touchY = (event.getY() - minY) / (maxY - minY); + player.changeViewpoint(touchX,touchY - 1 * 2); + + + } else if (event.getAction() == MotionEvent.ACTION_UP) { + + touchX = 0.0f; + touchY = 0.0f; + player.changeViewpoint(touchX,touchY); + } + return true; + } + }); + } //sampleUiFragmentからそのまま持ってきた public void initGameWindowView() { diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/SignUpFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/SignUpFragment.java index 9d42402..6893c1a 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/SignUpFragment.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/SignUpFragment.java @@ -94,6 +94,4 @@ } }); } - - } \ No newline at end of file