예제 #1
0
 public override void DestroyBehaviour()
 {
     UninitEvent();
     mUIObject   = null;
     mTargetMono = null;
     base.DestroyBehaviour();
 }
예제 #2
0
    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();
    }
예제 #3
0
    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"));
        }
    }
예제 #4
0
    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>();
    }
예제 #5
0
        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();
            }
        }
예제 #6
0
    private void Start()
    {
        actor = gameObject.GetComponent <ActorMono>();

        //InitCastCards();
        InitCards();
    }
예제 #7
0
 public Combat(ActorMono user, Card atkCard, ActorMono target)
 {
     card_atk  = atkCard;
     actor_dfd = target;
     card_dfd  = target.FocusedCard;
     actor_atk = user;
 }
예제 #8
0
 /// <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();
 }
예제 #9
0
    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;
    }
예제 #10
0
        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();
        }
예제 #11
0
    // 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);
                }
            }
        }
    }
예제 #12
0
 public void SetHolder(ActorMono actor)
 {
     for (int i = 0; i < cards_list.Count; i++)
     {
         Card card = cards_list[i];
         card.holder = actor;
     }
 }
예제 #13
0
    public void StartCombat(ActorMono user, Card usedCard, ActorMono target)
    {
        Combat combat = new Combat(user, usedCard, target);

        // 计算combat
        combat.StartThisCombat();
        // 应用计算结果并演出
        StartCoroutine(ActionShow(combat));
    }
예제 #14
0
    public void CastCard(Card card, ActorMono target)
    {
        ActionPoint -= 1;

        UIManager.instance.UpdateActorFloatUI(gameObject, card.cardName, 2);
        CombatManager.instance.StartCombat(this, card, target);

        DiscardCard(card);
    }
예제 #15
0
 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());
 }
예제 #16
0
    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);
    }
예제 #17
0
        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();
            }
        }
예제 #18
0
 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;
 }
예제 #19
0
    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 + "";
    }
예제 #20
0
        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);
        }
예제 #21
0
        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);
        }
예제 #22
0
    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;
    }
예제 #23
0
        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();
            }
        }
예제 #24
0
    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;
        }
    }
예제 #25
0
    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();
    }
예제 #26
0
        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);
            }
        }
예제 #27
0
    /// <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);
            }
        }
    }
예제 #28
0
    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;
                    }
                }
            }
        }
    }