public void ReplaceSmallToken2(int originalViewID, int newViewID, bool destroy) { if (smallTokens.Contains(convertToKey(originalViewID))) { SmallToken token = (SmallToken)PhotonView.Find(newViewID).GetComponent <Token>(); string id = convertToKey(newViewID); AllTokens.Remove(convertToKey(originalViewID)); smallTokens.Remove(convertToKey(originalViewID)); smallTokens.Add(id, token); AllTokens.Add(id, token); if (destroy) { Token tkn = PhotonView.Find(originalViewID).GetComponent <Token>(); if (tkn != null) { GameObject.Destroy(tkn.gameObject); } } } if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
public void ReplaceBigToken2(int originalViewID, int newViewID, bool destroy) { if (bigToken.GetComponent <PhotonView>().ViewID == originalViewID) { BigToken token = (BigToken)PhotonView.Find(newViewID).GetComponentInParent <Token>(); string id = convertToKey(newViewID); AllTokens.Add(id, token); AllTokens.Remove(convertToKey(originalViewID)); if (destroy) { GameObject.Destroy(bigToken.gameObject); } bigToken = token; } if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
void FarmerDestroyed(Farmer farmer) { if (Farmers.Contains(farmer)) { Farmers.Remove(farmer); AllTokens.Remove(farmer); } }
public RuntimeErrorExpressionSegment(string originalContent, IEnumerable <IToken> originalTokens, Type exceptionType, string message) { if (string.IsNullOrWhiteSpace(originalContent)) { throw new ArgumentException("Null/blank originalContent specified"); } if (originalTokens == null) { throw new ArgumentNullException("originalTokens"); } if (exceptionType == null) { throw new ArgumentNullException("exceptionType"); } if (string.IsNullOrWhiteSpace(message)) { throw new ArgumentException("Null/blank message specified"); } AllTokens = originalTokens.ToList().AsReadOnly(); if (!AllTokens.Any()) { throw new ArgumentException("Empty originalTokens set specified - invalid"); } if (AllTokens.Any(t => t == null)) { throw new ArgumentException("Null reference encountered in originalTokens set - invalid"); } if (!typeof(Exception).IsAssignableFrom(exceptionType)) { throw new ArgumentException("The specified exceptionType must be derived from Exception"); } var acceptableConstructors = exceptionType.GetConstructors() .Where(c => { var constructorParameters = c.GetParameters(); if (!constructorParameters.Any() || (constructorParameters.First().ParameterType != typeof(string))) { return(false); } return((constructorParameters.Count() == 1) || constructorParameters.Skip(1).All(p => p.IsOptional)); }); if (!acceptableConstructors.Any()) { if (exceptionType.GetConstructor(new[] { typeof(string) }) == null) { throw new ArgumentException("The specified exceptionType must have a public constructor that takes a single string argument"); } } RenderedContent = originalContent; ExceptionType = exceptionType; Message = message; }
public void AddToken(Token token) { Type listType; listType = Heroes.GetListType(); if (listType.IsCompatibleWith(token.GetType())) { AllTokens.Add(token); Heroes.Add((Hero)token); return; } listType = Enemies.GetListType(); if (listType.IsCompatibleWith(token.GetType())) { AllTokens.Add(token); Enemies.Add((Enemy)token); return; } listType = Farmers.GetListType(); if (listType.IsCompatibleWith(token.GetType())) { AllTokens.Add(token); Farmers.Add((Farmer)token); return; } if (token is Fog) { AllTokens.Add(token); return; } if (token is Well) { AllTokens.Add(token); Well = (Well)token; return; } if (token is Witch) { AllTokens.Add(token); return; } if (token is Thorald) { AllTokens.Add(token); return; } // if none of these options means its an item AddItem(token); }
public void RemoveSmallToken2(int viewID) { AllTokens.Remove(convertToKey(viewID)); smallTokens.Remove(convertToKey(viewID)); if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
public List <player_base_info> get_player_list(string sid) { var list = new List <player_base_info>(); if (AllTokens.TryGetValue(sid, out var token)) { token.LastHeartBeat = DateTime.Now; } if (allPlayersBySid.TryGetValue(sid, out var bp)) { var r = bp.GetPlayerBaseInfo().Result; if (r.Length > 0) { gMap = GrainClient.GrainFactory.GetGrain <IMap>(r[0].LastMapId); token.CurrMapObserver = new MapObserver(); token.CurrMapObserver.OnMessage = (m) => { Console.WriteLine("mo got msg:" + m); if (allPlayerEventBuffer.TryGetValue(sid, out var eb)) { eb.CurrentEventsBuff.Add(new game_event() { Messages = new List <string>() { m } }); } }; var gmo = GrainClient.GrainFactory.CreateObjectReference <IMapObserver>(token.CurrMapObserver); token.CurrentMapGrain = gMap; token.SubscribedMapObserver = gmo.Result; gMap.Subscribe(gmo.Result); for (int i = 0; i < r.Length; i++) { var pbi = r[i]; list.Add(new player_base_info() { Map_id = pbi.LastMapId, Player_name = pbi.PlayerName, Last_map_pos = new vector3() { X = pbi.LastMapPos.x, Y = pbi.LastMapPos.y, Z = pbi.LastMapPos.z } }); } } } return(list); }
public void AddHelm2(Helm item) { string id = convertToKey(item.GetComponent <PhotonView>().ViewID); helm = item; AllTokens.Add(id, (Helm)item); if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
public void RemoveGold2(int viewID) { numOfGold--; AllTokens.Remove(convertToKey(viewID)); golds.Remove(convertToKey(viewID)); if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); EventManager.TriggerGoldUpdate(GameManager.instance.findHero(parentHero)); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
public void AddSmallToken2(SmallToken smallToken) { string id = convertToKey(smallToken.GetComponent <PhotonView>().ViewID); smallTokens.Add(id, (SmallToken)smallToken); AllTokens.Add(id, (SmallToken)smallToken); if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
public void RemoveHelm2(int viewID) { if (helm.GetComponent <PhotonView>().ViewID == viewID) { helm = null; AllTokens.Remove(convertToKey(viewID)); } if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
public void addGold2(GoldCoin gold) { string id = convertToKey(gold.GetComponent <PhotonView>().ViewID); golds.Add(id, (GoldCoin)gold); AllTokens.Add(id, (GoldCoin)gold); numOfGold++; if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); EventManager.TriggerGoldUpdate(GameManager.instance.findHero(parentHero)); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
public void RemoveToken(int objectIndex) { if (objectIndex > AllTokens.Count - 1 || objectIndex < 0) { return; } Token token = AllTokens[objectIndex]; AllTokens.Remove(token); Type listType = Heroes.GetListType(); if (listType.IsCompatibleWith(token.GetType())) { Heroes.Remove((Hero)token); InventoryUICell.instance.ForceUpdate(this, cellID); return; } listType = Enemies.GetListType(); if (listType.IsCompatibleWith(token.GetType())) { Enemies.Remove((Enemy)token); InventoryUICell.instance.ForceUpdate(this, cellID); return; } listType = Farmers.GetListType(); if (listType.IsCompatibleWith(token.GetType())) { Farmers.Remove((Farmer)token); InventoryUICell.instance.ForceUpdate(this, cellID); return; } if (typeof(Well).IsCompatibleWith(token.GetType())) { Well = null; InventoryUICell.instance.ForceUpdate(this, cellID); return; } InventoryUICell.instance.ForceUpdate(this, cellID); }
public List <game_event> get_events(string sid) { if (string.IsNullOrWhiteSpace(sid)) { return(new List <game_event>()); } if (AllTokens.TryGetValue(sid, out var token)) { token.LastHeartBeat = DateTime.Now; } if (allPlayerEventBuffer.TryGetValue(sid, out var eb)) { var xx = eb.CurrentEventsBuff.ToList();//有必要拷贝一次? eb.SwapEventBuffList(); return(xx); } else { return(new List <game_event>()); } }
public bool join_game(string sid, string player_name) { // if (allPlayersBySid.TryGetValue(sid, out var bp)) { var res = bp.JoinGame(player_name); if (res.Result) { if (AllTokens.TryGetValue(sid, out var token)) { token.PlayerName = player_name; } } else { if (AllTokens.TryGetValue(sid, out var token)) { token.PlayerName = string.Empty; } } return(res.Result); } return(false); }
public void SetUserTokens(HttpResponse response, AllTokens tokens) { SetUserTokens(response, tokens?.AccessToken, tokens?.RefreshToken); }
public AllTokensReturn(AllTokens obj) { AccessToken = obj.AccessToken; RefreshToken = obj.RefreshToken; }