博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【转】Unity3.5 GameCenter基础教程
阅读量:6291 次
发布时间:2019-06-22

本文共 3366 字,大约阅读时间需要 11 分钟。

  1.  
  2. using UnityEngine;
  3. using UnityEngine.
    SocialPlatforms;
  4.  
  5. public
    class Startup :
  6. {
  7.   
    // we'll create some buttons in OnGui, allowing us to bump achievement and
  8.   
    // score values for testing
  9.   
  10.   
    private
    double ach1 =
    0;
  11.   
    private
    double ach2 =
    0;
  12.   
    private
    double ach3 =
    0;
  13.   
    private
    double ach4 =
    0;
  14.   
  15.   
    private
    long score1 =
    1000;
  16.   
    private
    long score2 =
    200;
  17.   
  18.   
    private
    int buttonWidth =
    120;
  19.   
    private
    int buttonHeight =
    50;
  20.   
    private
    int buttonGap =
    10;
  21.   
  22.   
    void
    (
    )
  23.   
    {
  24.      . .
    (HandleAuthenticated
    );
  25.   
    }
  26.   
  27.   
    // authentication
  28.   
  29.   
    private
    void HandleAuthenticated
    (
    bool
    )
  30.   
    {
  31.      .
    (
    "*** HandleAuthenticated: success = " +
    );
  32.     
    if
    (
    )
    {
  33.        . .
    (HandleFriendsLoaded
    );
  34.        .
    (HandleAchievementsLoaded
    );
  35.        .
    (HandleAchievementDescriptionsLoaded
    );
  36.     
    }
  37.   
    }
  38.   
  39.   
    private
    void HandleFriendsLoaded
    (
    bool
    )
  40.   
    {
  41.      .
    (
    "*** HandleFriendsLoaded: success = " +
    );
  42.     
    foreach
    ( friend
    in . .
    )
    {
  43.        .
    (
    "*   friend = " + friend.
    (
    )
    );
  44.     
    }
  45.   
    }
  46.   
  47.   
    private
    void HandleAchievementsLoaded
    (
    [
    ] achievements
    )
  48.   
    {
  49.      .
    (
    "*** HandleAchievementsLoaded"
    );
  50.     
    foreach
    ( achievement
    in achievements
    )
    {
  51.        .
    (
    "*   achievement = " + achievement.
    (
    )
    );
  52.     
    }
  53.   
    }
  54.   
  55.   
    private
    void HandleAchievementDescriptionsLoaded
    (
    [
    ] achievementDescriptions
    )
  56.   
    {
  57.      .
    (
    "*** HandleAchievementDescriptionsLoaded"
    );
  58.     
    foreach
    ( achievementDescription
    in achievementDescriptions
    )
    {
  59.        .
    (
    "*   achievementDescription = " + achievementDescription.
    (
    )
    );
  60.     
    }
  61.   
    }
  62.   
  63.   
    // achievements
  64.   
  65.   
    public
    void
    (
    string achievementId,
    double
    )
  66.   
    {
  67.     
    if
    ( . .
    )
    {
  68.        .
    (achievementId, , HandleProgressReported
    );
  69.     
    }
  70.   
    }
  71.   
  72.   
    private
    void HandleProgressReported
    (
    bool
    )
  73.   
    {
  74.      .
    (
    "*** HandleProgressReported: success = " +
    );
  75.   
    }
  76.   
  77.   
    public
    void ShowAchievements
    (
    )
  78.   
    {
  79.     
    if
    ( . .
    )
    {
  80.        .
    (
    );
  81.     
    }
  82.   
    }
  83.   
  84.   
    // leaderboard
  85.   
  86.   
    public
    void
    (
    string leaderboardId,
    long score
    )
  87.   
    {
  88.     
    if
    ( . .
    )
    {
  89.        .
    (score, leaderboardId, HandleScoreReported
    );
  90.     
    }
  91.   
    }
  92.   
  93.   
    public
    void HandleScoreReported
    (
    bool
    )
  94.   
    {
  95.      .
    (
    "*** HandleScoreReported: success = " +
    );
  96.   
    }
  97.   
  98.   
    public
    void ShowLeaderboard
    (
    )
  99.   
    {
  100.     
    if
    ( . .
    )
    {
  101.        .
    (
    );
  102.     
    }
  103.   
    }
  104.   
  105.   
    // gui
  106.   
  107.   
    public
    void
    (
    )
  108.   
    {
  109.     
    // four buttons, allowing us to bump and test setting achievements
  110.     
    int yDelta = buttonGap;
  111.     
    if
    ( .
    (
    new
    (buttonGap, yDelta, buttonWidth, buttonHeight
    ),
    "Ach 1"
    )
    )
    {
  112.       
    (
    "A0001", ach1
    );
  113.       ach1 =
    (ach1 ==
    100
    ) ?
    0 : ach1 +
    10;
  114.     
    }
  115.     yDelta += buttonHeight + buttonGap;
  116.     
    if
    ( .
    (
    new
    (buttonGap, yDelta, buttonWidth, buttonHeight
    ),
    "Ach 2"
    )
    )
    {
  117.       
    (
    "A0002", ach2
    );
  118.       ach2 =
    (ach2 ==
    100
    ) ?
    0 : ach2 +
    10;
  119.     
    }
  120.     yDelta += buttonHeight + buttonGap;
  121.     
    if
    ( .
    (
    new
    (buttonGap, yDelta, buttonWidth, buttonHeight
    ),
    "Ach 3"
    )
    )
    {
  122.       
    (
    "A0003", ach3
    );
  123.       ach3 =
    (ach3 ==
    100
    ) ?
    0 : ach3 +
    10;
  124.     
    }
  125.     yDelta += buttonHeight + buttonGap;
  126.     
    if
    ( .
    (
    new
    (buttonGap, yDelta, buttonWidth, buttonHeight
    ),
    "Ach 4"
    )
    )
    {
  127.       
    (
    "A0004", ach4
    );
  128.       ach4 =
    (ach4 ==
    100
    ) ?
    0 : ach4 +
    10;
  129.     
    }
  130.     
    // show achievements
  131.     yDelta += buttonHeight + buttonGap;
  132.     
    if
    ( .
    (
    new
    (buttonGap, yDelta, buttonWidth, buttonHeight
    ),
    "Show Achievements"
    )
    )
    {
  133.       ShowAchievements
    (
    );
  134.     
    }
  135.     
  136.     
    // two buttons, allowing us to bump and test setting high scores
  137.     
    int xDelta = .
    width - buttonWidth - buttonGap;
  138.     yDelta = buttonGap;
  139.     
    if
    ( .
    (
    new
    (xDelta, yDelta, buttonWidth, buttonHeight
    ),
    "Score 1"
    )
    )
    {
  140.       
    (
    "L01", score1
    );
  141.       score1 +=
    500;
  142.     
    }
  143.     yDelta += buttonHeight + buttonGap;
  144.     
    if
    ( .
    (
    new
    (xDelta, yDelta, buttonWidth, buttonHeight
    ),
    "Score 2"
    )
    )
    {
  145.       
    (
    "L02", score2
    );
  146.       score2 +=
    100;
  147.     
    }
  148.     
    // show leaderboard
  149.     yDelta += buttonHeight + buttonGap;
  150.     
    if
    ( .
    (
    new
    (xDelta, yDelta, buttonWidth, buttonHeight
    ),
    "Show Leaderboard"
    )
    )
    {
  151.       ShowLeaderboard
    (
    );
  152.     
    }
  153.   
    }
  154. }

转载地址:http://dvkta.baihongyu.com/

你可能感兴趣的文章
rpmfusion 的国内大学 NEU 源配置
查看>>
spring jpa 配置详解
查看>>
IOE,为什么去IOE?
查看>>
Storm中的Worker
查看>>
dangdang.ddframe.job中页面修改表达式后进行检查
查看>>
Web基础架构:负载均衡和LVS
查看>>
Linux下c/c++相对路径动态库的生成与使用
查看>>
SHELL实现跳板机,只允许用户执行少量允许的命令
查看>>
SpringBoot 整合Redis
查看>>
2014上半年大片早知道
查看>>
Android 6.0指纹识别App开发案例
查看>>
正文提取算法
查看>>
轻松学PHP
查看>>
Linux中的网络监控命令
查看>>
this的用法
查看>>
windows下安装redis
查看>>
CentOS7 yum 安装git
查看>>
启动日志中频繁出现以下信息
查看>>
httpd – 对Apache的DFOREGROUND感到困惑
查看>>
分布式锁的一点理解
查看>>