果盟广告SDK

//
//  GuomobWallView.h
//  GuoMobWallSample
//
//  Created by keyrun on 14-1-21.
//  Copyright (c) 2014年 AK. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GuoMobWallViewController.h"

@interface GuomobWallView : NSObject

@end
//
//  GuomobWallView.m
//  GuoMobWallSample
//
//  Created by keyrun on 14-1-21.
//  Copyright (c) 2014年 AK. All rights reserved.
//

#import "GuomobWallView.h"
#import "GuoMobWallViewController.h"
static GuoMobWallViewController * guomobwall=nil;
@implementation GuomobWallView

+(void)InitGuoMobWall:(NSString *)appkey updatetime:(int)updatetime modelname:(NSString *)name{
    if (!guomobwall) {
        guomobwall=[[GuoMobWallViewController alloc]initWithId:appkey Model:name];
        guomobwall.updatetime=updatetime;
    }
}
extern "C" void InitGuoMobWall(const char * appkey,int time,const char * ModelName)
{
    [GuomobWallView InitGuoMobWall:[NSString stringWithUTF8String:appkey] updatetime:time modelname:[NSString stringWithUTF8String:ModelName]];
}
extern "C" void LoadGuoMobWall(int rotation,int screen)
{
    if (guomobwall) {
        [guomobwall pushGuoMobWall:rotation Hscreen:screen];
    }
}
extern "C" void GuoMobWallSetOtherID(const char * OtherID)
{
    if (guomobwall) {
        guomobwall.OtherID=[NSString stringWithUTF8String:OtherID];
    }
}
extern "C" void GuoMobWallSetStatusBar(int isStatusBarHidden)
{
    if (guomobwall) {
        guomobwall.isStatusBarHidden=isStatusBarHidden;
    }
}
extern "C" int GuoMobWallreadpoint()
{
    if (guomobwall) {
        int point=[guomobwall readPoint];
        return point;
    }
    return nil;
}
extern "C" void GuoMobWallwritepoint(int point)
{
    if (guomobwall) {
        [guomobwall writePoint:point];
    }
}
extern "C" int GuoMobWallcheckpoint()
{
    if (guomobwall) {
        int point=[guomobwall checkPoint];
        return point;
    }
    return nil;
}
extern "C" void GuoMobWallupdatepoint()
{
    if (guomobwall) {
        [guomobwall updatePoint];//更新积分
    }
}
extern "C" void ReleaseGuoMobWall()
{
    if(guomobwall!=nil)
    {
        [guomobwall release];
        guomobwall=nil;
    }
}
- (void)dealloc
{
    if(guomobwall!=nil)
    {
        [guomobwall release];
        guomobwall=nil;
    }
    [super dealloc];
}
@end
//
//  GuoMobWall.h
//  GuoMobWall
//
//  Created by qq on 12-11-21.
//  Copyright (c) 2012年 AK. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface GuoMobWallViewController : UIViewController

- (id)initWithId:(NSString *)appKey Model:(NSString*)name;
-(void)pushGuoMobWall:(BOOL)allow Hscreen:(BOOL)isHscreen;
//查询积分
- (int)checkPoint;
//读取所有积分并清空
- (int)readPoint;
//追加积分
- (void)writePoint:(int)writepoint;
//刷新积分
-(void)updatePoint;

@property(nonatomic)NSTimeInterval updatetime;//自动刷新积分的时间间隔
@property(nonatomic)BOOL isStatusBarHidden;//积分墙是否显示状态栏
@property(nonatomic,copy) NSString * OtherID;//使用积分服务器回调时候的可选参数
@end

GuoMobWall.cs

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class GuoMobWall : MonoBehaviour {

    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
    
    }

    [DllImport("__Internal")]
    private static extern void InitGuoMobWall(string appkey,int updatetime,string ObjectName); 
    [DllImport("__Internal")]
    private static extern void LoadGuoMobWall(int rotation,int screen);
    [DllImport("__Internal")]
    private static extern void GuoMobWallSetOtherID(string OtherID);
    [DllImport("__Internal")]
    private static extern void GuoMobWallSetStatusBar(int isStatusBarHidden);
    [DllImport("__Internal")]
    private static extern int GuoMobWallreadpoint();
    [DllImport("__Internal")]
    private static extern void GuoMobWallwritepoint(int point);
    [DllImport("__Internal")]
    private static extern int GuoMobWallcheckpoint();
    [DllImport("__Internal")]
    private static extern void GuoMobWallupdatepoint();
    [DllImport("__Internal")]
    private static extern void ReleaseGuoMobWall();

    //初始化积分墙  参数: appkey:果盟广告密钥

    //updatetime:设置自动刷新积分的时间间隔
    //******注:不设置该updatetime参数的话,SDK默认为20秒,自动刷新时间最小值为15******
    //******设置updatetime为0为不自动刷新,开发者自己去控制刷新******

    //ObjectName: GMWallDelegate.cs脚本绑定的Object名称  比如 Main Camera
    public static void U3DInitGuoMobWall(string appkey,int updatetime,string ObjectName)
    {
        
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            InitGuoMobWall(appkey,updatetime,ObjectName); 
        }
    }

    //加载积分墙 rotation:积分墙是否自适应旋转  1---旋转, 0---不旋转
    //           screen:积分墙初始横竖屏状态 1---横屏, 0---竖屏
    public static void U3DLoadGuoMobWall(int rotation,int screen)
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            LoadGuoMobWall(rotation,screen);
        }
    }
    public static void U3DGuoMobWallSetOtherID(string OtherID)
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            GuoMobWallSetOtherID(OtherID);
        }
    }
    public static void U3DGuoMobWallSetStatusBar(int isStatusBarHidden)
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            GuoMobWallSetStatusBar(isStatusBarHidden);
        }
    }

    //读取积分,全部读取积分并且清零,返回整形的积分
    public static int U3DGuoMobWallreadpoint()
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            return GuoMobWallreadpoint();
        }
        return 0;
    }

    //添加积分,减分参数请设置为负数
    public static void U3DGuoMobWallwritepoint(int point)
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            GuoMobWallwritepoint(point);
        }
    }

    //查询积分,不清零,返回整形的积分
    public static int U3DGuoMobWallcheckpoint()
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            return GuoMobWallcheckpoint();
        }
        return 0;
    }

    //更新服务器已经完成任务但没有取走的积分
    public static void U3DGuoMobWallupdatepoint()
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            GuoMobWallupdatepoint();
        }
    }

    //释放积分墙,释放后会停止自动更新积分,释放后再次加载需要重新初始化积分墙
    public static void U3DReleaseGuoMobWall()
    {
        if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
            ReleaseGuoMobWall();
        }
    }

}

GMWallDelegate.cs

using UnityEngine;
using System.Collections;

public class GMWallDelegate : MonoBehaviour {

    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
    
    }

    //加载回调 表示加载成功
    void loadWallAdSuccess()
    {
        print("loadWallAdSuccess");
    }

    //加载积分墙出错时候的回调  返回错误信息
    void GMWallDidFailWithError(string error){
        print(error);
    }

    //更新积分出错时候的回调  返回错误信息
    void GMUpdatePointError(string error){
        print(error);
    }

    //点击下载按钮
    void onClickDownLoad(){
        print("onClickDownLoad");
    }

    //点击返回按钮
    void onClickBack(){
        print("onClickBack");
    }

    //
    //可以只在积分point不为0的情况下提示, 回调格式为:
    // 名字,积分 如: 新三国,200  表示用户通过下载新三国得到了200积分
    void GMWallGetPoint(string NameAndPoint){
        print(NameAndPoint);
    }
}

 

posted @ 2014-07-07 17:55  ing...  阅读(608)  评论(0编辑  收藏  举报