Exemple #1
0
    private void CallMonster(Player player)
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit rayHit;

        if (Physics.Raycast(ray, out rayHit))
        {
            if (rayHit.collider.name == "BattleRage")
            {
                if (downMonster == null)
                {
                    if (downView.type == CardModel.Type.Monster)
                    {
                        if (callCount > 0)
                        {
                            ShowStateSelect();
                        }
                        else
                        {
                            EventManager.PostEvent(TipSystem.DataType.ShowTip, "不可召唤怪物,已到本回合抽取召唤上限", current == Round.Self ? true : false);
                        }
                    }
                }
            }
            else if (rayHit.collider.name == "Monster(Clone)")
            {
                if (downMonster != null)
                {
                    if (downMonster.IsMine(current) && downMonster.canAttack)
                    {
                        Monster monster = rayHit.collider.GetComponent <Monster>();

                        if (((monster.isSelf && current == Round.Enemy) || (!monster.isSelf && current == Round.Self)) && !attacking)
                        {
                            attacking      = true;
                            hurtMonster    = monster;
                            attackMonster  = downMonster;
                            attackPosition = downMonster.origin.transform.position;

                            downMonster.origin.transform.DOMove(monster.transform.position - new Vector3(0, monster.isSelf ? -15f : 15f), 1f).OnComplete(() => {
                                // 播放攻击动画 **** 未完待续 ****
                                Animator anim = attackMonster.origin.transform.FindChild("Monster").GetComponent <Animator>();
                                anim.SetBool("Attack", true);
                            });

                            downMonster.SetState(false, false);
                        }
                    }
                }
                else
                {
                    if (downView.type == CardModel.Type.Equip)
                    {
                        Monster monster = rayHit.collider.GetComponent <Monster>();

                        if ((monster.isSelf && current == Round.Self) || (!monster.isSelf && current == Round.Enemy))
                        {
                            if (monster.equip.Equals(new Monster.MonsterEquip()))
                            {
                                CardBattle.PlayAudio("装备");

                                monster.AddEquip(int.Parse(downView.Health.text), int.Parse(downView.Attack.text), int.Parse(downView.Defend.text));

                                if (monster.isSelf)
                                {
                                    self.RemoveEquip(downView.handId);
                                }
                                else
                                {
                                    enemy.RemoveEquip(downView.handId);
                                }

                                monster.UpdateCard();
                            }
                            else
                            {
                                EventManager.PostEvent(TipSystem.DataType.ShowTip, "当前怪物已有装备", current == Round.Self ? true : false);
                            }
                        }
                    }
                }
            }
        }

        downMonster = null;
    }