示例#1
0
    //艦船の配置。
    public void DeployShip(Ship_test ship, Vector3 point)
    {
        //クラスが持っている艦級を取得。
        GameObject ship_model = (GameObject)Resources.Load("3d/Ship_model/" + ship.ship_class);

        //スケール調整。今回は半分にする。最終的にはモデルを調整
        ship_model.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);

        //中のメッシュモデルだけ変えてみる。
        //ship_model.GetComponentInChildren<MeshFilter>().mesh =

        //Assets/Resources/Models/AK_1.obj

        GameObject ship_object = Instantiate(ship_model, point, Quaternion.identity);

        //インスタンス化したうえで、艦名を指定する。
        ship_object.name = ship.ship_id.ToString();

        //艦名を表示
        ship_object.GetComponent <Ship_Ui_Controller>().UPdateUI(ship);


        //hpバーを指定する。
        ship_object.GetComponent <Ship_Ui_Controller>().UpdateHpSlider(ship.hp, ship.max_hp);

        //列に加え入れる.
        ship_obj_list.Add(ship_object);
    }
示例#2
0
    //戦闘を設計する。
    // Start is called before the first frame update
    void Start()
    {
        //艦隊の初期配置を設定。
        Ship_test fune1 = new Ship_test(0, "DD 吹雪", "DD1", false, 300, 300, 50, 20, 100, "DD");
        Ship_test fune2 = new Ship_test(1, "DD 初雪", "DD1", false, 300, 300, 50, 20, 100, "DD");
        Ship_test fune3 = new Ship_test(2, "DD 深雪", "DD1", false, 300, 300, 50, 20, 100, "DD");
        Ship_test fune4 = new Ship_test(3, "DD 睦月", "DD1", false, 300, 300, 50, 30, 100, "DD");
        Ship_test fune5 = new Ship_test(4, "DD 長良", "DD1", false, 300, 300, 50, 20, 100, "DD");


        Ship_test e_fune1 = new Ship_test(5, "AK A式輸送艦_1", "AK1", true, 100, 100, 2, 10, 100, "AK");
        Ship_test e_fune2 = new Ship_test(6, "AK A式輸送艦_2", "AK1", true, 100, 100, 2, 10, 100, "AK");
        Ship_test e_fune3 = new Ship_test(7, "AK A式輸送艦_3", "AK1", true, 100, 100, 2, 10, 100, "AK");


        ship_list.Add(fune1);
        ship_list.Add(fune2);
        ship_list.Add(fune3);
        ship_list.Add(fune4);
        ship_list.Add(fune5);

        ship_list.Add(e_fune1);
        ship_list.Add(e_fune2);
        ship_list.Add(e_fune3);
    }
示例#3
0
    //攻撃。
    public Attack_log Attack(Ship_test enemy_ship)
    {
        bool flg_hit;
        bool flg_sunk;
        int  arwd_money;

        //攻撃処理。俊敏性が一定より高いと入らなくなる。
        if (Random.Range(1f, 100f) > enemy_ship.agility)
        {
            flg_hit = true;

            enemy_ship.hp -= this.atk_point;

            //爆発処理を呼びたい。

            //デバッグログ
            //Debug.Log(this.ship_name + "の攻撃処理開始");
            //Debug.Log(enemy_ship.ship_name + "が対象");
            //Debug.Log(enemy_ship.hp + ":攻撃後の敵HP");

            //攻撃で撃沈されてたら表示切り替え。
            if (enemy_ship.hp <= 0)
            {
                flg_sunk   = true;
                arwd_money = enemy_ship.reward_money;
            }
            else
            {
                flg_sunk   = false;
                arwd_money = 0;
            }
        }
        else
        {
            flg_hit    = false;
            flg_sunk   = false;
            arwd_money = 0;
            //Debug.Log(this.ship_name + "は攻撃失敗した。");
        }


        Attack_log al = new  Attack_log(1, this.ship_id, enemy_ship.ship_id, flg_hit, flg_sunk, 1, enemy_ship.hp, enemy_ship.max_hp, arwd_money);

        return(al);
    }
示例#4
0
    //個別のシップをインスタンス化する処理。実際には建造に相当する処理。
    public void CreateShip(string this_ship_name, bool enemy_flg, Ship_Class sc)
    {
        if (RM.GetComponent <ResourceManager>().Check_enough_money(sc.money_to_make))
        {
            //艦船を作るときにお金を減らす。
            //RM.GetComponent<ResourceManager>().money -= sc.money_to_make;
            RM.GetComponent <ResourceManager>().UseMoney(sc.money_to_make);

            //インスタンス化する処理。
            Ship_test n_ship = new Ship_test
                                   (ship_id,
                                   this_ship_name + ship_id.ToString(),
                                   sc.ship_class_name,
                                   enemy_flg,
                                   sc.max_hp,
                                   sc.max_hp,
                                   sc.atk_point,
                                   sc.agility,
                                   sc.reward_money,
                                   sc.ship_type
                                   );

            ship_id += 1;

            Debug.Log(ship_id + "だよ");
            Debug.Log(n_ship.ship_id + "だよ");


            //軍港に配置。
            List_ships_in_port.Add(n_ship);

            //UI更新
            PortShiplistUpdate();
        }
        else
        {
            //お金ないでつ。
            Debug.Log("お金ないです");
        }
    }
示例#5
0
    //索敵
    public Ship_test Search(List <Ship_test> list_ships)
    {
        //自分と異なる部隊を選択。 条件としては、敵かつ生存を条件にしている。
        List <Ship_test> result_rist = list_ships.FindAll(a => a.enemy_flg != this.enemy_flg & a.hp > 0);

        Debug.Log(this.ship_name + "についての対象となりうる敵船数" + result_rist.Count);

        if (result_rist.Count > 0 & this.hp > 0)
        {
            Debug.Log(this.ship_name + "対象選定フラグ");

            //敵が生存している&自分が生きている。
            //対象を一つに対象。。
            Ship_test hoge = result_rist[Random.Range(0, result_rist.Count)];

            return(hoge);
        }
        else
        {
            return(null);
        }

        //ランダムなレンジから取得する。
    }
示例#6
0
 //インスタンス化した艦船を軍港に入れる処理。
 public void AddShiptoPort(Ship_test st)
 {
     List_ships_in_port.Add(st);
     Debug.Log(List_ships_in_port.Count + "隻が軍港にあります。");
     PortShiplistUpdate();
 }
示例#7
0
 public void UPdateUI(Ship_test ship)
 {
     text_name.text = ship.ship_name;
 }