/// <summary> /// If disable is true, make sure to call Ready again later. This prevents spell casting. /// </summary> public void Cancel(bool disable) { if(mTarget != null) { mState = disable ? State.Inactive : State.None; mTarget = null; } }
public static IList <UnitEntity> GetHospitalsByVendor(string vendorId) { var sql = string.Format(@"SELECT {0} FROM units WHERE id IN ( SELECT hospital_id FROM vendor_hospitals where vendor_id = @p_vendor_id ) ORDER BY name", COLUMN_SQL); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId); var list = new List <UnitEntity>(); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var unit = new UnitEntity(); unit.Init(reader); list.Add(unit); } } return(list); }
/// <summary> /// 添加或编辑计量单位 /// </summary> /// <param name="entity"></param> /// <param name="isNew">添加或编辑</param> /// <returns></returns> public int Save(UnitEntity entity, bool isNew) { IMapper map = DatabaseInstance.Instance(); int ret = -2; if (isNew) { //检查编号是否已经存在 if (IsUnitCodeExists(entity)) { return(-1); } ret = map.Execute("insert into WM_UM(UM_CODE, UM_NAME) " + "values(@COD, @NAM)", new { COD = entity.UnitCode, NAM = entity.UnitName }); } else { //更新 ret = map.Execute("update WM_UM set UM_NAME = @NAM where UM_CODE = @COD", new { COD = entity.UnitCode, NAM = entity.UnitName }); } return(ret); }
public Telegraph(TelegraphDamageEntry telegraphDamageEntry, UnitEntity caster, Vector3 position, Vector3 rotation) { TelegraphDamage = telegraphDamageEntry; Caster = caster; Position = position; Rotation = rotation; }
public void ReplaceInputUnitTarget(UnitEntity newTarget) { var component = CreateComponent <InputUnitTargetComponent>(InputComponentsLookup.InputUnitTarget); component.target = newTarget; ReplaceComponent(InputComponentsLookup.InputUnitTarget, component); }
protected void Impact() { GetComponent <Rigidbody>().velocity = Vector3.zero; if (impactEffect != null) { GameObject impact = Instantiate(impactEffect); impact.transform.position = new Vector3(transform.position.x, transform.position.y + 5, transform.position.z); } if (damage != null) { UnitEntity unit = target.GetComponent <UnitEntity>(); if (unit != null) { unit.dealDamage(damage); } } foreach (ParticleSystem system in particleSystems) { system.Stop(); } foreach (Renderer renderer in renderers) { renderer.enabled = false; Debug.Log("disabling " + renderer); } finished = true; }
public static IList <UnitEntity> GetVendorsByHospitalUnit(string unitId) { var sql = string.Format(@"SELECT {0} FROM units WHERE id IN ( SELECT b.vendor_id FROM hospital_products a JOIN vendor_products b ON a.product_id=b.product_id WHERE a.unit_id = @p_unit_id ) ORDER BY name", COLUMN_SQL); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_unit_id", DbType.String, unitId); var list = new List <UnitEntity>(); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var unit = new UnitEntity(); unit.Init(reader); list.Add(unit); } } return(list); }
public static IList <UnitEntity> GetByBusinessType(string rootId, string userId, UnitBusinessType businessType) { var sql = string.Format(@"select {0} from units where root_id=@p_root_id and business_type=@p_business_type and id in (select unit_id from user_privilege where user_id=@p_user_id and unit_root_id=@p_root_id and operate=1) order by name", COLUMN_SQL); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_root_id", DbType.String, rootId); db.AddInParameter(dc, "p_user_id", DbType.String, userId); db.AddInParameter(dc, "p_business_type", DbType.Int32, (int)businessType); var list = new List <UnitEntity>(); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var entity = new UnitEntity(); entity.Init(reader); list.Add(entity); } } return(list); }
void Update() { if (Input.GetMouseButtonDown(0)) { var rayStart = Camera.main.ScreenToWorldPoint(Input.mousePosition); var hit = Physics2D.Raycast(rayStart, Vector2.zero, 0); if (hit.transform != null) { var link = hit.transform.GetComponent <EntityLink>(); if (link != null) { var entity = link.entity as UnitEntity; if (entity != null) { SelectedEntity = entity; } } } } if (Input.GetMouseButtonDown(1)) { if (SelectedEntity != null) { var input = GameController.Universe.Contexts.input.CreateEntity(); var dest = Camera.main.ScreenToWorldPoint(Input.mousePosition); input.AddInputUnitTarget(SelectedEntity); input.AddSetUnitDestination(dest); } } }
private static object Heal(Dictionary <string, object> args) { UnitEntity entity = (UnitEntity)args["entity"]; entity.Heal((float)args["amount"]); return(null); }
public void ExecuteAbility(UnitEntity self, World world) { List <string> abilities = self.Combat.Abilities; Dictionary <string, float> abilityScores = new Dictionary <string, float>(); Dictionary <string, Vector3Int> targets = new Dictionary <string, Vector3Int>(); foreach (string ability in abilities) { abilityScores.Add(ability, 0); targets.Add(ability, self.Position); } CalculateAbilityScores(self, world, abilityScores, targets); List <KeyValuePair <string, float> > scores = abilityScores.ToList(); scores.Sort(CompareAbilityScore); if (scores[0].Value > 0) { string id = scores[0].Key; Debug.Log(self.Name + " casting " + id); Ability ability = GlobalAbilityDictionary.GetAbility(id); self.Combat.CastAbility(ability, targets[id]); } }
private void HandleEffectSummonMount(UnitEntity target, SpellTargetInfo.SpellTargetEffectInfo info) { // TODO: handle NPC mounting? if (!(target is Player player)) { return; } if (player.VehicleGuid != 0u) { return; } var mount = new Mount(player, parameters.SpellInfo.Entry.Id, info.Entry.DataBits00, info.Entry.DataBits01, info.Entry.DataBits04); mount.EnqueuePassengerAdd(player, VehicleSeatType.Pilot, 0); // usually for hover boards /*if (info.Entry.DataBits04 > 0u) * { * mount.SetAppearance(new ItemVisual * { * Slot = ItemSlot.Mount, * DisplayId = (ushort)info.Entry.DataBits04 * }); * }*/ player.Map.EnqueueAdd(mount, player.Position); // FIXME: also cast 52539,Riding License - Riding Skill 1 - SWC - Tier 1,34464 // FIXME: also cast 80530,Mount Sprint - Tier 2,36122 }
public ActionResult GetUnit(decimal cd, string languageType) { M_UNIT unit = _context.M_UNITS.FirstOrDefault(x => x.UNIT_CD == cd); if (unit == null) { return(Ok(new Result { Status = 404, Message = string.Empty, Data = null })); } UnitEntity entity = new UnitEntity(); entity.cd = unit.UNIT_CD; if (string.IsNullOrEmpty(languageType) || languageType.Equals(Constant.LANGUAGE_VN)) { entity.name = unit.UNIT_NAME; } else { entity.name = unit.UNIT_NAME_EN; } return(Ok(new Result { Status = 200, Message = string.Empty, Data = entity })); }
public UnitEntity SpawnUnit(EntityView entityView) { if (!cardLookUp.ContainsKey(entityView.prototype)) { throw new System.Exception("Could not find a prototype '" + entityView.prototype); } PrototypeData prototype = cardLookUp[entityView.prototype]; if (string.IsNullOrEmpty(prototype.unitPrefab)) { throw new System.Exception("Prototype does not have a unitPrefab associated with it."); } GameObject prefab = AssetManager.Instance.GetUnitPrefab(prototype.unitPrefab); if (prefab == null) { throw new System.Exception("Could not find prefab '" + prototype.unitPrefab + "'"); } GameObject go = Instantiate(prefab); UnitEntity unit = go.GetComponent <UnitEntity>(); unit.EntityView = entityView; AddEntity(unit); if (unit == null) { Destroy(go); throw new System.Exception("Unit prefab did not have UnitEntity component"); } return(unit); }
public void Create(string description) { UnitEntity unit = new UnitEntity(); unit.Description = description; _unitRepository.Add(unit); }
public TileTargetSelector( UnitEntity selector, TileEntity[] tiles, Func <UnitEntity, TileEntity, TTarget> getTargetFromTileFunction, UnityAction <TTarget> onTileSelected ) { _tiles = tiles; foreach (var tile in _tiles) { Assert.IsTrue(tile.hasTile); Assert.IsTrue(tile.hasView); var con = tile.view.GameObject.GetComponent <TileController>(); con.Span.enabled = true; var target = getTargetFromTileFunction(selector, tile); if (target != null) { tile.AddTileAction(() => { onTileSelected(target); ClearSelection(); }); } } }
public static void Add(UnitEntity unit, Database db, DbTransaction trans) { var sql = string.Format(@"INSERT INTO units({0}) VALUES(@p_id, @p_name, @p_description, @p_contact_id, @p_short_code, @p_default_receipt_id, @p_type, @p_parent_id, @p_root_id, @p_business_type, @p_created_id, @p_created_time, @p_updated_id, @p_updated_time)", COLUMN_SQL); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_id", DbType.String, unit.Id); db.AddInParameter(dc, "p_name", DbType.String, unit.Name); db.AddInParameter(dc, "p_description", DbType.String, unit.Description); db.AddInParameter(dc, "p_contact_id", DbType.String, unit.ContactId); db.AddInParameter(dc, "p_short_code", DbType.String, unit.ShortCode); db.AddInParameter(dc, "p_default_receipt_id", DbType.String, unit.DefaultReceiptId); db.AddInParameter(dc, "p_type", DbType.Int32, unit.Type); db.AddInParameter(dc, "p_parent_id", DbType.String, unit.ParentId); db.AddInParameter(dc, "p_root_id", DbType.String, unit.RootId); db.AddInParameter(dc, "p_business_type", DbType.Int32, unit.BusinessType); db.AddInParameter(dc, "p_created_id", DbType.String, unit.CreatedId); db.AddInParameter(dc, "p_created_time", DbType.DateTime, unit.CreatedTime); db.AddInParameter(dc, "p_updated_id", DbType.String, unit.UpdatedId); db.AddInParameter(dc, "p_updated_time", DbType.DateTime, unit.UpdatedTime); db.ExecuteNonQuery(dc, trans); }
public void Update(int id, string description, double price, bool isAvailable, DateTime deliveryDate, int typeId, int unitId ) { ProductEntity productEntity = _productRepository.Get(id); if (productEntity != null) { UnitEntity unitEntity = _unitRepository.Get(unitId); TypeEntity typeEntity = _typeRepository.Get(typeId); if (unitEntity != null && typeEntity != null) { productEntity.Unit = unitEntity; productEntity.Type = typeEntity; productEntity.Description = description; productEntity.Price = price; productEntity.IsAvailable = isAvailable; productEntity.DelivaryDate = deliveryDate; productEntity.TypeId = typeId; productEntity.UnitID = unitId; _productRepository.Update(productEntity); } } }
public static IList <UnitEntity> GetApplyUnits(string userId, string hospitalId) { var sql = string.Format(@"SELECT {0} FROM units WHERE id IN (SELECT unit_id FROM user_privilege WHERE user_id=@p_user_id AND unit_root_id=@p_root_id AND operate=1) and id in (select distinct unit_id from hospital_products where hospital_id=@p_root_id) ORDER BY name", COLUMN_SQL); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_user_id", DbType.String, userId); db.AddInParameter(dc, "p_root_id", DbType.String, hospitalId); var list = new List <UnitEntity>(); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var unit = new UnitEntity(); unit.Init(reader); list.Add(unit); } } return(list); }
public static IList <UnitEntity> Query(string name, string rootId, int count = 20) { var sql = string.Format(@"select top {1} {0} from units where 1=1 and name like @p_name and root_id = @p_root_id order by name", COLUMN_SQL, count); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_name", DbType.String, "%" + name + "%"); db.AddInParameter(dc, "p_root_id", DbType.String, rootId); var list = new List <UnitEntity>(); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var entity = new UnitEntity(); entity.Init(reader); list.Add(entity); } } return(list); }
public static IList <UnitEntity> Query(string rootId, UnitType unitType) { var sql = string.Format("SELECT {0} FROM units WHERE type=@p_type and root_id=@p_root_id ORDER BY name", COLUMN_SQL); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_type", DbType.Int32, (int)unitType); db.AddInParameter(dc, "p_root_id", DbType.String, rootId); var list = new List <UnitEntity>(); using (IDataReader reader = db.ExecuteReader(dc)) { while (reader.Read()) { var entity = new UnitEntity(); entity.Init(reader); list.Add(entity); } } return(list); }
private void CalculateAbilityScores(UnitEntity self, World world, Dictionary <string, float> scores, Dictionary <string, Vector3Int> targets) { foreach (Vector3Int tile in world.GetAdjacents(self.Position)) { UnitEntity unit = world.UnitManager.GetUnitAt <UnitEntity>(tile); if (unit != null && unit.Combat.IsEnemy(self.Combat)) { scores["attack"] = 2; targets["attack"] = tile; break; } } Ability fireball = GlobalAbilityDictionary.GetAbility("fireball"); foreach (Vector3Int tile in fireball.GetWithinRange(self, world)) { int count = 0; foreach (Vector3Int area in fireball.GetAreaOfEffect(self.Position, tile, world)) { UnitEntity unit = world.UnitManager.GetUnitAt <UnitEntity>(area); if (unit != null && unit.Combat.IsEnemy(self.Combat)) { count++; } } float score = 2.5f * count; if (scores["fireball"] < score) { scores["fireball"] = score; targets["fireball"] = tile; } } }
public Transform CreateUnit(UnitEntity unitEnt, TilePosition posinfo) { var pos = posinfo.Point; Quaternion ur = UnitTemplate.rotation; Quaternion rot = new Quaternion(ur.x + 0.14f, ur.y, ur.z, ur.w); Vector3 unitvec = ConvertUnitPos(pos); var unitobj = (Transform)Instantiate(UnitTemplate, unitvec, rot); var info = unitobj.gameObject.AddComponent <UnitInformation>(); unitobj.gameObject.AddComponent <UnitViewHandler>(); unitobj.gameObject.AddComponent <UnitControllerHandler>(); info.SetEntity(unitEnt); UnitGraphics graphic = (UnitGraphics)GraphicFactory.ConstuctGraphic(unitEnt.getUnitType()); graphic.SetUnitObj(unitobj.gameObject); graphic.Initialize(this); info.SetGraphics(graphic); var viewhandler = unitobj.gameObject.GetComponent <UnitViewHandler>(); viewhandler.Factory = this; viewhandler.HealthBar = (Transform)Instantiate(this.HealthBarTemplate); viewhandler.HealthBar.GetComponent <HealthbarView>().SetPosition(pos); this.gameobjLookUp.Add(unitEnt, unitobj.gameObject); return(unitobj); }
public void Create(string description, double price, bool isAvailable, DateTime deliveryDate, int typeId, int unitId ) { UnitEntity unit = _unitRepository.Get(unitId); TypeEntity type = _typeRepository.Get(typeId); if (unit != null && type != null) { ProductEntity productEntity = new ProductEntity(); productEntity.Description = description; productEntity.Price = price; productEntity.IsAvailable = isAvailable; productEntity.DelivaryDate = deliveryDate; productEntity.TypeId = typeId; productEntity.UnitID = unitId; productEntity.Unit = unit; productEntity.Type = type; _productRepository.Add(productEntity); } }
/// <summary> /// 检查计量单位编码是否已存在 /// </summary> /// <param name="unit"></param> /// <returns></returns> private bool IsUnitCodeExists(UnitEntity unit) { IMapper map = DatabaseInstance.Instance(); string id = map.ExecuteScalar <string>("select UM_CODE from WM_UM where UM_CODE = @COD", new { COD = unit.UnitCode }); return(!string.IsNullOrEmpty(id)); }
public LinkedList <Vector3Int> GetMovementPath(UnitEntity self, Dictionary <Vector3Int, float> posScores) { List <KeyValuePair <Vector3Int, float> > scores = posScores.ToList(); scores.Sort(PositioningCompare); return(self.Movement.GetMoveables().GetPathTo(scores[0].Key)); }
private static object PauseAnimation(Dictionary <string, object> args) { UnitEntity entity = (UnitEntity)args["entity"]; entity.display.PauseAnimation(); return(null); }
private void HandleEffectRapidTransport(UnitEntity target, SpellTargetInfo.SpellTargetEffectInfo info) { TaxiNodeEntry taxiNode = GameTableManager.Instance.TaxiNode.GetEntry(parameters.TaxiNode); if (taxiNode == null) { return; } WorldLocation2Entry worldLocation = GameTableManager.Instance.WorldLocation2.GetEntry(taxiNode.WorldLocation2Id); if (worldLocation == null) { return; } if (!(target is Player player)) { return; } var rotation = new Quaternion(worldLocation.Facing0, worldLocation.Facing0, worldLocation.Facing2, worldLocation.Facing3); player.Rotation = rotation.ToEulerDegrees(); player.TeleportTo((ushort)worldLocation.WorldId, worldLocation.Position0, worldLocation.Position1, worldLocation.Position2); }
public void ReplaceTarget(UnitEntity newTarget) { var component = CreateComponent <TargetComponent>(BulletComponentsLookup.Target); component.value = newTarget; ReplaceComponent(BulletComponentsLookup.Target, component); }
private static object ChangeHP(Dictionary <string, object> args) { UnitEntity entity = (UnitEntity)args["entity"]; entity.ChangeHP((float)args["value"]); return(null); }
public CardAbilityCaller(CardActionGroup callerActionGroup, UnitEntity caster, CardEntity card) { _caster = caster; _card = card; _ability = _card.ability.Ability; _callerGroup = callerActionGroup; }
public void CastTo(UnitEntity target) { if(target != null && !target.isReleased) { mState = State.Casting; mStartTime = Time.time; mTarget = target; } }
/// <summary> /// Decrease count for selected units to recruit and update visual to recruit /// </summary> /// <param name="textbox"></param> /// <param name="entity"></param> /// <param name="count"></param> public void DecrCount(TextBox textbox, UnitEntity entity, int count) { if (count <= 0) return; _recruitmentCount[entity]--; textbox.Text = _recruitmentCount[entity].ToString(); UpdateTotalTroupsCost(); }
void Start() { this.unit = GameManager.Instance.GetEntity(data.entityId).GetComponent<UnitEntity>(); this.unit.AwaitingAck = false; this.unit.Deselect(); UnitSlot slot = GameManager.Instance.gameBoard.GetSlot(data.x, data.y); slot.Unit = unit; unit.lerper.SetPosition(slot.transform.position, moveTime); Debug.Log(unit + " is moving to " + slot.x + "," + slot.y); }
protected virtual void SpawnUnit() { hasSpawned = true; spawned = GameManager.Instance.SpawnUnit(summoned); spawned.transform.position = transform.position; UnitEntity unit = spawned.GetComponent<UnitEntity>(); unit.transform.localScale = new Vector3(0, 0, 0); targetSlot.Unit = unit; unit.lerper.SetScale(Vector3.one, 0.75f); }
/* public override bool IsBlocking { get { if (base.IsBlocking) return true; if (unit != null) return true; return base.IsBlocking; } } */ void Start() { unit = (UnitEntity)GameManager.Instance.GetEntity(data.entityId); transform.position = unit.transform.position; unit.Remove(); if(unit.deathPrefab != null) { Instantiate(unit.deathPrefab, unit.transform.position, Quaternion.identity); } }
void Start () { particleSystems = GetComponentsInChildren<ParticleSystem>(); unit = GetComponentInParent<UnitEntity>(); if(unit == null) { Debug.LogWarning("Disabled expected to be under UnitEntity"); enabled = false; } foreach (ParticleSystem ps in particleSystems) { var em = ps.emission; em.enabled = false; } }
public SpellInstance(UnitEntity unit, SpellBase spell) { mCurTime = 0; mTickStart = Time.fixedTime; mSpell = spell; if(unit.statusIndicator != null && unit.statusIndicator.curIcon != mSpell.icon) { unit.statusIndicator.Show(mSpell.icon, mSpell.duration); } if(mSpell.mod != null) { unit.stats.AddMod(mSpell.mod); } unit.StartCoroutine(DebuffUpdate(unit)); }
//remove, basically (used by something like dispell) public void Stop(UnitEntity unit) { if(alive) { if(unit.statusIndicator != null && unit.statusIndicator.curIcon == mSpell.icon) { unit.statusIndicator.Hide(); } if(mSpell.mod != null) { unit.stats.RemoveMod(mSpell.mod); } Remove(unit); mSpell = null; } }
public bool CanCastTo(UnitEntity target) { return mState == State.None && target != null && target.SpellCheck(mInfo.data); }
protected virtual void AutoAttackCheck(UnitEntity unit) { if(!(type == ActionType.Attack || type == ActionType.Retreat)) { ActionTarget target = unit.actionTarget; if(target != null && target.type == ActionType.Attack && target.vacancy && currentPriority <= target.priority) { currentTarget = target; } } }
/// <summary> /// Buy selected units (increment count and decrement ressources) /// </summary> /// <param name="unitEntity"></param> /// <param name="count"></param> private void Buy(UnitEntity unitEntity, int count) { var cost = UnitManager.Instance.Units[unitEntity].GetUnitCost(); for (int i = 0; i < count; i++) { // when no more ressources if (!CheckRessourcesAvailability(cost)) { ErrorManager.Instance.AddError(new Error.Error() { Description = Error.Error.Type.RECRUITMENT_RESSOURCES_CAP }); return; } UnitManager.Instance.UnitsAvailables[unitEntity]++; } }
private void CheckField(UnitEntity unitEntity, TextBox textBox) { var unit = UnitManager.Instance.Units[unitEntity]; var space = unit.GetUnitStats().Space; var max = UnitManager.Instance.TotalUnits / space; var value = 0; var result = int.TryParse(textBox.Text, out value); if (!result) return; _recruitmentCount[unitEntity] = value; if (value > max) { _recruitmentCount[unitEntity] = max; } textBox.Text = _recruitmentCount[unitEntity].ToString(); }
/// <summary> /// Increase count of selected units to recruit and update visual to recruit /// </summary> /// <param name="textbox"></param> /// <param name="entity"></param> /// <param name="count"></param> public void IncrCount(TextBox textbox, UnitEntity entity, int count) { var unit = UnitManager.Instance.Units[entity]; var space = unit.GetUnitStats().Space; var max = UnitManager.Instance.TotalUnits/space; _recruitmentCount[entity]++; if (_recruitmentCount[entity] > max) _recruitmentCount[entity] = max; textbox.Text = _recruitmentCount[entity].ToString(); UpdateTotalTroupsCost(); }
public void PlaceUnit(UnitEntity unit) { int row = unit.EntityView.row; int col = unit.EntityView.column; UnitSlot slot = unitSlots[col,row]; if(slot == null) { throw new System.Exception("Missing slot: " + col + "x" + row); } if(slot.Unit != null) { Debug.LogError("Slot already has a unit, that shouldn't happen"); } slot.Unit = unit; unit.transform.localPosition = Vector3.zero; unit.transform.localRotation = Quaternion.identity; }
// Use this for initialization void Start() { UnitInformation info = this.gameObject.GetComponent<UnitInformation>(); entity = info.Entity; graphics = info.Graphics; direction = new Vector(entity.PositionAs<TilePosition>().Point, new Point(0, 0)).Direction; //this.gameObject.renderer.material.color = info.ControllerInfo.FocusColor; entity.Register(new Trigger<ActionHandShakeInqueryEvent<MoveAction>>(evt => evt.Action.HandShakeRequired = true)); entity.Register(new Trigger<ActionStartingEvent<MoveAction>>(OnStartMoveAction)); entity.Register(new Trigger<BeginMoveEvent>(OnUnitBeginMove)); entity.Register(new Trigger<UnitTakesDamageEvent>(OnTakeDamage)); entity.Register(new Trigger<ActionStartingEvent<MovePathAction>>(OnUnitBeginPathMove)); entity.Register(new Trigger<ActionCompletedEvent<MovePathAction>>(OnUnitFinishPathMove)); entity.Register(new Trigger<UnitDieEvent>(OnUnitDeath)); this.HealthBar.GetComponent<HealthbarView>().SetHealthPct(this.entity.Module<HealthModule>().HealthPct); this.HealthBar.parent = this.transform; this.graphics.UseUnitAnimation(StandardUnitAnimations.Idle); }
//when update needs to start again public void Resume(UnitEntity unit) { if(alive) { if(unit.statusIndicator != null && unit.statusIndicator.curIcon == mSpell.icon) { unit.statusIndicator.Show(mSpell.icon, mSpell.duration - mCurTime); } mTickStart = Time.fixedTime; unit.StartCoroutine(DebuffUpdate(unit)); } }
//for both summon/unsummon private void ApplySummon(ActMode toMode) { if(mCurActMode != toMode) { //revert previous switch(mCurActMode) { case ActMode.Normal: mCursor.RevertToNeutral(); break; case ActMode.Summon: break; case ActMode.UnSummon: //revert currently selected unsummon if(mCurUnSummonUnit != null && !mCurUnSummonUnit.isReleased) { mCurUnSummonUnit.FSM.SendEvent(EntityEvent.Resume); mCurUnSummonUnit = null; } break; } mCurActMode = toMode; switch(mCurActMode) { case ActMode.Normal: player.state = EntityState.normal; UpdateAttackSensorDisplay(); break; case ActMode.Summon: player.state = EntityState.castSummon; break; case ActMode.UnSummon: player.state = EntityState.castUnSummon; break; } } }
//unit is also about to be destroyed or released to entity manager void OnGroupUnitRemove(FlockUnit unit) { FlockActionController actionListen = unit.GetComponent<FlockActionController>(); if(actionListen != null) { actionListen.defaultTarget = null; actionListen.leader = null; } UnitEntity ent = unit.GetComponent<UnitEntity>(); if(ent != null) { //check unsummoning if(mCurActMode == ActMode.UnSummon && mCurUnSummonUnit == ent) { //refund based on hp percent mPlayer.stats.curResource += ent.stats.loveHPScale; mCurUnSummonUnit = null; } } }
// Update is called once per frame void Update() { switch(mState) { case State.Inactive: case State.None: break; case State.Casting: if(Time.time - mStartTime >= mInfo.castDelay) { if(mTarget != null && !mTarget.isReleased) { mTarget.SpellAdd(mInfo.data); mTarget = null; if(castDoneCallback != null) { castDoneCallback(this); } } mStartTime = Time.time; mState = State.Cooldown; } break; case State.Cooldown: if(Time.time - mStartTime >= mInfo.cooldown) { mState = State.None; } break; } }
IEnumerator DebuffUpdate(UnitEntity unit) { while(alive) { if(mCurTime < mSpell.duration) { mCurTime += Time.fixedDeltaTime; if(mSpell.tickDelay > 0.0f && Time.fixedTime - mTickStart > mSpell.tickDelay) { Tick(unit); mTickStart = Time.fixedTime; } yield return new WaitForFixedUpdate(); } else { Stop(unit); unit.SpellRemoveDead(); } } yield break; }
public virtual SpellInstance Start(UnitEntity unit) { return new SpellInstance(unit, this); }
private void GrabUnSummonUnit() { PlayerGroup grp; grp = (PlayerGroup)FlockGroup.GetGroup(mPlayer.stats.flockGroup); mCurUnSummonUnit = grp.GrabUnit(mTypeSummons[mCurSummonInd].data.type, ActionTarget.Priority.High); if(mCurUnSummonUnit != null) { mCurUnSummonUnit.FSM.SendEvent(EntityEvent.Remove); } }
protected virtual void Remove(UnitEntity unit) { }
void SummonUnitSpawned(SummonController summonController, UnitEntity ent) { mTypeSummons[(int)ent.stats.type].UpdateSummonQueueAmount(-1); }
protected virtual void Tick(UnitEntity unit) { }