进入游戏狂欢时刻
parent
2aa64192a4
commit
5bc5543ce5
|
@ -5,6 +5,9 @@ package com.ljsd.battle.actor;
|
|||
|
||||
import com.ljsd.battle.BattleRequest;
|
||||
import com.ljsd.battle.room.SceneManager;
|
||||
import com.ljsd.battle.statics.AnalysisEventType;
|
||||
import com.ljsd.battle.statics.AnalysisSourceData;
|
||||
import com.ljsd.battle.statics.MessageBoxUtils;
|
||||
import com.ljsd.jieling.config.SChallengeMapConfig;
|
||||
import com.ljsd.jieling.util.CellUtil;
|
||||
|
||||
|
@ -47,6 +50,7 @@ public abstract class Creature extends SceneActor{
|
|||
|
||||
public void costMineral(int mineral) {
|
||||
this.mineral -= mineral;
|
||||
MessageBoxUtils.onGameEvent(AnalysisEventType.DIGGER_NUMS,getScene(),new AnalysisSourceData(this.getId(),-1,mineral));
|
||||
}
|
||||
|
||||
public void tick(){
|
||||
|
@ -55,6 +59,7 @@ public abstract class Creature extends SceneActor{
|
|||
|
||||
public void addMineral(int mineral) {
|
||||
this.mineral += mineral;
|
||||
MessageBoxUtils.onGameEvent(AnalysisEventType.DIGGER_NUMS,getScene(),new AnalysisSourceData(this.getId(),1,this.mineral));
|
||||
}
|
||||
|
||||
public void exec(int tyep, Object parm){
|
||||
|
|
|
@ -122,6 +122,16 @@ public class Scene implements Runnable{
|
|||
|
||||
private List<String> cacheMsg = new ArrayList<>(2);
|
||||
|
||||
private int quickEnd = -1; //快速结束时间
|
||||
|
||||
private int quickPlayId = 0;//快速结束玩家uid
|
||||
|
||||
private Set<Integer> possibaleQuickUids = new HashSet<>();
|
||||
|
||||
public void addQuickPossibalePlays(int quickPlayId){
|
||||
possibaleQuickUids.add(quickPlayId);
|
||||
}
|
||||
|
||||
|
||||
public void monsterReflush(){
|
||||
Iterator<Map.Entry<Integer, Integer>> iterator = monsterRecoryMap.entrySet().iterator();
|
||||
|
@ -149,6 +159,31 @@ public class Scene implements Runnable{
|
|||
}
|
||||
|
||||
|
||||
public void checkNeedRestartQuickEnd(){
|
||||
if(possibaleQuickUids.isEmpty()){
|
||||
return;
|
||||
}
|
||||
int[] settleTime = SBloodyBattleSetting.sBloodyBattleSetting.getSettleTime();
|
||||
int endTick = settleTime[1]*20 + tick;
|
||||
if(endTick>SceneManager.bloodyMap.getEndRound()){
|
||||
return;
|
||||
}
|
||||
for( Integer possibaleQuickUid : possibaleQuickUids){
|
||||
if(quickPlayId!=0 || quickPlayId == possibaleQuickUid){
|
||||
continue;
|
||||
}
|
||||
SceneActor sceneActor = sceneActorMap.get(possibaleQuickUid);
|
||||
Creature creature = (Creature)sceneActor;
|
||||
if(creature.getMineral()>settleTime[0]){
|
||||
startQuickTime(possibaleQuickUid,endTick);
|
||||
break;
|
||||
}
|
||||
}
|
||||
possibaleQuickUids.clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void tick() throws InterruptedException {
|
||||
Iterator<Map.Entry<Integer, SceneActor>> iterator = sceneActorMap.entrySet().iterator();
|
||||
while (iterator.hasNext()){
|
||||
|
@ -161,6 +196,7 @@ public class Scene implements Runnable{
|
|||
for(Integer removeId : builder.getRemoveActorIdList()){
|
||||
sceneActorMap.remove(removeId);
|
||||
}
|
||||
checkNeedRestartQuickEnd();
|
||||
for(SceneActor sceneActor : sceneActorMap.values()){
|
||||
if(sceneActor.getType() != ActorType.Npc){
|
||||
if(willUpdateActors.contains(sceneActor.getId())){
|
||||
|
@ -235,7 +271,11 @@ public class Scene implements Runnable{
|
|||
if(isEnd){
|
||||
break;
|
||||
}
|
||||
|
||||
tick++;
|
||||
if(checkIsEnd()){
|
||||
break;
|
||||
}
|
||||
sysTick();
|
||||
tick();
|
||||
if(tick/20 == 1 && tick%20==0){
|
||||
|
@ -248,6 +288,14 @@ public class Scene implements Runnable{
|
|||
|
||||
}
|
||||
|
||||
public boolean checkIsEnd(){
|
||||
if(tick> SceneManager.bloodyMap.getEndRound() || (quickEnd!=-1 && tick>quickEnd)){
|
||||
gameEnd();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void startAllRunning(){
|
||||
for(SceneActor sceneActor : sceneActorMap.values()){
|
||||
if(sceneActor.getType()== ActorType.Player){
|
||||
|
@ -459,4 +507,24 @@ public class Scene implements Runnable{
|
|||
public void addCahceBroadMsg(String msg){
|
||||
cacheMsg.add(msg);
|
||||
}
|
||||
|
||||
|
||||
public int getQuickEnd() {
|
||||
return quickEnd;
|
||||
}
|
||||
|
||||
public int getQuickPlayId() {
|
||||
return quickPlayId;
|
||||
}
|
||||
|
||||
public void startQuickTime(int quickPlayId,int quickEnd){
|
||||
this.quickPlayId = quickPlayId;
|
||||
this.quickEnd = quickEnd;
|
||||
addCahceBroadMsg("进入游戏狂欢时刻,剩余" + (quickEnd-tick)/20 + "秒");
|
||||
}
|
||||
|
||||
public void clearQuickTime(){
|
||||
this.quickEnd = -1;
|
||||
this.quickPlayId = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.ljsd.battle.vo.UserBloodySnpInfo;
|
|||
import com.ljsd.battle.actor.*;
|
||||
import com.ljsd.battle.vo.FamilyHeroInfo;
|
||||
import com.ljsd.battle.vo.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.config.SBloodyBattleSetting;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.RoomProto;
|
||||
|
||||
|
@ -93,6 +94,13 @@ public class BeanToProto {
|
|||
Integer value = item.getValue();
|
||||
builder.addPosMineral(CommonProto.PosMineral.newBuilder().setPos(key).setNums(value).build());
|
||||
}
|
||||
long endTime = SBloodyBattleSetting.sBloodyBattleSetting.getBattleTime();
|
||||
if(scene.getQuickEnd()!=-1){
|
||||
long startTime = scene.getStartTime();
|
||||
endTime = startTime + scene.getQuickEnd()*50;
|
||||
}
|
||||
int remainTime = SBloodyBattleSetting.sBloodyBattleSetting.getBattleTime() - (int)((System.currentTimeMillis() - scene.getStartTime()) / 1000);
|
||||
builder.setRemainTime(remainTime);
|
||||
builder.addAllBarrierPoint(SceneManager.bloodyMap.getBarrierPoints());
|
||||
return builder.build();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ public class BloodyMap {
|
|||
|
||||
private int round;
|
||||
|
||||
private int endRound;
|
||||
|
||||
public BloodyMap(int mapId) {
|
||||
this.mapId = mapId;
|
||||
}
|
||||
|
@ -35,4 +37,12 @@ public class BloodyMap {
|
|||
public void setRound(int round) {
|
||||
this.round = round;
|
||||
}
|
||||
|
||||
public int getEndRound() {
|
||||
return endRound;
|
||||
}
|
||||
|
||||
public void setEndRound(int endRound) {
|
||||
this.endRound = endRound;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ public class SceneManager {
|
|||
}
|
||||
|
||||
bloodyMapTmp.setRound(max*20);
|
||||
bloodyMapTmp.setEndRound(SBloodyBattleSetting.sBloodyBattleSetting.getBattleTime()*20);
|
||||
bloodyMap = bloodyMapTmp;
|
||||
calPossiblePoss();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ljsd.battle.statics;
|
|||
public enum AnalysisEventType {
|
||||
BATTLE,
|
||||
DIGGER,
|
||||
DIGGER_NUMS,
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public class MessageBoxUtils {
|
|||
//更新统计数据 数据汇总聚合
|
||||
analysisEventTypeIntegerMap.put(AnalysisEventType.BATTLE,new BattleAnalysisProcessor());
|
||||
analysisEventTypeIntegerMap.put(AnalysisEventType.DIGGER,new DiggerAnalysisProcessor());
|
||||
analysisEventTypeIntegerMap.put(AnalysisEventType.DIGGER_NUMS,new MineralNumsAnalysisProcessor());
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.ljsd.battle.statics;
|
||||
|
||||
|
||||
import com.ljsd.battle.actor.Scene;
|
||||
import com.ljsd.jieling.config.SBloodyBattleSetting;
|
||||
|
||||
public class MineralNumsAnalysisProcessor implements AnalysisProcessor{
|
||||
@Override
|
||||
public void process(Scene scene, AnalysisSourceData analysisSourceData) {
|
||||
int targetId = analysisSourceData.getTargetId();
|
||||
int caster = analysisSourceData.getCaster();
|
||||
int value = analysisSourceData.getValue();
|
||||
int[] settleTime = SBloodyBattleSetting.sBloodyBattleSetting.getSettleTime();
|
||||
int quickPlayId = scene.getQuickPlayId();
|
||||
if(quickPlayId == targetId && caster == -1 && value<settleTime[0]){
|
||||
scene.clearQuickTime();
|
||||
}
|
||||
if(quickPlayId != targetId && caster == 1 && value >= settleTime[0]){
|
||||
scene.addQuickPossibalePlays(targetId);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue