diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index c0813ee..f414542 100644
--- a/.idea/caches/build_file_checksums.ser
+++ b/.idea/caches/build_file_checksums.ser
Binary files differ
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 17f0e89..4cab8bc 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,11 +1,25 @@
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.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;
@@ -68,6 +82,7 @@
updateCamera();
}
+
public void setPlayerId(String id) {
playerId = id;
}
@@ -76,9 +91,22 @@
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() + touchX));//視線
+ .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()));//視線
}
+//
+// @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押されましたよ----------------------------------------------------");
+// }
@Override
public boolean onEvent(PadEvent event) {
@@ -86,6 +114,7 @@
charaVector3d.normalize();//キャラの向きを単位ベクトルに
MotionEvent motionEvent = event.getMotionEvent();
+
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN || motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
isTouched = true;
touchX = (float) (Math.cos(event.getAngle()) * event.getLength());
@@ -99,17 +128,50 @@
actor.setVelocity(vel);
isTouched = false;
}
+
return false;
}
@Override
public void update(double interval) {
updateCamera();
+ Velocity3D vel = actor.getVelocity();
+ Vector3d actorVec = actor.getDirection();
if (isTouched) {
- Velocity3D vel = actor.getVelocity();
- vel.setX(touchX);
- vel.setY(touchY);
+
+ Vector3d up = new Vector3d(0,1,0);
+ Vector3d total = new Vector3d();
+ Vector3d right = new Vector3d();
+
+ right.cross(actorVec,up);
+
+ Vector3d touchXVec = right.clone();
+ Vector3d touchYVec = actorVec.clone();
+
+ touchXVec.scale(touchX * -5);
+ touchYVec.scale(touchY * 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);
+
+
+ } else {
+ vel.setX(0.0);
+ vel.setZ(0.0);
+
actor.setVelocity(vel);
}
@@ -142,4 +204,18 @@
public void onResponse(String response) {
}
+
+ public void jump(){
+ if(actor.isOnGround()) {
+ Velocity3D vel = actor.getVelocity();
+ vel.setY(vel.getY() + 5);
+ actor.setVelocity(vel);
+ System.out.print("Jumpしました。");
+ }else{
+ System.out.print("地に足がついてない。");
+ }
+ System.out.print("onClick押されましたよ----------------------------------------------------");
+
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/CharactersFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/CharactersFragment.java
index a85f43b..dc07b5c 100644
--- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/CharactersFragment.java
+++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/CharactersFragment.java
@@ -31,7 +31,6 @@
import java.util.Map;
public class CharactersFragment extends Fragment {
-
private CharactersFragmentConnection connection;
private String instanceId;
private Account account;
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 111ab9c..ec06ad5 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
@@ -1,13 +1,18 @@
package org.ntlab.radishforandroidstudio.cactusClient.views;
+import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
+import android.support.v7.widget.ActivityChooserView;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import org.ntlab.radishforandroidstudio.R;
import org.ntlab.radishforandroidstudio.cactusClient.connections.ObjectsConnection;
@@ -23,6 +28,7 @@
import org.ntlab.radishforandroidstudio.framework.gameMain.RealTime3DFragment;
import org.ntlab.radishforandroidstudio.framework.model3D.BaseObject3D;
import org.ntlab.radishforandroidstudio.framework.physics.Ground;
+import org.ntlab.radishforandroidstudio.framework.physics.Velocity3D;
import org.ntlab.radishforandroidstudio.java3d.AmbientLight;
import org.ntlab.radishforandroidstudio.java3d.Appearance;
import org.ntlab.radishforandroidstudio.java3d.Color3f;
@@ -30,6 +36,7 @@
import org.ntlab.radishforandroidstudio.java3d.IndexedTriangleArray;
import org.ntlab.radishforandroidstudio.java3d.Material;
import org.ntlab.radishforandroidstudio.java3d.Point3d;
+import org.ntlab.radishforandroidstudio.java3d.Vector3d;
import org.ntlab.radishforandroidstudio.java3d.Vector3f;
public class PlayerFragment extends RealTime3DFragment {
@@ -40,6 +47,7 @@
private OtherPlayerCharactersModel otherPlayerCharactersModel;
private MovableObjectModel movableObjectModel;
private ObjectsConnection con;
+ RWTUIFragment f = null;
public PlayerFragment() {
// Required empty public constructor
@@ -111,12 +119,21 @@
@Override
protected void progress(long interval) {
super.progress(interval);
+ Button jumpButton = (Button) getActivity().findViewById(R.id.Button);
+ jumpButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ player.jump();
+ }
+ });
+
+
}
+
+ //sampleUiFragmentからそのまま持ってきた
public void initGameWindowView() {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
-
RWTUIFragment f = new RWTUIFragment();
f.setListener(this);
View uiLayout = parentView.findViewById(R.id.ui_layout);
diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java
index 5082cd9..5e97251 100644
--- a/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java
+++ b/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java
@@ -7,18 +7,23 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import org.ntlab.radishforandroidstudio.R;
+import org.ntlab.radishforandroidstudio.cactusClient.models.OwnPlayer;
import org.ntlab.radishforandroidstudio.cactusClient.views.PlayerFragment;
import org.ntlab.radishforandroidstudio.framework.event.PadEvent;
import org.ntlab.radishforandroidstudio.framework.listener.PadListener;
+import org.ntlab.radishforandroidstudio.framework.physics.Velocity3D;
import static android.view.View.*;
+import static org.ntlab.radishforandroidstudio.framework.subject.PadSubject.own;
public class RWTUIFragment extends Fragment implements OnTouchListener,PadListener {
PlayerFragment listener = null;
View v = null;
+
public RWTUIFragment() {}
@Override
@@ -35,6 +40,9 @@
RWTPad pad = v.findViewById(R.id.pad);
pad.addListener(this);
+
+
+
if (listener != null) {
listener.onCreateFragmentEvent(this);
}
@@ -46,6 +54,11 @@
System.out.println("RWTUIFragment touch");
return false;
}
+//
+//
+// public void onClick(View v) {
+// System.out.print("onClick押されましたよ----------------------------------------------------IN RWTUIFragment");
+// }
@Override
public boolean onEvent(PadEvent event) {
diff --git a/app/src/main/res/layout/ui_fragment.xml b/app/src/main/res/layout/ui_fragment.xml
index 996ee1f..b7877bf 100644
--- a/app/src/main/res/layout/ui_fragment.xml
+++ b/app/src/main/res/layout/ui_fragment.xml
@@ -7,25 +7,26 @@
+
+
\ No newline at end of file