底比斯天堂
瘋天堂私服發佈網站廣告欄位!
害怕天堂私服倒閉嗎?快使用天堂分析師!
天堂私服抽獎扭蛋物品及機率測試器
天堂私服稱號顏色製造器
瘋天堂私服發佈網站教您註冊推文收藏私服!
天堂私服血量魔力計算器
瘋天堂私服發布網站廣告贊助及爆料私服客服
教您如何不用註冊也可以推文天堂私服!
天堂私服270怪物查詢掉落資料庫
天堂私服盟徽製造器
test0428
2005-02-21 18:29

天堂掃街活動的java寫法!

L1PcInstance

if (lastAttacker instanceof L1GuardianInstance) {
if (getPkCountForElf() > 0) {
setPkCountForElf(getPkCountForElf() - 1);
}
setLastPkForElf(null);
}

下面加入

// 掃街活動
if(L1KillAllMan.getInstance().getGameStatus() == 1) {
int count = 2; //噴裝數量
caoPenaltyResult(count);
}
// end

// 最後に殺したキャラがプレイヤーだったら、赤ネームにする
L1PcInstance player = null;
if (lastAttacker instanceof L1PcInstance) {
player = (L1PcInstance) lastAttacker;
}
if (player != null) {
if (getLawful() >= 0 && isPinkName() == false) {


下面加入

// 掃街活動
if(L1KillAllMan.getInstance().getGameStatus() == 1) {
return;
}
// end


GameServer

// 掃街活動
L1KillAllMan.getInstance();


插入一隻檔案

L1KillAllMan

/**
* License by 涼介
*/
package l1j.kinlinlo;

import java.util.Timer;
import java.util.TimerTask;
import l1j.server.server.GetNowTime;
import l1j.server.server.model.L1World;
import l1j.server.server.serverpackets.S_ServerMessage;

public class L1KillAllMan {
private static final int STATUS_PLAYING = 1;
private static final int STATUS_END = 2;
private static int StartTIME = 21; // 開始時間
private static int PLAY_TIME = 1 * 60; // 遊戲時間(小時)
private static int EndTIME = StartTIME + PLAY_TIME / 60;
private static int WAIT_TIME = 5; // (分)
private static int nextGAMETIME = 24 * 60 - PLAY_TIME;
private static L1KillAllMan instance;

public static L1KillAllMan getInstance() {
if (instance == null) {
instance = new L1KillAllMan();
}
return instance;
}

L1KillAllMan() {
int Htime = 0;
int Mtime = 0;
if (GetNowTime.GetNowHour() < StartTIME) {
if (StartTIME - GetNowTime.GetNowHour() > 1) {
Htime = StartTIME - GetNowTime.GetNowHour();
}
Mtime = 60 - GetNowTime.GetNowMinute();
} else if (GetNowTime.GetNowHour() >= StartTIME
&& GetNowTime.GetNowHour() < EndTIME) {
WAIT_TIME = 0;
PLAY_TIME = PLAY_TIME - GetNowTime.GetNowMinute();
new RaceTimer(0).begin();
return;
} else if (GetNowTime.GetNowHour() >= EndTIME) {
return;
}
int totaltime = Htime * 60 + Mtime;
if (totaltime < WAIT_TIME) {
totaltime = 0;
WAIT_TIME = totaltime;
} else {
totaltime = totaltime - WAIT_TIME;
}
new RaceTimer(totaltime).begin();
}

private int _status = 0;

public void setGameStatus(int i) {
_status = i;
}

public int getGameStatus() {
return _status;
}

private class RaceTimer extends TimerTask {
int _startTime;

RaceTimer(int startTime) {
_startTime = startTime;
}

@Override
public void run() {

try {
for (int loop = 0; loop < WAIT_TIME; loop++) {
if (WAIT_TIME - loop != 0) { // 開始前五分鐘內每分鐘倒數公告
L1World.getInstance().broadcastPacketToAll(
new S_ServerMessage(166, (new StringBuilder())
.append("活動【掃街】將在" + (WAIT_TIME - loop)
+ "分鐘後開始!!").toString()));
}
Thread.sleep(60 * 1000);
}
L1World.getInstance().broadcastPacketToAll(
new S_ServerMessage(166, (new StringBuilder()).append(
"活動【掃街】開始!!").toString()));
setGameStatus(STATUS_PLAYING);
for (int loop = 0; loop < PLAY_TIME; loop++) {
/*
* if(PLAY_TIME - loop != 0) { //每分鐘倒數公告
* L1World.getInstance().broadcastPacketToAll(new
* S_ServerMessage(166, (new
* StringBuilder()).append("活動【掃街】進行中!!剩餘【"+ (PLAY_TIME -
* loop) +"】分").toString())); }
*/
if (PLAY_TIME - loop == 1) { // 結束前一分鐘公告
L1World.getInstance()
.broadcastPacketToAll(
new S_ServerMessage(166,
(new StringBuilder()).append(
"活動【掃街】將在1分鐘後結束!!")
.toString()));
}
Thread.sleep(60 * 1000);
}
setGameStatus(STATUS_END);
L1World.getInstance().broadcastPacketToAll(
new S_ServerMessage(166, (new StringBuilder()).append(
"活動【掃街】結束!!").toString()));
this.cancel();
new RaceTimer(nextGAMETIME).begin();
} catch (InterruptedException e) {
e.printStackTrace();
}

}

public void begin() {
Timer timer = new Timer();
timer.schedule(this, _startTime * 60 * 1000);
}
}
}


插入一隻檔案

GetNowTime

//********************************************************************
// GetNowTime.java
// by mca
// 2008/4/1
//********************************************************************
package l1j.server.server;

import java.util.*;// class Scanner
//************************************************************************
// 取得現在時間
//************************************************************************

public class GetNowTime {
public static int GetNowYear() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowYear;
nowYear = rightNow.get(Calendar.YEAR); // 取得現年之值
return nowYear; // 傳回取得現年之值
}

public static int GetNowMonth() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowMonth;
nowMonth = rightNow.get(Calendar.MONTH); // 取得現月之值
return nowMonth; // 傳回取得現月之值
}

public static int GetNowDay() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowDay;
nowDay = rightNow.get(Calendar.DATE); // 取得今日之值
return nowDay; // 傳回取得今日之值
}

public static int GetNowWeek() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowWeek;
nowWeek = rightNow.get(Calendar.WEEK_OF_MONTH); // 取得此週之值
return nowWeek; // 傳回取得此週之值
}

public static int GetNowDayWeek() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowDayWeek;
nowDayWeek = rightNow.get(Calendar.DAY_OF_WEEK); // 取得週幾之值
return nowDayWeek; // 傳回取得週幾之值
}

public static int GetNowHour() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowHour;
nowHour = rightNow.get(Calendar.HOUR_OF_DAY); // 取得此時之值
return nowHour; // 傳回取得此時之值
}

public static int GetNowMinute() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowMinute;
nowMinute = rightNow.get(Calendar.MINUTE); // 取得此分之值
return nowMinute; // 傳回取得此分之值
}

public static int GetNowSecond() {
Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
int nowSecond;
nowSecond = rightNow.get(Calendar.SECOND); // 取得此秒之值
return nowSecond; // 傳回取得此秒之值
}
}



上一篇文章:天堂新增怪物掉落追加強化值的java寫法!
下一篇文章:天堂新種類的魔法武器的java寫法!

分享文章:分享到微博! 分享到臉書! 分享到噗浪! 分享到維特! 分享到Google+! 分享到LINE!