Beispiel #1
0
        override protected void OnLateUpdate()
        {
            int id = -1;

            become = true;
            foreach (UnitCtl unitCtl in builds)
            {
                if (unitCtl.unitData.isNeutral)
                {
                    become = false;
                    break;
                }

                if (id < 0)
                {
                    id = unitCtl.unitData.legionId;
                }
                else if (id != unitCtl.unitData.legionId)
                {
                    become = false;
                    break;
                }
            }

            if (become)
            {
                if (legionId != id)
                {
                    legionId = id;
                    time     = Time.deltaTime;
                }
                else
                {
                    time += Time.deltaTime;
                }
            }
            else
            {
                time     = 0;
                legionId = 0;
            }

            view.time     = (int)time;
            view.legionId = legionId;

            if (time >= winConfig.t1_time)
            {
                if (War.ownLegionData.GetRelation(legionId) == RelationType.Enemy)
                {
                    state = WinState.Fail;
                    War.Over(OverType.Lose);
                }
                else
                {
                    state = WinState.Success;;
                    War.Over(OverType.Win);
                }
            }
        }
Beispiel #2
0
        /** 发送--战斗退出 */
        public void C_BattleLeave_0x813()
        {
            if (War.realPlayerCount <= 1)
            {
                War.Over(OverType.Lose);
                return;
            }


            C_BattleLeave_0x813 msg = new C_BattleLeave_0x813();

            msg.battle_room_id = War.scene.buildList.Count;
            packetManager.SendMessage <C_BattleLeave_0x813>(SocketId.Battle, msg);
        }
Beispiel #3
0
 /// <summary>
 /// 游戏结束
 /// </summary>
 public static void Over(OverType overType)
 {
     War.Over(overType, false);
 }
        public void Execute()
        {
//			Debug.Log("UpdateHP War.processState = "+ War.processState);
            if (War.processState != WarProcessState.Gameing)
            {
                return;
            }

            friendHP = 0f;
            totalHP  = 0f;


            friendBuildCount = 0;
            totalBuildCount  = 0;
            legionHP.Clear();
            //			Debug.Log(("<color=green>------------------</color>"));

            foreach (KeyValuePair <int, LegionData> kvp in War.sceneData.legionDict)
            {
                if (kvp.Value.type != LegionType.Neutral)
                {
                    legionHP.Add(kvp.Value.legionId, 0);
                }
            }

            foreach (UnitCtl unit in buildList)
            {
                //				Debug.Log(string.Format("<color=green>buildList unit.teamData.team={0},   unit.teamData.type={1},   totalHP={2}</color>", unit.teamData.team, unit.teamData.type, totalHP));
                if (unit.legionData.type == LegionType.Neutral)
                {
                    continue;
                }

                AddBuild(unit);
            }

            foreach (UnitCtl unit in soliderList)
            {
                //				Debug.Log(string.Format("<color=green>soliderList unit.teamData.team={0},   unit.teamData.type={1},   totalHP={2}</color>", unit.teamData.team, unit.teamData.type, totalHP));
                if (unit.legionData.type == LegionType.Neutral)
                {
                    continue;
                }

                AddHP(unit);
            }

            if (totalHP > 0)
            {
                friendHPRate = friendHP / totalHP;
            }
            else
            {
                friendHPRate = 0.5f;
            }



//			if(totalHP > 0)
//			{
//
//				//				Debug.Log("<color=green>totalHP="+totalHP+"</color>");
//				if(legionHP.ContainsKey(War.ownLegionData.legionId))
//				{
//					myHPRate =legionHP[War.ownLegionData.legionId] / totalHP;
//				}
//				else
//				{
//					myHPRate = 0F;
//
//					//					Debug.Log("<color=green>myHPRate = 0F;</color>");
//				}
//			}
//			else
//			{
//				if(legionHP.ContainsKey(War.ownLegionData.legionId))
//				{
//					myHPRate =0F;
//					//					Debug.Log("<color=green>----myHPRate = 0F;</color>");
//				}
//			}

            //			Debug.Log("<color=green>myHPRate="+myHPRate+"</color>");



            if (friendBuildCount <= 0)
            {
                War.Over(OverType.Lose);
            }
            else if (friendBuildCount >= totalBuildCount)
            {
                War.Over(OverType.Win);
            }
            else if (War.timeLimit && War.time >= War.timeMax)
            {
                if (friendBuildCount == totalBuildCount * 0.5f)
                {
                    War.Over(OverType.Draw, true);
                }
                else if (friendBuildCount <= totalBuildCount * 0.5f)
                {
                    War.Over(OverType.Lose, true);
                }
                else
                {
                    War.Over(OverType.Win, true);
                }
            }

            return;

            if (friendHPRate <= 0)
            {
                War.Over(OverType.Lose);
            }
            else if (friendHPRate >= 1)
            {
                War.Over(OverType.Win);
            }
            else if (War.timeLimit && War.time >= War.timeMax)
            {
                if (War.vsmode == VSMode.PVE_Expedition)
                {
                    War.Over(OverType.Win, true);
                }
                else
                {
                    bool  isWin     = false;
                    float buildRate = friendBuildCount * 1f / totalBuildCount;
                    if (buildRate == 0.5f)
                    {
                        isWin = friendHPRate > 0.5f;
                    }
                    else
                    {
                        isWin = buildRate > 0.5f;
                    }
                    Debug.LogFormat("buildRate={0}, friendBuildCount={1}, totalBuildCount={2}, myHPRate={3}, isWin={4}", buildRate, friendBuildCount, totalBuildCount, friendHPRate, isWin);

                    War.Over(isWin ? OverType.Win : OverType.Lose, true);
                }
            }
            else
            {
                if (War.vsmode == VSMode.PVE_Expedition)
                {
                    if (War.GetLegionData(1).expeditionTotalHP < 1 && War.GetLegionData(2).expeditionTotalHP < 1)
                    {
                        War.Over(OverType.Win);
                    }
                }
            }
        }