ForEasySignUp #59

Merged h-matsumoto merged 3 commits into nitta-lab-2018:master from nitta-lab-2018:ForEasySignUp on 16 Nov 2018
Showing 7 changed files
View
2
■■■
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/connections/BulletCreateConnection.java
 
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);
}
}
View
2
■■■
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/BulletsManager.java
import org.ntlab.radishforandroidstudio.cactusClient.connections.BulletGetConnection;
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;
import java.util.Set;
View
0
■■■■■
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/DummyBullet.java 0 → 100644
View
91
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java
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;
import org.ntlab.radishforandroidstudio.framework.gameMain.OvergroundActor;
 
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;
private CharacterConnection con;
updateCamera();
}
 
 
 
 
public void setPlayerId(String id) {
playerId = id;
}
 
public void updateCamera() {
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()));//視線
}
//
// @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押されましたよ----------------------------------------------------");
// }
.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));//視線
}
 
/**
* パッドを動かしたときのイベント処理
*
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());
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) {
Velocity3D vel = actor.getVelocity();
vel.setX(0);
vel.setY(0);
actor.setVelocity(vel);
isTouched = false;
isPadTouched = false;
}
 
return false;
}
Vector3d actorVec = actor.getDirection();
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();
Vector3d right = new Vector3d();
 
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);
 
System.out.print("onClick押されましたよ----------------------------------------------------");
 
}
 
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;
}
View
2
■■■
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/LoginFragment.java
connection.addFormParam("userPass", passWord.getText().toString());
if(testFlag == false)connection.doPut();
}
});
 
 
}
}
View
30
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java
private BulletsManager bulletsManager;
private MovableObjectModel movableObjectModel;
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
}
public void onClick(View v) {
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() {
FragmentManager fragmentManager = getFragmentManager();
View
2
■■■
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/SignUpFragment.java
connection.doPost();
}
});
}
 
 
}