Unity 타겟 3개 순환해서 따라다니기

using UnityEngine; 
using System.Collections; 
 
public class NavMesh : MonoBehaviour { 
 
  public Transform target1; 
    public Transform target2; 
    public Transform target3; 
 
  private NavMeshAgent nav; 
    private int flag = 0; 
  // Use this for initialization 
  void Start () { 
 
    nav = GetComponent<NavMeshAgent>(); 
    nav.SetDestination(target1.position); 
   
  } 
   
  // Update is called once per frame 
  void Update () { 
      if(Input.GetButtonDown("Fire1")) //클릭했을 때 
        { 
            ++flag; //플래그 변수 1씩 증가 
            if (flag == 3) //총 세개니 0,1,2까지만 허용해야함 
                flag = 0; //0으로 바꿔줌 
 
            switch(flag) //플래그를 기준으로 
            { 
                case 0: 
                    nav.SetDestination(target1.position); //각 타겟의 포지션으로 목적지 설정 
                    break; 
                case 1: 
                    nav.SetDestination(target2.position); 
                    break; 
                case 2: 
                    nav.SetDestination(target3.position); 
                    break; 
            } 
        } 
  } 
} 

 

JSP 랜덤사용 채널추첨기


확인하기(새 창)



위의 내용은 새로고침시 변경됩니다.

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<%@ page import="java.util.*" %> 
<%! 
  int type = 0; 
  int channel = 0; 
  int first, last = 0; 
  String channelStr, channelStr2; 
%> 
<!DOCTYPE HTML> 
<html> 
<head> 
<meta charset = "UTF-8"> 
<title>에픽빔 발사!</title> 
</head> 
<body> 
<% 
  Random r = new Random(); 
  type = r.nextInt(3); 
  int channelrandom = 0; 
  boolean isSingle = false; 
   
  switch(type) { 
  case 0: 
    channelrandom = r.nextInt(12); 
    channelStr = "일반지역"; 
    break; 
  case 1: 
    channelrandom = r.nextInt(5); 
    channelStr = "특수지역"; 
    break; 
  case 2: 
    channelrandom = r.nextInt(2); 
    channelStr = "일반채널"; 
    break; 
  default: 
    break; 
  } 
   
  if(type == 0) { 
    if(channelrandom == 0) { 
      first = 1; 
      last = 20; 
      channelStr2 = "실버크라운"; 
    } 
    else if(channelrandom == 1 || channelrandom == 3 || channelrandom == 5) { 
      first = 1; 
      last = 10; 
      if(channelrandom == 1) { 
        channelStr2 = "멜트다운"; 
      } 
      else if(channelrandom == 3) { 
        channelStr2 = "역천의 폭포"; 
      } 
      else if(channelrandom == 5) { 
        channelStr2 = "안트베르 협곡"; 
      } 
    } 
    else if(channelrandom == 2 || channelrandom == 4 || channelrandom == 8) { 
      first = 11; 
      last = 20; 
      if(channelrandom == 2) { 
        channelStr2 = "표류동굴"; 
      } 
      else if(channelrandom == 4) { 
        channelStr2 = "체념의 빙벽"; 
      } 
      else if(channelrandom == 8) { 
        channelStr2 = "파워스테이션"; 
      } 
    } 
    else if(channelrandom == 6) { 
      first = 1; 
      last = 5; 
      channelStr2 = "해상열차"; 
    } 
    else if(channelrandom == 7) { 
      first = 1; 
      last = 26; 
      channelStr2 = "시간의 문"; 
    } 
    else if(channelrandom == 9) { 
      first = 21; 
      last = 39; 
      channelStr2 = "노블스카이"; 
    } 
    else if(channelrandom == 10) { 
      first = 21; 
      last = 25; 
      channelStr2 = "죽은자의 성"; 
    } 
    else if(channelrandom == 11) { 
      first = 30; 
      last = 47; 
      channelStr2 = "메트로센터"; 
    } 
    else { 
      out.print("error : type is " + type + ", channel is " + channel); 
    } 
  } 
  else if(type == 1) { 
    if(channelrandom == 0) { 
      first = 21; 
      last = 25; 
      channelStr2 = "망자의 협곡"; 
    } 
    else if(channelrandom == 1){ 
      first = 1; 
      last = 10; 
      channelStr2 = "차원의 균열"; 
    } 
    else if(channelrandom == 2) { 
      first = 1; 
      last = 13; 
      channelStr2 = "이계 던전"; 
    } 
    else if(channelrandom == 3) { 
      first = 15; 
      last = 19; 
      channelStr2 = "고대 던전"; 
    } 
    else if(channelrandom == 4) { 
      first = 61; 
      last = 62; 
      channelStr2 = "거래 - 경매장"; 
    } 
  } 
  else if(type == 2) { 
    if(channelrandom == 0) { 
      isSingle = true; 
      channelStr2 = "거래 - 경매장"; 
    } 
    else if(channelrandom == 1) { 
      first = 63; 
      last = 64; 
      channelStr2 = "일반"; 
    } 
    else { 
      out.print("error : type is " + type + ", channel is " + channel); 
    } 
  } 
  if(isSingle == false) { 
    channel = r.nextInt((last-first)+1) + first; 
  } 
  else { 
    channel = 65; 
  } 
%> 
<%= channelStr %> <br> 
<%= channelStr2 %> &nbsp; 
<%=channel%>채널 
</body> 
</html>

 

견고한 다리

다운로드
 

MainActivity.java

package kr.razberry.test; 
 
import android.content.Context; 
import android.database.Cursor; 
import android.database.sqlite.SQLiteDatabase; 
import android.database.sqlite.SQLiteException; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.EditText; 
import android.widget.LinearLayout; 
import android.widget.ListView; 
import android.widget.Toast; 
import java.util.Vector; 
 
 
public class MainActivity extends AppCompatActivity { 
    //Vector cardVec = new Vector(); 
    DBHelper helper; 
    SQLiteDatabase db; 
    EditText nameTxt; 
    EditText telTxt; 
    ListView cardlistView = null; 
    Friend clickedFriend = null; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_main); 
        helper = new DBHelper(this); 
        try { 
            db = helper.getWritableDatabase(); 
        } 
        catch (SQLiteException ex) { 
            db = helper.getReadableDatabase(); 
        } 
        nameTxt = (EditText) findViewById(R.id.nameTxt); 
        telTxt = (EditText) findViewById(R.id.telTxt); 
        cardlistView = (ListView)findViewById(R.id.listview); 
 
        cardlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
            @Override 
            public void onItemClick(AdapterView <?> parent, View v, int position, long id) { 
                nameTxt.setText(((EditText)(v.findViewById(R.id.nameTxt))).getText().toString()); 
                telTxt.setText(((EditText)(v.findViewById(R.id.telTxt))).getText().toString()); 
                clickedFriend = (Friend)v.getTag(); 
                Toast.makeText(getBaseContext(),clickedFriend.getName(),Toast.LENGTH_LONG).show(); 
            } 
        }); 
    } 
 
    public void makeToast(View V) { 
        Toast.makeText(getBaseContext(),"btnClicked" ,Toast.LENGTH_SHORT).show(); 
    } 
    public void insertCard(View v) { 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
        db.execSQL("INSERT INTO contacts VALUES (null, '" + name + "', '" + tel + "');"); 
        Toast.makeText(getApplicationContext(),"성공적으로 추가되었음",Toast.LENGTH_SHORT).show(); 
        nameTxt.setText(""); 
        telTxt.setText(""); 
        showList("SELECT * FROM contacts"); 
    } 
    public void updateCard(View v) { 
        if(clickedFriend == null) { 
            return; 
        } 
 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
       db.execSQL("update contacts set name='" + name + "', tel='" + tel + "' where name='" + clickedFriend.getName() + "';"); 
        showList("SELECT * FROM contacts"); 
    } 
 
    public void deleteCard(View v) { 
        if(clickedFriend == null) { 
            return; 
        } 
        db.execSQL("delete from contacts where name = '" + clickedFriend.getName() + "'; "); 
        showList("SELECT * FROM contacts"); 
    } 
 
    public void searchCard(View v) { 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
 
        showList("SELECT * FROM contacts where name like '%" + name + "%' and tel like '%" + tel +"%'"); 
    } 
    private void showList(String s) { 
        Cursor cursor = db.rawQuery(s, null); 
        startManagingCursor(cursor); 
        String[] from = { "name" , "tel" }; 
        int[] to = { R.id.nameTxt, R.id.telTxt }; 
        MyDBCursorAdapter adapter = new MyDBCursorAdapter(this, R.layout.cardlayout, cursor, from, to); 
 
        cardlistView.setAdapter(adapter); 
 
        clickedFriend = null; 
        nameTxt.setText(""); 
        telTxt.setText(""); 
    } 
 
 
}

 

[백업글]JSP 톰캣 WAR파일로 올리기

kakaotalk_20161028_205324016

tomcat 기본 홈페이지(localhost:8080 등)을 접속해보면 우측에 manager가 있다.

manager에서 (로그인 필요, 톰캣 유저 xml에 있음)  프로젝트 단위로 stop/start 시킬 수 있다.

(같은 이름의 프로젝트 war파일이 안 올려지는걸로 봐선 undeploy로 삭제 후 다시 올려야 할 것 같다.)

 

Eclipse IDE에서 Context를 자동으로 생성해  주는데,  이를 war파일로 묶어서 서버에 던질 경우 적용이 안 되어있을 수 있다.

이런 경우 수동으로 설정을 해 주어야 하는데,  이럴 땐 Undeploy가 안된다!! (해당 Context를 주석처리하면 Undeploy시킬 수 있다)

JSP태그로 Header와 Footer 처리하기

Main.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
<jsp:include page="10_header.jsp"/> 
메인 화면입니다. <br> 
<a href="10_sub.jsp">서브 페이지로 이동</a> 
<jsp:include page="10_footer.jsp"/> 
</body> 
</html>

Header.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<h3> 이부분은header입니다.</h3> 
<hr>

Footer.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<hr> 
<h4> 이부분은footer입니다.</h4>

 

Sub.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
<jsp:include page="10_header.jsp"/> 
서브 화면입니다. <br> 
<a href="10_main.jsp">메인 페이지로 되돌아가기</a> 
<jsp:include page="10_footer.jsp"/> 
</body> 
</html>

[백업글]JSP 기본 로그인 폼

필요할때 갖다 붙여쓰면 편할듯

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE HTML> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
<form method="post" action="04_testLogin.jsp"> 
<label for="userid"> 아이디 : </label> 
<input type="text" name="id" id="userid"><br> 
<label for="userpwd"> 암 &nbsp; 호 : </label> 
<input type ="password" name="pwd" id="userpwd"><br> 
<input type="submit" value="로그인"> 
</form> 
</body> 
</html>

 

JSP Application

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
<% 
String appPath = application.getContextPath(); 
String filePath = application.getRealPath("06_application.jsp"); 
String serverInfo = application.getServerInfo(); 
%> 
웹 애플리케이션의 컨텍스트 패스명<br> 
<b><%=appPath%></b><hr> 
웹 애플리케이션의 파일 경로명<br> 
<b><%=filePath%></b><br> 
컨테이너의 이름과 버전 번환<br> 
<b><%=serverInfo%></b><br> 
</body> 
</html>

 

냥캣 소스

스크립트가 사방에 분포해있어서 보기 힘들지도..

 
다운로드

 

GameController.cs

게임 총괄 소스

using UnityEngine; 
using System.Collections; 
using UnityEngine.SceneManagement; 
 
public class GameController : MonoBehaviour { 
    //controller 
    public static GameController controller = null; 
 
    //boolean 
    public bool ready = true; 
    public bool isOver = false; 
 
    //prefab 
    public GameObject obstructions; 
    public GameObject saw; 
 
    //objects 
    public GameObject gameOverImg; 
    public GameObject window; 
    public GameObject retry; 
    public GameObject Player; 
    public GameObject Floor; 
    public GameObject bestImg; 
    public GameObject clicktostart; 
 
    //texts 
    public TextMesh score; 
    //public TextMesh finalScoreText; 
    public TextMesh bestScoreText; 
 
    // Use this for initialization 
    void Start () { 
         
  } 
    void OnEnable() 
    { 
        controller = this; 
    } 
   
  // Update is called once per frame 
  void Update () { 
      if(Input.GetMouseButtonDown(0) && ready ==true) 
        { 
            ready = false; 
            Destroy(clicktostart); 
            InvokeRepeating("createObs",1.0f, 2.5f); 
        } 
        else if(!ready && isOver && Input.GetKeyDown(KeyCode.Escape)) 
        { 
            SceneManager.LoadScene(0); 
        } 
  } 
 
    void createObs() 
    { 
        int x = Random.Range(0, 2); 
 
        if (x == 0) 
        { 
            Instantiate(obstructions); 
        } 
        else 
        { 
            Instantiate(saw); 
        } 
 
    } 
 
    public void gameOver() 
    { 
        if(isOver) 
        { 
            return; 
        } 
        isOver = true; 
        backgroundScroll.bkctl.isstop = true; 
         
        CancelInvoke("createObs"); 
        iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("x", 0.2, "y", 0.2, "time", 0.5f)); 
        iTween.MoveTo(gameOverImg, iTween.Hash("y", 1, "delay", 1.3f, "time", 0.5f)); 
        iTween.MoveTo(window, iTween.Hash("y", 0.1, "delay", 1.3f, "time", 0.5f)); 
        iTween.MoveTo(retry, iTween.Hash("y", -1, "delay", 1.3f, "time", 0.5f)); 
        if (GlobalVar.count > PlayerPrefs.GetInt("Best")) 
        { 
            PlayerPrefs.SetInt("Best", GlobalVar.count); 
            iTween.FadeTo(bestImg, iTween.Hash("alpha", 255, "time", 0.5f)); 
             
        } 
 
        //finalScoreText.text = GlobalVar.count.ToString(); 
        bestScoreText.text = PlayerPrefs.GetInt("Best").ToString(); 
        Player.GetComponent<Rigidbody>().useGravity = true; 
        Floor.GetComponent<BoxCollider>().isTrigger = true; 
 
        this.GetComponent<AudioSource>().Play(); 
 
         
 
    } 
 
    public void getScore() 
    { 
        if (!controller.isOver) 
        { 
            GlobalVar.count++; 
            Debug.Log(GlobalVar.count); 
            score.text = GlobalVar.count.ToString(); 
        } 
    } 
} 

 

JSP Request의 정보(Request info) 알아내기

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
컨텍스트 패스 : <%= request.getContextPath() %> <br> 
요청방식 : <%= request.getMethod() %> <br> 
요청한 URL : <%= request.getRequestURL() %> <br> 
요청한 URI : <%= request.getRequestURI() %> <br> 
서버의 이름 : <%= request.getServerName() %> <br> 
프로토콜 : <%= request.getProtocol() %> <br> 
</body> 
</html>