Exemplo n.º 1
0
    /// <summary>
    /// プレイヤー→敵の単体攻撃の結果を判定。倒したかどうか。trueで倒す。
    /// </summary>
    /// <param name="Damage"></param>
    /// <returns></returns>
    public static bool JudgeDamageResult_Single_Player(int Damage)
    {
        bool result = false;

        var query_Enemy = (from x in BattleStaticValiable.xdoc2.Descendants("Enemy")
                           where x.Element("BattleNo").Value == GameManager.TargetFlg
                           select x).Single();

        int EnemyHP = int.Parse(query_Enemy.Element("EnemyHP").Value);

        if (Damage == EnemyHP)
        {
            query_Enemy.Element("EnemyHP").Value = "0";
            BattleStaticValiable.xdoc2.Save(GetXmlPath.BattleEnemyDataSheetPath());
            result = true;
        }
        else if (Damage > EnemyHP)
        {
            query_Enemy.Element("EnemyHP").Value = "0";
            BattleStaticValiable.xdoc2.Save(GetXmlPath.BattleEnemyDataSheetPath());
            result = true;
        }
        else if (Damage < EnemyHP)
        {
            query_Enemy.Element("EnemyHP").Value = Convert.ToString(EnemyHP - Damage);
            BattleStaticValiable.xdoc2.Save(GetXmlPath.BattleEnemyDataSheetPath());
            result = false;
        }

        return(result);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 雑魚敵のデータを戦闘開始時にロードする
    /// </summary>
    public void LoadEnemy(int AreaLevel)
    {
        Level = AreaLevel;  //どうにかしてエリアのレベルを取得する
        //Level = 1; //デバッグ用で1を設定

        //エリアレベルをもとに敵のNoを選出したリストを作成する
        //その後、ランダム(重複あり)に抽出し、配列にする
        List <int> EnemyChoiceList = new List <int>(ConvertEnemyNoFromAreaLavel(AreaLevel));

        int[] NoRadomChoice = new int[EnemyChoiceList.Count];

        for (int i = 0; i <= EnemyChoiceList.Count - 1; i++)
        {
            NoRadomChoice[i] = EnemyChoiceList[UnityEngine.Random.Range(0, EnemyChoiceList.Count - 1)];
        }

        //乱数で敵の出現数を設定
        int EnemyCount = UnityEngine.Random.Range(1, 3);

        //エリアレベル1の時は1体だけ
        if (Level == 1)
        {
            EnemyCount = 1;
        }

        string    EnemyCountToString = Convert.ToString(EnemyCount);
        XDocument XmlDoc             = XDocument.Load(GetXmlPath.EnemyDataPath());
        XDocument xmlDoc2            = XDocument.Load(GetXmlPath.BattleEnemyDataSheetPath());

        //バトルシート値リセット
        ResetXML.ResetBattleSheet();

        //乱数をもとにクエリ生成し、バトルシートに転写
        for (int i = 0; i <= EnemyCount - 1; i++)
        {
            //EnemyData
            var query = from x in XmlDoc.Descendants("Enemy")
                        where x.Attribute("No").Value == NoRadomChoice[i].ToString()
                        select new
            {
                EnemyNo            = x.Attribute("No").Value,
                EnemyName          = x.Element("EnemyName").Value,
                EnemyHP            = x.Element("EnemyHP").Value,
                EnemyAttackValue   = x.Element("EnemyAttackValue").Value,
                EnemyDiffenceValue = x.Element("EnemyDiffenceValue").Value,
                EnemySpeedValue    = x.Element("EnemySpeedValue").Value,
                EnemyExperience    = x.Element("EnemyExperience").Value,

                EnemySkill_Name_No1         = x.Element("EnemySkill_Name_No1").Value,
                EnemySkill_StringValue1_No1 = x.Element("EnemySkill_StringValue1_No1").Value,
                EnemySkill_StringValue2_No1 = x.Element("EnemySkill_StringValue2_No1").Value,
                EnemySkill_StringValue3_No1 = x.Element("EnemySkill_StringValue3_No1").Value,
                EnemySkill_IntValue1_No1    = x.Element("EnemySkill_IntValue1_No1").Value,
                EnemySkill_IntValue2_No1    = x.Element("EnemySkill_IntValue2_No1").Value,
                EnemySkill_IntValue3_No1    = x.Element("EnemySkill_IntValue3_No1").Value,

                EnemySkill_Name_No2         = x.Element("EnemySkill_Name_No2").Value,
                EnemySkill_StringValue1_No2 = x.Element("EnemySkill_StringValue1_No2").Value,
                EnemySkill_StringValue2_No2 = x.Element("EnemySkill_StringValue2_No2").Value,
                EnemySkill_StringValue3_No2 = x.Element("EnemySkill_StringValue3_No2").Value,
                EnemySkill_IntValue1_No2    = x.Element("EnemySkill_IntValue1_No2").Value,
                EnemySkill_IntValue2_No2    = x.Element("EnemySkill_IntValue2_No2").Value,
                EnemySkill_IntValue3_No2    = x.Element("EnemySkill_IntValue3_No2").Value,

                EnemySkill_Name_No3         = x.Element("EnemySkill_Name_No3").Value,
                EnemySkill_StringValue1_No3 = x.Element("EnemySkill_StringValue1_No3").Value,
                EnemySkill_StringValue2_No3 = x.Element("EnemySkill_StringValue2_No3").Value,
                EnemySkill_StringValue3_No3 = x.Element("EnemySkill_StringValue3_No3").Value,
                EnemySkill_IntValue1_No3    = x.Element("EnemySkill_IntValue1_No3").Value,
                EnemySkill_IntValue2_No3    = x.Element("EnemySkill_IntValue2_No3").Value,
                EnemySkill_IntValue3_No3    = x.Element("EnemySkill_IntValue3_No3").Value,

                EnemyResistance_Name_No1         = x.Element("EnemyResistance_Name_No1").Value,
                EnemyResistance_StringValue1_No1 = x.Element("EnemyResistance_StringValue1_No1").Value,
                EnemyResistance_StringValue2_No1 = x.Element("EnemyResistance_StringValue2_No1").Value,
                EnemyResistance_StringValue3_No1 = x.Element("EnemyResistance_StringValue3_No1").Value,
                EnemyResistance_IntValue1_No1    = x.Element("EnemyResistance_IntValue1_No1").Value,
                EnemyResistance_IntValue2_No1    = x.Element("EnemyResistance_IntValue2_No1").Value,
                EnemyResistance_IntValue3_No1    = x.Element("EnemyResistance_IntValue3_No1").Value,

                DropItem    = x.Element("DropItem").Value,
                DropItemID  = x.Element("DropItemID").Value,
                DropPercent = x.Element("DropPercent").Value,
            };

            //BattleEnemyDataSheet
            var query2 = (from y in xmlDoc2.Root.Descendants("Enemy")
                          where y.Element("BattleNo").Value == Convert.ToString(i + 1)
                          select y).Single();

            foreach (var item in query)
            {
                query2.Attribute("No").Value               = item.EnemyNo;
                query2.Element("EnemyName").Value          = item.EnemyName;
                query2.Element("EnemyHP").Value            = item.EnemyHP;
                query2.Element("EnemyAttackValue").Value   = item.EnemyAttackValue;
                query2.Element("EnemyDiffenceValue").Value = item.EnemyDiffenceValue;
                query2.Element("EnemySpeedValue").Value    = item.EnemySpeedValue;
                query2.Element("EnemyExperience").Value    = item.EnemyExperience;

                query2.Element("EnemySkill_Name_No1").Value         = item.EnemySkill_Name_No1;
                query2.Element("EnemySkill_StringValue1_No1").Value = item.EnemySkill_StringValue1_No1;
                query2.Element("EnemySkill_StringValue2_No1").Value = item.EnemySkill_StringValue2_No1;
                query2.Element("EnemySkill_StringValue3_No1").Value = item.EnemySkill_StringValue3_No1;
                query2.Element("EnemySkill_IntValue1_No1").Value    = item.EnemySkill_IntValue1_No1;
                query2.Element("EnemySkill_IntValue2_No1").Value    = item.EnemySkill_IntValue2_No1;
                query2.Element("EnemySkill_IntValue3_No1").Value    = item.EnemySkill_IntValue3_No1;

                query2.Element("EnemySkill_Name_No2").Value         = item.EnemySkill_Name_No2;
                query2.Element("EnemySkill_StringValue1_No2").Value = item.EnemySkill_StringValue1_No2;
                query2.Element("EnemySkill_StringValue2_No2").Value = item.EnemySkill_StringValue2_No2;
                query2.Element("EnemySkill_StringValue3_No2").Value = item.EnemySkill_StringValue3_No2;
                query2.Element("EnemySkill_IntValue1_No2").Value    = item.EnemySkill_IntValue1_No2;
                query2.Element("EnemySkill_IntValue2_No2").Value    = item.EnemySkill_IntValue2_No2;
                query2.Element("EnemySkill_IntValue3_No2").Value    = item.EnemySkill_IntValue3_No2;

                query2.Element("EnemySkill_Name_No3").Value         = item.EnemySkill_Name_No3;
                query2.Element("EnemySkill_StringValue1_No3").Value = item.EnemySkill_StringValue1_No3;
                query2.Element("EnemySkill_StringValue2_No3").Value = item.EnemySkill_StringValue2_No3;
                query2.Element("EnemySkill_StringValue3_No3").Value = item.EnemySkill_StringValue3_No3;
                query2.Element("EnemySkill_IntValue1_No3").Value    = item.EnemySkill_IntValue1_No3;
                query2.Element("EnemySkill_IntValue2_No3").Value    = item.EnemySkill_IntValue2_No3;
                query2.Element("EnemySkill_IntValue3_No3").Value    = item.EnemySkill_IntValue3_No3;

                query2.Element("EnemyResistance_Name_No1").Value         = item.EnemyResistance_Name_No1;
                query2.Element("EnemyResistance_StringValue1_No1").Value = item.EnemyResistance_StringValue1_No1;
                query2.Element("EnemyResistance_StringValue2_No1").Value = item.EnemyResistance_StringValue2_No1;
                query2.Element("EnemyResistance_StringValue3_No1").Value = item.EnemyResistance_StringValue3_No1;
                query2.Element("EnemyResistance_IntValue1_No1").Value    = item.EnemyResistance_IntValue1_No1;
                query2.Element("EnemyResistance_IntValue2_No1").Value    = item.EnemyResistance_IntValue2_No1;
                query2.Element("EnemyResistance_IntValue3_No1").Value    = item.EnemyResistance_IntValue3_No1;

                query2.Element("DropItem").Value    = item.DropItem;
                query2.Element("DropItemID").Value  = item.DropItem;
                query2.Element("DropPercent").Value = item.DropPercent;

                xmlDoc2.Save(GetXmlPath.BattleEnemyDataSheetPath());
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 戦闘開始処理
    /// </summary>
    private void StartUP()
    {
        Texture2D texture_Enemy1;
        Texture2D texture_Enemy2;
        Texture2D texture_Enemy3;

        //敵の情報を取得
        XDocument xdoc = XDocument.Load(GetXmlPath.BattleEnemyDataSheetPath());

        var query = from x in xdoc.Descendants("Enemy")
                    where x.Element("EnemyName").Value != ""
                    select x;
        List <string> CountList = new List <string>();

        foreach (var item in query)
        {
            CountList.Add(item.Element("EnemyName").Value);
        }

        string EnemyName1;
        string EnemyName2;
        string EnemyName3;

        switch (CountList.Count)
        {
        case 1:
            EnemyName1 = CountList[0];
            break;

        case 2:
            EnemyName1 = CountList[0];
            EnemyName2 = CountList[1];
            break;

        case 3:
            EnemyName1 = CountList[0];
            EnemyName2 = CountList[1];
            EnemyName3 = CountList[2];
            break;

        default:
            break;
        }

        //味方側の処理
        XDocument xdoc2 = XDocument.Load(GetXmlPath.PlayerDataPath());

        var query2 = (from x in xdoc2.Descendants("Player")
                      select x).Single();

        //戦闘用パラメータをセット
        query2.Element("PlayerAttackValue_OnBattle").Value   = query2.Element("PlayerAttackValue").Value;
        query2.Element("PlayerDiffenceValue_OnBattle").Value = query2.Element("PlayerDiffenceValue").Value;
        query2.Element("PlayerSpeedValue_OnBattle").Value    = query2.Element("PlayerSpeedValue").Value;
        xdoc2.Save(GetXmlPath.PlayerDataPath());

        //各種ウィンドウに値反映
        CharaName_StatusWindow.text = query2.Element("PlayerName").Value;
        HPValue_StatusWindow.text   = query2.Element("PlayerNowHP").Value;
        ENValue_StatusWindow.text   = query2.Element("PlayerNowEN").Value;

        //味方の画像を入れる
        Texture2D texture_Player_BattleImage1 = Resources.Load("Player_BattleImage1") as Texture2D;

        CharaImage_StatusWindow.sprite = Sprite.Create(texture_Player_BattleImage1,
                                                       new Rect(0, 0, texture_Player_BattleImage1.width, texture_Player_BattleImage1.height),
                                                       Vector2.zero);

        //Bulletを描写
        Texture2D texture_BulletIcon         = Resources.Load("BulletIcon") as Texture2D;
        Texture2D texture_BulletIcon_NoImage = Resources.Load("NoImage") as Texture2D;

        Bullet1.sprite = Sprite.Create(texture_BulletIcon,
                                       new Rect(0, 0, texture_BulletIcon.width, texture_BulletIcon.height),
                                       Vector2.zero);
        Bullet2.sprite = Sprite.Create(texture_BulletIcon,
                                       new Rect(0, 0, texture_BulletIcon.width, texture_BulletIcon.height),
                                       Vector2.zero);
        Bullet3.sprite = Sprite.Create(texture_BulletIcon,
                                       new Rect(0, 0, texture_BulletIcon.width, texture_BulletIcon.height),
                                       Vector2.zero);
        Bullet4.sprite = Sprite.Create(texture_BulletIcon_NoImage,
                                       new Rect(0, 0, texture_BulletIcon.width, texture_BulletIcon.height),
                                       Vector2.zero);
        Bullet5.sprite = Sprite.Create(texture_BulletIcon_NoImage,
                                       new Rect(0, 0, texture_BulletIcon.width, texture_BulletIcon.height),
                                       Vector2.zero);

        //敵を描写
        switch (CountList.Count)
        {
        case 1:
            texture_Enemy1     = Resources.Load(CountList[0]) as Texture2D;
            EnemyImage1.sprite = Sprite.Create(texture_Enemy1,
                                               new Rect(0, 0, texture_Enemy1.width, texture_Enemy1.height),
                                               Vector2.zero);
            Text_MainWindow.text = CountList[0] + GetEncountText.EncountText(CountList[0]);      //敵単体時のみ特別メッセージ
            break;

        case 2:     //位置調整必須 widthとheightを変更
            texture_Enemy1     = Resources.Load(CountList[0]) as Texture2D;
            EnemyImage1.sprite = Sprite.Create(texture_Enemy1,
                                               new Rect(0, 0, texture_Enemy1.width, texture_Enemy1.height),
                                               Vector2.zero);
            texture_Enemy2     = Resources.Load(CountList[1]) as Texture2D;
            EnemyImage2.sprite = Sprite.Create(texture_Enemy2,
                                               new Rect(0, 0, texture_Enemy2.width, texture_Enemy2.height),
                                               Vector2.zero);
            Text_MainWindow.text = CountList[0] + "たちが\n襲いかかってきた!";
            break;

        case 3:
            texture_Enemy1     = Resources.Load(CountList[0]) as Texture2D;
            EnemyImage1.sprite = Sprite.Create(texture_Enemy1,
                                               new Rect(0, 0, texture_Enemy1.width, texture_Enemy1.height),
                                               Vector2.zero);
            texture_Enemy2     = Resources.Load(CountList[1]) as Texture2D;
            EnemyImage2.sprite = Sprite.Create(texture_Enemy2,
                                               new Rect(0, 0, texture_Enemy2.width, texture_Enemy2.height),
                                               Vector2.zero);
            texture_Enemy3     = Resources.Load(CountList[2]) as Texture2D;
            EnemyImage2.sprite = Sprite.Create(texture_Enemy2,
                                               new Rect(0, 0, texture_Enemy3.width, texture_Enemy3.height),
                                               Vector2.zero);
            Text_MainWindow.text = CountList[0] + "たちが\n襲いかかってきた!";
            break;

        default:
            break;
        }

        StartCoroutine(WaitTime_2());
        Text_MainWindow.text = "";
    }
    /// <summary>
    /// 単体攻撃で敵を倒した時の処理
    /// </summary>
    /// <param name="TargetFlg"></param>
    public static void DeadEnemy_Single(string TargetFlg)
    {
        //バトルシートからデータを消す
        //HPは0のままにしとく
        //Experienceは残しておく
        var query_Enemy = (from x in BattleStaticValiable.xdoc2.Descendants("Enemy")
                           where x.Element("BattleNo").Value == GameManager.TargetFlg
                           select x).Single();

        GameManager.Text_MainWindow.text = query_Enemy.Element("EnemyName").Value + GetEnemyDeadText.EnemyDeadText(query_Enemy.Element("EnemyName").Value);

        MonoBehaviour mono = new MonoBehaviour();

        mono.StartCoroutine(GameManager.WaitTime_1());

        query_Enemy.Attribute("No").Value               = "";
        query_Enemy.Element("EnemyName").Value          = "";
        query_Enemy.Element("EnemyHP").Value            = "0";
        query_Enemy.Element("EnemyAttackValue").Value   = "";
        query_Enemy.Element("EnemyDiffenceValue").Value = "";
        query_Enemy.Element("EnemySpeedValue").Value    = "";

        query_Enemy.Element("EnemySkill_Name_No1").Value         = "";
        query_Enemy.Element("EnemySkill_StringValue1_No1").Value = "";
        query_Enemy.Element("EnemySkill_StringValue2_No1").Value = "";
        query_Enemy.Element("EnemySkill_StringValue3_No1").Value = "";
        query_Enemy.Element("EnemySkill_IntValue1_No1").Value    = "";
        query_Enemy.Element("EnemySkill_IntValue2_No1").Value    = "";
        query_Enemy.Element("EnemySkill_IntValue3_No1").Value    = "";

        query_Enemy.Element("EnemySkill_Name_No2").Value         = "";
        query_Enemy.Element("EnemySkill_StringValue1_No2").Value = "";
        query_Enemy.Element("EnemySkill_StringValue2_No2").Value = "";
        query_Enemy.Element("EnemySkill_StringValue3_No2").Value = "";
        query_Enemy.Element("EnemySkill_IntValue1_No2").Value    = "";
        query_Enemy.Element("EnemySkill_IntValue2_No2").Value    = "";
        query_Enemy.Element("EnemySkill_IntValue3_No2").Value    = "";

        query_Enemy.Element("EnemySkill_Name_No3").Value         = "";
        query_Enemy.Element("EnemySkill_StringValue1_No3").Value = "";
        query_Enemy.Element("EnemySkill_StringValue2_No3").Value = "";
        query_Enemy.Element("EnemySkill_StringValue3_No3").Value = "";
        query_Enemy.Element("EnemySkill_IntValue1_No3").Value    = "";
        query_Enemy.Element("EnemySkill_IntValue2_No3").Value    = "";
        query_Enemy.Element("EnemySkill_IntValue3_No3").Value    = "";

        query_Enemy.Element("EnemyResistance_Name_No1").Value         = "";
        query_Enemy.Element("EnemyResistance_StringValue1_No1").Value = "";
        query_Enemy.Element("EnemyResistance_StringValue2_No1").Value = "";
        query_Enemy.Element("EnemyResistance_StringValue3_No1").Value = "";
        query_Enemy.Element("EnemyResistance_IntValue1_No1").Value    = "";
        query_Enemy.Element("EnemyResistance_IntValue2_No1").Value    = "";
        query_Enemy.Element("EnemyResistance_IntValue3_No1").Value    = "";

        BattleStaticValiable.xdoc2.Save(GetXmlPath.BattleEnemyDataSheetPath());

        //死んだ敵の画像を消す
        Image     EnemyImage    = GameObject.Find("EnemyImage" + GameManager.TargetFlg).GetComponent <Image>();
        Texture2D texture_Enemy = Resources.Load("NoImage") as Texture2D;

        EnemyImage.sprite = Sprite.Create(texture_Enemy,
                                          new Rect(0, 0, texture_Enemy.width, texture_Enemy.height),
                                          Vector2.zero);
    }