GameObject FindTouchCity(ChampionBehaviour soldscript, Vector2 touch) { if (soldscript.belongCity == null) { return(null); } GameObject tarCity = null; foreach (Transform oneCityTrans in citys.transform) { if (oneCityTrans.GetComponent <RoundManager>().IsTouchPointInCity(touch)) { tarCity = oneCityTrans.gameObject; } } string belongName = soldscript.belongCity.gameObject.name; string[] cityList = city2Citys[belongName]; if (tarCity != null && string.Join("", cityList).Contains(tarCity.name)) { return(tarCity); } else { return(null); } }
void Awake() { if (champion == null) { champion = GetComponent <ChampionBehaviour>(); } }
/// <summary> /// 敌人减血 /// </summary> /// <param name="tar">敌人</param> public void ReachedVit(ChampionBehaviour tar) { if (!IsDead) { tar.ReceiveDamage(prop.damage, this); } }
//ChampionBehaviour tar; public void Attack(ChampionBehaviour tar = null) { if (GetComponent <ChampionSkill>().CanAttack() && IsAlive()) { curStatus = Status.RoundAttacking; tar = belongCity.ChooseAim(this); if (prop.attackDistance == AttackDistance.Short) { ctl = true; myPos = new Vector3(battlePosTarTrans.position.x, transform.position.y, battlePosTarTrans.position.z); //tar = belongCity.ChooseAim (this); tarPos = new Vector3(tar.transform.position.x, transform.position.y, tar.transform.position.z); ReachedVit(tar); ActionSpeed = (Vector3.Distance(myPos, tarPos) * 2) / belongCity.OneAttackTime; } else { CreateBullet(tar); } if (prop.energy >= prop.maxEnergy && prop.mana >= 10) { skillLogic.LaunchActiveSkill(); prop.energy = 0; prop.mana -= 10; } } }
/// <summary> /// 疾风箭 /// </summary> void WindArrow() { bulletType = BulletType.StunBullet; ChampionBehaviour enemy = champion.belongCity.ChooseAim(champion); champion.CreateBullet(enemy); bulletType = BulletType.none; }
public override void LaunchActiveSkill() { StartCoroutine(ShowActiveSkillText()); ChampionBehaviour enemy = champion.belongCity.ChooseAim(champion); WindArrow(); Invoke("WindArrow", 0.5f); }
public void DelOnWayChampionList(ChampionBehaviour chmp) { if (!onWayChampionList.Contains(chmp)) { return; } onWayChampionList.Remove(chmp); }
public void AddOnWayChampionList(ChampionBehaviour chmp) { if (onWayChampionList.Contains(chmp)) { return; } onWayChampionList.Add(chmp); }
void OnWayUpdate() { ChampionBehaviour tar = GetOnWayEnemy(); //城外即时战斗 if (tar != null && !belongCity.IsInCity(transform.position)) { if (Time.time - lastOnWayAttackTime > onWayAttackInterval) { CreateBullet(tar); lastOnWayAttackTime = Time.time; } } else { GoToTarCity(); } }
public void CreateBullet(ChampionBehaviour tar) { string bulletName = skillLogic.GetBulletName(); GameObject createBullet = null; ResManager.LoadPrefab("bullet".ToLower() + LuaFramework.AppConst.ExtName, bulletName, (System.Action <UnityEngine.Object[]>)(objs => { GameObject bulletPreb = objs[0] as GameObject; createBullet = (GameObject)Instantiate(bulletPreb); if (UnityEngine.Object.Equals((UnityEngine.Object)createBullet, (UnityEngine.Object)null)) { Debug.LogWarning("UnityEngine.Object.Equals((UnityEngine.Object)createBullet, (UnityEngine.Object)null)"); return; } createBullet.GetComponent <Bullet>().SetInfo(gameObject, tar.gameObject); createBullet.GetComponent <Bullet>().SetDamage(skillLogic.CalRealBulletHurt(prop.damage)); }) ); }
void Update() { string parentname = transform.parent.gameObject.name; parentname = parentname.Substring(0, parentname.Length - 3); string strooptag = parentname + "troop"; string soldiername = gameObject.name; soldiername = soldiername.Substring(0, soldiername.Length - 3); linkChampion = null; foreach (GameObject soldier in GameObject.FindGameObjectsWithTag(strooptag)) { if (soldiername == soldier.name) { linkChampion = soldier.GetComponent <ChampionBehaviour>(); } } if (linkChampion == null || linkChampion.curStatus != Status.Peace) { gameObject.SetActive(false); } }
public virtual void ReceiveDamage(float damage, ChampionBehaviour att) { if (prop.isDead) { return; } float realdamage = skillLogic.CalRealDamageReceived(damage); if (neutralAI != null) { neutralAI.DamageCount(damage, att); } prop.blood -= realdamage; prop.energy = prop.energy + 10; if (prop.blood <= 0) { Die(); } skillLogic.DamageCount += 1; skillLogic.SetCurNumber(); }
public void DamageCount(float damage, ChampionBehaviour champion) { side2DamageCount[champion.GetSide()] += damage; }
public void SetClickBtnLinkSoldier(ChampionBehaviour soldier) { //ShowLogTool.ReceiveLog("SetClickBtnLinkSoldier"); linkSoldier = soldier; //showtext2 = linkSoldier.ToString(); }
void HandleTouchEvent() { foreach (Touch touch in Input.touches) { switch (touch.phase) { case TouchPhase.Began: //ShowLogTool.ReceiveLog("TouchPhase.Began"+linkSoldier.ToString()); if (linkSoldier) { if (fingerID2Soldier.ContainsKey(touch.fingerId)) { fingerID2Soldier.Remove(touch.fingerId); } fingerID2Soldier.Add(touch.fingerId, linkSoldier); //linkSoldier = null; } if (fingerID2StartPos.ContainsKey(touch.fingerId)) { fingerID2StartPos.Remove(touch.fingerId); } fingerID2StartPos.Add(touch.fingerId, touch.position); //if (Physics.Raycast(ray, out hit)) //{ // if ((hit.transform.gameObject.tag.IndexOf("red") != -1)||(hit.transform.gameObject.tag.IndexOf("blue") != -1)) // { // soldierTrans = hit.transform; // } // else // { // soldierTrans = null; // } //} //else //{ // soldierTrans = null; //} break; case TouchPhase.Moved: break; case TouchPhase.Ended: ChampionBehaviour fingerSold = null; Vector2 fingerPos = Vector2.zero; if (fingerID2Soldier.ContainsKey(touch.fingerId)) { fingerSold = fingerID2Soldier[touch.fingerId]; fingerID2Soldier.Remove(touch.fingerId); } if (fingerID2StartPos.ContainsKey(touch.fingerId)) { fingerPos = fingerID2StartPos[touch.fingerId]; fingerID2StartPos.Remove(touch.fingerId); } //ShowLogTool.ReceiveLog("TouchPhase.Ended"+fingerSold.ToString()); if (fingerSold != null && fingerPos != Vector2.zero) { direction = touch.position - fingerPos; GameObject city = FindTouchCity(fingerSold, touch.position); if (city != null) { fingerSold.belongCity.ChampionLeaveCity(fingerSold); fingerSold.SetStatus(Status.OnWay); fingerSold.GetComponent <ChampionBehaviour>().SetTarCity(city.transform); AddOnWayChampionList(fingerSold); } } break; } } }