| | 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; |
---|
| | } |
---|
| |
---|
| | |
カメラ ちょいバグやけど、動くからいいって”こにしさん”にいわれた
こにしさんはそんなこと言ってませんでした
b4b0319
intomaster
fromForEasySignUp
on 16 Nov 2018