示例#1
0
    void instantiateAvatar(GameData.TEAM team, GameData.TYPE hero)
    {
        Debug.Log("INSTA " + team + " , " + hero);
        Avatar             avt     = null;
        EntityMotorActions actions = null;

        avt     = PrefabBank.GET_AVATAR(hero);
        actions = EntityMotorActionBank.GET(hero);
        if (avt == null)
        {
            return;
        }

        m_entityMotor.resetState();
        if (m_avatar != null)
        {
            GameObject.Destroy(m_avatar.gameObject);
        }
        if (m_entityMotorActions != null)
        {
            m_entityMotorActions.unLink(this.m_entityMotor);
            GameObject.Destroy(m_entityMotorActions.gameObject);
            m_entityMotorActions = null;
        }
        Avatar me = GameObject.Instantiate <Avatar>(avt);

        me.transform.parent        = this.transform;
        me.transform.localPosition = Vector3.zero;
        me.transform.localRotation = Quaternion.identity;
        //Debug.Log(team);
        if (team == GameData.TEAM.RED)
        {
            me.setMaterial(BANK_PREFAB.MAT_TEAM_RED);
        }
        else if (team == GameData.TEAM.BLUE)
        {
            me.setMaterial(BANK_PREFAB.MAT_TEAM_BLUE);
        }

        if (me.m_head == null)
        {
            m_netTransformChildHead.enabled = false;
        }
        else
        {
            m_netTransformChildHead.enabled = true;
            m_netTransformChildHead.target  = me.m_head.transform;
        }
        m_avatar = me;
        if (actions != null)
        {
            m_entityMotorActions = GameObject.Instantiate <EntityMotorActions>(actions);
            m_entityMotorActions.link(m_entityMotor);
        }
    }
    public static EntityMotorActions GET(GameData.TYPE hero)
    {
        EntityMotorActions actions = null;

        switch (hero)
        {
        case GameData.TYPE.A:
            actions = ME.AVT_ROCKET;
            break;

        case GameData.TYPE.B:
            actions = ME.AVT_KABOOM;
            break;

        case GameData.TYPE.C:
            actions = ME.AVT_TRICKSTER;
            break;

        case GameData.TYPE.MONK:
            actions = ME.MONK;
            break;
        }
        return(actions);
    }