| | package org.ntlab.radishforandroidstudio.cactusClient.models; |
---|
| | |
---|
| | 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.ViewGroup; |
---|
| | import android.widget.Button; |
---|
| | |
---|
| | import net.arnx.jsonic.JSON; |
---|
| | |
---|
| | import org.ntlab.radishforandroidstudio.R; |
---|
| | import org.ntlab.radishforandroidstudio.cactusClient.connections.CharacterConnection; |
---|
| | import org.ntlab.radishforandroidstudio.framework.animation.Animation3D; |
---|
| | import org.ntlab.radishforandroidstudio.framework.event.PadEvent; |
---|
| | import org.ntlab.radishforandroidstudio.framework.gameMain.GameBaseModel; |
---|
| |
---|
| | 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() + 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 boolean onEvent(PadEvent event) { |
---|
| |
---|
| | vel.setX(0); |
---|
| | vel.setY(0); |
---|
| | actor.setVelocity(vel); |
---|
| | isTouched = false; |
---|
| | } |
---|
| | }// ここのelse if いらなくない? |
---|
| | |
---|
| | 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.JumpButton); |
---|
| | // 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); |
---|
| | } |
---|
| | |
---|
| | nextConnectRenaimdTime -= interval; |
---|
| |
---|
| | |