public override void DestroyBehaviour() { UninitEvent(); mUIObject = null; mTargetMono = null; base.DestroyBehaviour(); }
void OnTriggerEnter(Collider other) { if (other.gameObject == null || other.gameObject.layer != mPlayerMask) { return; } // 不是本地玩家,不要捡 ActorMono actor_mono = ActorHelper.GetActorMono(other.gameObject); if (actor_mono == null) { return; } var actor = actor_mono.BindActor; if (actor == null || actor.UID.obj_idx != Game.GetInstance().LocalPlayerID.obj_idx) { return; } // 死了也不要捡 if (actor.IsDead()) { return; } //Pick(); }
private void OnTriggerExit(Collider other) { if (other.gameObject == null || other.gameObject.layer != mPlayerMask) { return; } ActorMono actor_mono = ActorHelper.GetActorMono(other.gameObject); if (actor_mono == null) { return; } var actor = actor_mono.BindActor; if (actor == null || actor.UnitType != EUnitType.UNITTYPE_PLAYER) { return; } actor.IsInSafeArea = false; if (actor == Game.GetInstance().GetLocalPlayer()) { UINotice.Instance.ShowMessage(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_45")); } }
public void OnBattleStart() { BattleState = State.BattleStart; GameManager.instance.gameInputMode = GameManager.InputMode.play; UIManager.instance.ActiveUI("BattleMode", true); UIManager.instance.ActiveUI("BattleStartButton", false); UIManager.instance.ActiveUI("UIArea", true); UIManager.instance.ActiveUI("TurnEnd", true); UIManager.instance.SetActorsUI(actorsInBattle_list); foreach (var actor in actorsInBattle_list) { if (actor.GetComponent <ActorMono>().group == ActorMono.Group.monster) { continue; } actor.SendMessage("OnBattle"); var actorMono = actor.GetComponent <ActorMono>(); actorMono.OnBattle(); actorMono.InitDeck(); actorMono.ShuffleDeck(); } // 确定对战队列 ActorSortByAdvantage sort = new ActorSortByAdvantage(); actorsQueue_list = new List <GameObject>(actorsInBattle_list); actorsQueue_list.Sort(sort); actor_curTurn = actorsQueue_list[0].GetComponent <ActorMono>(); }
void TryRefreshSelectPlayer() { if (DBInstanceTypeControl.Instance.HidePvpHpBar(InstanceManager.Instance.InstanceType, InstanceManager.Instance.InstanceSubType)) { SetHpBarPanelVisible(false); return; } ActorMono perfect_player = GetPerfectPlayer(); if (perfect_player != null && perfect_player == mTargetMono) { return; } mTargetMono = perfect_player; if (mTargetMono == null) { SetHpBarPanelVisible(false); } else { SetHpBarPanelVisible(true); SetInfoPanel(); } }
private void Start() { actor = gameObject.GetComponent <ActorMono>(); //InitCastCards(); InitCards(); }
public Combat(ActorMono user, Card atkCard, ActorMono target) { card_atk = atkCard; actor_dfd = target; card_dfd = target.FocusedCard; actor_atk = user; }
/// <summary> /// 发动卡片 /// </summary> /// <param name="target"></param> private void DoCasted(ActorMono target) { //holder.GetComponent<ActorMono>().StartCoroutine(holder.GetComponent<ActorMono>().CastCard(card, target)); holder.GetComponent <ActorMono>().CastCard(card, target); state = State.none; OnNone(); }
public override void Init(ActorMono src, ActorMono target, DBBulletTrace.BulletInfo bulletInfo, SkillAttackInstance inst) { base.Init(src, target, bulletInfo, inst); if (target == null || target.BindActor == null) { Debug.LogError("Target is lost"); DestroySelf(); return; } if (bulletInfo == null) { Debug.LogError("BulletInfo is null"); DestroySelf(); return; } m_BulletInfo = bulletInfo; mTarget = target; mTargetStartPos = TargetPos; mTraceSpeed = bulletInfo.FlySpeed; float move_per_frame = mTraceSpeed * 0.0333f; mSqrReachRange = move_per_frame * move_per_frame; Vector3 dir = mTargetStartPos - cacheTrans.position; dir.Normalize(); mTransDir = dir * mTraceSpeed; }
void OnSelectActorChange(CEventBaseArgs msg) { if (mUIObject == null) { return; } if (msg == null || msg.arg == null) { mTargetMono = null; SetHpBarPanelVisible(false); return; } var monoActor = msg.arg as ActorMono; if (monoActor == null || monoActor.BindActor == null || !monoActor.BindActor.IsBoss()) { mTargetMono = null; SetHpBarPanelVisible(false); return; } if (mTargetMono != null && monoActor.BindActor.UID == mTargetMono.BindActor.UID) { return; } SetHpBarPanelVisible(true); mTargetMono = monoActor; InitData(); SetBossInfoPanel(); }
// Start is called before the first frame update // Update is called once per frame void Update() { if (actor != null) { ActorMono actor_mono = actor.GetComponent <ActorMono>(); Grid grid = PathFinderManager.instance.grid; Vector3 worldPos = actor_mono.WorldPos + grid.cellSize.y * new Vector3(0, 1.5f, 0); worldPos.x = actor_mono.WorldPos.x; if (dirSign.activeInHierarchy) { dirSign.transform.position = Camera.main.WorldToScreenPoint(worldPos); } worldPos += grid.cellSize.y * new Vector3(0, -2.3f, 0); if (healPoint.activeInHierarchy) { healPoint.transform.position = Camera.main.WorldToScreenPoint(worldPos); } worldPos += grid.cellSize.y * new Vector3(0f, 2.3f, 0); if (healPointReduce_text.activeInHierarchy) { Color color = healPointReduce_text.GetComponent <Text>().color; healPointReduce_text.GetComponent <Text>().color = new Color(color.r, color.g, color.b, color.a -= Time.deltaTime); healPointReduce_text.transform.position = Camera.main.WorldToScreenPoint(worldPos); if (color.a <= 0) { healPointReduce_text.SetActive(false); } } worldPos += grid.cellSize.y * new Vector3(0f, -0.4f, 0); if (action_text.activeInHierarchy) { action_text.transform.position = Camera.main.WorldToScreenPoint(worldPos); Color color = action_text.GetComponent <Text>().color; action_text.GetComponent <Text>().color = new Color(color.r, color.g, color.b, color.a -= Time.deltaTime); if (color.a <= 0) { action_text.SetActive(false); } } worldPos += grid.cellSize.y * new Vector3(0, 0.6f, 0); if (action_card_text.activeInHierarchy) { action_card_text.transform.position = Camera.main.WorldToScreenPoint(worldPos); Color color = action_card_text.GetComponent <Text>().color; action_card_text.GetComponent <Text>().color = new Color(color.r, color.g, color.b, color.a -= Time.deltaTime); if (color.a <= 0) { action_card_text.SetActive(false); } } } }
public void SetHolder(ActorMono actor) { for (int i = 0; i < cards_list.Count; i++) { Card card = cards_list[i]; card.holder = actor; } }
public void StartCombat(ActorMono user, Card usedCard, ActorMono target) { Combat combat = new Combat(user, usedCard, target); // 计算combat combat.StartThisCombat(); // 应用计算结果并演出 StartCoroutine(ActionShow(combat)); }
public void CastCard(Card card, ActorMono target) { ActionPoint -= 1; UIManager.instance.UpdateActorFloatUI(gameObject, card.cardName, 2); CombatManager.instance.StartCombat(this, card, target); DiscardCard(card); }
public override void EnableBehaviour(bool isEnable) { base.EnableBehaviour(isEnable); SetActive_check(m_is_active); if (IsEnable == false) { mTargetMono = null; } //GameDebug.LogError("start EnableBehaviour = " + isEnable.ToString()); TryRefreshSelectPlayer(); //GameDebug.LogError("end EnableBehaviour = " + isEnable.ToString()); }
public void UpdateDirSignUI(bool isActive) { if (!isActive) { dirSign.SetActive(false); return; } dirSign.SetActive(true); ActorMono actor_mono = actor.GetComponent <ActorMono>(); ChangeDirSign(actor_mono.FocusedCard.sign_up, actor_mono.FocusedCard.sign_down); }
void OnLeaveAOI(CEventBaseArgs data) { if (data == null || data.arg == null) { return; } uint leave_uuid = (uint)data.arg; if (mLastEnemyActorMono != null && mLastEnemyActorMono.BindActor != null && leave_uuid == mLastEnemyActorMono.BindActor.UID.obj_idx) { mLastEnemyActorMono = null; TryRefreshSelectPlayer(); } }
public void Reset() { FollowActorIsAttacked = false; TargetActorIsCounterattack = false; mFollowActor = null; FollowBackupPosition = Vector3.zero; //TargetSkill = null; TargetSkillId = 0; TargetActor = null; TargetMonsterId = 0; TargetDropId = 0; TargetCollectionId = 0; OriginalSelfActorPos = SelfActor.transform.position; }
public void UpdateHpUI(bool isActive) { if (!isActive) { healPoint.SetActive(false); //Debug.Log(actor.name + "death"); return; } healPoint.SetActive(true); //Debug.Log(actor.name); ActorMono actor_mono = actor.GetComponent <ActorMono>(); healPoint_text.GetComponent <Text>().text = actor_mono.healPoint + ""; }
ActorMono GetPerfectPlayer() { var local_player = Game.Instance.GetLocalPlayer(); if (local_player == null || local_player.IsDestroy) { return(null); } if (local_player.AttackCtrl != null && local_player.AttackCtrl.CurSelectActor != null) { ActorMono localPlayerSelectActor = local_player.AttackCtrl.CurSelectActor; if (localPlayerSelectActor.BindActor != null && localPlayerSelectActor.BindActor.IsDestroy == false) { if (localPlayerSelectActor.BindActor.IsPlayer() && localPlayerSelectActor.BindActor.IsLocalPlayer == false) { return(localPlayerSelectActor); } // bool show_tips = false; // if(PKModeManagerEx.Instance.IsLocalPlayerCanAttackActor(localPlayerSelectActor.BindActor, ref show_tips)) // { // return localPlayerSelectActor; // } } } if (PKModeManagerEx.Instance.IsPVPBattleState == false) { return(null); } if (mLastEnemyActorMono != null && mLastEnemyActorMono.BindActor != null && mLastEnemyActorMono.BindActor.IsDestroy == false) { if (local_player.AttackCtrl != null && local_player.transform != null && mLastEnemyActorMono.BindActor.transform != null) { float max_range = local_player.AttackCtrl.LeaveRange; if ((local_player.transform.position - mLastEnemyActorMono.BindActor.transform.position).sqrMagnitude < max_range * max_range) { return(mLastEnemyActorMono); } } } return(null); }
public bool IfCanCast(ActorMono _holde, ActorMono actor) { float dis_x = UnityEngine.Mathf.Abs(actor.WorldPos.x - _holde.WorldPos.x); float dis_y = UnityEngine.Mathf.Abs(actor.WorldPos.y - _holde.WorldPos.y); if (cast_type == CastType.指向单体) { if (dis_x > cast_extent_x + 0.5f || dis_y > cast_extent_y + 0.5f) { return(false); } else { return(true); } } if (cast_type == CastType.射线单体) { float dis = Vector3.Distance(actor.WorldPos, _holde.WorldPos); UnityEngine.RaycastHit2D[] hits = Physics2D.RaycastAll(_holde.WorldPos, (actor.WorldPos - _holde.WorldPos).normalized, dis); RaycastHit2D hit = new RaycastHit2D(); for (int i = 0; i < hits.Length; i++) { hit = hits[i]; if (hit.collider.tag == "Obstacle") { return(false); } if (hit.collider.GetComponent <ActorMono>() != null) { if (hit.collider.GetComponent <ActorMono>() == actor) { return(true); } } } } return(false); }
public override void Init(ActorMono src, ActorMono target, DBBulletTrace.BulletInfo bulletInfo, SkillAttackInstance inst) { base.Init(src, target, bulletInfo, inst); if (target == null || target.BindActor == null) { Debug.LogError("Target is lost"); DestroySelf(); return; } if (bulletInfo == null) { Debug.LogError("BulletInfo is null"); DestroySelf(); return; } m_BulletInfo = bulletInfo; mTarget = target; }
void AddOneEnemy(CEventBaseArgs data) { if (data == null || data.arg == null) { return; } UnitID uid = data.arg as UnitID; if (uid == null) { return; } Actor enemy_actor = ActorManager.Instance.GetActor(uid); if (enemy_actor != null && enemy_actor.IsPlayer() && enemy_actor.IsLocalPlayer == false) { mLastEnemyActorMono = enemy_actor.GetActorMono(); TryRefreshSelectPlayer(); } }
void OnTriggerExit(Collider other) { if (other.gameObject == null || other.gameObject.layer != mPlayerMask) { return; } ActorMono actor_mono = ActorHelper.GetActorMono(other.gameObject); if (actor_mono == null) { return; } var actor = actor_mono.BindActor; if (actor == null || actor.UID.obj_idx != Game.GetInstance().LocalPlayerID.obj_idx) { return; } }
public void OnTurnEnd() { if (BattleState == State.None) { return; } if (IfBattleEnd) { OnBattleEnd(); return; } BattleState = State.TurnEnd; if (actor_curTurn.group == ActorMono.Group.player) { actor_curTurn.DiscardEndCard(); actor_curTurn.ResumeActionPointToZero(); } // 选择下一个激活的对象 do { turnIndex += 1; if (turnIndex >= actorsQueue_list.Count) { // 一轮结束,下一轮重新根据优先级决定队列 ActorSortByAdvantage sort = new ActorSortByAdvantage(); actorsQueue_list = new List <GameObject>(actorsInBattle_list); actorsQueue_list.Sort(sort); turnIndex = 0; } actor_curTurn = actorsQueue_list[turnIndex].GetComponent <ActorMono>(); }while (actor_curTurn.battleState == ActorMono.BattleState.death); OnTurnStart(); }
void OnTriggerExit(Collider other) { if (other.gameObject == null || other.gameObject.layer != LayerMask.NameToLayer("Player")) { return; } Actor localPlayer = Game.Instance.GetLocalPlayer(); if (localPlayer != null && localPlayer.GetModelParent().Equals(other.gameObject) == false) { return; } ActorMono act_mono = ActorHelper.GetActorMono(other.gameObject); if (act_mono == null) { return; } Player act = act_mono.BindActor as Player; if (act != null && act.UID.Equals(Game.GetInstance().LocalPlayerID)) { if (ExitId > 0) { UranusManager.Instance.ActiveLevelNode(ExitId); if (LifeTime == Neptune.Collider.ETypeLifeTime.ONCE) { ColliderObjectManager.Instance.RemoveColliderObject(Id); } } ColliderObjectManager.Instance.TriggerColliderObject(Id); } }
/// <summary> /// 响应点击玩家的消息 /// </summary> /// <param name="data"></param> void OnClickPlayer(CEventBaseArgs data) { if (SceneHelp.Instance.IgnoreClickPlayer) { return; } GameObject select_object = (GameObject)data.arg; if (select_object != null) { ActorMono act_mono = ActorHelper.GetActorMono(select_object); if (act_mono != null && act_mono.BindActor != null) { if (act_mono.BindActor.IsDead() || act_mono.BindActor.IsLocalPlayer) { return; } m_LvText.text = act_mono.BindActor.Level.ToString(); for (int i = 0; i < m_IconImage.childCount; ++i) { m_IconImage.GetChild(i).gameObject.SetActive(false); } int voc_id = (int)act_mono.BindActor.VocationID; var voc_image_object = m_IconImage.Find(voc_id.ToString()); if (voc_image_object != null) { voc_image_object.gameObject.SetActive(true); } m_Target = select_object; gameObject.SetActive(true); } } }
private void Casted() { UIManager.instance.TranslateUIPos("TargetSelect", HolderPos); Vector3 mousePosition = Input.mousePosition; mousePosition.z = 10; Vector3 mouse_pos = Camera.main.ScreenToWorldPoint(mousePosition); // 检测距离 bool CanSelect = true; float dis_x = Mathf.Abs(mouse_pos.x - holder.WorldPos.x); float dis_y = Mathf.Abs(mouse_pos.y - holder.WorldPos.y); if (dis_x > card.cast_extent_x + 0.5f || dis_y > card.cast_extent_y + 0.5f) { CanSelect = false; } Collider2D collider = new Collider2D(); if (CardModel.cast_type == Card.CastType.射线单体) { if (!CanSelect) { UIManager.instance.UpdateLineUI(HolderPos, mouse_pos, false); return; } RaycastHit2D[] hits = Physics2D.RaycastAll(holder.WorldPos, (mouse_pos - holder.WorldPos).normalized, Vector3.Distance(holder.WorldPos, mouse_pos)); List <GameObject> hitObjects = new List <GameObject>(); RaycastHit2D hit = new RaycastHit2D(); bool isHitTarget = false; for (int i = 0; i < hits.Length; i++) { hit = hits[i]; if (hit.collider.gameObject == holder.gameObject) // 射到自己 跳过 { isHitTarget = false; continue; } if (hit.collider.tag == "Ladder") // 射到梯子 跳过 { isHitTarget = false; continue; } if (hit.collider.tag == "Obstacle") // 射到墙壁 中断 { isHitTarget = true; break; } if (hit.collider.tag == "Actor") { isHitTarget = true; hitObjects.Add(hit.collider.gameObject); } } if (!isHitTarget) { UIManager.instance.UpdateLineUI(holder.WorldPos, mouse_pos, true); } else if (hit) { Vector3 target_pos = hit.point; UIManager.instance.UpdateLineUI(holder.WorldPos, target_pos, true); } if (hit.collider.tag == "Actor" && isHitTarget) { collider = hit.collider; ActorMono targetMono = hit.collider.gameObject.GetComponent <ActorMono>(); if (targetMono != null) { CanSelect = true; targetMono.OnMouseSelect(CanSelect); } else { CanSelect = false; } } } else if (CardModel.cast_type == Card.CastType.指向单体) { collider = Physics2D.OverlapPoint(mouse_pos); if (collider != null) { ActorMono targetMono = collider.gameObject.GetComponent <ActorMono>(); if (targetMono != null) { targetMono.OnMouseSelect(CanSelect); } } } if (Input.GetKeyDown(KeyCode.Mouse1)) { UIManager.instance.UpdateLineUI(HolderPos, mouse_pos, false); GameManager.instance.gameInputMode = GameManager.InputMode.play; state = State.none; OnNone(); } if (CanSelect) { if (Input.GetKeyDown(KeyCode.Mouse0)) { // 进行cast if (collider != null) { ActorMono targetMono = collider.gameObject.GetComponent <ActorMono>(); if (targetMono != null) { targetMono.OnMouseSelect(false); UIManager.instance.UpdateLineUI(HolderPos, mouse_pos, false); DoCasted(collider.gameObject.GetComponent <ActorMono>()); //GameManager.instance.gameInputMode = GameManager.InputMode.play; } } } } }