private void place_monster(int type, int side, int road_index)
    {
        if (type < (int)MonsterType.Monster1 || type > (int)MonsterType.Monster3)
        {
            return;
        }

        if (side != (int)SideType.SideA && side != (int)SideType.SideB)
        {
            return;
        }

        if (road_index < 0 || road_index >= this.monster_roads.Length)
        {
            return;
        }

        if (type >= this.monster_prefabs.Length) // 没有对应小怪的资源
        {
            return;
        }

        GameObject m = GameObject.Instantiate(this.monster_prefabs[type]);

        m.transform.SetParent(this.transform, false);
        monster_move agent = m.AddComponent <monster_move>();

        Vector3[] road_data = null;

        if (side == (int)SideType.SideA)
        {
            road_data = this.road_data_set[road_index].path_sideA;
        }
        else
        {
            road_data = this.road_data_set[road_index].path_sideB;
        }

        monster mon = m.AddComponent <monster>();

        mon.init(type, side, m.GetComponent <CapsuleCollider>().radius, road_data, agent);
        this.monsters.Add(mon);

        //创建要给ui血条
        UI_show_blood ui_blood = this.ui_blood_mgr.place_ui_blood_on_monster(side);

        mon.ui_blood = ui_blood;
        //end
    }
Beispiel #2
0
    public void init(int type, int side, float body_R, Vector3[] road_data, monster_move local_move)
    {
        this.anim       = this.GetComponent <Animation>();
        this.local_move = local_move;
        this.type       = type;
        this.side       = side;
        this.body_R     = body_R;
        this.road_data  = road_data;
        if (this.road_data.Length < 2)
        {
            this.state = (int)State.Idle;
        }
        else
        {
            this.state = (int)State.Walk;
        }

        this.logic_pos          = this.road_data[0];
        this.transform.position = this.logic_pos;
        this.next_step          = 1;
    }