Ejemplo n.º 1
0
        internal static async Task <string> setCarAbility(State s, Ability a)
        {
            if (!(a.pType == "mile" || a.pType == "business" || a.pType == "volume" || a.pType == "speed"))
            {
                return("");
            }
            else
            {
                ////Regex r = new Regex("^car(?<car>[A-E]{1})_(?<key>[a-f0-9]{32})$");
                ////var m = r.Match(a.car);
                //// var m_Target = rex_Target.Match(attack.TargetOwner);
                ////  if (m.Success)//&& m_Target.Success)
                {
                    //   var targetOwner = m_Target.Groups["target"].Value;

                    //  Console.WriteLine($"正则匹配成功:{m.Groups["car"] }+{m.Groups["key"] }");
                    //if (m.Groups["key"].Value == s.Key)
                    {
                        var getPosition = new SetAbility()
                        {
                            c   = "SetAbility",
                            Key = s.Key,
                            //   car = "car" + m.Groups["car"].Value,
                            pType = a.pType
                        };
                        var msg = Newtonsoft.Json.JsonConvert.SerializeObject(getPosition);
                        await Startup.sendInmationToUrlAndGetRes(Room.roomUrls[s.roomIndex], msg);
                    }
                }
                return("");
            }
        }
    // sets the ability property and does any necessary behavior for making the ability active
    public void EquipAbility(Ability ability)
    {
        EquippedAbility = ability;
        Debug.Log(EquippedAbility);

        SetAbility?.Invoke(EquippedAbility.abilityName, EquippedAbility.abilityColor, EquippedAbility.abilitySprite);
        _cooldownMinusCast = EquippedAbility.cooldown - EquippedAbility.castTime;
        EquippedAbility.Setup();
    }
Ejemplo n.º 3
0
 public static void InvokeSetAbility(Mobile mobile, int index) => SetAbility?.Invoke(mobile, index);
Ejemplo n.º 4
0
 public static void InvokeSetAbility(SetAbilityEventArgs e)
 {
     SetAbility?.Invoke(e);
 }
Ejemplo n.º 5
0
        internal async Task <string> SetAbility(SetAbility sa)
        {
            if (string.IsNullOrEmpty(sa.car))
            {
                return("wrong car");
            }
            else if (!(sa.car == "carA" || sa.car == "carB" || sa.car == "carC" || sa.car == "carD" || sa.car == "carE"))
            {
                return($"wrong car:{sa.car}");
            }
            else if (string.IsNullOrEmpty(sa.pType))
            {
                return($"wrong pType:{sa.pType}");
            }
            else if (!(sa.pType == "mile" || sa.pType == "business" || sa.pType == "volume" || sa.pType == "speed"))
            {
                return($"wrong pType:{sa.pType}");;
            }
            else
            {
                List <string> notifyMsg = new List <string>();
                lock (this.PlayerLock)
                {
                    if (this._Players.ContainsKey(sa.Key))
                    {
                        var carIndex = getCarIndex(sa.car);
                        var player   = this._Players[sa.Key];
                        var car      = player.getCar(carIndex);
                        if (player.Bust)
                        {
                            WebNotify(player, "您已破产");
                            return($"{player.Key} go bust!");

#warning 这里要提示前台,已经进行破产清算了。
                        }
                        else
                        {
                            switch (sa.pType)
                            {
                            case "mile":
                            case "business":
                            case "volume":
                            case "speed":
                            {
                                if (player.PromoteDiamondCount[sa.pType] > 0)
                                {
                                    car.ability.AbilityAdd(sa.pType, player, car, ref notifyMsg);
                                    player.PromoteDiamondCount[sa.pType]--;
                                    SendPromoteCountOfPlayer(sa.pType, player, ref notifyMsg);
                                }
                            }; break;
                            }
                        }
                    }
                    else
                    {
                        return($"not has player-{sa.Key}!");
                    }
                }
                for (var i = 0; i < notifyMsg.Count; i += 2)
                {
                    var url     = notifyMsg[i];
                    var sendMsg = notifyMsg[i + 1];
                    Console.WriteLine($"url:{url}");

                    await Startup.sendMsg(url, sendMsg);
                }
                return("ok");
            }
        }