예제 #1
0
 //ユニット設置可能なマスにタイルを描く
 void DrawTile()
 {
     unitsetposlist.Clear();
     for (int i = 0; i < Mapclass.mapxnum; i++)
     {
         for (int j = 0; j < Mapclass.mapynum; j++)
         {
             if (BattleVal.mapdata[(int)MapdataList.MAPUNITSET][j][i] == 1)
             {
                 unitsetlist.Add(Instantiate(UnitSetTile));
                 Mapclass.DrawCharacter(unitsetlist[unitsetlist.Count - 1], i, j);
                 //1つ目の座標に視点移動
                 if (unitsetposlist.Count == 0)
                 {
                     Vector3 temp = new Vector3();
                     Mapclass.TranslateMapCoordToPosition(ref temp, i, j);
                     CameraAngle.CameraPoint(temp);
                 }
                 unitsetposlist.Add(new int[] { i, j });
             }
         }
     }
 }
예제 #2
0
    //キャラクターの座標を入れ替える関数(配置変更用)
    public static void Swap_Unit_Position(Unitdata unit1, Unitdata unit2)
    {
        int tmpx, tmpy;

        tmpx = unit1.x;
        tmpy = unit1.y;

        //unit1のGameObjectの位置を変更
        Vector3 r1 = new Vector3();

        Mapclass.TranslateMapCoordToPosition(ref r1, unit2.x, unit2.y);
        unit1.gobj.transform.position = r1;
        unit1.gobj.transform.LookAt(new Vector3(r1.x, unit1.gobj.transform.position.y, r1.z));
        unit1.x = unit2.x;
        unit1.y = unit2.y;

        //unit2のGameObjectの位置を変更
        Mapclass.TranslateMapCoordToPosition(ref r1, tmpx, tmpy);
        unit2.gobj.transform.position = r1;
        unit2.gobj.transform.LookAt(new Vector3(r1.x, unit2.gobj.transform.position.y, r1.z));
        unit2.x = tmpx;
        unit2.y = tmpy;

        //map上のキャラクターIDの更新
        int tmpmap1 = BattleVal.mapdata[(int)MapdataList.MAPUNIT][unit1.y][unit1.x];

        BattleVal.mapdata[(int)MapdataList.MAPUNIT][unit1.y][unit1.x]
            = BattleVal.mapdata[(int)MapdataList.MAPUNIT][unit2.y][unit2.x];
        BattleVal.mapdata[(int)MapdataList.MAPUNIT][unit2.y][unit2.x] = tmpmap1;

        //ディクショナリのアップデート
        BattleVal.id2index.Remove(string.Format("{0},{1}", unit2.x, unit2.y));  //swap後なのでこれはunit1の消去であることに注意
        BattleVal.id2index.Remove(string.Format("{0},{1}", unit1.x, unit1.y));  //swap後なのでこれはunit2の消去であることに注意
        BattleVal.id2index.Add(string.Format("{0},{1}", unit1.x, unit1.y), unit1);
        BattleVal.id2index.Add(string.Format("{0},{1}", unit2.x, unit2.y), unit2);
    }
예제 #3
0
    //キャラクターの座標を変更する関数(1手戻し、配置変更用)
    public static void Change_Unit_Position(Unitdata unit, int[] old_pos, int[] new_pos)
    {
        //unitのGameObjectの位置を変更
        Vector3 r1 = new Vector3();

        Mapclass.TranslateMapCoordToPosition(ref r1, new_pos[0], new_pos[1]);
        unit.gobj.transform.position = r1;
        unit.gobj.transform.LookAt(new Vector3(r1.x, unit.gobj.transform.position.y, r1.z));
        unit.x = new_pos[0];
        unit.y = new_pos[1];


        //map上のキャラクターIDの更新
        BattleVal.mapdata[(int)MapdataList.MAPUNIT][new_pos[1]][new_pos[0]]
            = BattleVal.mapdata[(int)MapdataList.MAPUNIT][old_pos[1]][old_pos[0]];
        BattleVal.mapdata[(int)MapdataList.MAPUNIT][old_pos[1]][old_pos[0]] = 0;

        //ディクショナリのアップデート
        BattleVal.id2index.Remove(string.Format("{0},{1}", old_pos[0], old_pos[1]));
        BattleVal.id2index.Add(string.Format("{0},{1}", new_pos[0], new_pos[1]), unit);

        //unitの行動フラグを戻す
        unit.movable = true;
    }
예제 #4
0
    public GameObject defeatEffect;    //撃墜時のエフェクト
    private void Update()
    {
        //戦闘中
        if (BattleVal.status == STATUS.BATTLE)
        {
            bool critflag  = false;
            bool dodgeflag = false;
            int  damage    = 0;
            switch (bstate)
            {
            case BATTLE_STATUS.SETVECT:
                //キャラの向きの調整
                Vector3 r0 = new Vector3();     //攻撃元
                Vector3 r1 = new Vector3();     //攻撃先
                Mapclass.TranslateMapCoordToPosition(ref r0, BattleVal.selectX, BattleVal.selectY);
                Mapclass.TranslateMapCoordToPosition(ref r1, attackedpos[0], attackedpos[1]);

                //攻撃対象の登録
                Unitdata temp = BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])];
                damage = Calc_Damage(BattleVal.selectedUnit, temp);
                float dex  = Calc_Dexterity(BattleVal.selectedUnit, temp);
                float rate = Calc_CriticalRate(BattleVal.selectedUnit, temp);
                //当たった場合
                if (Is_Hit(dex))
                {
                    //クリティカル発生かどうか
                    if (Is_Hit(rate))
                    {
                        damage   = (int)(damage * 1.5f);
                        critflag = true;
                    }

                    temp.hp -= damage;     //ダメージ処理


                    string damagetext = string.Format("{0}", damage);
                    int    count      = 1;
                    //ダメージテキストの中心座標
                    Vector3 damage_center = Camera.main.WorldToScreenPoint(r1);

                    //テキストの登録
                    foreach (char a in damagetext)
                    {
                        int num = (int)char.GetNumericValue(a);     //数を取得

                        damagenum.Add(Instantiate(damagetextprefab, r1, Quaternion.identity));
                        damagenum[count - 1].text = a.ToString();
                        //サイズ取得
                        damagenum[count - 1].rectTransform.sizeDelta =
                            new Vector2(damagenum[count - 1].preferredWidth, damagenum[count - 1].preferredHeight);
                        damagenum[count - 1].rectTransform.sizeDelta =
                            new Vector2(damagenum[count - 1].preferredWidth, damagenum[count - 1].preferredHeight);
                        damagenum[count - 1].transform.SetParent(canvas.transform, false);
                        damagenum[count - 1].transform.localPosition = damage_center - new Vector3(canvas.GetComponent <RectTransform>().sizeDelta.x / 2, canvas.GetComponent <RectTransform>().sizeDelta.y / 2, 0);
                        //1桁当たりの文字ブロック
                        Vector3 numsize = damagenum[count - 1].GetComponent <RectTransform>().sizeDelta *damagenum[count - 1].GetComponent <RectTransform>().localScale;
                        numsize.y = 0;
                        numsize.z = 0;

                        damagenum[count - 1].transform.localPosition += (count - 1) * numsize;
                        damagenum[count - 1].transform.localPosition += new Vector3(0, 30, 0);
                        damagenum[count - 1].gameObject.SetActive(false);
                        damagenum[count - 1].color = new Vector4(1, 0, 0, 1);
                        count++;
                    }
                    //クリティカルの場合、そのテキストを表示
                    if (critflag)
                    {
                        damagenum.Add(Instantiate(damagetextprefab, r1, Quaternion.identity));
                        damagenum[count - 1].text = "Critical!";
                        //サイズ取得
                        damagenum[count - 1].rectTransform.sizeDelta =
                            new Vector2(damagenum[count - 1].preferredWidth, damagenum[count - 1].preferredHeight);
                        damagenum[count - 1].rectTransform.sizeDelta =
                            new Vector2(damagenum[count - 1].preferredWidth, damagenum[count - 1].preferredHeight);
                        damagenum[count - 1].transform.SetParent(canvas.transform, false);
                        damagenum[count - 1].transform.localPosition  = damage_center - new Vector3(canvas.GetComponent <RectTransform>().sizeDelta.x / 2, canvas.GetComponent <RectTransform>().sizeDelta.y / 2, 0);
                        damagenum[count - 1].transform.localPosition += new Vector3(0, 100, 0);
                        damagenum[count - 1].gameObject.SetActive(false);
                        damagenum[count - 1].color = new Color(1.0f, 1.0f, 0);
                        count++;
                    }
                }
                else
                {
                    dodgeflag = true;
                    //ダメージテキストの中心座標
                    Vector3 damage_center = Camera.main.WorldToScreenPoint(r1);

                    //テキストの登録
                    damagenum.Add(Instantiate(damagetextprefab, r1, Quaternion.identity));
                    damagenum[0].text = "DODGE!";
                    //サイズ取得
                    damagenum[0].rectTransform.sizeDelta =
                        new Vector2(damagenum[0].preferredWidth, damagenum[0].preferredHeight);
                    damagenum[0].rectTransform.sizeDelta =
                        new Vector2(damagenum[0].preferredWidth, damagenum[0].preferredHeight);
                    damagenum[0].transform.SetParent(canvas.transform, false);
                    damagenum[0].transform.localPosition  = damage_center - new Vector3(canvas.GetComponent <RectTransform>().sizeDelta.x / 2, canvas.GetComponent <RectTransform>().sizeDelta.y / 2, 0);
                    damagenum[0].transform.localPosition += new Vector3(0, 30, 0);
                    damagenum[0].gameObject.SetActive(false);
                    damagenum[0].color = new Vector4(1, 1, 1, 1);
                }
                //initialize
                nowtime = -1;

                //キャラ向きの調整(お互いに向き合う)
                float tempy = r1.y;
                r1.y = r0.y;
                BattleVal.selectedUnit.gobj.transform.LookAt(r1);
                r0.y = tempy;
                temp.gobj.transform.LookAt(r0);

                //行動スタックのクリア(1手戻し不可能に)
                BattleVal.actions.Clear();

                //state undate
                if (critflag)
                {
                    bstate = BATTLE_STATUS.EFFECT;
                    //クリティカル攻撃・構えモーション
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Play("CriticalPre");
                }
                else
                {
                    bstate = BATTLE_STATUS.BATTLE;
                    //攻撃モーション開始
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Play("Attack");
                }

                attackedAnimator  = temp.gobj.GetComponent <Animator>();
                attackedanimstate = "Damage";
                if (dodgeflag)
                {
                    attackedanimstate = "Dodge";
                }

                break;

            //クリティカル攻撃の演出
            case BATTLE_STATUS.EFFECT:

                //クリティカル攻撃・構えモーションが終了し、音声はなり終わったか?
                if (BattleVal.selectedUnit.gobj.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime >= 1 &&
                    !BattleVal.selectedUnit.gobj.GetComponent <CharaAnimation>().voiceSource.isPlaying &&
                    !BattleVal.selectedUnit.gobj.GetComponent <CharaAnimation>().seSource.isPlaying)
                {
                    //クリティカル攻撃モーションへ
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Play("CriticalAttack");
                    bstate = BATTLE_STATUS.BATTLE;
                }


                break;

            case BATTLE_STATUS.BATTLE:
                //バトルのアニメーション
                //ヒット判定で効果音+被ダメージアニメーション
                if (BattleVal.selectedUnit.gobj.GetComponent <CharaAnimation>().isHit)
                {
                    attackedAnimator.Play(attackedanimstate);
                    if (attackedanimstate == "Dodge")
                    {
                        Operation.setSE(seDodge);
                    }
                    else
                    {
                        Operation.setSE(seHitN);
                        Vector3 effectpos = new Vector3();
                        Mapclass.TranslateMapCoordToPosition(ref effectpos, attackedpos[0], attackedpos[1]);
                        hitEffect = Instantiate(BattleVal.selectedUnit.attackeffect, effectpos, BattleVal.selectedUnit.attackeffect.transform.rotation);
                    }

                    //テキスト表示
                    foreach (Text a in damagenum)
                    {
                        a.gameObject.SetActive(true);
                    }
                }

                //攻撃者の攻撃モーションが終わったか?
                if (!BattleVal.selectedUnit.gobj.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsTag("Attack"))
                {
                    //ダメージテキストの表示
                    if (nowtime == -1)
                    {
                        nowtime = 0;
                    }
                    else if (nowtime >= battle_time - Time.deltaTime)
                    {
                        bstate = BATTLE_STATUS.AFTERBATTLE;

                        //ダメージ数値のテキストを消す処理
                        foreach (Text a in damagenum)
                        {
                            Destroy(a.gameObject);
                        }

                        damagenum.Clear();

                        //攻撃可能フラグをオフに
                        BattleVal.selectedUnit.atackable = false;
                    }
                    else
                    {
                        //ダメージ数値のテキストを消す処理
                        //damagetext.color -= new Color(0,0,0,Time.deltaTime);
                        foreach (Text a in damagenum)
                        {
                            a.color -= new Color(0, 0, 0, Time.deltaTime);
                            a.transform.position += new Vector3(0, 1, 0);
                        }
                        nowtime += Time.deltaTime;
                    }
                }
                break;

            //戦闘後処理
            case BATTLE_STATUS.AFTERBATTLE:
                //ヒットエフェクトの消去
                Destroy(hitEffect);
                //獲得経験値
                int getexp = 10;     //基本値

                //撃墜処理
                if (BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])].hp <= 0)
                {
                    Vector3 effectpos = new Vector3();
                    Mapclass.TranslateMapCoordToPosition(ref effectpos, attackedpos[0], attackedpos[1]);

                    Unitdata unit = BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])];
                    //撃墜エフェクト
                    StartCoroutine(UnitDefeat.DefeatHandle(unit, defeatEffect, effectpos));

                    //撃墜ボーナス
                    getexp += BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])].status.needexp;

                    //ユニットデータを消去
                    ////BattleVal.unitlistから消去
                    for (int i = 0; i < BattleVal.unitlist.Count; i++)
                    {
                        if (BattleVal.unitlist[i].x == unit.x && BattleVal.unitlist[i].y == unit.y)
                        {
                            BattleVal.unitlist.RemoveAt(i);
                            break;
                        }
                    }
                    ////BattleVal.id2indexから消去
                    BattleVal.id2index.Remove(string.Format("{0},{1}", unit.x, unit.y));
                    ////mapdataからユニット情報の削除
                    BattleVal.mapdata[(int)MapdataList.MAPUNIT][unit.y][unit.x] = 0;
                }

                //ユニットセレクトに戻る
                bstate = BATTLE_STATUS.SETVECT;
                if (BattleVal.selectedUnit.team == 0)
                {
                    //経験値を獲得するキャラの場合
                    if (BattleVal.selectedUnit.status.needexp != 0 &&
                        BattleVal.selectedUnit.status.level < 99 && BattleVal.selectedUnit.status.level >= 1)
                    {
                        Operation.AddGetExp(BattleVal.selectedUnit, getexp);
                        BattleVal.status = STATUS.GETEXP;
                    }
                    else
                    {
                        BattleVal.status = STATUS.PLAYER_UNIT_SELECT;
                    }
                }
                else
                {
                    BattleVal.status = STATUS.ENEMY_UNIT_SELECT;
                }
                break;
            }
        }
    }
예제 #5
0
    //Update
    private void Update()
    {
        //戦闘中
        if (BattleVal.status == STATUS.USESKILL)
        {
            int damage = 0;
            switch (bstate)
            {
            case BATTLE_STATUS.SETVECT:
                //キャラの向き調整;攻撃元が発動場所を向く
                Vector3 r0     = new Vector3(); //攻撃元
                Vector3 rSkill = new Vector3();
                Mapclass.TranslateMapCoordToPosition(ref r0, BattleVal.selectX, BattleVal.selectY);
                Mapclass.TranslateMapCoordToPosition(ref rSkill, skillpos[0], skillpos[1]);
                rSkill.y = r0.y;
                BattleVal.selectedUnit.gobj.transform.LookAt(rSkill);

                /*
                 * //攻撃対象
                 * foreach (int[] attackedpos in attackedposlist)
                 * {
                 *  Vector3 r1 = new Vector3(); //攻撃先
                 *  Mapclass.TranslateMapCoordToPosition(ref r1, attackedpos[0], attackedpos[1]);
                 *  Unitdata temp = BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])];
                 *  damage = Calc_Damage(BattleVal.selectedUnit, temp);
                 *
                 *  temp.hp -= damage; //ダメージ処理
                 *
                 *  string damagetext = string.Format("{0}", (int)Mathf.Abs(damage));
                 *  int count = 1;
                 *  //ダメージテキストの中心座標
                 *  Vector3 damage_center = Camera.main.WorldToScreenPoint(r1);
                 *
                 *  //テキストの登録
                 *  List<Text> damagenumtmp = new List<Text>();
                 *  foreach (char a in damagetext)
                 *  {
                 *      int num = (int)char.GetNumericValue(a); //数を取得
                 *
                 *      damagenumtmp.Add(Instantiate(damagetextprefab, r1, Quaternion.identity));
                 *      damagenumtmp[count - 1].text = a.ToString();
                 *      //サイズ取得
                 *      damagenumtmp[count - 1].rectTransform.sizeDelta =
                 *          new Vector2(damagenumtmp[count - 1].preferredWidth, damagenumtmp[count - 1].preferredHeight);
                 *      damagenumtmp[count - 1].rectTransform.sizeDelta =
                 *          new Vector2(damagenumtmp[count - 1].preferredWidth, damagenumtmp[count - 1].preferredHeight);
                 *      damagenumtmp[count - 1].transform.SetParent(canvas.transform, false);
                 *      damagenumtmp[count - 1].transform.localPosition = damage_center - new Vector3(canvas.GetComponent<RectTransform>().sizeDelta.x / 2, canvas.GetComponent<RectTransform>().sizeDelta.y / 2, 0);
                 *
                 *      //1桁当たりの文字ブロック
                 *      Vector3 numsize = damagenumtmp[count - 1].GetComponent<RectTransform>().sizeDelta * damagenumtmp[count - 1].GetComponent<RectTransform>().localScale;
                 *      numsize.y = 0;
                 *      numsize.z = 0;
                 *
                 *      damagenumtmp[count - 1].transform.localPosition += (count - 1) * numsize;
                 *      damagenumtmp[count - 1].transform.localPosition += new Vector3(0, 30, 0);
                 *      damagenumtmp[count - 1].color = new Vector4(1, 0, 0, 1);
                 *      if (damage < 0) damagenumtmp[count - 1].color = new Vector4(0.7f,1,0.7f,1);
                 *      damagenumtmp[count - 1].gameObject.SetActive(false);
                 *      count++;
                 *
                 *  }
                 *  damagenum.Add(damagenumtmp);
                 *
                 *  //アニメーション設定
                 *  attackedAnimator.Add(temp.gobj.GetComponent<Animator>());
                 *  if(damage > 0)
                 *      attackedanimstate.Add(hitAnimName);    //共通モーションだと思うが、一部キャラで回復・ダメージが混ざる将来性も加味する
                 *  else
                 *      attackedanimstate.Add(healAnimName); //暫定 Healモーションも作る
                 *  attackedCharaAnimation.Add(temp.gobj.GetComponent<CharaAnimation>());
                 * }
                 */
                nowtime = -1;     //initialize

                //スキルの消費
                selectedskill.Consume(1);
                //行動スタックのクリア(1手戻し不可能に)
                BattleVal.actions.Clear();

                //カットイン演出の場合
                if (selectedskill.is_cutscene)
                {
                    gobjCutin = Instantiate(selectedskill.prefab_cutin);
                    bstate    = BATTLE_STATUS.CUTIN;
                }
                else
                {
                    //通常スキルの場合
                    //スキル使用モーション再生
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Play(selectedskill.animname);
                    //state update
                    bstate         = BATTLE_STATUS.EFFECT;
                    skilltext.text = selectedskill.skillname;
                    skillnamePanel.SetActive(true);
                }


                break;

            case BATTLE_STATUS.CUTIN:
                if (gobjCutin.GetComponent <CutinChecker>().cutinFinish)
                {
                    Destroy(gobjCutin);
                    //スキル使用モーション再生
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Play(selectedskill.animname);
                    //state update
                    bstate         = BATTLE_STATUS.EFFECT;
                    skilltext.text = selectedskill.skillname;
                    skillnamePanel.SetActive(true);
                }
                break;

            case BATTLE_STATUS.EFFECT:
                //スキル使用モーションが終了し、音声はなり終わったか?

                /*
                 * if (BattleVal.selectedUnit.gobj.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime >= 1
                 *  && !BattleVal.selectedUnit.gobj.GetComponent<CharaAnimation>().voiceSource.isPlaying
                 *  && !BattleVal.selectedUnit.gobj.GetComponent<CharaAnimation>().seSource.isPlaying)
                 */
                if (!BattleVal.selectedUnit.gobj.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).shortNameHash.Equals(Animator.StringToHash(selectedskill.animname)) &&
                    !BattleVal.selectedUnit.gobj.GetComponent <CharaAnimation>().voiceSource.isPlaying &&
                    !BattleVal.selectedUnit.gobj.GetComponent <CharaAnimation>().seSource.isPlaying)
                {
                    Vector3 effectcampoint = new Vector3();
                    Mapclass.TranslateMapCoordToPosition(ref effectcampoint, skillpos[0], skillpos[1]);
                    CameraAngle.CameraPoint(effectcampoint);

                    //エフェクト再生へ
                    Vector3 reffect = new Vector3();
                    Mapclass.TranslateMapCoordToPosition(ref reffect, skillpos[0], skillpos[1]);
                    hitEffect = Instantiate(selectedskill.skillefect, reffect, selectedskill.skillefect.transform.rotation);
                    bstate    = BATTLE_STATUS.BATTLE;
                }
                break;

            case BATTLE_STATUS.BATTLE:
                //バトルのアニメーション

                //エフェクトの再生が終了したか?
                if (hitEffect == null)
                {
                    //被弾モーション再生
                    if (nowtime == -1)
                    {
                        //攻撃対象
                        foreach (int[] attackedpos in attackedposlist)
                        {
                            Vector3 r1 = new Vector3();     //攻撃先
                            Mapclass.TranslateMapCoordToPosition(ref r1, attackedpos[0], attackedpos[1]);
                            Unitdata temp = BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])];
                            damage = Calc_Damage(BattleVal.selectedUnit, temp);

                            temp.hp -= damage;     //ダメージ処理

                            string damagetext = string.Format("{0}", (int)Mathf.Abs(damage));
                            int    count      = 1;
                            //ダメージテキストの中心座標
                            Vector3 damage_center = Camera.main.WorldToScreenPoint(r1);

                            //テキストの登録
                            List <Text> damagenumtmp = new List <Text>();
                            foreach (char a in damagetext)
                            {
                                int num = (int)char.GetNumericValue(a);     //数を取得

                                damagenumtmp.Add(Instantiate(damagetextprefab, r1, Quaternion.identity));
                                damagenumtmp[count - 1].text = a.ToString();
                                //サイズ取得
                                damagenumtmp[count - 1].rectTransform.sizeDelta =
                                    new Vector2(damagenumtmp[count - 1].preferredWidth, damagenumtmp[count - 1].preferredHeight);
                                damagenumtmp[count - 1].rectTransform.sizeDelta =
                                    new Vector2(damagenumtmp[count - 1].preferredWidth, damagenumtmp[count - 1].preferredHeight);
                                damagenumtmp[count - 1].transform.SetParent(canvas.transform, false);
                                damagenumtmp[count - 1].transform.localPosition = damage_center - new Vector3(canvas.GetComponent <RectTransform>().sizeDelta.x / 2, canvas.GetComponent <RectTransform>().sizeDelta.y / 2, 0);

                                //1桁当たりの文字ブロック
                                Vector3 numsize = damagenumtmp[count - 1].GetComponent <RectTransform>().sizeDelta *damagenumtmp[count - 1].GetComponent <RectTransform>().localScale;
                                numsize.y = 0;
                                numsize.z = 0;

                                damagenumtmp[count - 1].transform.localPosition += (count - 1) * numsize;
                                damagenumtmp[count - 1].transform.localPosition += new Vector3(0, 30, 0);
                                damagenumtmp[count - 1].color = new Vector4(1, 0, 0, 1);
                                if (damage < 0)
                                {
                                    damagenumtmp[count - 1].color = new Vector4(0.7f, 1, 0.7f, 1);
                                }
                                damagenumtmp[count - 1].gameObject.SetActive(false);
                                count++;
                            }
                            damagenum.Add(damagenumtmp);

                            //アニメーション設定
                            attackedAnimator.Add(temp.gobj.GetComponent <Animator>());
                            if (damage > 0)
                            {
                                attackedanimstate.Add(hitAnimName);        //共通モーションだと思うが、一部キャラで回復・ダメージが混ざる将来性も加味する
                            }
                            else
                            {
                                attackedanimstate.Add(healAnimName);     //暫定 Healモーションも作る
                            }
                            attackedCharaAnimation.Add(temp.gobj.GetComponent <CharaAnimation>());
                        }
                        for (int i = 0; i < attackedAnimator.Count; i++)
                        {
                            //Count不一致するかも?
                            attackedAnimator[i].Play(attackedanimstate[i]);
                            if (attackedanimstate[i] == hitAnimName)
                            {
                                attackedCharaAnimation[i].seSource.clip = seDamage;
                            }
                            else
                            {
                                attackedCharaAnimation[i].seSource.clip = seHeal;
                            }
                            attackedCharaAnimation[i].seSource.Play();
                        }
                        //テキスト表示
                        foreach (List <Text> damagenumtmp in damagenum)
                        {
                            foreach (Text a in damagenumtmp)
                            {
                                a.gameObject.SetActive(true);
                            }
                            //CameraAngle.CameraPoint(BattleVal.selectedUnit.gobj.transform.position);
                        }
                        nowtime = 0;
                    }
                    else if (nowtime >= battle_time - Time.deltaTime)
                    {
                        //戦闘後処理
                        bstate = BATTLE_STATUS.AFTERBATTLE;

                        //ダメージ数値のテキストを消す処理
                        foreach (List <Text> damagenumtmp in damagenum)
                        {
                            foreach (Text a in damagenumtmp)
                            {
                                Destroy(a.gameObject);
                            }
                        }
                        //戦闘用のダメージ表示などの判定が終了した後に、カメラの位置の移動
                        CameraAngle.CameraPoint(BattleVal.selectedUnit.gobj.transform.position);
                        //アニメーション関連の初期化
                        attackedAnimator.Clear();
                        attackedanimstate.Clear();
                        attackedCharaAnimation.Clear();
                        damagenum.Clear();
                        skillnamePanel.SetActive(false);
                        //攻撃可能フラグをオフに
                        BattleVal.selectedUnit.atackable = false;
                    }
                    else
                    {
                        //ダメージ数値のテキストを消す処理
                        //damagetext.color -= new Color(0,0,0,Time.deltaTime);
                        foreach (List <Text> damagenumtmp in damagenum)
                        {
                            foreach (Text a in damagenumtmp)
                            {
                                a.color -= new Color(0, 0, 0, Time.deltaTime);
                                a.transform.position += new Vector3(0, 1, 0);
                            }
                        }
                        nowtime += Time.deltaTime;
                    }
                }


                break;

            //戦闘後処理
            case BATTLE_STATUS.AFTERBATTLE:
                //獲得経験値
                int getexp = 10;     //基本値
                //撃墜処理
                foreach (int[] attackedpos in attackedposlist)
                {
                    Unitdata temp = BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])];
                    //撃墜処理
                    if (temp.hp <= 0)
                    {
                        Vector3 defeatpos = new Vector3();
                        Mapclass.TranslateMapCoordToPosition(ref defeatpos, attackedpos[0], attackedpos[1]);
                        StartCoroutine(UnitDefeat.DefeatHandle(temp, defeatEffect, defeatpos));

                        //撃墜ボーナス
                        getexp += BattleVal.id2index[string.Format("{0},{1}", attackedpos[0], attackedpos[1])].status.needexp;

                        //ユニットデータを消去
                        ////BattleVal.unitlistから消去
                        for (int i = 0; i < BattleVal.unitlist.Count; i++)
                        {
                            if (BattleVal.unitlist[i].x == temp.x && BattleVal.unitlist[i].y == temp.y)
                            {
                                BattleVal.unitlist.RemoveAt(i);
                                break;
                            }
                        }
                        ////BattleVal.id2indexから消去
                        BattleVal.id2index.Remove(string.Format("{0},{1}", temp.x, temp.y));
                        ////mapdataからユニット情報の削除
                        BattleVal.mapdata[(int)MapdataList.MAPUNIT][temp.y][temp.x] = 0;
                    }
                    if (temp.hp > temp.status.maxhp)
                    {
                        temp.hp = temp.status.maxhp;
                    }
                }

                //必殺技の場合、獲得経験値が1.5倍ボーナス
                if (selectedskill.is_cutscene)
                {
                    getexp = (int)((float)getexp * 1.5f);
                }
                //ユニットセレクトに戻る
                bstate = BATTLE_STATUS.SETVECT;
                if (BattleVal.selectedUnit.team == 0)
                {
                    //経験値を獲得するキャラの場合
                    if (BattleVal.selectedUnit.status.needexp != 0 &&
                        BattleVal.selectedUnit.status.level < 99 && BattleVal.selectedUnit.status.level >= 1)
                    {
                        Operation.AddGetExp(BattleVal.selectedUnit, getexp);
                        BattleVal.status = STATUS.GETEXP;
                    }
                    else
                    {
                        BattleVal.status = STATUS.PLAYER_UNIT_SELECT;
                    }
                }
                else
                {
                    BattleVal.status = STATUS.ENEMY_UNIT_SELECT;
                }
                break;
            }
        }
        else
        {
        }
    }
예제 #6
0
    //Update
    private void Update()
    {
        //移動中の場合
        if (BattleVal.status == STATUS.MOVING)
        {
            switch (mstate)
            {
            case MOVING_STATUS.SETVECT:

                //移動終了の判定
                if (nowstep == movepath.Count - 1)
                {
                    //行動スタックを積む(1手戻し用)
                    if (BattleVal.status == STATUS.MOVING)
                    {
                        Action thisact = new Action(BattleVal.selectedUnit,
                                                    BattleVal.selectedUnit.x, BattleVal.selectedUnit.y, movepath[nowstep][0], movepath[nowstep][1]);
                        BattleVal.actions.Push(thisact);
                    }

                    //map上のキャラクターIDの更新
                    //座標情報のアップデート
                    BattleVal.mapdata[(int)MapdataList.MAPUNIT][movepath[nowstep][1]][movepath[nowstep][0]]
                        = BattleVal.mapdata[(int)MapdataList.MAPUNIT][movepath[0][1]][movepath[0][0]];
                    //移動した場合
                    if (nowstep != 0)
                    {
                        BattleVal.mapdata[(int)MapdataList.MAPUNIT][movepath[0][1]][movepath[0][0]] = 0;
                    }
                    //BattleVal.selectedUnit.gobj.GetComponent<QuerySDMecanimController>().ChangeAnimation(QuerySDMecanimController.QueryChanSDAnimationType.NORMAL_STAND);
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().SetBool("Walk", false);
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().SetBool("Jump", false);
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Play("Idle");
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Update(0);

                    BattleVal.selectedUnit.x = movepath[nowstep][0];
                    BattleVal.selectedUnit.y = movepath[nowstep][1];
                    //ディクショナリのアップデート
                    BattleVal.id2index.Remove(string.Format("{0},{1}", BattleVal.selectX, BattleVal.selectY));
                    BattleVal.id2index.Add(string.Format("{0},{1}", movepath[nowstep][0], movepath[nowstep][1]), BattleVal.selectedUnit);

                    //Battleval.statusのアップデート
                    Debug.Log(BattleVal.turnplayer);
                    if (BattleVal.turnplayer == 0)
                    {
                        BattleVal.status  = STATUS.PLAYER_UNIT_SELECT;
                        BattleVal.selectX = -1;
                        BattleVal.selectY = -1;
                    }
                    else
                    {
                        BattleVal.status = STATUS.ENEMY_UNIT_SELECT;
                    }

                    //移動可能フラグをオフに
                    BattleVal.selectedUnit.movable = false;


                    break;
                }
                //速度ベクトル(実空間)の計算
                Vector3 r0 = new Vector3();
                Mapclass.TranslateMapCoordToPosition(ref r0, movepath[nowstep][0], movepath[nowstep][1]);
                Vector3 r1 = new Vector3();
                Mapclass.TranslateMapCoordToPosition(ref r1, movepath[nowstep + 1][0], movepath[nowstep + 1][1]);
                velocity = (1.0f / steptime) * (r1 - r0);      //1マスの移動に0.5sec
                nowtime  = 0;
                stoptime = 0;

                if (Mathf.Abs(BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][movepath[nowstep + 1][1]][movepath[nowstep + 1][0]] - BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][movepath[nowstep][1]][movepath[nowstep][0]]) > 0)
                {
                    //ジャンプモーション
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().Play("Jump");
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().SetBool("Walk", false);
                    stoptime = 0.3f;
                }
                else
                {
                    BattleVal.selectedUnit.gobj.GetComponent <Animator>().SetBool("Walk", true);
                }

                /*
                 * //もしもジャンプする場合
                 * if (BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][movepath[nowstep + 1][1]][movepath[nowstep + 1][0]] - BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][movepath[nowstep][1]][movepath[nowstep][0]] > 0)
                 * {
                 *  //ジャンプモーション
                 *  BattleVal.selectedUnit.gobj.GetComponent<Animator>().SetBool("Walk", false);
                 *  BattleVal.selectedUnit.gobj.GetComponent<Animator>().SetBool("Jump",true);
                 *  //BattleVal.selectedUnit.gobj.GetComponent<QuerySDMecanimController>().ChangeAnimation(QuerySDMecanimController.QueryChanSDAnimationType.NORMAL_FLY_UP);
                 *  stoptime = 0.3f;
                 * }
                 * else if (BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][movepath[nowstep + 1][1]][movepath[nowstep + 1][0]] - BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][movepath[nowstep][1]][movepath[nowstep][0]] < 0)
                 * {
                 *  //ジャンプモーション
                 *  BattleVal.selectedUnit.gobj.GetComponent<Animator>().SetBool("Walk", false);
                 *  BattleVal.selectedUnit.gobj.GetComponent<Animator>().SetBool("Jump", true);
                 *
                 *  //BattleVal.selectedUnit.gobj.GetComponent<QuerySDMecanimController>().ChangeAnimation(QuerySDMecanimController.QueryChanSDAnimationType.NORMAL_FLY_DOWN);
                 *  stoptime = 0.3f;
                 * }
                 * else
                 * {
                 *  //歩行モーション
                 *  //BattleVal.selectedUnit.gobj.GetComponent<QuerySDMecanimController>().ChangeAnimation(QuerySDMecanimController.QueryChanSDAnimationType.NORMAL_WALK);
                 *  BattleVal.selectedUnit.gobj.GetComponent<Animator>().SetBool("Jump", false);
                 *  BattleVal.selectedUnit.gobj.GetComponent<Animator>().SetBool("Walk", true);
                 *
                 * }
                 */
                //キャラの向きの調整
                Mapclass.TranslateMapCoordToPosition(ref r1, movepath[nowstep + 1][0], movepath[nowstep + 1][1]);
                BattleVal.selectedUnit.gobj.transform.LookAt(r1);
                //mstateのアップデート
                mstate = MOVING_STATUS.MOVING;

                break;

            case MOVING_STATUS.MOVING:

                //ステップ終了の判定
                if (nowtime >= steptime - Time.deltaTime)
                {
                    if (now_stop_time == 0)
                    {
                        //BattleVal.selectedUnit.gobj.GetComponent<Animator>().SetBool("Jump", false);
                    }
                    //終点に表示
                    if (now_stop_time > stoptime)
                    {
                        r1 = new Vector3();
                        Mapclass.TranslateMapCoordToPosition(ref r1, movepath[nowstep + 1][0], movepath[nowstep + 1][1]);
                        BattleVal.selectedUnit.gobj.transform.position = r1;
                        BattleVal.selectedUnit.gobj.transform.LookAt(new Vector3(r1.x, BattleVal.selectedUnit.gobj.transform.position.y, r1.z));
                        CameraAngle.CameraPoint(BattleVal.selectedUnit.gobj.transform.position);
                        nowstep++;
                        now_stop_time = 0;
                        mstate        = MOVING_STATUS.SETVECT;
                        break;
                    }
                    now_stop_time += Time.deltaTime;
                    nowtime       += Time.deltaTime;

                    /*
                     * //終点に表示
                     *
                     * r1 = new Vector3();
                     * Mapclass.TranslateMapCoordToPosition(ref r1, movepath[nowstep + 1][0], movepath[nowstep + 1][1]);
                     * BattleVal.selectedUnit.gobj.transform.position = r1;
                     * BattleVal.selectedUnit.gobj.transform.LookAt(new Vector3(r1.x, BattleVal.selectedUnit.gobj.transform.position.y, r1.z));
                     * CameraAngle.CameraPoint(BattleVal.selectedUnit.gobj.transform.position);
                     * nowstep++;
                     * now_stop_time = 0;
                     * mstate = MOVING_STATUS.SETVECT;
                     * break;
                     */
                }
                else
                {
                    r1 = new Vector3();
                    Mapclass.TranslateMapCoordToPosition(ref r1, movepath[nowstep + 1][0], movepath[nowstep + 1][1]);
                    BattleVal.selectedUnit.gobj.transform.LookAt(new Vector3(r1.x, BattleVal.selectedUnit.gobj.transform.position.y, r1.z));
                    //nowtime 加算処理
                    nowtime += Time.deltaTime;
                    //移動
                    BattleVal.selectedUnit.gobj.transform.position += new Vector3(velocity.x, 0, velocity.z) * Time.deltaTime;
                    //カメラの移動
                    CameraAngle.CameraPoint(BattleVal.selectedUnit.gobj.transform.position);

                    if (nowtime < steptime / 2 && velocity.y > 0)
                    {
                        BattleVal.selectedUnit.gobj.transform.position += new Vector3(0, (float)velocity.y * steptime * 60 * nowtime, 0) * Time.deltaTime;
                    }
                    else if (nowtime >= steptime / 2 && velocity.y > 0)
                    {
                        float tempvelocity = (r1.y - BattleVal.selectedUnit.gobj.transform.position.y) / (steptime - nowtime);
                        BattleVal.selectedUnit.gobj.transform.position += new Vector3(0, tempvelocity, 0) * Time.deltaTime;
                    }
                    else if (velocity.y < 0)
                    {
                        BattleVal.selectedUnit.gobj.transform.position += new Vector3(0, velocity.y, 0) * Time.deltaTime;
                    }

                    /*
                     * //モーションチェンジ
                     *
                     * if (nowtime < steptime / 2 && velocity.y > 0)
                     * {
                     *  BattleVal.selectedUnit.gobj.transform.position += new Vector3(0, (float)velocity.y * steptime * 60 * nowtime, 0) * Time.deltaTime;
                     * }
                     * else if (nowtime >= steptime / 2 && velocity.y > 0)
                     * {
                     *  BattleVal.selectedUnit.gobj.transform.position -= new Vector3(0, (float)(velocity.y * steptime * 16 + Physics.gravity.y) * (nowtime - steptime / 2)) * Time.deltaTime;
                     * }
                     * else if (velocity.y < 0)
                     * {
                     *  BattleVal.selectedUnit.gobj.transform.position -= new Vector3(0, (float)(velocity.y * steptime * 8 - Physics.gravity.y) * nowtime - steptime) * Time.deltaTime;
                     * }
                     */
                }

                break;
            }
        }
    }