예제 #1
0
 void FetchRound()
 {
     Rounds.Clear();
     foreach (FighterController f in F1)
     {
         if (f.BindMember.HP > 0 && f.BindMember.MP > SkillManager.MinMP(f.BindMember.Magics))
         {
             Rounds.Add(f);
         }
     }
     foreach (FighterController f in F2)
     {
         if (f.BindMember.HP > 0 && f.BindMember.MP > SkillManager.MinMP(f.BindMember.Magics))
         {
             Rounds.Add(f);
         }
     }
     Rounds.Sort((m2, m1) => (m1.BindMember.SPD + Random.Range(-10, 10)).CompareTo(m2.BindMember.SPD + Random.Range(-10, 10)));
     foreach (FighterController f in Rounds)
     {
         SkillManager.BuffProcess(f, 0);
     }
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        ttick += Time.deltaTime;

        if (BattleStep == 3 && Msg.Count == 0)
        {
            Rounds[0].BindMember.LastSkill = lSk;

            Rounds[0].BindMember.MP -= lSk.MP;
            BattleStep = 4; ttick = 0;
            TeamInfoController tt = TarTeam.GetComponent <TeamInfoController>();
            tt.BindMember       = new TeamController.Member();
            tt.BindMember.Name  = tar.BindMember.Name;
            tt.BindMember.HP    = tar.BindMember.HP;
            tt.BindMember.MaxHP = tar.BindMember.MaxHP;
            tt.UpdateInfo();

            Injury  = lSk.Strength * Rounds[0].BindMember.ATK;
            Injury /= 1.5f;
            if (lSk.Strength > 0)
            {
                Injury -= tar.BindMember.DEF;
            }
            Source  = Injury;
            Injury *= TeamController.JC[(int)lSk.Job - 1, (int)tar.BindMember.Job[0] - 1];
            Injury *= TeamController.JC[(int)lSk.Job - 1, (int)tar.BindMember.Job[1] - 1];

            if (lSk.Strength >= 0)
            {
                tar.State = FighterController.BattleState.Hurt;
            }
            GameObject fab = (GameObject)Resources.Load("Epic Toon FX\\Prefabs\\" + lSk.Animate);
            SkObj = Instantiate(fab,
                                new Vector3(tar.transform.position.x, tar.transform.position.y, tar.transform.position.z),
                                Quaternion.identity, this.transform.parent);
            SkObj.transform.localScale       = new Vector3(2.5f, 2.5f, 2.5f);
            SkObj.transform.localEulerAngles = new Vector3(-90f, 0, 0);
            SkObj.SetActive(true);
        }

        if (BattleStep == 4 && ttick >= 3.0f)
        {
            float fi = Injury / Source;
            if (lSk.Strength != 0)
            {
                if (fi >= 1.1f && fi <= 1.3f)
                {
                    Msg.Add("效果不错");
                }
                if (fi > 1.3f)
                {
                    Msg.Add("效果绝佳!!!");
                }
                if (fi >= 0.75f && fi <= 0.9f)
                {
                    Msg.Add("效果不咋的...");
                }
                if (fi < 0.75f && fi > 0f)
                {
                    Msg.Add("好像对对方没什么用...");
                }
                if (fi == 0f)
                {
                    Msg.Add("似乎完全没有效果。");
                }
            }
            tar.BindMember.HP -= Mathf.Floor(Injury);
            tar.State          = FighterController.BattleState.Normal;

            if (tar.BindMember.HP > tar.BindMember.MaxHP)
            {
                tar.BindMember.HP = tar.BindMember.MaxHP;
            }
            if (tar.BindMember.HP / tar.BindMember.MaxHP <= 0.3f && tar.BindMember.HP > 0)
            {
                Msg.Add(tar.BindMember.Name + "快要撑不住了!");
                tar.State = FighterController.BattleState.BadHurt;
            }
            if (tar.BindMember.HP <= 0)
            {
                tar.BindMember.HP = 0;
                Msg.Add(tar.BindMember.Name + "倒下了!");
                Rounds.Remove(tar);
                tar.State = FighterController.BattleState.Die;
            }

            if (Rounds[0].State == FighterController.BattleState.Hurt)
            {
                Rounds[0].State = FighterController.BattleState.Normal;
            }
            BattleStep = 0; ttick = 0;
            try{ Destroy(SkObj); }catch {}

            bool GameClosed = false;
            if (F1.FindIndex(m => m.BindMember.HP > 0) == -1)
            {
                GameClosed = true;
                foreach (FighterController f in F2.FindAll(m => m.BindMember.HP > 0))
                {
                    f.State = FighterController.BattleState.Win;
                }
                BGM.GetComponent <AudioSource>().Stop();
                SoundPlayer.Play("Defeat2");
                Msg.Add("我方败给了敌方!");
            }
            if (F2.FindIndex(m => m.BindMember.HP > 0) == -1)
            {
                GameClosed = true;
                foreach (FighterController f in F1.FindAll(m => m.BindMember.HP > 0))
                {
                    f.State = FighterController.BattleState.Win;
                }
                BGM.GetComponent <AudioSource>().Stop();
                SoundPlayer.Play("Victory1");
                Msg.Add("我方战胜了敌方!");
            }
            if (GameClosed)
            {
                Rounds.Clear(); return;
            }

            float nHP = tar.BindMember.HP;
            SkillManager.BuffProcess(tar, 1);
            if (tar.BindMember.HP - nHP != 0)
            {
                Debug.Log("追加回合");
                BattleStep = 4; ttick = 0;
                TeamInfoController tt = TarTeam.GetComponent <TeamInfoController>();
                tt.BindMember       = new TeamController.Member();
                tt.BindMember.Name  = tar.BindMember.Name;
                tt.BindMember.HP    = nHP;
                tt.BindMember.MaxHP = tar.BindMember.MaxHP;
                tt.UpdateInfo();
                Injury = tar.BindMember.HP - nHP;
                Source = Injury;
            }
            else
            {
                SkillManager.ExtraSkill(lSk.Name, Rounds[0], tar);
                Rounds.RemoveAt(0);
                if (Rounds.Count == 0)
                {
                    FetchRound();
                }
            }
        }

        bool ttA = (BattleStep >= 4);

        if (TarTeam.activeSelf != ttA)
        {
            TarTeam.SetActive(ttA);
        }
        if (ttA)
        {
            TeamInfoController tt = TarTeam.GetComponent <TeamInfoController>();
            tt.BindMember.HP += (tar.BindMember.HP - Injury - tt.BindMember.HP) / 10;
            tt.BindMember.HP  = Mathf.Floor(tt.BindMember.HP);
            if (tt.BindMember.HP < 0)
            {
                tt.BindMember.HP = 0;
            }
            if (tt.BindMember.HP > tt.BindMember.MaxHP)
            {
                tt.BindMember.HP = tt.BindMember.MaxHP;
            }
            tt.UpdateInfo();
        }

        bool ShowUI = (Msg.Count == 0);

        if (ShowUI != LastShow || BattleStep != LastBattle)
        {
            LastShow = ShowUI; LastBattle = BattleStep;
            DialogB.SetActive(!ShowUI);
            DialogT.SetActive(!ShowUI);
            foreach (GameObject go in BattleBtn)
            {
                go.SetActive(ShowUI && BattleStep == 0);
            }
        }
        if (ShowUI && Rounds.Count > 0)
        {
            if (!Rounds[0].Equals(lfc))
            {
                if (!(lfc == null))
                {
                    lfc.IsYourTurn = false; lfc.State = FighterController.BattleState.Normal;
                }
                lfc = Rounds[0];
                Rounds[0].IsYourTurn = true;
                Msg.Add(lfc.BindMember.Name + "(" + (lfc.IsEne ? "敌方" : "我方") + ")的回合!");
                if (lfc.IsEne)
                {
                    EneUse();
                }
            }
        }

        float cx = cox, cy = coy, cz = coz;
        float ins = 1;

        //FighterController f = Rounds[0];
        if (ShowUI)
        {
            cx = Rounds[0].gameObject.transform.position.x;
            cz = Rounds[0].gameObject.transform.position.z - 14;
        }
        if (BattleStep == 4)
        {
            cx  = tar.gameObject.transform.position.x;
            cz  = tar.gameObject.transform.position.z - 12;
            ins = 0.3f;
        }
        if (BattleStep == 1)
        {
            cx += 12;
        }
        if (BattleStep == 2)
        {
            if (lSk.Strength >= 0)
            {
                cx += 5;
            }
            else
            {
                cx -= 10;
            }
        }
        Vector3 v2 = Camera.main.transform.position;

        Camera.main.transform.position = new Vector3(v2.x + (cx - v2.x) / 10, v2.y + (cy - v2.y) / 10, v2.z + (cz - v2.z) / 10);

        Lights.intensity += (ins - Lights.intensity) / 10;

        Transform Sk = SkillBoard.transform;
        float     px = 1380;

        if (BattleStep == 1)
        {
            px = 420;
        }
        if (BattleStep == 2)
        {
            px = -439;
        }
        Sk.localPosition = new Vector3(px + (Sk.localPosition.x - px) / 10, Sk.localPosition.y, Sk.localPosition.z);

        if (!ShowUI)
        {
            DialogT.GetComponent <Text>().text = Msg[0];
        }
        if (Input.GetMouseButtonUp(0))
        {
            GraphicRaycaster gr   = this.GetComponent <GraphicRaycaster>();
            PointerEventData data = new PointerEventData(EventSystem.current);
            data.pressPosition = Input.mousePosition;
            data.position      = Input.mousePosition;
            List <RaycastResult> results = new List <RaycastResult>();
            gr.Raycast(data, results);

            foreach (RaycastResult rr in results)
            {
                Carry(rr.gameObject.name, rr.gameObject);
            }
        }
    }