public IActionResult CreateBeast(Beast beast) { _context.Beasts.Add(beast); _context.SaveChanges(); return(CreatedAtRoute("GetBeast", new { id = beast.id }, beast)); }
public virtual void OnCastSkillEffect(CastSkillParam castSkillParam) { if (castSkillParam != null) { Beast beast = Singleton <BeastManager> .singleton.GetBeastById(castSkillParam.m_unMasterBeastId); if (beast != null) { DataSkillShow data = beast.GetSkillShow(this.m_unskillId); int attackEffectId = 0; int beAttackEffectId = 0; this.GetEffectId(beast.Id, ref attackEffectId, ref beAttackEffectId); if (castSkillParam.listTargetRoleID.Count == 1) { this.m_nEffectId = EffectManager.Instance.PlayEffect(attackEffectId, beast.Id, Hexagon.GetHex3DPos(this.GetHeroPosByCastSkillParam(castSkillParam), Space.World) , null, castSkillParam.listTargetRoleID[0], Hexagon.GetHex3DPos(castSkillParam.vec3TargetPos, Space.World), null, Vector3.zero); } if (data != null && data.IsEffectForward) { this.AdjustAttackDirection(castSkillParam, beast); } } } }
public override void Process() { Beast beast = Singleton <BeastManager> .singleton.GetBeastById(this.m_dwRoleId); if (beast != null) { int hp = beast.Hp; int hpChange = this.m_btHp - hp; Debug.Log("Hp Change:" + hpChange); if (!Singleton <RoomManager> .singleton.ProcessHpChangedAsync(this.m_dwRoleId, (byte)this.m_btHp)) { Singleton <BeastManager> .singleton.OnBeastHpChange(this.m_dwRoleId, this.m_btHp); } if (Singleton <SequenceShowManager> .singleton.CanRecevieMsg) { Debug.Log("HPfwefefef"); Singleton <SequenceShowManager> .singleton.OnMsg(this, hp); } else { HpChangeEvent hpChangeEvent = new HpChangeEvent(); hpChangeEvent.DurationTime = 0.5f; hpChangeEvent.BeastId = this.m_dwRoleId; hpChangeEvent.HpChange = hpChange; Singleton <ActEventManager> .singleton.AddEvent(hpChangeEvent); } } }
public void setBeast(Beast beast) { if (beast is Wolf) { this.wolf = (Wolf)beast; } }
/// <summary> /// 调整攻击者的方向 /// </summary> /// <param name="param"></param> /// <param name="masteBeast"></param> public virtual void AdjustAttackDirection(CastSkillParam param, Beast masteBeast) { Vector2 forward = Vector2.zero; if (null == param) { return; } if (param.listTargetRoleID.Count > 0) { if (param.listTargetRoleID[0] != masteBeast.Id) { Beast beAttacker = Singleton <BeastManager> .singleton.GetBeastById(param.listTargetRoleID[0]); if (beAttacker != null) { forward = beAttacker.RealPos2D - masteBeast.RealPos2D; masteBeast.Forward = forward; } } } else { Vector2 targetPos = Hexagon.GetHexPosByIndex(param.vec3TargetPos.nRow, param.vec3TargetPos.nCol, Space.World); forward = targetPos - masteBeast.RealPos2D; masteBeast.Forward = forward; } }
public void AddCow_ExcludePolarLionIsCalled_Test() { //1. Arrange var existingBooking = new Booking { ID = 1, Date = DateTime.Now.AddDays(1) }; var list = new List <Beast>(); var beast = new Beast { Name = "Koe", Type = "Boerderij" }; //list.Add(beast); beast.Booking.Add(existingBooking); _boekingsRepository.Setup(b => b.TempBooking).Returns(new BookingVM { ID = 2, Date = DateTime.Now }); _beastRepository.Setup(b => b.GetAll()).Returns(GetListLion()); _bookingscontroller = new BookingController(_boekingsRepository.Object, _beastRepository.Object, _accessoryRepository.Object, _contactpersonRepository.Object); //2. Act _bookingscontroller.AddCheckedAnimal(new BeastVM(beast)); //3. Assert _beastRepository.VerifySet(m => m.ExcludePolarLion = true); }
/// <summary> /// 根据神兽ID取得技能攻击的特效 /// </summary> /// <param name="beastId"></param> /// <param name="attackerEffectId"></param> /// <param name="beAttackerEffectId"></param> /// <returns></returns> public bool GetEffectId(long beastId, ref int attackerEffectId, ref int beAttackerEffectId) { Beast beast = Singleton <BeastManager> .singleton.GetBeastById(beastId); if (null == beast) { return(false); } //如果普通攻击的话,要根据神兽类型id * 100取得DataSkillShow else if (this.m_unskillId == 1) { DataSkillShow data = beast.GetSkillShow(beast.BeastTypeId * 100); if (data != null) { attackerEffectId = data.AttackerEffectId; beAttackerEffectId = data.BeAttackerEffectId; return(true); } else { this.m_log.Debug("找不到该技能"); } } else { DataSkillShow data = beast.GetSkillShow(this.m_unskillId); if (data != null) { attackerEffectId = data.AttackerEffectId; beAttackerEffectId = data.BeAttackerEffectId; return(true); } } return(false); }
private void Translate(Beast beast, IXUIListItem uiListItem, bool bSmooth) { if (beast != null && uiListItem != null) { if (null != beast.Object) { IXUIListHeadInfoItem iXUIListHeadInfoItem = uiListItem as IXUIListHeadInfoItem; if (iXUIListHeadInfoItem == null) { XLog.Log.Error("null == uiListItemHeadInfo"); } else { Vector3 movingPos = beast.MovingPos; movingPos.y += beast.Height + 2f; Vector3 position = Camera.main.WorldToScreenPoint(movingPos); Vector3 vector = Singleton <UIManager> .singleton.UICamera.ScreenToWorldPoint(position); Vector3 position2 = iXUIListHeadInfoItem.CachedGameObject.transform.position; Vector3 position3 = bSmooth ? Vector3.Lerp(position2, vector, 0.6f) : vector; iXUIListHeadInfoItem.CachedTransform.position = position3; Vector3 localPosition = iXUIListHeadInfoItem.CachedTransform.localPosition; localPosition.z = vector.z / 100f; iXUIListHeadInfoItem.CachedTransform.localPosition = localPosition; } } } }
public void AddLion_NoFarmAnimalsInList_Test() { //1. Arrange var existingBooking = new Booking { ID = 1, Date = DateTime.Now.AddDays(1) }; var list = new List <Beast>(); var beast = new Beast { Name = "Leeuw" }; //list.Add(beast); beast.Booking.Add(existingBooking); _boekingsRepository.Setup(b => b.TempBooking).Returns(new BookingVM { ID = 2, Date = DateTime.Now }); _beastRepository.Setup(b => b.GetAll()).Returns(GetListLion()); _bookingscontroller = new BookingController(_boekingsRepository.Object, _beastRepository.Object, _accessoryRepository.Object, _contactpersonRepository.Object); //2. Act var result = (RedirectToRouteResult)_bookingscontroller.AddCheckedAnimal(new BeastVM(beast)); //3. Assert _beastRepository.VerifySet(m => m.ExcludeFarm = true); }
private void UpdatePlayerHp(Beast beast, IXUIListHeadInfoItem uiListHeadInfoItem) { if (beast != null && null != uiListHeadInfoItem) { float rate = beast.Hp / beast.HpMax; IXUIProgress iXUIProgress = uiListHeadInfoItem.GetUIObject("pb_hp") as IXUIProgress; iXUIProgress.value = rate; CampData ourCampData = Singleton <RoomManager> .singleton.GetOurCampData(); CampData enemyCampData = Singleton <RoomManager> .singleton.GetEnemyCampData(); if (beast.eCampType == ourCampData.CampType) { uiListHeadInfoItem.SetSprite("sp_bighp", "BlueHeadInfo"); uiListHeadInfoItem.SetSprite("sp_hpred", "bluehp"); //uiListHeadInfoItem.SetSprite("Sprite_Light_Green", "Light_Green"); } else { uiListHeadInfoItem.SetSprite("sp_bighp", "RedHeadInfo"); uiListHeadInfoItem.SetSprite("sp_hpred", "redhp"); //uiListHeadInfoItem.SetSprite("Sprite_Light_Green", "Light_Red"); } } }
public override void Process() { //所有的神兽进入战斗等待阶段 ICollection <Beast> allBeasts = Singleton <BeastManager> .singleton.GetAllBeasts(); foreach (var beast in allBeasts) { Singleton <BeastManager> .singleton.OnBeastEnterRoleStage(this.m_dwRoleID, EClientRoleStage.ROLE_STAGE_WAIT, 0u); } XLog.Log.Debug("CPtcG2CNtf_StartGame"); Singleton <RoomManager> .singleton.BattleStartTime = Time.time; Singleton <RoomManager> .singleton.TimeLimitForSelectBornPos = this.m_wTimeLimit; Singleton <RoomManager> .singleton.SetCampMaxHp((uint)this.m_btEmpireHp, (uint)this.m_btLeagueHp); Singleton <RoomManager> .singleton.OnCampHpChange(ECampType.CAMP_EMPIRE, (uint)this.m_btEmpireHp); Singleton <RoomManager> .singleton.OnCampHpChange(ECampType.CAMP_LEAGUE, (uint)this.m_btLeagueHp); //初始化神兽战斗顺序 for (int i = 0; i < this.m_oPlayOrder.Count; i++) { Beast beast = Singleton <BeastManager> .singleton.GetBeastById(this.m_oPlayOrder[i]); if (null != beast) { beast.Order = i + 1; } } }
/// <summary> /// 刷新所有己方角色信息 /// </summary> public void RefreshAllRole() { if (Singleton <RoomManager> .singleton.MatchType == EMatchtype.MATCH_1C3) { if (base.Prepared) { List <Beast> list = Singleton <BeastManager> .singleton.GetAllBeastByCamp(Singleton <PlayerRole> .singleton.CampType); for (int i = 0; i < list.Count; i++) { IXUIListItem item = base.uiBehaviour.m_List_RoleList.GetItemByIndex(i); if (null == item) { item = base.uiBehaviour.m_List_RoleList.AddListItem(); } Beast beast = list[i]; item.Id = beast.Id; DataBeastlist data = GameData <DataBeastlist> .dataMap[beast.BeastTypeId]; int hp = beast.Hp; int hpMax = beast.HpMax; string text = string.Format("{0}/{1}", hp, hpMax); if (data != null) { item.SetText("lb_roleName", data.Name); //设置神兽名称 item.SetText("lb_life", text); //设置神兽血量 item.SetIconSprite(data.IconFile, UIManager.singleton.GetAtlasName(EnumAtlasType.Beast, data.IconFile)); } } } } }
/// <summary> /// 初始化神兽出生坐标,设置到这个格子坐标上然后初始化正方向 /// </summary> /// <param name="unBeastId"></param> /// <param name="vec3Hex"></param> public void InitBeastPos(long unBeastId, CVector3 vec3Hex) { Beast beast = this.GetBeastById(unBeastId); if (beast != null) { beast.Move(vec3Hex); beast.SetVisible(true); Singleton <ClientMain> .singleton.scene.RoleSetToInitialPos(beast.Id, vec3Hex); ECampType eCampType = ECampType.CAMP_EMPIRE; if (eCampType == beast.eCampType) { eCampType = ECampType.CAMP_LEAGUE; } //取得和该神兽对立阵营的基地坐标 CVector3 baseHexPos = Singleton <ClientMain> .singleton.scene.GetBasePos(eCampType); Vector3 baseHex3DPos = Hexagon.GetHex3DPos(baseHexPos, Space.World); Vector3 hex3DPos = Hexagon.GetHex3DPos(vec3Hex, Space.World); Vector3 vector = baseHex3DPos - hex3DPos; //然后得到神兽的正方向 beast.Forward = new Vector2(vector.x, vector.z); //SkillManager.NotifyHeroPosChange(unHeroId); } }
/// <summary> /// 选择地图格子点 /// </summary> /// <param name="vecHexPos"></param> /// <returns></returns> public bool OnSelectPos(CVector3 vecHexPos) { bool result; if (this.m_dicOpState[this.m_eOpStateCurrent].OnSelectPos(vecHexPos)) { this.m_oPos.nCol = vecHexPos.nCol; this.m_oPos.nRow = vecHexPos.nRow; result = true; } else { Beast beast = Singleton <BeastManager> .singleton.GetBeastByPos(vecHexPos); if (beast != null && !beast.IsError) { if (this.m_dicOpState[this.m_eOpStateCurrent].OnClickBeast(beast.Id)) { result = true; } } result = false; } return(result); }
public override void Trigger() { base.Trigger(); XLog.Log.Debug("HpChangeEvent:Trigger"); if (this.HpChange > 0) { //浮动加血文字显示 DlgBase <DlgFlyText, DlgFlyTextBehaviour> .singleton.AddHpEffect(this.HpChange, this.m_unBeastId, EnumHpEffectType.eHpEffectType_Heal); } else { DlgBase <DlgFlyText, DlgFlyTextBehaviour> .singleton.AddHpEffect(this.HpChange, this.m_unBeastId, EnumHpEffectType.eHpEffectType_Damage); //浮动扣血文字显示 int hpChange = this.HpChange; Beast beast = Singleton <BeastManager> .singleton.GetBeastById(this.BeastId); if (beast != null && !beast.IsError) { if (hpChange < 0) { //可能播放扣血的特效 } } } }
/// <summary> /// 技能cd改变 /// </summary> /// <param name="beastId"></param> /// <param name="skillId"></param> /// <param name="value"></param> /// <param name="msg"></param> public void OnCDChange(long beastId, int skillId, byte value, CPtcM2CNtf_CDChanged msg) { int type = skillId >> 16; int cdValue = (int)value; ECoolDownType eCoolDownType = (ECoolDownType)type; Beast beast = this.GetBeastById(beastId); if (beast != null) { switch (eCoolDownType) { case ECoolDownType.COOL_DOWN_SKILL: cdValue = beast.SkillManager.GetSkillCD(skillId); Singleton <BeastManager> .singleton.OnBeastSkillCDChange(beastId, skillId, (int)value); break; case ECoolDownType.COOL_DOWN_EQUIP: break; } if (!beast.IsDead) { if (Singleton <SequenceShowManager> .singleton.CanRecevieMsg) { Singleton <SequenceShowManager> .singleton.OnMsg(msg, cdValue); } } } }
public IEnumerator DoAnimation(int distance, Beast newBeast, string direction) { float time = distance * .05f; while (time > 0) { time -= Time.deltaTime; yield return null; } this.SetInnerBeastSprites(newBeast.inner); /*if (newBeast.inner != newBeast) { this.inner.sprite = newBeast.inner.sprite; this.inner.color = newBeast.inner.color; } else { this.inner.sprite = null; }*/ this.oldSprite.sprite = this.newSprite.sprite; this.oldSprite.color = this.newSprite.color; this.newSprite.sprite = newBeast.sprite; this.newSprite.color = newBeast.color; this.GetComponent<Animator>().SetTrigger("Fill"); this.GetComponent<Animator>().SetTrigger("InnerFill"); if (this.edgy) { this.RenderEdges(); } }
public static async Task <int> AddOrUpdateBeast(Beast beast) { using (var DbContext = new SQLiteDbContext()) { bool newBeast = false; var currentBeast = DbContext.Beasts.Find(beast.Id); if (beast.Id == 0 || currentBeast == null) { DbContext.Beasts.Add(beast); newBeast = true; } else { currentBeast.Name = beast.Name; currentBeast.Description = beast.Description; currentBeast.Species = beast.Species; currentBeast.Gender = beast.Gender; DbContext.Beasts.Update(currentBeast); } await DbContext.SaveChangesAsync(); if (newBeast) { return(beast.Id); } return(currentBeast.Id); } }
public void setBeast(Beast beast) { if (beast is Horse) { this.horse = (Horse)beast; } }
/// <summary> /// 取得攻击者和被攻击者之间的距离 /// </summary> /// <param name="beAttackerId"></param> /// <returns></returns> private uint GetDistanceByTargetBeastId(long beAttackerId) { Beast attacker = Singleton <BeastManager> .singleton.GetBeastById(this.AttackerId); Beast beAttacker = Singleton <BeastManager> .singleton.GetBeastById(beAttackerId); if (attacker != null && beAttacker != null) { int nRow = 0; int nCol = 0; Hexagon.GetHexIndexByPos(attacker.MovingPos, out nRow, out nCol); CVector3 pos = new CVector3(); pos.nRow = nRow; pos.nCol = nCol; Hexagon.GetHexIndexByPos(beAttacker.MovingPos, out nRow, out nCol); CVector3 pos2 = new CVector3(); pos2.nRow = nRow; pos2.nCol = nCol; return(Singleton <ClientMain> .singleton.scene.CalDistance(pos, pos2)); } else { return(0u); } }
public override void Trigger() { int attackEftId = 0; int beAttackEftId = 0; SkillGameManager.GetSkillAttackEffectId(this.SkillId, this.AttackerId, ref attackEftId, ref beAttackEftId); Beast beast = Singleton <BeastManager> .singleton.GetBeastById(this.AttackerId); if (beast != null) { DataSkillShow data = beast.GetSkillShow(this.SkillId); if (!this.MainBeAttacker && data != null) { if (data.SubHitEffectId != 0) { beAttackEftId = data.SubHitEffectId; } } if (bShowMissEffect) { //显示MIss漂浮字样 } else if (beAttackEftId > 0) { //取得被攻击者的位置,然后播放特效 Vector3 vTargetPos = this.BeAttackPos.Count > 0 ? Hexagon.GetHex3DPos(this.BeAttackPos[0], Space.World) : Vector3.zero; EffectManager.Instance.PlayEffect(beAttackEftId, this.BeAttackerId, Vector3.zero, null, 0L, vTargetPos, null, Vector3.zero); } } }
public override bool OnSelectPos(CVector3 pos) { Beast beast = Singleton <BeastManager> .singleton.GetBeastById(Singleton <BeastRole> .singleton.Id); if (beast.UsedAttackToBaseBuildingCount >= 1) { //弹出攻击过的提示消息 DlgBase <DlgFlyText, DlgFlyTextBehaviour> .singleton.AddSystemInfo(StringConfigMgr.GetString("DlgMain.AttactOncePreRound")); return(false); } else { if (this.m_listValidTargetPos.Exists((CVector3 p) => p.Equals(pos))) { Beast beastByPos = Singleton <BeastManager> .singleton.GetBeastByPos(pos); if (beastByPos != null) { this.m_unTargetBeastId = beastByPos.Id; } else { this.m_unTargetBeastId = 0; } this.m_vec3TargetPos = pos; this.OnButtonOkClick(); } return(true); } }
public Beast get(int id) { Beast b = new Beast(); SqlConnection myConnection = new SqlConnection(con); string line = "select * from Beast_directory where id=@id"; SqlCommand cmd = new SqlCommand(line, myConnection); cmd.Parameters.AddWithValue("@id", id); myConnection.Open(); SqlDataReader oReader = cmd.ExecuteReader(); oReader.Read(); b.name = oReader["name"].ToString(); b.Summoned = (bool)oReader["isSummoned"]; b.HitPoints = (int)oReader["hp"]; b.Defense = (int)oReader["defence"]; b.Power = (int)oReader["power"]; b.Speed = (int)oReader["speed"]; b.Skill = (int)oReader["skill"]; b.MOVES = (int)oReader["moves"]; b.MoveA = (int)oReader["moveA"]; b.MoveB = (int)oReader["moveB"]; myConnection.Close(); return(b); }
public override void Create() { Name = "Forest"; var three1 = new Tree(); var three2 = new Tree(); var water = new Water(); Elements = new Element[] { three1, three2, water }; foreach (var element in Elements) { element.Create(); } var elf = new Elf(); var human = new Human(); var animal1 = new Animal(); var animal2 = new Animal(); var beast = new Beast(); Creatures = new Creature[] { elf, human, animal1, animal2, beast }; foreach (var creature in Creatures) { creature.Create(); } }
public override void Process() { XLog.Log.Debug("CPtcM2CNtf_CastSkill"); if (Singleton <ClientMain> .singleton.EGameState == EnumGameState.eState_GameMain) { UseSkillParam useSkillParam = new UseSkillParam(); useSkillParam.m_dwRoleId = this.m_dwRoleId; useSkillParam.m_dwSkillId = this.m_dwSkillId; useSkillParam.m_dwTargetRoleId = this.m_dwTargetRoleId; useSkillParam.m_oTargetPos = this.m_oTargetPos; Singleton <BeastManager> .singleton.OnUseSkill(this.m_dwRoleId, EnumSkillType.eSkillType_Skill, this.m_dwSkillId, useSkillParam); Singleton <SequenceShowManager> .singleton.UseSeqShow = true; if (Singleton <SequenceShowManager> .singleton.UseSeqShow) { Singleton <SequenceShowManager> .singleton.OnMsg(this); } //让神兽说出话 Beast beast = Singleton <BeastManager> .singleton.GetBeastById(this.m_dwRoleId); if (beast != null) { beast.ResetMomentForVoiceInRound(); } /* * if (beast.Role) * { * Singleton<BeastRole>.singleton.LockUseSkill(EnumSkillType.eSkillType_Skill, this.m_dwSkillId, false); * } */ } }
public void MyCode() { // The FIRST line of code should be BELOW this line NumberGenerator theNumberGenerator = new NumberGenerator(); BattleLog theLog = new BattleLog(); // Original battle logic (1-on-1) #region 1-on-1 battle logic Hero theHero = new Hero(theNumberGenerator, theLog, 100, 10, 30); Beast theBeast = new Beast(theNumberGenerator, theLog, 90, 10, 25); while (!theHero.Dead && !theBeast.Dead) { int damageByHero = theHero.DealDamage(); theBeast.ReceiveDamage(damageByHero); if (!theBeast.Dead) { int damageByBeast = theBeast.DealDamage(); theHero.ReceiveDamage(damageByBeast); } } theLog.PrintLog(); #endregion // New battle logic (1-on-many) #region 1-on-many battle logic theHero.Reset(); theLog.Reset(); BeastArmy theArmy = new BeastArmy(); Beast theBeast1 = new Beast(theNumberGenerator, theLog, 40, 10, 25); Beast theBeast2 = new Beast(theNumberGenerator, theLog, 20, 5, 15); Beast theBeast3 = new Beast(theNumberGenerator, theLog, 30, 8, 12); theArmy.AddBeast(theBeast1); theArmy.AddBeast(theBeast2); theArmy.AddBeast(theBeast3); while (!theHero.Dead && !theArmy.Dead) { int damageByHero = theHero.DealDamage(); theArmy.ReceiveDamage(damageByHero); if (!theArmy.Dead) { int damageByArmy = theArmy.DealDamage(); theHero.ReceiveDamage(damageByArmy); } } theLog.PrintLog(); #endregion // The LAST line of code should be ABOVE this line }
public float GetEffectHitTime(int effect_id, Beast caster, Beast target) { EffectData effectData = null; float result; if (!this.m_EffectDatas.ContainsKey(effect_id)) { result = 0f; } else { effectData = this.m_EffectDatas[effect_id]; float allTime = 0f; foreach (EffectInstanceData current in effectData.InstanceDatas) { float num2 = 0f; if (current.Type == EffectInstanceType.UITrace) { allTime = current.TraceTime; } if (current.Type == EffectInstanceType.Trace) { if (current.InstanceTraceMoveType == TraceMoveType.FixMoveSpeed) { Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; if (null != caster) { EffectInstance.GetBindPos(caster, current.CasterBindType, out zero); } if (null != target) { EffectInstance.GetBindPos(target, current.TargetBindType, out zero2); } float num3 = Vector3.Magnitude(zero2 - zero); if (current.MoveSpeed != 0f) { num2 = num3 / current.MoveSpeed; } else { num2 = current.TraceTime; } } else { num2 = current.TraceTime; } } if (allTime < num2) { allTime = num2; } } allTime += effectData.HitPointTime; result = allTime; } return(result); }
public void AddPath(Beast.BeastLink link, GameObject startSprite, GameObject continueSprite, GameObject endSprite, GameObject onlySprite = null) { if (onlySprite == null) { onlySprite = startSprite; } this.SetHasSprites(true); this.link = link; Vector3 currentPosition = this.transform.position; Vector3 preScale = this.spriteParent.transform.localScale; this.spriteParent.transform.localScale = new Vector3(1, 1, 1); for (int i = 0; i < link.directions.Length; i++) { GameObject sprite = onlySprite; if (link.directions.Length != 1) { if (i == 0) { sprite = startSprite; } else if (i == link.directions.Length - 1) { sprite = endSprite; } else { sprite = continueSprite; } } Vector3 rotation = new Vector3(); Vector3 position = new Vector3(); string direction = link.directions[i]; switch (direction) { case "left": rotation = new Vector3(0, 0, 180); position = currentPosition + new Vector3(-0.5f, 0, 0); this.AddLink(sprite, rotation, position); currentPosition += new Vector3(-1, 0, 0); break; case "right": rotation = new Vector3(0, 0, 0); position = currentPosition + new Vector3(0.5f, 0, 0); this.AddLink(sprite, rotation, position); currentPosition += new Vector3(1, 0, 0); break; case "up": rotation = new Vector3(0, 0, 90); position = currentPosition + new Vector3(0, 0.5f, 0); this.AddLink(sprite, rotation, position); currentPosition += new Vector3(0, 1, 0); break; case "down": rotation = new Vector3(0, 0, 270); position = currentPosition + new Vector3(0, -0.5f, 0); this.AddLink(sprite, rotation, position); currentPosition += new Vector3(0, -1, 0); break; } } this.spriteParent.transform.localScale = preScale; }
public int PlayEffect(int id, long unCastId, long unTargetId) { Beast caster = Singleton <BeastManager> .singleton.GetBeastById(unCastId); Beast target = Singleton <BeastManager> .singleton.GetBeastById(unTargetId); return(base.PlayEffect(id, caster, Vector3.zero, null, target, Vector3.zero, null, Vector3.zero)); }
/// <summary> /// 播放特效 /// </summary> /// <param name="id"></param> /// <param name="unCastId"></param> /// <param name="vec3SrcPos"></param> /// <param name="uiObjCast"></param> /// <param name="unTargetId"></param> /// <param name="vec3DestPos"></param> /// <param name="uiObjTarget"></param> /// <param name="vec3FixDir"></param> /// <returns></returns> public int PlayEffect(int id, long unCastId, Vector3 vec3SrcPos, IXUIObject uiObjCast, long unTargetId, Vector3 vec3DestPos, IXUIObject uiObjTarget, Vector3 vec3FixDir) { Beast caster = Singleton <BeastManager> .singleton.GetBeastById(unCastId); Beast target = Singleton <BeastManager> .singleton.GetBeastById(unTargetId); return(base.PlayEffect(id, caster, vec3SrcPos, uiObjCast, target, vec3DestPos, uiObjTarget, vec3FixDir)); }
public HeadInfoEntity(long unBeastId, IXUIListHeadInfoItem uiHeadInfo) { this.m_unBeastId = unBeastId; this.m_uiHeadInfoItem = uiHeadInfo; Beast heroById = Singleton <BeastManager> .singleton.GetBeastById(unBeastId); uiHeadInfo.Id = heroById.BeastTypeId; }
/// <summary> /// 取得技能攻击到目标时间(目标神兽) /// </summary> /// <param name="effectId"></param> /// <param name="castId"></param> /// <param name="targetId"></param> /// <returns></returns> public float GetEffectHitTime(int effectId, long castId, long targetId) { Beast attacker = Singleton <BeastManager> .singleton.GetBeastById(castId); Beast beAttacker = Singleton <BeastManager> .singleton.GetBeastById(targetId); return(base.GetEffectHitTime(effectId, attacker, beAttacker)); }
public Beast() { this.up = this; this.down = this; this.left = this; this.right = this; this.inner = this; this.color = new Color(Random.Range(.8f, 1.0f), Random.Range(.8f, 1.0f), Random.Range(.8f, 1.0f)); }
public void OnUnitDeath(Beast victim, string killer) { units.Remove(victim); Destroy(victim.gameObject); Destroy(victim); if(units.Count == 0){ spawnTimer = spawnCooldown; GrantBuff(killer); } }
public IEnumerator DoInnerAnimation(int distance, Beast newInnerBeast) { float time = distance * .05f; while (time > 0) { time -= Time.deltaTime; yield return null; } this.oldInner.sprite = this.inner.sprite; this.oldInner.color = this.inner.color; if (newInnerBeast != this.beast) { this.inner.sprite = newInnerBeast.sprite; this.inner.color = newInnerBeast.color; } else { this.inner.sprite = null; } this.GetComponent<Animator>().SetTrigger("InnerFill"); }
public Chain(World world,int linkCount, Beast beastA, Beast beastB) { this.world = world; this.linkCount = linkCount; this.beastA = beastA; this.beastB = beastB; Vector2 startPos = beastA.GetPos(); Vector2 endPos = beastB.GetPos(); //Vector2 delta = (endPos - startPos) / (float)LINK_COUNT; ChainLink previousLink = null; for (int c = 0; c<linkCount; c++) { ChainLink link; bool isLastLink = (c == linkCount-1); if(isLastLink) { link = ChainLink.Create(world, beastB); } else { link = ChainLink.Create(world, null); } Vector2 linkPos = new Vector2(startPos.x + ChainLink.LENGTH * (c), startPos.y); link.Init(this, previousLink, linkPos, isLastLink); links.Add(link); previousLink = link; } beastA.transform.position = new Vector3(startPos.x * FPhysics.POINTS_TO_METERS, startPos.y * FPhysics.POINTS_TO_METERS); beastB.transform.position = new Vector3(endPos.x * FPhysics.POINTS_TO_METERS, endPos.y * FPhysics.POINTS_TO_METERS); }
public Beast LoadBeasts() { string data = Resources.Load<TextAsset>("output").text; string[] lines = data.Split('\n'); //Dictionary<string, Beast> beasts = new Dictionary<string, Beast>(); foreach (string line in lines) { if (line.Length < 1 || line[0] == '#') { continue; } string[] parts = line.Split(','); string id = parts[0]; Sprite sprite = this.LoadSprite(parts[1]); Beast b = new Beast(); b.sprite = sprite; this.beasts.Add(id, b); } foreach (string line in lines) { if (line.Length < 1 || line[0] == '#') { continue; } string[] parts = line.Split(','); string id = parts[0]; Beast b = this.beasts[id]; b.right = this.beasts[parts[2]]; b.up = this.beasts[parts[3]]; b.left = this.beasts[parts[4]]; b.down = this.beasts[parts[5]]; b.inner = this.beasts[parts[6]]; b.SetSong(parts[7].Replace('/', ',')); b.tickTime = float.Parse(parts[8]); b.currentTickTime = float.Parse(parts[8]); } return this.beasts["player"]; }
public void AddToTutPath(Beast.BeastLink to) { this.AddPath(to, this.continueSprite, this.continueSprite, this.startSprite, this.startSprite); }
public void AddTutPath(Beast.BeastLink from, Beast.BeastLink to) { this.AddPath(to, this.continueSprite, this.continueSprite, this.endSprite, this.endSprite); this.AddPath(from, this.continueSprite, this.continueSprite, this.startSprite, this.startSprite); }
public void MouseOverPath(Beast.BeastLink path) { this.ClearPath(); this.AddPath(path, this.continueSprite, this.continueSprite, this.endSprite, this.endSprite); }
private void AttackBeast(Beast beast) { gameObject.GetComponent<Rigidbody>().velocity += Vector3.up * 20f; if (IsCriticalStrike()) beast.RecieveDamage(GetDamageOutput() * 2, gameObject.name); else beast.RecieveDamage(GetDamageOutput(), gameObject.name); atkCooldown = 1f; anim.Play("Attack", 1, 0); skinnedMesh.SetBlendShapeWeight(1, 100); skinnedMesh.SetBlendShapeWeight(2, 0); //transform.LookAt(beast.transform.position); transform.LookAt(2 * transform.position - beast.transform.position); }
public void set(Beast v) { switch (this.getLastDirection()) { case "up": this.beast.up = v; break; case "down": this.beast.down = v; break; case "left": this.beast.left = v; break; case "right": this.beast.right = v; break; case "inner": this.beast.inner = v; break; case "all": this.beast.left = v; this.beast.right = v; this.beast.up = v; this.beast.down = v; break; case "self": throw new System.Exception("Can't tut ema."); } }
private void populateBeast() { Beast start = this.origin; this.beast = start; foreach (string direction in this.directions) { this.beast = start; start = this.hop(start, direction); } }
void Awake() { myBeast = this.transform.GetComponentInParent<Beast>(); }
public void Render(Beast center, bool doAnimations = false) { Beast current = center; List<string> directions = new List<string>(); Vector3 target = this.transform.position; int dy = (int)(target.y); int dx = (int)(target.x); int x_sign = dx > 0 ? 1 : -1; int y_sign = dy > 0 ? 1 : -1; float v = ((float)dy * y_sign) / (dx * x_sign); float f = 0; string lastDirection = null; for (int x = 0; x < dx * x_sign; x++) { f += v; while (f >= 1) { lastDirection = y_sign == 1 ? "up" : "down"; directions.Add(lastDirection); current = y_sign == 1 ? current.up : current.down; f -= 1; } current = x_sign == 1 ? current.right : current.left; lastDirection = x_sign == 1 ? "right" : "left"; directions.Add(lastDirection); } if (dx == 0) { for (int y = 0; y < dy * y_sign; y++) { current = y_sign == 1 ? current.up : current.down; lastDirection = y_sign == 1 ? "up" : "down"; directions.Add(lastDirection); } } bool beastChanged = this.beast != current; bool innerChanged = this.innerBeast != current.inner; this.innerBeast = current.inner; this.beast = current; if (innerChanged && !beastChanged) { if (doAnimations) { StartCoroutine(this.DoInnerAnimation(directions.Count, current.inner)); } else { this.SetInnerBeastSprites(current.inner); } } if (beastChanged) { if (doAnimations) { StartCoroutine(this.DoAnimation(directions.Count, current, lastDirection)); } else { this.oldSprite.sprite = current.sprite; this.oldSprite.color = current.color; this.newSprite.sprite = current.sprite; this.newSprite.color = current.color; this.SetInnerBeastSprites(current.inner); } this.link = new Beast.BeastLink(center, directions.ToArray()); this.UpdateLeyLines(); } }
public static ChainLink Create(World world, Beast endBeast) { GameObject linkGO; if(endBeast == null) { linkGO = new GameObject("ChainLink"); } else { linkGO = endBeast.gameObject; } ChainLink link = linkGO.AddComponent<ChainLink>(); link.world = world; return link; }
private void SetInnerBeastSprites(Beast newInnerBeast) { this.oldInner.sprite = this.inner.sprite; this.oldInner.color = this.inner.color; if (newInnerBeast != this.beast) { this.inner.sprite = newInnerBeast.sprite; this.inner.color = newInnerBeast.color; } else { this.inner.sprite = null; } }
public static BeastLink ParseRelative(Beast origin, string word) { List<string> words = new List<string>(); while (word.Length > 0) { if (word.StartsWith("ro")) { words.Add("right"); word = word.Substring(2); } else if (word.StartsWith("go")) { words.Add("left"); word = word.Substring(2); } else if (word.StartsWith("bo")) { words.Add("up"); word = word.Substring(2); } else if (word.StartsWith("po")) { words.Add("down"); word = word.Substring(2); } else if (word.StartsWith("wo")) { words.Add("inner"); word = word.Substring(2); } else if (word.StartsWith("ema")) { words.Add("self"); word = word.Substring(3); } else { throw new System.Exception("Invalid selector: " + word); } } return new BeastLink(origin, words.ToArray()); }
public void Start() { this.playerBeast = this.LoadBeasts(); this.lurkerBeast = this.beasts["player_lurker"]; this.RefreshScreen(); }
public void AddIbiTutPath(Beast.BeastLink condA, Beast.BeastLink condB, Beast.BeastLink from, Beast.BeastLink to) { this.AddPath(condA, this.continueSprite, this.continueSprite, this.startSprite, this.startSprite); this.AddPath(condB, this.continueSprite, this.continueSprite, this.startSprite, this.startSprite); this.AddTutPath(from, to); }
public void MouseOver(Beast.BeastLink link) { this.playerLey.MouseOverPath(link); }
public void AddFromTutPath(Beast.BeastLink to) { this.AddPath(to, this.continueSprite, this.continueSprite, this.endSprite, this.endSprite); }
private Beast hop(Beast beast, string direction) { switch (direction) { case "up": return beast.up; case "down": return beast.down; case "left": return beast.left; case "right": return beast.right; case "inner": return beast.inner; default: return beast; } }
public void AddFakeHeartPath(Beast.BeastLink link) { this.AddPath(link, this.continueSprite, this.continueSprite, this.continueSprite, this.continueSprite); }
public BeastLink(Beast origin, string[] directions) { this.origin = origin; this.directions = directions; this.populateBeast(); }
public void MouseOverPath(Beast.BeastLink to) { }