Пример #1
0
        public Card PlayCard(Card c = null)
        {
            if (c == null)
            {
                c = lastCard;
            }
            int i = cardList.IndexOf(c);

            if (i < 0)
            {
                Debug.LogError("??? no card in hand: " + c.index + " " + c.cName);
                i = 0;
            }
            cardList.RemoveAt(i);
            cardArray[c.cindex]--;
            playCardList.Add(c);
            MyEventSystem.SendEvent(new CardEvent(CardEvent.PLAY_CARD, new CardEvent.CardData(this.index, c)));
            MyEventSystem.SendEvent(new CardEvent(CardEvent.UI_UPDATE_HAND_CARD, new CardEvent.CardData(this.index, cardList)));
            return(c);
        }
    void Start()
    {
        GameObject createView = GameObject.Find("CreateView");

        otherCanvasGroup       = createView.GetComponent <CanvasGroup>();
        otherCanvasGroup.alpha = 0;

        headImg    = PlayerInfoModel.Instance.headImg;
        playerBody = PlayerInfoModel.Instance.playerBody;

        occupationName = PlayerInfoModel.Instance.occupationName;

        //角色模型显示位置
        stage = GameObject.Find("Stage").transform;

        //加载已创建角色
        Init();
        LoadCreatedCharacter();

        MyEventSystem.AddListener(EventsNames.updateCharacter, UpdateCharacter);
    }
Пример #3
0
    public void AddCharacter(string name, int occupation, int server, int sex, int level = 1)
    {
        //创建玩家类
        Player player = PlayerFactory.GeneratePlayer((OccupationType)occupation, name);

        //找到账号路径并添加角色信息
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.Load(playerInfoPath);

        XmlNode    root      = xmlDoc.SelectSingleNode("root");
        XmlElement character = xmlDoc.CreateElement("character");

        character.SetAttribute("name", name);
        character.SetAttribute("level", level.ToString());
        character.SetAttribute("exp", player.Exp.ToString());
        character.SetAttribute("server", server.ToString());
        character.SetAttribute("sex", sex.ToString());
        character.SetAttribute("money", player.Money.ToString());
        character.SetAttribute("occupation", occupation.ToString());
        character.SetAttribute("hp", player.Hp.ToString());
        character.SetAttribute("maxHp", player.MaxHp.ToString());
        character.SetAttribute("mp", player.Mp.ToString());
        character.SetAttribute("maxMp", player.MaxMp.ToString());
        character.SetAttribute("atk", player.Atk.ToString());
        character.SetAttribute("def", player.Def.ToString());
        character.SetAttribute("strength", player.Strength.ToString());
        character.SetAttribute("intelligence", player.Intelligence.ToString());
        character.SetAttribute("magicPower", player.MagicPower.ToString());
        character.SetAttribute("agility", player.Agility.ToString());
        root.AppendChild(character);

        player.SetData(character);
        //添加进容器
        characterInfoList.Add(player);
        xmlDoc.Save(playerInfoPath);

        MyEventSystem.Dispatch(EventsNames.updateCharacter);
    }
Пример #4
0
    protected override void Start()
    {
        base.Start();

        player = PlayerInfoModel.Instance.SelectedPlayer;
        //加载头像
        Transform head = transform.FindChild("Head");

        headImg        = head.FindChild("HeadImg").GetComponent <Image>();
        headImg.sprite = PlayerInfoModel.Instance.headImg[player.occupation, player.sex];

        //加载血量和魔法值信息
        hp = head.FindChild("HP").GetComponent <Slider>();
        hp.wholeNumbers = true;
        hp.maxValue     = player.MaxHp;
        hp.value        = player.Hp;
        hpValue         = hp.transform.FindChild("Text").GetComponent <Text>();
        hpValue.text    = "HP " + hp.value + "/" + hp.maxValue;

        mp = head.FindChild("MP").GetComponent <Slider>();
        mp.wholeNumbers = true;
        mp.maxValue     = player.MaxMp;
        mp.value        = player.Mp;
        mpValue         = mp.transform.FindChild("Text").GetComponent <Text>();
        mpValue.text    = "MP " + mp.value + "/" + mp.maxValue;
        MyEventSystem.AddListener(EventsNames.updatePlayerMp, UpadatePlayerMp);

        //经验条信息加载
        exp = head.FindChild("Exp").GetComponent <Slider>();
        exp.wholeNumbers = true;
        exp.maxValue     = player.MaxExp;
        exp.value        = player.Exp;
        expValue         = exp.transform.FindChild("Text").GetComponent <Text>();
        expValue.text    = "Exp " + exp.value + "/" + exp.maxValue;
        MyEventSystem.AddListener(EventsNames.updatePlayerExp, UpadatePlayerExp);

        level      = exp.transform.FindChild("Level").GetComponent <Text>();
        level.text = "LV " + player.level;
    }
Пример #5
0
    // Use this for initialization

    void Start()
    {
        GameObject p = Resources.Load <GameObject>("PenWu");

        p.SetActive(false);

        penwuParticleGroup1.Add(GameObject.Instantiate <GameObject>(p));
        penwuParticleGroup1.Add(GameObject.Instantiate <GameObject>(p));
        penwuParticleGroup1.Add(GameObject.Instantiate <GameObject>(p));

        penwuParticleGroup2.Add(GameObject.Instantiate <GameObject>(p));
        penwuParticleGroup2.Add(GameObject.Instantiate <GameObject>(p));
        penwuParticleGroup2.Add(GameObject.Instantiate <GameObject>(p));

        SLFather       = GameObject.Find("SLFather").GetComponent <MakeAnimation>();
        SLFather.state = MakeAnimation.AnimationState.play;

        //leftArmAni = GameObject.Find("钻头机械臂001").GetComponent<Animator>();
        //rightArmAim = GameObject.Find("钻头机械臂002").GetComponent<Animator>();

        for (int i = 0; i < maxNUM; i++)
        {
            GameObject go = GameObject.Find("Ban" + i);

            if (go != null)
            {
                BanList.Add(go);
                GameObject childGo = FindChildAll(go, child);
                if (childGo != null)
                {
                    BanChildList.Add(childGo);
                }
            }
        }

        InitZNCM();
        MyEventSystem.AddListenter("ZNCMrestart", Restart);
    }
Пример #6
0
 private void UnRegisterEvent()
 {
     MyEventSystem.UnRegistEvent(MyGameEvent.MAP_OK, OnMapOkHandler);
 }
Пример #7
0
 void AcceptTask()
 {
     MyEventSystem.Dispatch(EventsNames.setTaskdata, curTask);
     OnExit();
 }
Пример #8
0
 public override void OnPointerClick(PointerEventData eventData)
 {
     MyEventSystem.SendEvent(new MyGameEvent(MyGameEvent.UICRAFT_CLICK_RECIPE, this));
 }
Пример #9
0
 public void Selected()
 {
     MyEventSystem.Dispatch(EventsNames.setPlayerAttackTarget, gameObject);
     print("目标选中");
 }
Пример #10
0
 private void OnMapGenerated()
 {
     Debug.Log("===MAP OK!!!");
     MyEventSystem.SendEvent(new MyGameEvent(MyGameEvent.MAP_OK));
 }
Пример #11
0
 private void SendDrawCardEvent(Card currcard)
 {
     MyEventSystem.SendEvent(new CardEvent(CardEvent.UI_UPDATE_DRAW_CARD, new CardEvent.CardData(currentPlayer, currcard)));
 }
Пример #12
0
 private void OnEnable()
 {
     MyEventSystem.DispatchEvent("ZNCMrestart");
 }
Пример #13
0
 MyEventSystem()
 {
     _instance = this;
 }
Пример #14
0
 public static void GlobalMessage(object msg)
 {
     MyEventSystem.SendEvent(new MyGameEvent(MyGameEvent.GLOBAL_MESSAGE, msg));
 }
Пример #15
0
    void CMJMove()
    {
        m_Time += Time.deltaTime;
        if (isFirst && m_Time >= 3f)
        {
            leftArmAni.CrossFade("LeftArm_DH", 0f);
            rightArmAim.CrossFade("RightArm_DH", 0f);
            isFirst = false;
            m_Time  = 0f;
            curStep = typeofStep.step1;

            Training.TrainingManager.ExecuteScript("SkipVRCamera,ZNCM_TZ");

            MovieAction.ExecuteScript("PLayMovie,ZJ_JK,JX_ZJCZ.ogg,0");
            MovieAction.ExecuteScript("PLayMovie,CMJ_JK,JX_CMJCZ.ogg,0");
            MovieAction.ExecuteScript("PLayMovie,JKZX_JK,JX_JKCZ.ogg,0");
            MovieAction.ExecuteScript("PLayMovie,ZJ_JK2,JX_ZJJK.ogg,0");
            MovieAction.ExecuteScript("PLayMovie,CMJ_JK2,JX_CMJJK.ogg,0");
            MovieAction.ExecuteScript("PLayMovie,JKZX_JK2,JX_JKJK.ogg,0");

            AudioAction.ExecuteScript("SetAudioState,caimeiji.wav,3.2:0:-53.3,90,0.3,0");
            AudioAction.ExecuteScript("SetAudioState,posuiji.wav,-46.77:0:-27.49,40,0.3,0");
            AudioAction.ExecuteScript("SetAudioState,caimeiji.wav,56.5:-0.88:9.11,50,0.3,0");

            if (Cutter2DAnimation.singleton != null)
            {
                Cutter2DAnimation.singleton.InitilizeAll(CMJGo.transform.Find("CMJ1/CMJ").gameObject);
            }
        }

        if (curStep == typeofStep.step1 && m_Time >= 4.2f) //第一次割煤
        {
            //yield return new WaitForSeconds(4.2f);
            if (curIndex <= 18)
            {
                distance = (CMJGo.transform.position - BanChildList[curIndex].transform.position).magnitude;
                CMJGo.transform.forward = BanChildList[curIndex].transform.position - BanChildList[curIndex - 1].transform.position;
                //Vector3 Dir = BanChildList[curIndex].transform.position - BanChildList[curIndex - 1].transform.position;
                //CMJGo.transform.forward = Vector3.Lerp(CMJGo.transform.forward, Dir, Time.deltaTime);
                CMJGo.transform.Translate(CMJGo.transform.forward * CMJSpeed * Time.deltaTime, Space.World);

                if (distance <= 0.4f)
                {
                    Cutter2D(curIndex);
                    curIndex++;
                    MyEventSystem.DispatchEvent("BeginMove", curIndex);
                }
            }
            else
            {
                CastTransfrom.singleton.LeftArmDown();
                CastTransfrom.singleton.RightArmUp();
                curStep = typeofStep.step2;
                m_Time  = 0f;
                //割三角煤
                ZhuAnimation.PlayAnimation(new Vector2(16, 0), 0.5f, new float[] { 0.5f }, ZhuAnimation.ZhuAnimationMode.Mode2);
                if (Cutter2DAnimation.singleton.playing)
                {
                    CastTransfrom.singleton.MiddleVisible(false);
                    CastTransfrom.singleton.HintVisible(false);
                    Cutter2DAnimation.singleton.StopCutter1SecondStageAnimation();
                    Cutter2DAnimation.singleton.StopCutter2SecondStageAnimation();
                }
                leftArmAni.CrossFade("LeftArm_DHR", 0f);
                rightArmAim.CrossFade("RightArm_DHR", 0f);

                if (Cutter2DAnimation.singleton.playing)
                {
                    CastTransfrom.singleton.CutTri();
                    CastTransfrom.singleton.ToRight();
                }
            }
        }
        else if (curStep == typeofStep.step2 && m_Time >= 4.2f) //第二次割煤--割三角煤
        {
            //yield return new WaitForSeconds(4.2f);

            if (curIndex >= 3)
            {
                distance = (CMJGo.transform.position - BanChildList[curIndex - 1].transform.position).magnitude;
                CMJGo.transform.Translate(-CMJGo.transform.forward * CMJSpeed * Time.deltaTime, Space.World);

                if (curIndex == 15)
                {
                    if (Cutter2DAnimation.singleton.playing)
                    {
                        Cutter2DAnimation.singleton.StartCutter2ThirdStageAnimation();
                    }
                }

                //Debug.Log(distance);
                if (distance <= 0.4f)
                {
                    SetGroup1Particle(curIndex + 5);
                    SetGroup2Particle(curIndex - 4);
                    curIndex--;
                    MyEventSystem.DispatchEvent("Step2", curIndex);
                }
            }
            else
            {
                CastTransfrom.singleton.LeftArmUp();
                CastTransfrom.singleton.RightArmDown();
                if (Cutter2DAnimation.singleton.playing)
                {
                    CastTransfrom.singleton.MiddleVisible(false);
                    CastTransfrom.singleton.HintVisible(false);
                    Cutter2DAnimation.singleton.StopCutter2ThirdStageAnimation();
                }
                //割底煤
                leftArmAni.CrossFade("LeftArm_DH", 0f);
                rightArmAim.CrossFade("RightArm_DH", 0f);

                if (Cutter2DAnimation.singleton.playing)
                {
                    CastTransfrom.singleton.ToLeft();
                    CastTransfrom.singleton.CutDown();
                }
                curStep = typeofStep.step3;
                m_Time  = 0f;
            }
        }
        else if (curStep == typeofStep.step3 && m_Time >= 4.2f)//第三次割煤--割底煤--中部跟机
        {
            //yield return new WaitForSeconds(4.2f);

            if (curIndex < BanChildList.Count - 1)
            {
                distance = (CMJGo.transform.position - BanChildList[curIndex].transform.position).magnitude;
                CMJGo.transform.Translate(CMJGo.transform.forward * CMJSpeed * Time.deltaTime, Space.World);

                //Debug.Log(distance);
                if (distance <= 0.4f)
                {
                    SetGroup1Particle(curIndex - 3);
                    SetGroup2Particle(curIndex - 3 + 9);

                    curIndex++;

                    //中部跟机
                    if (curIndex == 19)
                    {
                        //SetDT_YJQDTextContent("中部跟机");
                        if (Cutter2DAnimation.singleton.playing)
                        {
                            CastTransfrom.singleton.FollowMiddle();
                            Cutter2DAnimation.singleton.StartCutter1ThirdStageAnimation();
                        }
                    }
                    if (curIndex == 20)
                    {
                        ZhuAnimation.PlayAnimation(new Vector2(curIndex - 20, curIndex - 11), 0.1f,
                                                   new float[] { 1.0f, 0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f }, ZhuAnimation.ZhuAnimationMode.Mode3);
                    }

                    if (curIndex > 20 && curIndex % 10 == 0)
                    {
                        ZhuAnimation.PlayAnimation(new Vector2(curIndex - 29, curIndex - 11), 0.1f,
                                                   new float[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f }, ZhuAnimation.ZhuAnimationMode.Mode3); //, 1.0f, 0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f
                        //ZhuAnimation.PlayAnimation(new Vector2(curIndex - 20, curIndex - 11), 0.1f,
                        //    new float[] { 1.0f, 0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f }, ZhuAnimation.ZhuAnimationMode.Mode3);
                    }

                    MyEventSystem.DispatchEvent("Step3", curIndex);
                }
            }
            else
            {
                CastTransfrom.singleton.LeftArmDown();
                leftArmAni.CrossFade("LeftArm_DHR", 0f);

                if (Cutter2DAnimation.singleton.playing)
                {
                    CastTransfrom.singleton.MiddleVisible(false);
                    CastTransfrom.singleton.HintVisible(false);
                    Cutter2DAnimation.singleton.StopCutter1ThirdStageAnimation();
                }
                if (Cutter2DAnimation.singleton.playing)
                {
                    CastTransfrom.singleton.CutDown();
                    CastTransfrom.singleton.ToRight();
                }
                curStep = typeofStep.step4;
                m_Time  = 0f;
            }
        }
        else if (curStep == typeofStep.step4 && m_Time >= 4.2f) //第四次割煤--割底煤
        {
            if (curIndex > 42)
            {
                distance = (CMJGo.transform.position - BanChildList[curIndex - 1].transform.position).magnitude;
                CMJGo.transform.Translate(-CMJGo.transform.forward * CMJSpeed * Time.deltaTime, Space.World);

                if (distance <= 0.4f)
                {
                    SetGroup1Particle(curIndex + 5);
                    SetGroup2Particle(curIndex - 4);

                    curIndex--;
                    MyEventSystem.DispatchEvent("Step4");
                }
            }
            else
            {
                if (Cutter2DAnimation.singleton.playing)
                {
                    CastTransfrom.singleton.MiddleVisible(false);
                    CastTransfrom.singleton.HintVisible(false);
                }
                curStep = typeofStep.step5;
                m_Time  = 0f;
            }
        }
        else if (curStep == typeofStep.step5 && m_Time >= 0.5f) //第五次割煤--回到待机位
        {
            //yield return new WaitForSeconds(0.5f);

            if (curIndex < BanChildList.Count - 1)
            {
                distance = (CMJGo.transform.position - BanChildList[curIndex].transform.position).magnitude;
                CMJGo.transform.Translate(CMJGo.transform.forward * CMJSpeed * Time.deltaTime, Space.World);


                //Debug.Log(distance);
                if (distance <= 0.4f)
                {
                    if (curIndex == 47)
                    {
                        ZhuAnimation.PlayAnimation(new Vector2(31, 45), 0.1f,
                                                   new float[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 0.65f, 0.6f, 0.55f }, ZhuAnimation.ZhuAnimationMode.Mode3);
                    }
                    SetGroup1Particle(curIndex - 3);
                    SetGroup2Particle(curIndex - 3 + 9);

                    curIndex++;
                    MyEventSystem.DispatchEvent("Step5", curIndex);
                }
            }
            else
            {
                m_Time = 0f;
                MyEventSystem.DispatchEvent("ZNCMrestart");
            }
        }
    }
Пример #16
0
 protected override void UnRegisterEvent()
 {
     MyEventSystem.UnRegistEvent(MyGameEvent.UICRAFT_CLICK_RECIPE, OnClickRecipe);
 }
Пример #17
0
    // Update is called once per frame
    void Update()
    {
        //更新玩家数据模型中的位置信息
        selfPlayer.pos = transform.position;

        //释放技能
        PlayerSkillTrigger();

        if (Input.GetMouseButtonDown(0))
        {
            //射线和UI碰撞
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Ground")
                {
                    desPos = hit.point;

                    //生成点击效果预制物
                    if (clickEffectGo == null)
                    {
                        GameObject go = ResourceManager.Instance.Load("Effect_Prefeb/Efx_Click_Red");
                        clickEffectGo = Instantiate(go);
                    }

                    clickEffectGo.transform.position = hit.point;

                    agent.Resume();
                    agent.destination = hit.point;
                    //停止技能释放
                    //skillQueue.Clear();
                    selfState = PlayerState.AutoWalk;
                    MyEventSystem.Dispatch(EventsNames.cannotRotatePlayer);
                }

                else if (hit.collider.tag == "NPC01")
                {
                    UIManager.Instance.LoadUI(UIPanelType.chat);
                }

                else if (hit.collider.tag == "Monster")
                {
                    target = hit.collider.gameObject;
                }
            }
        }

        else
        {
            Check();
        }

        if (selfState == PlayerState.AutoWalk)
        {
            animator.SetInteger(AnimatorHashIds.playserState, (int)PlayerState.Run);
            AutoMove(speed * 1.5f);
        }
        else
        {
            animator.SetInteger(AnimatorHashIds.playserState, (int)selfState);
        }

        //重置状态
        ResetState();
    }
Пример #18
0
    void ResetState()
    {
        switch (selfState)
        {
        case PlayerState.Idle:
            break;

        case PlayerState.Walk:
        case PlayerState.Run:
            isPlayerSkillPlaying = false;
            timer += Time.deltaTime;
            if (timer >= animator.GetCurrentAnimatorStateInfo(0).length / 4)
            {
                timer     = 0;
                selfState = PlayerState.Idle;
            }
            break;

        case PlayerState.Attack1:
        case PlayerState.Attack2:
        case PlayerState.Attack3:
        case PlayerState.Attack4:
            timer += Time.deltaTime;
            if (timer >= animator.GetCurrentAnimatorStateInfo(0).length)
            {
                timer = 0;
                isPlayerSkillPlaying = false;
                if (skillQueue.Count == 0)
                {
                    selfState = PlayerState.Idle;
                    animator.CrossFade(selfState.ToString(), 0.2f, 0);
                }
            }
            else
            {
                isPlayerSkillPlaying = true;
            }
            break;

        case PlayerState.Hit:
        case PlayerState.Dodge:
        case PlayerState.Defence:
            isPlayerSkillPlaying = false;
            timer += Time.deltaTime;
            if (timer >= animator.GetCurrentAnimatorStateInfo(0).length)
            {
                timer     = 0;
                selfState = PlayerState.Idle;
            }
            break;

        case PlayerState.Die:
            break;

        case PlayerState.AutoWalk:
            isPlayerSkillPlaying = false;
            return;

        default:
            break;
        }

        if (selfState == PlayerState.Idle)
        {
            MyEventSystem.Dispatch(EventsNames.cannotRotatePlayer);
        }
    }
Пример #19
0
    void Check()
    {
        #region 行走

        if (Input.GetKey(KeyCode.W))
        {
            //停止自动寻路和技能释放
            agent.Stop();
            transform.position += transform.forward * speed * Time.deltaTime;
            selfState           = PlayerState.Walk;
            MyEventSystem.Dispatch(EventsNames.canRotatePlayer);
        }

        else if (Input.GetKey(KeyCode.S))
        {
            //停止自动寻路和技能释放
            agent.Stop();

            transform.position -= transform.forward * speed * Time.deltaTime;
            selfState           = PlayerState.Walk;
            MyEventSystem.Dispatch(EventsNames.canRotatePlayer);
        }

        else if (Input.GetKey(KeyCode.A))
        {
            //停止自动寻路和技能释放
            agent.Stop();
            transform.position -= transform.right * speed * Time.deltaTime;
            transform.Rotate(-Vector3.up * angularSpeed * Time.deltaTime);
            selfState = PlayerState.Walk;
            MyEventSystem.Dispatch(EventsNames.canRotatePlayer);
        }

        else if (Input.GetKey(KeyCode.D))
        {
            //停止自动寻路和技能释放
            agent.Stop();
            transform.position += transform.right * speed * Time.deltaTime;
            selfState           = PlayerState.Walk;
            MyEventSystem.Dispatch(EventsNames.canRotatePlayer);
        }

        #endregion

        #region 奔跑
        if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift))
        {
            //停止自动寻路和技能释放
            agent.Stop();
            transform.position += transform.forward * speed * 1.5f * Time.deltaTime;
            selfState           = PlayerState.Run;
            MyEventSystem.Dispatch(EventsNames.canRotatePlayer);
        }

        else if (Input.GetKey(KeyCode.S) && Input.GetKey(KeyCode.LeftShift))
        {
            //停止自动寻路和技能释放
            agent.Stop();
            transform.position -= transform.forward * speed * 1.5f * Time.deltaTime;
            selfState           = PlayerState.Run;
            MyEventSystem.Dispatch(EventsNames.canRotatePlayer);
        }

        #endregion
    }
Пример #20
0
 public void OnPointerClickHandler()
 {
     Debug.Log("===click " + this.cardData.index);
     MyEventSystem.SendEvent(new CardEvent(CardEvent.CARD_CLICK, this));
 }
Пример #21
0
 private void Awake()
 {
     instance = this;
 }
Пример #22
0
 private void UnRegisterEvents()
 {
     MyEventSystem.UnRegistEvent(CardEvent.PLAY_CARD, OnPlayCardHandler);
     MyEventSystem.UnRegistEvent(CardEvent.UI_UPDATE_DRAW_CARD, OnUpdateDrawCardHandler);
     MyEventSystem.UnRegistEvent(CardEvent.UI_UPDATE_HAND_CARD, OnUpdateHandCardsHandler);
 }
Пример #23
0
    //绕着尽量攻击
    IEnumerator MoveAndShoot()
    {
        int[] rdV      = new[] { -1, 1 };
        var   passTime = 0.0;
        var   h        = 1;
        var   v        = 1;

        MyEventSystem.PushEventStatic(MyEvent.EventType.EnterShoot);

        var sleepTime = 0.0f;
        var useDun    = false;

        Debug.LogError("StartAI");
        var attPLsit = new List <float>()
        {
            4,
            2,
            1,
        };
        var moveLowList = new List <float>()
        {
            2,
            3,
            4,
        };
        float attackPer  = attPLsit[(int)aiDiff];
        float movePerLow = moveLowList[(int)aiDiff];
        float movePer    = 6;

        while (true)
        {
            if (ObjectManager.objectManager != null)
            {
                var player = ObjectManager.objectManager.GetMyPlayer();
                if (player != null)
                {
                    var enemy = SkillLogic.FindNearestEnemy(player);
                    if (enemy != null)
                    {
                        MyEventSystem.PushEventStatic(MyEvent.EventType.EnterShoot);
                        var dir = enemy.transform.position - player.transform.position;
                        dir.y = 0;
                        dir.Normalize();
                        var sevt = new MyEvent()
                        {
                            type = MyEvent.EventType.ShootDir,
                            vec2 = new Vector2(dir.x, dir.z),
                        };
                        MyEventSystem.myEventSystem.PushEvent(sevt);
                    }
                    if (passTime > attackPer)
                    {
                        var rd = Random.Range(0, 2);
                        h         = rdV[rd];
                        rd        = Random.Range(0, 2);
                        v         = rdV[rd];
                        passTime -= attackPer;
                        try
                        {
                            GameInterface.gameInterface.PlayerAttack();
                        }
                        catch (Exception)
                        {
                        }
                    }

                    sleepTime += Time.deltaTime;

                    if (sleepTime >= movePerLow && sleepTime <= movePer)
                    {
                        var evt = new MyEvent(MyEvent.EventType.MovePlayer);
                        evt.localID = ObjectManager.objectManager.GetMyLocalId();
                        evt.vec2    = new Vector2(0, 0);
                        MyEventSystem.myEventSystem.PushLocalEvent(evt.localID, evt);

                        if (!useDun)
                        {
                            useDun = true;
                            GameInterface_Skill.OnSkill(0);
                        }
                        //yield return null;
                    }
                    else
                    {
                        /*
                         * var evt = new MyEvent(MyEvent.EventType.MovePlayer);
                         * evt.localID = ObjectManager.objectManager.GetMyLocalId();
                         * evt.vec2 = new Vector2(h, v);
                         * evt.vec2.Normalize();
                         * MyEventSystem.myEventSystem.PushLocalEvent(evt.localID, evt);
                         */
                        var v2 = new Vector2(h, v);
                        v2.Normalize();
                        LeftController.Instance.MoveDir = v2;
                    }
                    if (sleepTime > movePer)
                    {
                        sleepTime = 0;
                        useDun    = false;
                    }
                }
            }
            passTime += Time.deltaTime;
            yield return(null);
        }

        Debug.LogError("StopAI");
        MyEventSystem.PushEventStatic(MyEvent.EventType.ExitShoot);
    }
Пример #24
0
 private void RegisterEvent()
 {
     MyEventSystem.RegistEvent(MyGameEvent.GLOBAL_MESSAGE, OnGlobalMessageHandler);
     MyEventSystem.RegistEvent(MyGameEvent.HINT_MESSAGE, OnHintMessageHandler);
     MyEventSystem.RegistEvent(MyKeyEvent.KEY_DOWN, OnKeyDownHandler);
 }
Пример #25
0
 public override void UseEffect()
 {
     //发送加血信息
     MyEventSystem.Dispatch(EventsNames.updatePlayerHp, hp);
 }
Пример #26
0
 private void UnRegistEvents()
 {
     MyEventSystem.UnRegistEvent(CardEvent.CARD_CLICK, OnClickCardHandler);
 }
Пример #27
0
    private void Update()
    {
        if (!CanProcessEvent)
        {
            return;
        }

        if (state == RightState.Idle)
        {
            if (WindowMng.windowMng.IsOtherUIOpen())
            {
                return;
            }

#if UNITY_EDITOR || UNITY_STANDALONE
            if (Input.GetMouseButtonDown(0))
            {
                var mousePos = Input.mousePosition;
                if (mousePos.x > Screen.width / 2)
                {
                    state = RightState.Move;
                    rb.EnterMove();
                    rf.EnterMove();
                    useMouse = true;

                    rb.SetFingerPos(mousePos);
                    rf.SetFingerPos(mousePos);

                    CalculateShootDir();
                    //MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot);
                    enterTime = Time.time;
                }
            }
            else
#endif
            {
                foreach (var touch in Input.touches)
                {
                    fingerId = touch.fingerId;
                    //if (fingerId > 0 && fingerId < Input.touchCount)
                    if (touch.phase == TouchPhase.Began)
                    {
                        if (Input.GetTouch(fingerId).position.x > Screen.width / 2)
                        {
                            state = RightState.Move;

                            var fp = Input.GetTouch(fingerId).position;
                            rb.EnterMove();
                            rf.EnterMove();
                            useMouse = false;
                            rb.SetFingerPos(fp);
                            rf.SetFingerPos(fp);
                            CalculateShootDir();
                            //MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot);
                            enterTime = Time.time;
                            break;
                        }
                    }
                }
            }
        }
        else
        {
            if (Time.time - enterTime > 0.0f && enterTime != 0)
            {
                MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterShoot);
                enterTime = 0;
            }

            if (WindowMng.windowMng.IsOtherUIOpen())
            {
                state = RightState.Idle;
                rb.ExitMove();
                rf.ExitMove();
                useMouse = false;
                MyEventSystem.PushEventStatic(MyEvent.EventType.ExitShoot);
                return;
            }

#if UNITY_EDITOR || UNITY_STANDALONE
            if (useMouse)
            {
                if (!Input.GetMouseButton(0))
                {
                    state = RightState.Idle;
                    rb.ExitMove();
                    rf.ExitMove();
                    useMouse = false;
                    var exit = new MyEvent()
                    {
                        type    = MyEvent.EventType.ExitShoot,
                        boolArg = !rb.IsCancel(),
                    };

                    MyEventSystem.myEventSystem.PushEvent(exit);

                    /*
                     * if (!rb.IsCancel())
                     * {
                     *  //MyEventSystem.PushEventStatic (MyEvent.EventType.Shoot);
                     *  GameInterface.gameInterface.PlayerAttack();
                     * }
                     */
                }
                else
                {
                    var mousePos = Input.mousePosition;
                    rb.SetFingerPos(mousePos);
                    rf.SetFingerPos(mousePos);
                    CalculateShootDir();
                }
            }
            else
#endif
            {
                var   find     = false;
                Touch touch    = new Touch();
                var   getTouch = false;
                foreach (var t in Input.touches)
                {
                    if (t.fingerId == fingerId)
                    {
                        touch    = t;
                        getTouch = true;
                        break;
                    }
                }

                if (getTouch)
                {
                    var phase = touch.phase;
                    find = phase == TouchPhase.Ended || phase == TouchPhase.Canceled;
                }
                else
                {
                    find = true;
                }
                if (find)
                {
                    state = RightState.Idle;
                    rb.ExitMove();
                    rf.ExitMove();

                    var exit = new MyEvent()
                    {
                        type    = MyEvent.EventType.ExitShoot,
                        boolArg = !rb.IsCancel(),
                    };
                    MyEventSystem.myEventSystem.PushEvent(exit);

                    /*
                     * if (!rb.IsCancel())
                     * {
                     *  GameInterface.gameInterface.PlayerAttack();
                     * }
                     */
                }
                else
                {
                    var pos = touch.position;
                    rb.SetFingerPos(pos);
                    rf.SetFingerPos(pos);
                    CalculateShootDir();
                }
            }
        }
    }
Пример #28
0
    void Update()
    {
        if (!CanProcessEvent)
        {
            return;
        }
        if (state == LeftState.Idle)
        {
            MoveDir = Vector3.zero;
#if UNITY_EDITOR || UNITY_STANDALONE
            if (Input.GetMouseButtonDown(0))
            {
                var mousePos = Input.mousePosition;
                if (mousePos.x < Screen.width / 2)
                {
                    state = LeftState.Move;
                    rb.EnterMove();
                    rf.EnterMove();
                    useMouse = true;

                    rb.SetFingerPos(mousePos);
                    rf.SetFingerPos(mousePos);

                    CalculateShootDir();
                    MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterMove);
                }
            }
            else
#endif
            {
                foreach (var touch in Input.touches)
                {
                    fingerId = touch.fingerId;
                    //if (fingerId > 0 && fingerId < Input.touchCount)
                    if (touch.phase == TouchPhase.Began)
                    {
                        if (touch.position.x < Screen.width / 2)
                        {
                            state = LeftState.Move;

                            var fp = touch.position;
                            rb.EnterMove();
                            rf.EnterMove();
                            useMouse = false;
                            rb.SetFingerPos(fp);
                            rf.SetFingerPos(fp);
                            CalculateShootDir();
                            MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.EnterMove);
                            break;
                        }
                    }
                }
            }
        }
        else
        {
#if UNITY_EDITOR || UNITY_STANDALONE
            if (useMouse)
            {
                if (!Input.GetMouseButton(0))
                {
                    state = LeftState.Idle;
                    rb.ExitMove();
                    rf.ExitMove();
                    useMouse = false;
                    MyEventSystem.PushEventStatic(MyEvent.EventType.ExitMove);
                }
                else
                {
                    var mousePos = Input.mousePosition;
                    rb.SetFingerPos(mousePos);
                    rf.SetFingerPos(mousePos);
                    CalculateShootDir();
                }
            }
            else
#endif
            {
                var   find     = false;
                Touch touch    = new Touch();
                var   getTouch = false;
                foreach (var t in Input.touches)
                {
                    if (t.fingerId == fingerId)
                    {
                        touch    = t;
                        getTouch = true;
                        break;
                    }
                }

                if (getTouch)
                {
                    var phase = touch.phase;
                    find = phase == TouchPhase.Ended || phase == TouchPhase.Canceled;
                }
                else
                {
                    find = true;
                }

                if (find)
                {
                    state = LeftState.Idle;
                    rb.ExitMove();
                    rf.ExitMove();
                    MyEventSystem.PushEventStatic(MyEvent.EventType.ExitMove);
                }
                else
                {
                    var pos = touch.position;
                    rb.SetFingerPos(pos);
                    rf.SetFingerPos(pos);
                    CalculateShootDir();
                }
            }
        }
    }