From fa456af06ddef00145aff72bdee795390c78586e Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期四, 14 二月 2019 17:27:52 +0800
Subject: [PATCH] 6197 【前端】【1.6】跨服匹配玩法
---
System/CrossServerOneVsOneClient/ClientCrossServerOneVsOneStage.cs | 194 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 194 insertions(+), 0 deletions(-)
diff --git a/System/CrossServerOneVsOneClient/ClientCrossServerOneVsOneStage.cs b/System/CrossServerOneVsOneClient/ClientCrossServerOneVsOneStage.cs
index 75b086b..911d22d 100644
--- a/System/CrossServerOneVsOneClient/ClientCrossServerOneVsOneStage.cs
+++ b/System/CrossServerOneVsOneClient/ClientCrossServerOneVsOneStage.cs
@@ -4,6 +4,200 @@
public class ClientCrossServerOneVsOneStage : Stage
{
+ static FightInfo fightInfo;
+ static PKStageType pkStageType;
+ PKStage currentStage;
+ public override void Initialize()
+ {
+ base.Initialize();
+ fightInfo = default(FightInfo);
+ currentStage = null;
+ }
+
+ protected override void OnStageLoadFinish()
+ {
+ base.OnStageLoadFinish();
+ currentStage = new WaitStartStage();
+ currentStage.Begin();
+ }
+
+ protected override void OnUpdate()
+ {
+ base.OnUpdate();
+
+ if (currentStage != null)
+ {
+ currentStage.Update();
+ if (currentStage.completed)
+ {
+ currentStage.End();
+ currentStage = null;
+ switch (pkStageType)
+ {
+ case PKStageType.WaitStart:
+ currentStage = new FightStage();
+ break;
+ case PKStageType.Fight:
+ if (fightInfo.isOver)
+ {
+ currentStage = new FightOverStage();
+ }
+ else
+ {
+ currentStage = new RoundPauseStage();
+ }
+ break;
+ case PKStageType.RoundPause:
+ currentStage = new FightStage();
+ break;
+ case PKStageType.FightOver:
+ break;
+ default:
+ break;
+ }
+
+ if (currentStage != null)
+ {
+ currentStage.Begin();
+ }
+ }
+ }
+ }
+
+ public abstract class PKStage
+ {
+ public float timer { get; protected set; }
+ public float duration { get; protected set; }
+ public bool completed { get; protected set; }
+
+ public abstract void Begin();
+ public abstract void Update();
+ public abstract void End();
+ }
+
+ public class WaitStartStage : PKStage
+ {
+ public override void Begin()
+ {
+ pkStageType = PKStageType.WaitStart;
+ duration = 10f;
+ //妯℃嫙寮�濮嬪�掕鏃�
+ }
+
+ public override void End()
+ {
+ //妯℃嫙鎴樻枟寮�濮嬪寘
+
+ }
+
+ public override void Update()
+ {
+ timer += duration;
+ completed = timer >= duration;
+ }
+ }
+
+ public class FightStage : PKStage
+ {
+ public override void Begin()
+ {
+ pkStageType = PKStageType.Fight;
+ duration = 60f;
+ fightInfo.roundCount++;
+ }
+
+ public override void End()
+ {
+ fightInfo.roundWinnerIds[fightInfo.roundCount - 1] = 1000;//璁板綍鑾疯儨鑰呯殑id
+ if (fightInfo.roundCount >= 2)
+ {
+ if (fightInfo.roundCount == 2)
+ {
+ if (fightInfo.roundWinnerIds[0] == fightInfo.roundWinnerIds[1])
+ {
+ fightInfo.isOver = true;
+ }
+ }
+ else
+ {
+ fightInfo.isOver = true;
+ }
+ }
+ }
+
+ public override void Update()
+ {
+ timer += Time.deltaTime;
+ if (timer >= duration)//鏃堕棿鍒版垨鑰呮湁涓�鏂规浜★紝灏辩畻缁撴潫
+ {
+ completed = true;
+ }
+ else
+ {
+ completed = false;
+ }
+ }
+
+ }
+
+ public class RoundPauseStage : PKStage
+ {
+ public override void Begin()
+ {
+ pkStageType = PKStageType.RoundPause;
+ duration = 3f;
+ }
+
+ public override void End()
+ {
+ //妯℃嫙鍙戞垬鏂楀紑濮嬪寘
+ }
+
+ public override void Update()
+ {
+ timer += Time.deltaTime;
+ completed = timer >= duration;
+ }
+ }
+
+ public class FightOverStage : PKStage
+ {
+ public override void Begin()
+ {
+ pkStageType = PKStageType.FightOver;
+ duration = 10f;
+ }
+
+ public override void End()
+ {
+ if (ClientCrossServerOneVsOne.isClientCrossServerOneVsOne)
+ {
+ ClientCrossServerOneVsOne.StopClientCrossServerOneVsOne();
+ }
+ }
+
+ public override void Update()
+ {
+ timer += Time.deltaTime;
+ completed = timer >= duration;
+ }
+
+ }
+
+ public enum PKStageType
+ {
+ WaitStart,
+ Fight,
+ RoundPause,
+ FightOver,
+ }
+
+ public struct FightInfo
+ {
+ public bool isOver;
+ public int roundCount;
+ public int[] roundWinnerIds;
+ }
}
--
Gitblit v1.8.0