static int Destory(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 1);
     Games.Module.Wars.War obj = (Games.Module.Wars.War)LuaScriptMgr.GetNetObjectSelf(L, 1, "Games.Module.Wars.War");
     obj.Destory();
     return(0);
 }
    static int _CreateGames_Module_Wars_War(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            Games.Module.Wars.War obj = new Games.Module.Wars.War();
            LuaScriptMgr.PushObject(L, obj);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: Games.Module.Wars.War.New");
        }

        return(0);
    }
Exemplo n.º 3
0
 public void Hide()
 {
     War.Play();
     gameObject.SetActive(false);
 }
Exemplo n.º 4
0
        IEnumerator DelayPause()
        {
            yield return(new WaitForEndOfFrame());

            War.Pause();
        }
Exemplo n.º 5
0
 public void OnClick()
 {
     War.Exit(true);
 }
Exemplo n.º 6
0
        protected override void OnUpdate()
        {
            base.OnUpdate();



            if (_team != unitData.legionId)
            {
                _preteam = _team;
                _team    = unitData.legionId;
                if (_preteam == -1)
                {
                    _preteam = _team;
                }
                unitData.death = true;

                if (_changeInactiveTime <= 0)
                {
                    _changeInactivePreTeam = _preteam;
                    _changeInactiveTeam    = _team;
                    if (!_hasHero)
                    {
                        // 添加经验--占领
                        War.GetLegionData(_team).levelData.AddExp_Build(unitCtl);
                    }
                }

                _changeInactiveTime = changeInactiveTime;

                Coo.soundManager.PlaySound("effect_get_build");
            }

            if (_changeInactiveTime > 0)
            {
                _changeInactiveTime -= Time.deltaTime;
                if (_changeInactiveTime <= 0 && _changeInactiveTeam != _team)
                {
                    // 添加经验--占领
                    War.GetLegionData(_team).levelData.AddExp_Build(unitCtl);
                }
            }

            _hasHero = unitData.hasHero;

            if (_death != unitData.death)
            {
                _death = unitData.death;

                if (_death)
                {
                    buildChangeManager.StopAll();
                    buildChangeAvatar.Play(0, hideAvatarTime, showAvatarTime, 0.02f, effect);
                }
            }

            if (_death)
            {
                unitData.deathTime -= Time.deltaTime;

                if (unitData.deathTime <= 0)
                {
//					if(unitData.level > 1) unitData.level -= 1;
                }
            }
        }
Exemplo n.º 7
0
        bool Rescue()
        {
//			Debug.Log("--------------Rescue--------------");

            // 救援,随机派部队数量
            int sendCount = aiConfig.GetRescueSendCount();

//			Debug.Log("救援,随机派部队数量 sendCount=" + sendCount);
            if (sendCount <= 0)
            {
                return(false);
            }

            UnitCtl rescueUnit     = null;
            float   minRescueScore = 9999999;

            foreach (UnitCtl build in ownBuilds)
            {
                build.unitData.GenerationFromLegionUnitTotalNum();
                if (build.unitData.attackUnitNum > 0)
                {
                    float distance = 0;
                    foreach (UnitCtl buildB in ownBuilds)
                    {
                        if (build == buildB)
                        {
                            continue;
                        }
                        distance += War.scene.GetBuildDistance(build, buildB);
                    }
                    distance = ownBuilds.Count > 1 ? distance / (ownBuilds.Count - 1) : 0;;
                    build.unitData.rescueScore = build.hp + distance * distanceScoreRate_Rescue;

                    if (build.unitData.rescueScore < minRescueScore)
                    {
                        minRescueScore = build.unitData.rescueScore;
                        rescueUnit     = build;
                    }
                }
            }

            if (rescueUnit == null)
            {
                return(false);
            }

            // 救援,生成派兵的建筑
            List <UnitCtl> ownSelectBuilds = new List <UnitCtl>();
            int            index           = 0;

            foreach (UnitCtl build in ownBuilds)
            {
                if (index < sendCount && build != rescueUnit)
                {
                    ownSelectBuilds.Add(build);
                    index++;
                    if (index >= sendCount)
                    {
                        break;
                    }
                }
            }

            if (ownSelectBuilds.Count <= 0)
            {
                return(false);
            }


            bool isSend = true;

            float rescueHP = 0;

            foreach (UnitCtl ownBuild in ownSelectBuilds)
            {
                rescueHP += ownBuild.unitData.hp * aiConfig.sendArmPercent;
            }

            float enemyHP = 0;

            foreach (KeyValuePair <int, int> kvp in rescueUnit.unitData.fromLegionUnitTotalNumDict)
            {
                if (kvp.Value > 0)
                {
                    LegionData itemLegionData = War.GetLegionData(kvp.Key);
                    if (unitData.GetRelation(itemLegionData.legionId) == RelationType.Enemy)
                    {
                        enemyHP += WarFormula.WD_Solider2Casern_Damage(rescueUnit.unitData.def, itemLegionData.soliderInitData.atk, kvp.Value * itemLegionData.soliderData.hp2UnitRate);
                    }
                    else
                    {
                        rescueHP += kvp.Value * itemLegionData.soliderData.hp2UnitRate;
                    }
                }
            }

            isSend = rescueHP > enemyHP;

            if (isSend)
            {
//				Debug.Log("<color=blue>救援</color>");
                foreach (UnitCtl ownBuild in ownSelectBuilds)
                {
                    BSendArming bSendArming = ownBuild.GetComponent <BSendArming>();
                    bSendArming.Send(rescueUnit, aiConfig.sendArmPercent);
                }
            }



            return(isSend);
        }
Exemplo n.º 8
0
 /** 战斗开始 */
 public void S_BattleStart_0x812(S_BattleStart_0x812 msg)
 {
     War.OnReadyPVP();
 }
Exemplo n.º 9
0
        void Test_StartGame()
        {
            int    stageId = 1091;
            VSMode vsModel = VSMode.Dungeon;

            TestWarParameter parameter = GameObject.Find("GlobalGenerator").GetComponent <TestWarParameter>();

            if (parameter != null)
            {
                stageId = parameter.stageId;
                vsModel = parameter.vsMode;


                if (parameter.useJsonData)
                {
                    StartCoroutine(OnUseJson());
                    return;
                }
                else if (parameter.useRecrodJson)
                {
                    StartCoroutine(WRTimeLineData.OnUseJson(parameter.watchRoleId));
                    return;
                }
                else if (parameter.useRecrodBinary)
                {
                    StartCoroutine(WRTimeLineData.OnUseBinary(parameter.watchRoleId));
                    return;
                }
            }

            // heroSkill=[heroId, skillId, skillLevel, skillId2, skillLevel2]
//			WarEnterData enterData = WarEnterData.CreateTest(3004, 1, new int[][]{
//				new int[]{2, 20002, 1, 1, 101, 1},
//				new int[]{5, 20003, 2, 1, 102, 1}
//			});



            WarEnterData enterData;


            enterData = WarEnterData.CreateTest(stageId, 1,
                                                // 自己技能
                                                new int[][] {
//										new int[]{20003, 8, 1, 0, 1},
//										new int[]{20004, 8, 1, 0, 1},
//										new int[]{20010, 8, 1, 0, 0},
//										new int[]{20102, 8, 1, 0, 0},
//										new int[]{20107, 8, 1, 0, 0},
//										new int[]{20109, 8, 1, 0, 0},
//                    new int[]{20202, 17, 1, 0, 0},
                //				new int[]{20204, 19, 1, 0, 0},
//				new int[]{20104, 8, 1, 0, 0},
//				new int[]{20205, 8, 1, 0, 0},

//									new int[]{20104, 3, 1, 0, 0},
//									new int[]{20206, 3, 1, 0, 0},
//									new int[]{20205, 12, 1, 0, 0},

                new int[] { 20301, 19, 1, 0, 0 },
                new int[] { 20302, 24, 1, 0, 0 },
                new int[] { 20303, 25, 1, 0, 0 },
                new int[] { 20304, 32, 1, 0, 0 },
                new int[] { 20305, 33, 1, 0, 0 },

//                    new int[]{20301, 8, 1, 0, 0},
//                    new int[]{20302, 32, 1, 0, 0},
//                    new int[]{20303, 32, 1, 0, 0},
//                    new int[]{20304, 3, 1, 0, 0},
//                    new int[]{20305, 32, 1, 0, 0},
                //new int[]{20202, 100004, 1, 0, 0},
                //new int[]{20204, 100005, 1, 0, 0},
                //new int[]{20205, 100006, 1, 0, 0},
                //new int[]{20301, 100007, 1, 0, 0},
                //new int[]{20302, 100008, 1, 0, 0},
            },


                                                //电脑技能
                                                new int[][] {
//					new int[]{20301, 251001, 1, 0, 0},
//					new int[]{20302, 251001, 1, 0, 0},
                //					new int[]{20303, 251001, 1, 0, 0},
                new int[] { 20301, 101001, 1, 0, 0 },
                new int[] { 20302, 191001, 1, 0, 0 },
                new int[] { 20303, 251001, 1, 0, 0 },
                new int[] { 20304, 311001, 1, 0, 0 },
            }
                                                );

            enterData.skillConfigDict = skillConfigs;
            enterData.vsmode          = vsModel;

            War.Start(enterData);
//			StartCoroutine(CloseSound());
        }
Exemplo n.º 10
0
 /// <summary>
 /// 游戏结束
 /// </summary>
 public static void Over(OverType overType)
 {
     War.Over(overType, false);
 }
Exemplo n.º 11
0
        /// <summary>
        /// 进入战斗
        /// </summary>
        /// <param name="enterData">进入战斗数据</param>


        public static void Start(WarEnterData enterData)
        {
            Debug.Log("进入战斗数据 enterData=" + enterData);

            if (War.isTest)
            {
                War.Clear();
            }

            War.enterData = enterData;
            War.isRecord  = enterData.isRecord;
            // 初始化
            War.Init();

            // 战斗流程状态--生成数据
            War.processState = WarProcessState.GenerateData;
            // 对战模式
            War.vsmode = enterData.vsmode;
            // 是否自动关闭加载面板
            War.isAutoCloseLoad = !War.requireSynch;
            // 自己势力ID
            War.ownLegionID = enterData.ownLegionId;

            Debug.LogFormat("type====={0}", enterData.vsmode);
            // 战斗已过时间
            War.time = 0;
            // 战斗环境配置--PC机是否开启PC操作模式
            War.config.PCOperater = ConstConfig.GetInt(ConstConfig.ID.War_PCOperater) == 1;

            // 生成战场数据
            War.sceneData = new SceneDataForEnterData();
            (War.sceneData as SceneDataForEnterData).Generation(enterData);

            // 生成预加载资源
            WarRes.GenerationPreloadList();

            // 战斗流程状态--加载中
            War.processState = WarProcessState.Loading;

            if (War.isEditor == false)
            {
                if (!War.isTest)
                {
                    LoadType loadType = LoadType.None;
                    switch (War.vsmode)
                    {
                    case VSMode.Dungeon:
                    case VSMode.Train:
                        loadType = LoadType.Scene_Dungeon;
                        break;

                    case VSMode.PVP:
                        loadType = LoadType.Scene_PVP;
                        break;

                    case VSMode.PVE:
                    case VSMode.PVE_Expedition:
                    default:
                        loadType = LoadType.Scene_Normal;
                        break;
                    }

                    Coo.menuManager.OpenMenuBack(MenuType.WarScene, enterData.backMenuId, null, loadType);
                }
            }

            War.signal.GenerateDataComplete();
            Debug.Log("	战斗数据生成完毕 War.sGenerateDataComplete.Dispatch();");

            LuaCallMethod("Start");
        }
Exemplo n.º 12
0
 public static bool IsSendService(LegionData legionData)
 {
     return(War.IsSendService(legionData.legionId, legionData.type));
 }
Exemplo n.º 13
0
        public static bool IsSendService(int legionId)
        {
            LegionData legionData = War.GetLegionData(legionId);

            return(War.IsSendService(legionData));
        }
Exemplo n.º 14
0
        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);
                    }
                }
            }
        }