查看: 1031|回复: 0
打印 上一主题 下一主题

[红蓝3D] MMO-简单Quest系统(原创).

[复制链接]

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-8-7 10:23:13 |只看该作者 |倒序浏览
这部分code来自于前一段我们team的一个实验项目.希望对新手有所帮助.我写的很乱,欢迎提问.
QuestInfo.js
import System.Data;

import System.IO;
var theSourceFile: FileInfo = null;

var reader: StreamReader = null;
public var descriptionQuest: String;

public var descriptionHint: String;

public var state:int=0;

public var currentProcess:int=1;

public var currentKill:int=0;
public var dataSave:GameObject;
function Start() {

if(!dataSave.GetComponent(DataSave).isLoading){

NewLoadDescription();

}
}
function NewLoadDescription(){

state=0;

currentKill=0;

descriptionQuest=LoadDescription("Quest");

descriptionHint=LoadDescription("Hint");

}
private function LoadDescription(filetype: String): String{

var descripition: String="";
theSourceFile=null;

reader=null;
//theSourceFile = new FileInfo ("QuestDescription/"+filetype+currentProcess+".txt");

theSourceFile = new FileInfo (Application.dataPath+"/QuestDescription/"+filetype+currentProcess+".txt");

if ( theSourceFile != null && theSourceFile.Exists )

reader = theSourceFile.OpenText();
if ( reader == null )

{

Debug.Log("Quest.txt not found or not readable");

}

else

{

// Read each line from the file
descripition = reader.ReadToEnd();

//Debug.Log(descripition);

theSourceFile=null;

reader=null;

return(descripition);

}
}
function Update () {

}
GameManager.js
function OnGUI(){
//.......
if(switchWindowQuest){
windowRectQuest=GUI.Window(2,windowRectQuest,QuestWindow,"Quest");
}
if(questInfo.state>0){
if(questInfo.state==1)

{

mystyle.normal.textColor=Color.white;

}else if(questInfo.state==2)

{

mystyle.normal.textColor=Color.yellow;

}
GUI.Label(Rect(Screen.width-270,100,270,60),questInfo.descriptionHint,mystyle);

if(questInfo.currentProcess<5)

{

GUI.Label(Rect(Screen.width-100,140,100,30),"Killed "+questInfo.currentKill+" / 5 ",mystyle);

}else{

GUI.Label(Rect(Screen.width-100,140,100,30),"Killed "+questInfo.currentKill+" / 1 ",mystyle);

}

}
if(showMessage)

{

if(Time.time>=(beginTime+(messageRate/2)))

{

mystyle2.normal.textColor.a=1.0-((Time.time-(beginTime+(messageRate/2)))/(messageRate/2));

}
GUI.Label(Rect(Screen.width/2-(messageText.length/2*23),Screen.height/2-100,messageText.length*23,50),messageText,mystyle2);

}
}
function OpenQuestWindow(isopening:boolean){
if(questInfo.state==2){

Reward();

mystyle.normal.textColor=Color.white;
questInfo.currentProcess++;
questInfo.NewLoadDescription();

}
GameObject.FindGameObjectWithTag("MainCamera").GetComponent(CameraControl).CameraLock(isopening);

switchWindowQuest=isopening;
//Debug.Log("switch="+switchWindowQuest);

}
function Reward(){
playerInfo.Experience(50);

playerInfo.SkillPoint(playerInfo.SkillPoint()+1);

GetComponent(ItemInfo).Number(GetComponent(ItemInfo).Number()+10);

ShowMessage("You Got 50 experience, 10 mushRooms and 1 skillpoint.");

}
function QuestWindow(windowID: int){
GUI.Label(Rect(30,40,250,240),questInfo.descriptionQuest,mystyle);
if(questInfo.state==0){

if(GUI.Button(Rect(117,300,67,23),"Accept")){
questInfo.state=1;

OpenQuestWindow(false);

}
}else if(questInfo.state==1){

if(GUI.Button(Rect(117,300,67,23),"Abandon")){

questInfo.state=0;

questInfo.currentKill=0;

OpenQuestWindow(false);

}

}
if(GUI.Button(Rect(117,335,67,23),"Close")){
OpenQuestWindow(false);

}

GUI.DragWindow();

}
欢迎大家提问和纠正.如果觉得有所帮助,希望版主大人能给点加分和升级,我需要下载资源。U吧之前给予我很多,以后我也会继续努力发帖的.
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-7-27 18:30 , Processed in 0.071640 second(s), 29 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部