/// <summary> /// /// </summary> /// <param name="local"></param> /// <param name="distant"></param> public AbstractEntityExchange(ExchangeTypeEnum type, AbstractEntity local, AbstractEntity distant) : base(type) { m_local = local; m_distant = distant; if (m_local.Inventory == null || m_distant.Inventory == null) { Logger.Debug("EntityExchange : exchange with an entity that hasnt an inventory."); } m_exchangedItems = new Dictionary <long, Dictionary <long, int> >() { { m_local.Id, new Dictionary <long, int>() }, { m_distant.Id, new Dictionary <long, int>() }, }; m_exchangedKamas = new Dictionary <long, long>() { { m_local.Id, 0 }, { m_distant.Id, 0 }, }; m_validated = new Dictionary <long, bool>() { { m_local.Id, false }, { m_distant.Id, false }, }; }
public IEnumerator EndConversation(AbstractEntity argEntity) { if (argEntity is Speaker) { //Go to idle pose ThirdPersonCamera.offset -= new Vector3(1, 1, 0) * 0.25f; ThirdPersonCamera.distance += 0.5f; ThirdPersonCamera.height -= 0.5f; AbstractBeing being = argEntity.GetComponent<AbstractBeing>(); if(being != null) being.Animation.CrossFade(AnimationResources.Idle); yield return StartCoroutine(argEntity.Deactivate(Speaker)); // Re-Enable Controllers if (ThirdPersonController != null) ThirdPersonController.enabled = true; // Disable GUIs RemoteGUI.Label = ""; RemoteGUI.Action = null; //DialogueGUI.CurrentLine = null; DialogueGUI.TransOut = true; } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendFightsInformations(AbstractEntity entity) { foreach (var fight in FightManager.Fights) { fight.SendMapFightInfos(entity); } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SendPaddockInformations(AbstractEntity entity) { if (m_paddock != null) { m_paddock.SendInformations(entity); } }
/// <summary> /// Send to queue pool /// </summary> /// <param name="entityList"></param> public static void Send(params AbstractEntity[] entityList) { AbstractEntity temp = null; try { //modify season:异步调用时不能保证提交的顺序,造成更新到Redis中不是最后一次的 lock (entitySyncRoot) { foreach (var entity in entityList) { if (entity == null) { continue; //cacheCollection has changed } temp = entity; TransSend(entity); } } } catch (Exception ex) { TraceLog.WriteError("Post changed key:{0} error:{1}", GetQueueFormatKey(temp), ex); } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void SpawnEntity(AbstractEntity entity) { AddMessage(() => { if (!m_entityById.ContainsKey(entity.Id)) { m_entityById.Add(entity.Id, entity); if (m_subInstance) // For npc etc { entity.SetMap(this); } Dispatch(WorldMessage.GAME_MAP_INFORMATIONS(OperatorEnum.OPERATOR_ADD, entity)); AddUpdatable(entity); if (entity.Type == EntityTypeEnum.TYPE_CHARACTER) { InitializeOnFirstPlayerEnter(); m_playerCount++; m_entityByName.Add(entity.Name.ToLower(), entity); AddHandler(entity.Dispatch); SendAllInformations(entity); } } else { Logger.Error("MapInstance::SpawnEntity : an entity with the same id alrezdy exists : " + entity.Name); WorldService.Instance.AddUpdatable(entity); } }); }
internal void OnChangedNotify(AbstractEntity sender, CacheItemEventArgs e) { if (ChangedHandle != null) { ChangedHandle(sender, e); } }
/// <summary> /// /// </summary> /// <param name="redisKey"></param> /// <param name="entity"></param> /// <param name="itemSet"></param> /// <param name="periodTime"></param> /// <returns></returns> public static bool AddOrUpdateEntity(string redisKey, AbstractEntity entity, out CacheItemSet itemSet, int periodTime = 0) { itemSet = null; KeyValuePair <string, CacheItemSet> itemPair; if (TryGetCacheItem(redisKey, out itemPair, periodTime)) { itemSet = itemPair.Value; switch (itemPair.Value.ItemType) { case CacheType.Entity: itemPair.Value.SetItem(entity); entity.IsInCache = true; return(true); case CacheType.Dictionary: var set = itemPair.Value.ItemData as BaseCollection; if (set != null) { if (set.AddOrUpdate(itemPair.Key, entity, (k, t) => entity) == entity) { entity.IsInCache = true; return(true); } return(false); } break; default: TraceLog.WriteError("Not suported CacheType:{0} for GetPersonalEntity key:{1}", itemPair.Value.ItemType, redisKey); break; } } return(false); }
private void DoChangedNotify(AbstractEntity sender, CacheItemEventArgs eventArgs) { if (OnChangedNotify != null) { OnChangedNotify(sender, eventArgs); } }
private void SetEntityValue(AbstractEntity entity, SchemaColumn fieldAttr, object value) { string columnName = fieldAttr.Name; object fieldValue; if (fieldAttr.IsSerialized) { //指定序列化方式 if (fieldAttr.DbType == ColumnDbType.LongBlob || fieldAttr.DbType == ColumnDbType.Blob) { fieldValue = DeserializeBinaryObject(value, fieldAttr); } else { fieldValue = DeserializeJsonObject(value, fieldAttr); } if (fieldValue is EntityChangeEvent) { ((EntityChangeEvent)fieldValue).PropertyName = columnName; } } else { fieldValue = AbstractEntity.ParseValueType(value, fieldAttr.ColumnType); } if (fieldAttr.CanWrite) { entity.SetPropertyValue(columnName, fieldValue); } else { entity.SetFieldValue(columnName, fieldValue); } }
/// <summary> /// 检查是否有绑定事件,防止没有绑定导致数据丢失 /// </summary> /// <param name="data"></param> private void CheckEventBind(AbstractEntity data) { if (data == null || data.IsReadOnly) { return; } var schema = data.GetSchema(); if (!schema.HasObjectColumns) { return; } var columns = schema.GetObjectColumns(); foreach (var column in columns) { var temp = data.GetPropertyValue(column.Name) as IItemChangeEvent; if (temp != null && temp.ItemEvent.Parent == null) { temp.PropertyName = column.Name; data.AddChildrenListener(temp); temp.IsInCache = true; } } }
/// <summary> /// 创建主键 /// </summary> /// <param name="Generator"></param> public virtual void CreatePrimaryKey(IPKGenerator Generator) { AbstractEntity Entity = m_Entity as AbstractEntity; //创建主键 if (Generator == null) { throw new MappingException("创建主键生成器失败,主键生成器必须实现Draco.DB.ORM.AutoSQL.PKGenerator.IPKGenerator接口,请检查映射文件中主键生成器的配置信息!"); } Hashtable Next = Generator.GeneratNextPrimaryKey(m_Mapping); if (Next != null && Next.Count > 0) { foreach (string PropertyName in Next.Keys) { object NextValue = Next[PropertyName]; PropertyInfo Property = Entity.GetType().GetProperty(PropertyName); if (Property != null) { object _value = Convert.ChangeType(NextValue, Property.PropertyType); Property.SetValue(Entity, _value, null); } } } }
public override void ProcessEntity(AbstractEntity entity) { MovementDataComponent md = (MovementDataComponent)entity.GetComponent(nameof(MovementDataComponent)); PositionComponent pos = (PositionComponent)entity.GetComponent(nameof(PositionComponent)); if (md != null && pos != null) { if (md.route != null && md.route.Count > 0) // Do they have a path set up? { Point dest = md.route[0]; if (pos.x == dest.X && pos.y == dest.Y) { md.route.RemoveAt(0); // We're on the actual square. This should never happen! } else if (this.Move(entity, md, pos, dest)) { md.route.RemoveAt(0); } } else if (md.offX != 0 || md.offY != 0) { if (pos.x + md.offX >= 0 && pos.x + md.offX < this.map_data.getWidth() && pos.y + md.offY >= 0 && pos.y + md.offY < this.map_data.getHeight()) { this.Move(entity, md, pos, new Point(pos.x + md.offX, pos.y + md.offY)); } // Reset movement for next turn md.offX = 0; md.offY = 0; } } }
void ConvertAttributes(AST.TypeMember node, AbstractEntity to) { if (node.Attributes.Count == 0) { to.Attributes = DefaultAttribute.EmptyAttributeList; } else { ClassFinder context; if (to is IClass) { context = new ClassFinder((IClass)to, node.LexicalInfo.Line, node.LexicalInfo.Column); } else { context = new ClassFinder(to.DeclaringType, node.LexicalInfo.Line, node.LexicalInfo.Column); } foreach (AST.Attribute a in node.Attributes) { to.Attributes.Add(new DefaultAttribute(new AttributeReturnType(context, a.Name)) { CompilationUnit = _cu, Region = GetRegion(a) }); } } to.Documentation = node.Documentation; }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <param name="guid"></param> /// <param name="quantity"></param> public override int RemoveItem(AbstractEntity entity, long guid, int quantity) { if (m_caseItems.ContainsKey(guid)) { var item = entity.Inventory.Items.Find(entry => entry.Id == guid); if (quantity >= m_caseItems[guid]) { quantity = m_caseItems[guid]; m_caseItems.Remove(guid); } else { m_caseItems[guid] -= quantity; } m_templateQuantity[item.TemplateId] -= quantity; if (m_templateQuantity[item.TemplateId] == 0) { m_templateQuantity.Remove(item.TemplateId); } CheckCraftable(); var exists = m_caseItems.ContainsKey(guid); Character.Dispatch(WorldMessage.EXCHANGE_LOCAL_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_REMOVE, item.Id.ToString())); if (exists) { Character.Dispatch(WorldMessage.EXCHANGE_LOCAL_MOVEMENT(ExchangeMoveEnum.MOVE_OBJECT, OperatorEnum.OPERATOR_ADD, item.Id.ToString() + '|' + m_caseItems[guid])); } return(quantity); } return(0); }
public AbstractEntity Parser(string line) { AbstractEntity result = null; var lineArray = line.Split("ç"); switch (lineArray[0]) { case AbstractEntity.SALESMAN_TYPE_ID: result = SalesmanParser(lineArray); break; case AbstractEntity.CUSTOMER_TYPE_ID: result = CustomerParser(lineArray); break; case AbstractEntity.SALES_TYPE_ID: result = SalesParser(lineArray); break; default: break; } return(result); }
public override void OnAttached(AbstractEntity entity) { this.iceSpike = entity as Entity; this.constants = Game.Instance.Simulation.EntityManager["player_constants"]; this.templates = Game.Instance.ContentManager.Load <LevelData>("Level/Common/DynamicTemplates"); entity.GetProperty <CollisionProperty>("collision").OnContact += IceSpikeCollisionHandler; string targetPlayerName = entity.GetString("target_player"); if (targetPlayerName != "") { targetPlayer = Game.Instance.Simulation.EntityManager[targetPlayerName]; Game.Instance.Simulation.EntityManager.EntityRemoved += OnEntityRemoved; } else { targetPlayer = null; } shootingPlayer = Game.Instance.Simulation.EntityManager[entity.GetString("player")]; createdAt = Game.Instance.Simulation.Time.At; (entity as Entity).OnUpdate += OnUpdate; }
public override void OnDetached(AbstractEntity player) { base.OnDetached(player); this.player.GetStringAttribute("active_island").ValueChanged -= OnActiveIslandChanged; this.player.GetStringAttribute("destination_island").ValueChanged -= OnDestinationIslandChanged; }
/// <summary> /// /// </summary> /// <param name="actor"></param> /// <param name="guid"></param> /// <param name="quantity"></param> /// <param name="price"></param> public override int AddItem(AbstractEntity actor, long guid, int quantity, long price = -1) { switch (Npc.AuctionHouse.TryAdd(Character, guid, quantity, price)) { case AuctionAddResultEnum.INVALID_PRICE: Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_INVALID_PRICE)); break; case AuctionAddResultEnum.INVALID_TYPE: Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.INFO, InformationEnum.INFO_AUCTION_ADD_INVALID_TYPE)); break; case AuctionAddResultEnum.ERROR: case AuctionAddResultEnum.INVALID_FLOOR: case AuctionAddResultEnum.INVALID_ITEM: case AuctionAddResultEnum.INVALID_QUANTITY: case AuctionAddResultEnum.TOO_HIGH_LEVEL: Character.Dispatch(WorldMessage.OBJECT_MOVE_ERROR()); break; case AuctionAddResultEnum.TOO_MANY_ENTRIES: Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_AUCTION_HOUSE_TOO_MANY_ITEMS)); break; case AuctionAddResultEnum.NOT_ENOUGH_KAMAS_FOR_TAXE: Character.Dispatch(WorldMessage.INFORMATION_MESSAGE(InformationTypeEnum.ERROR, InformationEnum.ERROR_NOT_ENOUGH_KAMAS_FOR_TAXE)); break; } return(0); }
public void AddOrUpdate(AbstractEntity persistedEntity) { using (new WriteLockDisposable(_locker)) { throw new NotImplementedException(); } }
public void OnEntityEvent(EntityEventType ev, AbstractEntity entity, object parameters) { if (Done) { return; } try { switch (ev) { case EntityEventType.FIGHT_KILL: var monster = parameters as MonsterEntity; if (monster != null) { foreach (var killMonster in CurrentStep.Objectives .OfType <KillMonsterObjective>() .Where(killMonster => killMonster.MonsterTemplateId == monster.Grade.Template.Id)) { UpdateObjective(killMonster.Id, int.Parse, i => i + 1); } } break; } } catch (Exception e) { Logger.Error("CharacterQuest::OnEntityEvent failed to update quest", e); } }
/// <summary> /// 创建更新SQL语句 /// </summary> /// <param name="Paras"></param> /// <returns></returns> public string CreateUpdataSQL(out IDataParameter[] Paras) { Paras = null; AbstractEntity Entity = m_Entity as AbstractEntity; if (Entity.ChangedProperties.Count > 0) { StringBuilder sBuilderPairs = new StringBuilder(); IDataParameters list = CreateDataParameters(m_DBAdapter); foreach (string Property in Entity.ChangedProperties.Keys) { object PropertyValue = Entity.ChangedProperties[Property]; if (!IsPrimaryKeyProperty(Property))//更新的时候不更新主键 { string segment = ConvertOneExpressToSQL(Expression.Eq(Property, PropertyValue), list); sBuilderPairs.Append(segment + ","); } } sBuilderPairs.Remove(sBuilderPairs.Length - 1, 1);//去掉最后的逗号; //Where 子句 string where = GetPrimaryKeySQL(ref list); //组装SQL string UpdateSQL = String.Format(CommonSQL.SQL_UPDATE, AdaptedTableName, sBuilderPairs.ToString(), where); Paras = list.Parameters; return(UpdateSQL); } return(""); }
private static object DeserializeJsonObject(SchemaTable schemaTable, AbstractEntity entity, object value, SchemaColumn fieldAttr, string columnName) { try { if (fieldAttr.ColumnType.IsSubclassOf(typeof(Array))) { value = value.ToString().StartsWith("[") ? value : "[" + value + "]"; } string tempValue = value.ToNotNullString(); if (!string.IsNullOrEmpty(fieldAttr.JsonDateTimeFormat) && tempValue.IndexOf(@"\/Date(") == -1) { return(JsonUtils.DeserializeCustom(tempValue, fieldAttr.ColumnType, fieldAttr.JsonDateTimeFormat)); } else { return(JsonUtils.Deserialize(tempValue, fieldAttr.ColumnType)); } } catch (Exception ex) { TraceLog.WriteError("Table:{0} key:{1} column:{2} deserialize json error:{3} to {4}\r\nException:{5}", schemaTable.EntityName, entity.GetKeyCode(), columnName, value, fieldAttr.ColumnType.FullName, ex); } return(null); }
void Awake() { phase = INITIAL_PHASE; //if (trigger_door!=null) trigger_door.GetComponent<triggerDoor>().enabled = false; //Debug.Log("PlayerPrefs.GetString(\"player\"): " + PlayerPrefs.GetString("player")); string playerTemplate = PlayerPrefs.GetString("player"); if ( playerTemplate != null ) { Instantiate (Resources.Load (playerTemplate)); } GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player != null) { playerEntity = player.GetComponent<AbstractEntity>(); } GameObject[] goSpawnPoints = GameObject.FindGameObjectsWithTag ("Spawner"); spawnPoints = new Transform[goSpawnPoints.Length]; for (int i=0; i<goSpawnPoints.Length; i++) { spawnPoints[i] = goSpawnPoints[i].transform; } if (playerEntity != null) { phase = INITIAL_PHASE; InvokeRepeating ("phase_control",0f,2.5f); } }
/// <summary> /// 以同步的方式更新Entity /// </summary> /// <param name="entityList"></param> public static bool SendSync(IEnumerable <AbstractEntity> entityList) { var keyList = new List <byte[]>(); var valueList = new List <byte[]>(); foreach (var entity in entityList) { if (entity == null) { continue; } entity.TempTimeModify = MathUtils.Now; string key = GetQueueFormatKey(entity); var keyValues = key.Split('_', '|'); int id = AbstractEntity.DecodeKeyCode(keyValues[1]).ToInt(); string keyCode = keyValues[2]; string redisKey = string.Format("{0}_{1}", keyValues[0], keyCode); byte[] idBytes = BufferUtils.GetBytes(id); var keyBytes = RedisConnectionPool.ToByteKey(redisKey); byte[] entityBytes; bool isDelete = entity.IsDelete; entityBytes = _serializer.Serialize(entity); //modify resean: set unchange status. entity.Reset(); byte[] stateBytes = BufferUtils.GetBytes(isDelete ? 1 : 0); byte[] values = BufferUtils.MergeBytes(BufferUtils.GetBytes(idBytes.Length + stateBytes.Length), idBytes, stateBytes, entityBytes); keyList.Add(keyBytes); valueList.Add(values); } return(ProcessRedisSyncQueue(string.Empty, keyList.ToArray(), valueList.ToArray())); }
/// <summary> /// Get entity from redis, but not surported mutil key of entity. /// </summary> /// <param name="personalId"></param> /// <param name="types"></param> /// <returns></returns> public static object[] Load(string personalId, params Type[] types) { personalId = AbstractEntity.EncodeKeyCode(personalId); var param = types.Where(t => !CacheFactory.ContainEntityKey(t, personalId)).ToArray(); if (param.Length == 0) { return(null); } var result = RedisConnectionPool.GetAllEntity(personalId, param); foreach (var t in result) { var entity = t as AbstractEntity; if (entity == null) { continue; } CacheItemSet itemSet; if (CacheFactory.AddOrUpdateEntity(entity, out itemSet)) { itemSet.OnLoadSuccess(); } } return(result); }
/// <summary> /// Send to queue pool /// </summary> /// <param name="entityList"></param> public static void Send(params AbstractEntity[] entityList) { AbstractEntity temp = null; try { //modify season:异步调用时不能保证提交的顺序,造成更新到Redis中不是最后一次的 var expireList = new List <AbstractEntity>(); foreach (var entity in entityList) { if (entity == null) { continue; } if (entity.IsExpired || !entity.IsInCache) { expireList.Add(entity); continue; } temp = entity; TransSend(entity); } if (expireList.Count > 0) { SendSync(expireList); } } catch (Exception ex) { TraceLog.WriteError("Post changed key:{0} error:{1}", GetQueueFormatKey(temp), ex); } }
public void StartCombat(AbstractEntity attacker, AbstractEntity target) { this.Show(); this.attacker = attacker; this.target = target; UpdateFightInfo(); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual bool Validate(AbstractEntity entity) { m_validated[entity.Id] = m_validated[entity.Id] == false; // inverse de la valeur actuelle base.Dispatch(WorldMessage.EXCHANGE_VALIDATE(entity.Id, m_validated[entity.Id])); if (m_validated.All(entry => entry.Value)) { foreach (var kv in m_exchangedItems[m_local.Id]) { m_distant.Inventory.AddItem(m_local.Inventory.RemoveItem(kv.Key, kv.Value)); } foreach (var kv in m_exchangedItems[m_distant.Id]) { m_local.Inventory.AddItem(m_distant.Inventory.RemoveItem(kv.Key, kv.Value)); } m_local.Inventory.SubKamas(m_exchangedKamas[m_local.Id]); m_distant.Inventory.SubKamas(m_exchangedKamas[m_distant.Id]); m_local.Inventory.AddKamas(m_exchangedKamas[m_distant.Id]); m_distant.Inventory.AddKamas(m_exchangedKamas[m_local.Id]); return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="actor"></param> /// <param name="guid"></param> /// <param name="quantity"></param> public override void SellItem(AbstractEntity entity, long guid, int quantity, long price = -1) { if (quantity < 1) { Logger.Debug("ShopExchange unable to sell, quantity < 1 : " + entity.Name); entity.Dispatch(WorldMessage.EXCHANGE_SELL_ERROR()); return; } var item = entity.Inventory.Items.Find(entry => entry.Id == guid); if (item == null) { Logger.Debug("ShopExchange unable to sell null item : " + entity.Name); entity.Dispatch(WorldMessage.EXCHANGE_SELL_ERROR()); return; } if (quantity > item.Quantity) { quantity = item.Quantity; } var sellPrice = (item.Template.Price / 10) * quantity; entity.Inventory.RemoveItem(guid, quantity); entity.Inventory.AddKamas(sellPrice); }
public override void OnDetached(AbstractEntity flame) { (flame as Entity).OnUpdate -= OnUpdate; flame.GetProperty <CollisionProperty>("collision").OnContact -= FlamethrowerCollisionHandler; flame.GetBoolAttribute(CommonNames.Fueled).ValueChanged -= FlameFuelChangeHandler; player.GetVector3Attribute(CommonNames.Position).ValueChanged -= PlayerPositionHandler; }
/// <summary> /// 确认主键是否有值 /// </summary> /// <returns></returns> public virtual bool CheckePrimaryKey() { AbstractEntity Entity = m_Entity as AbstractEntity; if (Entity.ChangedProperties != null && m_Mapping.PrimaryKeyCollection.Count > 0) { bool HasValue = true; foreach (IPrimaryKeyMapping mapping in m_Mapping.PrimaryKeyCollection) { if (!Entity.ChangedProperties.ContainsKey(mapping.PropertyName)) { //进一步检查主键属性是否有值,因为如果对象是由Handle查询创建的,那么修改的属性中是没有主键的 PropertyInfo property = Entity.GetType().GetProperty(mapping.PropertyName); object val = property.GetValue(Entity, null); if (val == null || val == DBNull.Value || Convert.ToString(val) == "" || Convert.ToString(val) == "0") { HasValue = false;//有一个主键没有值就要重新生成主键 } } } if (HasValue)//所有的主键都有值,那就返回了 { return(true); } } return(false); }
/// <summary> /// /// </summary> /// <param name="character"></param> public EntityInventory(AbstractEntity entity, int type, long id) : base(type, id) { m_equippedSets = new Dictionary<int, int>(); Entity = entity; AddHandler(Entity.Dispatch); }
public IEnumerator Open(AbstractEntity argEntity) { //debug.log(argEntity.name); ////debug.log("OPEN: " + name); Transform.parent.animation.Play("Open"); while (Transform.parent.animation.IsPlaying("Open")) yield return new WaitForFixedUpdate(); }
protected IEnumerator CloseDoor(AbstractEntity argEntity) { //// Wait on Delay //if (_IsTimedDoor) // yield return new WaitForSeconds(_DoorCloseDelay); StartCoroutine(argEntity.Deactivate(Speaker)); yield return new WaitForFixedUpdate(); }
public IEnumerator Drop(AbstractEntity argEntity) { foreach (DialogueEvent dialogueEvent in _DialogueDropEvents) if(dialogueEvent) dialogueEvent.Execute(); ////debug.log("DROP"); Collider.isTrigger = false; Rigidbody.useGravity = true; Rigidbody.isKinematic = false; yield return new WaitForFixedUpdate(); }
void Awake(){ myState = this.gameObject.GetComponent<AbstractEntity>(); ai = this.gameObject.GetComponent<BasicAI>(); set(myState.getMAXHP(),myState.getMAXMP(),myState.getHP(),myState.getMP(),leftX,topY,width,height); // animation timeLeftAnimationChange = timeBetweenAnimation; animationHealthForward = true; animationManaForward = false; animationHealthIndex = 0; animationManaIndex = 0; }
public IEnumerator Close(AbstractEntity argEntity) { yield return new WaitForSeconds(_DoorCloseDelay); while (Transform.parent.animation.IsPlaying("Open")) yield return new WaitForFixedUpdate(); ////debug.log("CLOSE: " + name); Transform.parent.animation.Play("Close"); while (Transform.parent.animation.IsPlaying("Close")) yield return new WaitForFixedUpdate(); }
public IEnumerator Pickup(AbstractEntity argEntity) { foreach (DialogueEvent dialogueEvent in _DialoguePickupEvents) { //debug.log(argEntity.name); if (dialogueEvent) dialogueEvent.Execute(argEntity as Speaker); } ////debug.log("PICKUP"); Collider.isTrigger = true; Rigidbody.useGravity = false; Rigidbody.isKinematic = true; yield return new WaitForFixedUpdate(); }
protected IEnumerator OpenDoor(AbstractEntity argEntity) { // Activate Door StartCoroutine(argEntity.Activate(Speaker)); // Target No Longet Needed Target = null; //// Wait Till Out of View //while (FindTarget() == argEntity) // yield return new WaitForFixedUpdate(); StartCoroutine(PowerOff(argEntity)); yield return new WaitForFixedUpdate(); }
protected IEnumerator DropItem(AbstractEntity argEntity) { StartCoroutine(argEntity.Deactivate(Speaker)); //Vision.objectsInRadius.Remove(argEntity.GameObject); //_StoredTarget.Drop(); argEntity.rigidbody.useGravity = true; argEntity.rigidbody.isKinematic = false; argEntity.collider.isTrigger = false; argEntity.Transform.parent = null; argEntity.Transform.position += Vector3.up * .25f; yield return new WaitForSeconds(1); }
// ATTACK public void attack(AbstractEntity enemy, Vector3 enemyPos){ if(this.isAlive() && enemy.isAlive()){ this.lookAt (enemyPos); if (timeForNextAction<=0){ if (animator.GetBool("attack_enabled")) animator.SetBool ("attack_enabled", false); if (animator.GetBool("walk_enabled")) animator.SetBool ("walk_enabled", false); if (!animator.GetBool("attack_enabled")) animator.SetBool ("attack_enabled", true); PNJAudio.PlayOgreHit(); enemy.onAttackReceived (DMG); timeForNextAction = timecost_perAction; } }else if (animator.GetBool("attack_enabled")){ animator.SetBool("attack_enabled",false); } }
/// <summary> /// entity data send to client /// </summary> /// <param name="sender"></param> /// <param name="eventargs"></param> public static void OnChange(AbstractEntity sender, CacheItemEventArgs eventargs) { try { if (sender == null || (sender as BaseEntity) == null || !sender.GetSchema().IsEntitySync) { return; } string key = sender.GetKeyCode(); if (!_syncPools.ContainsKey(key)) { _syncPools[key] = true; _sendQueue.Enqueue(sender as BaseEntity); singal.Set(); } } catch (Exception ex) { TraceLog.WriteError("EntitySync Notify error:{0}", ex); } }
void ConvertAttributes(AST.AttributedNode from, AbstractEntity to) { if (from.Attributes.Count == 0) { to.Attributes = DefaultAttribute.EmptyAttributeList; } else { ICSharpCode.NRefactory.Location location = from.Attributes[0].StartLocation; ClassFinder context; if (to is IClass) { context = new ClassFinder((IClass)to, location.Line, location.Column); } else { context = new ClassFinder(to.DeclaringType, location.Line, location.Column); } to.Attributes = VisitAttributes(from.Attributes, context); } }
// ATTACK public void attack(AbstractEntity enemy, Vector3 enemyPos){ this.lookAt(enemyPos); if(this.isAlive() && enemy.isAlive()){ if (timeForNextAction<=0){ float randomNumber = Random.Range(0f,100f); if (randomNumber<25){ if (animator.GetBool("attack_enabled")) animator.SetBool ("attack_enabled", false); if (!animator.GetBool("critical")) animator.SetBool ("critical", true); PNJAudio.PlayCriticalAttack(); // PlayAttackOK enemy.onAttackReceived (4*DMG); timeForNextAction = timecost_perAction; }else{ if (animator.GetBool("critical")) animator.SetBool ("critical", false); if (!animator.GetBool("attack_enabled")) animator.SetBool ("attack_enabled", true); PNJAudio.PlayAttackOK(); // PlayCriticalAttack enemy.onAttackReceived (DMG); timeForNextAction = timecost_perAction; } } }else if (animator.GetBool("attack_enabled")){ animator.SetBool("attack_enabled",false); }else if (animator.GetBool("critical")){ animator.SetBool("critical",false); } }
private void DoChangedNotify(AbstractEntity sender, CacheItemEventArgs eventArgs) { if (OnChangedNotify != null) { OnChangedNotify.BeginInvoke(sender, eventArgs, null, null); } }
public void AddEntity(AbstractEntity entity) { entities.Add(entity); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="eventargs"></param> protected virtual void DoChangedNotify(AbstractEntity sender, CacheItemEventArgs eventargs) { EntityChangedNotifyEvent handler = OnChangedNotify; if (handler != null) handler(sender, eventargs); }
/// <summary> /// Deactivate the Object /// </summary> public IEnumerator Deactivate(AbstractEntity argEntity) { Active = false; if (OnDeactivate != null) yield return StartCoroutine(OnDeactivate(argEntity)); }
protected bool FindClimbableSurface(AbstractEntity argEntity) { return argEntity.GetType() == typeof(IvyClimbingBox); }
private bool FindClosestDoor(AbstractEntity argEntity) { Door door = argEntity as Door; return door != null && !door.Active && door.CanOpen(GetComponent<Speaker>()); }
public float Distance(AbstractEntity argObject) { return Vector3.Distance(argObject.transform.position, Transform.position); }
protected IEnumerator StopClimbing(AbstractEntity argEntity) { StartCoroutine(argEntity.Deactivate(Speaker)); GetComponent<ThirdPersonController>().enabled = true; GetComponent<ThirdPersonController>()._Gravity = 20; climbCheck = false; yield return new WaitForFixedUpdate(); }
public IEnumerator Absorb(AbstractEntity argEntity) { StartCoroutine(argEntity.LerpAlpha(0, 0.3f)); StartCoroutine(argEntity.ShrinkTo(Vector3.zero, 1)); yield return StartCoroutine(argEntity.MoveTo(Transform.position, 1)); if (renderer != null) renderer.enabled = false; }
protected IEnumerator StartClimbing(AbstractEntity argEntity) { StartCoroutine(argEntity.Activate(Speaker)); GetComponent<ThirdPersonController>().enabled = false; animation[AnimationResources.Climb].speed = 1.5f; GameObject.animation.CrossFade(AnimationResources.Climb); GetComponent<ThirdPersonController>()._Gravity = 0; GetComponent<ThirdPersonController>().MoveSpeed = 0; climbCheck = true; yield return new WaitForFixedUpdate(); }
/* /// <summary> /// /// </summary> private void BindEvent(object obj) { AddChildrenListener(obj); } /// <summary> /// 当前对象(包括继承)的属性触发通知事件 /// </summary> /// <param name="sender">触发事件源</param> /// <param name="eventArgs"></param> protected override void Notify(object sender, CacheItemEventArgs eventArgs) { //IItemChangeEvent val = sender as IItemChangeEvent; //if (val != null && !val.HasChanged) //{ // return; //} _hasChanged = true; PutToChangeKeys(sender as AbstractEntity); DoChangedNotify(sender as AbstractEntity, eventArgs); } /// <summary> /// 当前对象中的属性包含的子类触发通知事件,通知到此层为根 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> protected override void NotifyByChildren(object sender, CacheItemEventArgs eventArgs) { _hasChanged = true; PutToChangeKeys(sender as AbstractEntity); DoChangedNotify(sender as AbstractEntity, eventArgs); } private void DoChangedNotify(AbstractEntity sender, CacheItemEventArgs eventArgs) { if (OnChangedNotify != null) { OnChangedNotify(sender, eventArgs); } } internal void SetUnChange() { _hasChanged = false; } */ #endregion private void PutToChangeKeys(AbstractEntity entity) { DataSyncQueueManager.Send(entity); }
private void OnChangedNotify(AbstractEntity sender, CacheItemEventArgs e) { if (sender != null) { //���ﴦ��Model����֪ͨ Console.WriteLine("update:{0},{1},{2}", sender.GetType().Name, e.ChangeType, e.PropertyName); EntitySyncManger.OnChange(sender, e); } }
public void FindChanges(AbstractEntity newObject, AbstractEntity oldEntity, ChangeHandler changes) { newEntity = newObject; TraceChanges(newObject, oldEntity, changes, string.Empty); }
/// <summary> /// Send to queue pool /// </summary> /// <param name="entityList"></param> public static void Send(AbstractEntity[] entityList) { string key = ""; try { if (entityList == null || entityList.Length == 0) return; var groupList = entityList.GroupBy(t => t.GetIdentityId()); foreach (var g in groupList) { var valueList = g.ToList(); byte[][] keyBytes = new byte[valueList.Count][]; byte[][] valueBytes = new byte[valueList.Count][]; string queueKey = GetRedisSyncQueueKey(g.Key); byte[] idBytes = BufferUtils.GetBytes(g.Key); int index = 0; foreach (var entity in valueList) { key = string.Format("{0}_{1}", entity.GetType().FullName, entity.GetKeyCode()); keyBytes[index] = RedisConnectionPool.ToByteKey(key); byte[] stateBytes = BufferUtils.GetBytes(entity.IsDelete ? 1 : 0); valueBytes[index] = BufferUtils.MergeBytes( BufferUtils.GetBytes(idBytes.Length + stateBytes.Length), idBytes, stateBytes, ProtoBufUtils.Serialize(entity)); index++; } RedisConnectionPool.Process(client => client.HMSet(queueKey, keyBytes, valueBytes)); } } catch (Exception ex) { TraceLog.WriteError("Post changed key:{0} error:{1}", key, ex); } }