Пример #1
0
        protected override void Run(ETModel.Session session, A1012_NewMonster_M2C message)
        {
            //服务端通知客户端刷新一窝野怪
            TimerComponent     timerComponent     = ETModel.Game.Scene.GetComponent <TimerComponent>();
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            GameObject         bundleGameObject   = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit");
            ConfigComponent    config             = Game.Scene.GetComponent <ConfigComponent>();
            Moba5V5Component   moba = Moba5V5Component.instance;

            //野怪点ID 编号分别为:49 51 52 54 57 58 59 60 61 62 63 64 65 68 70 71
            int configID;      //配置编号
            int monsterNumber; //野怪数量

            switch (message.MonsterID)
            {
            case 49:     //蜥蜴
                configID      = 49;
                monsterNumber = 2;
                break;

            case 51:     //蓝Buff
                configID      = 51;
                monsterNumber = 1;
                break;

            case 52:     //狼
                configID      = 52;
                monsterNumber = 2;
                break;

            case 54:     //熊
                configID      = 54;
                monsterNumber = 3;
                break;

            case 57:     //红Buff
                configID      = 57;
                monsterNumber = 1;
                break;

            case 58:     //鸟
                configID      = 58;
                monsterNumber = 1;
                break;

            case 59:     //河道蟹
                configID      = 59;
                monsterNumber = 1;
                break;

            case 60:     //河道蟹
                configID      = 60;
                monsterNumber = 1;
                break;

            case 61:     //大Boss
                configID      = 61;
                monsterNumber = 1;
                break;

            case 62:     //小Boss
                configID      = 62;
                monsterNumber = 1;
                break;

            case 63:     //鸟
                configID      = 63;
                monsterNumber = 1;
                break;

            case 64:     //红buff
                configID      = 64;
                monsterNumber = 1;
                break;

            case 65:     //熊
                configID      = 65;
                monsterNumber = 3;
                break;

            case 68:     //狼
                configID      = 68;
                monsterNumber = 2;
                break;

            case 70:     //蓝Buff
                configID      = 70;
                monsterNumber = 1;
                break;

            case 71:     //蜥蜴
                configID      = 71;
                monsterNumber = 2;
                break;

            default:
                throw new Exception("未知野怪点");
            }

            for (int i = 0; i < monsterNumber; i++)
            {
                if (i == 12)
                {
                    continue;
                }

                //获取角色配置
                Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + configID);
                GameObject    prefab        = bundleGameObject.Get <GameObject>(moba5V5Config.Prefab);
                prefab.transform.position    = new Vector3((float)moba5V5Config.Position[0], (float)moba5V5Config.Position[1], (float)moba5V5Config.Position[2]);
                prefab.transform.eulerAngles = new Vector3(0, moba5V5Config.Rotation, 0);

                //创建角色
                Gamer gamer = ETModel.ComponentFactory.Create <Gamer>();
                gamer.GameObject = UnityEngine.Object.Instantiate(prefab);
                gamer.GameObject.transform.SetParent(GameObject.Find($"/Global/Unit").transform, false);
                int mobaID = moba.MobaID;             //获取ID
                moba.mobaIDGamers.Add(mobaID, gamer); //添加到词典

                //添加Unity组件
                NavMeshAgent navMeshAgent = gamer.GameObject.AddComponent <NavMeshAgent>();
                navMeshAgent.radius                = 0.2f;
                navMeshAgent.height                = 0.8f;
                navMeshAgent.angularSpeed          = 360f;
                navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;

                //添加ET组件
                gamer.AddComponent <GamerAnimatorComponent>();
                gamer.AddComponent <GamerMoveComponent>();
                gamer.AddComponent <GamerTurnComponent>();
                gamer.AddComponent <GamerPathComponent>();

                //设置角色
                CharacterComponent character = gamer.AddComponent <CharacterComponent>();
                character.mobaID = mobaID;
                character.group  = moba5V5Config.Group; //阵营
                character.type   = moba5V5Config.Type;  //类型
            }
        }
    private IEnumerator ReleaseCoroutineModded(string second)
    {
        TimerComponent timerComponent = Module.Bomb.Bomb.GetTimer();
        int            target         = Mathf.FloorToInt(timerComponent.TimeRemaining);
        bool           waitingMusic   = true;

        string[]   times  = second.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        List <int> result = new List <int>();

        foreach (string time in times)
        {
            string[] split = time.Split(':');
            int      minutesInt = 0, hoursInt = 0, daysInt = 0;
            switch (split.Length)
            {
            case 1 when int.TryParse(split[0], out int secondsInt):
            case 2 when int.TryParse(split[0], out minutesInt) && int.TryParse(split[1], out secondsInt):
            case 3 when int.TryParse(split[0], out hoursInt) && int.TryParse(split[1], out minutesInt) && int.TryParse(split[2], out secondsInt):
            case 4 when int.TryParse(split[0], out daysInt) && int.TryParse(split[1], out hoursInt) && int.TryParse(split[2], out minutesInt) && int.TryParse(split[3], out secondsInt):
                result.Add(daysInt * 86400 + hoursInt * 3600 + minutesInt * 60 + secondsInt);

                break;

            default:
                yield break;
            }
        }
        yield return(null);

        bool minutes = times.Any(x => x.Contains(":"));

        minutes |= result.Any(x => x >= 60);

        if (!minutes)
        {
            target %= 60;
            result  = result.Select(x => x % 60).Distinct().ToList();
        }

        for (int i = result.Count - 1; i >= 0; i--)
        {
            int r = result[i];
            if (!minutes && !OtherModes.ZenModeOn)
            {
                waitingMusic &= target + (r > target ? 60 : 0) - r > 30;
            }
            else if (!minutes)
            {
                waitingMusic &= r + (r < target ? 60 : 0) - target > 30;
            }
            else if (!OtherModes.ZenModeOn)
            {
                if (r > target)
                {
                    result.RemoveAt(i);
                    continue;
                }

                waitingMusic &= target - r > 30;
            }
            else
            {
                if (r < target)
                {
                    result.RemoveAt(i);
                    continue;
                }

                waitingMusic &= r - target > 30;
            }
        }

        if (!result.Any())
        {
            yield return
                ($"sendtochaterror The button was not {(_held ? "released" : "tapped")} because all of your specified times are {(OtherModes.ZenModeOn ? "less" : "greater")} than the time remaining.");

            yield break;
        }

        if (waitingMusic)
        {
            yield return("waiting music");
        }

        while (result.All(x => x != target))
        {
            yield return($"trycancel The button was not {(_held ? "released" : "tapped")} due to a request to cancel.");

            target = (int)(timerComponent.TimeRemaining + (OtherModes.ZenModeOn ? -0.25f : 0.25f));
            if (!minutes)
            {
                target %= 60;
            }
        }

        if (!_held)
        {
            yield return(DoInteractionClick(_button));
        }
        else
        {
            DoInteractionEnd(_button);
        }

        _held = false;
    }
    private IEnumerator ReleaseCoroutineModded(string second)
    {
        bool longwait = false;

        string[]   list        = second.Split(' ');
        List <int> sortedTimes = new List <int>();

        foreach (string value in list)
        {
            if (!int.TryParse(value, out int time))
            {
                int pos = value.LastIndexOf(':');
                if (pos == -1)
                {
                    continue;
                }
                int hour = 0;
                if (!int.TryParse(value.Substring(0, pos), out int min))
                {
                    int pos2 = value.IndexOf(":");
                    if ((pos2 == -1) || (pos == pos2))
                    {
                        continue;
                    }
                    if (!int.TryParse(value.Substring(0, pos2), out hour))
                    {
                        continue;
                    }
                    if (!int.TryParse(value.Substring(pos2 + 1, pos - pos2 - 1), out min))
                    {
                        continue;
                    }
                }
                if (!int.TryParse(value.Substring(pos + 1), out int sec))
                {
                    continue;
                }
                time = (hour * 3600) + (min * 60) + sec;
            }
            sortedTimes.Add(time);
        }
        sortedTimes.Sort();
        sortedTimes.Reverse();
        if (sortedTimes.Count == 0)
        {
            yield break;
        }

        yield return("release");

        TimerComponent timerComponent = BombCommander.Bomb.GetTimer();

        int timeTarget = sortedTimes[0];

        sortedTimes.RemoveAt(0);

        int waitTime = (int)(timerComponent.TimeRemaining + 0.25f);

        waitTime -= timeTarget;
        if (waitTime >= 30)
        {
            yield return("elevator music");

            if (waitTime >= 120)
            {
                yield return(string.Format("sendtochat !!!WARNING!!! - you might want to do a !cancel right about now, as you will be waiting for {0} minutes and {1} seconds for button release. Seed #{2} applies to this button.", waitTime / 60, waitTime % 60, VanillaRuleModifier.GetRuleSeed()));

                yield return(string.Format("sendtochat Click the button with !{0} tap. Click the button at time with !{0} tap 8:55 8:44 8:33. Hold the button with !{0} hold. Release the button with !{0} release 9:58 9:49 9:30.", Code));

                longwait = true;
            }
        }

        float timeRemaining = float.PositiveInfinity;

        while (timeRemaining > 0.0f)
        {
            if (Canceller.ShouldCancel)
            {
                Canceller.ResetCancel();
                if (timeTarget < 10)
                {
                    yield return(string.Format("sendtochat The button was not {0} due to a request to cancel. Remember that the rule set that applies is seed #{1}", _held ? "released" : "tapped", VanillaRuleModifier.GetRuleSeed()));
                }
                else
                {
                    yield return(string.Format("sendtochat The button was not {0} due to a request to cancel.", _held ? "released" : "tapped"));
                }
                yield break;
            }

            timeRemaining = (int)(timerComponent.TimeRemaining + 0.25f);

            if (timeRemaining < timeTarget)
            {
                if (sortedTimes.Count == 0)
                {
                    yield return(string.Format("sendtochaterror The button was not {0} because all of your specfied times are greater than the time remaining.", _held ? "released" : "tapped"));

                    yield break;
                }
                timeTarget = sortedTimes[0];
                sortedTimes.RemoveAt(0);

                waitTime  = (int)timeRemaining;
                waitTime -= timeTarget;
                if (waitTime >= 30)
                {
                    yield return("elevator music");

                    if (waitTime >= 120 && !longwait)
                    {
                        yield return(string.Format("sendtochat !!!WARNING!!! - you might want to do a !cancel right about now, as you will be waiting for {0} minutes and {1} seconds for button release. Seed #{2} applies to this button.", waitTime / 60, waitTime % 60, VanillaRuleModifier.GetRuleSeed()));

                        yield return(string.Format("sendtochat Click the button with !{0} tap. Click the button at time with !{0} tap 8:55 8:44 8:33. Hold the button with !{0} hold. Release the button with !{0} release 9:58 9:49 9:30.", Code));
                    }
                    longwait = true;
                }

                continue;
            }
            if (Math.Abs(timeRemaining - timeTarget) < 0.1f)
            {
                if (!_held)
                {
                    DoInteractionStart(_button);
                    yield return(new WaitForSeconds(0.1f));
                }
                DoInteractionEnd(_button);
                _held = false;
                yield break;
            }

            yield return(null);
        }
    }