示例#1
0
        /// <summary>
        /// 存储过程
        /// </summary>
        /// <param name="procName">存储过程名称</param>
        /// <param name="pars">参数</param>
        /// <returns></returns>
        public static string SqlProc(string procName, params SqlParameter[] pars)
        {
            SqlConnection con = new SqlConnection(connectString);

            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = new SqlCommand(procName, con);
            //存储过程
            da.SelectCommand.CommandType = CommandType.StoredProcedure;

            //设置存储过程的参数值,其中@id 为存储过程的参数.
            if (pars != null && pars.Length > 0)
            {
                foreach (SqlParameter p in pars)
                {
                    da.SelectCommand.Parameters.Add(p);
                }
            }
            //SqlParameter id = da.SelectCommand.Parameters.Add("@id", SqlDbType.NText);
            DataSet ds = new DataSet();

            da.Fill(ds, "data");
            con.Close();
            string dsString = ToolsFunction.dataSetToJson(ds);

            return(dsString);
        }
示例#2
0
 //*******************************************************
 ///按钮函数
 /// <summary>
 ///按下测试按钮
 /// </summary>
 /// <param name="go"></param>
 private void OnBtnSetting(GameObject go)   //暂时先不使用点击,测试滑过事件
 {
     ToolsFunction.Log(this.gameObject, "按下NGUI的设置按钮");
     ControlSettingBtn();
     //CMySql.GetDataSet("delete from test");OK
     //CMySql.GetDataSet("insert into unity values(43, '43', '543534')");OK
 }
示例#3
0
        /// <summary>
        /// 倒计时的协程函数
        /// </summary>
        /// <param name="nTotalScond">想要计时的总的秒数</param>
        /// <returns></returns>
        IEnumerator TimerCount(int nTotalScond)
        {
            int second = 0;
            int nTotal = nTotalScond;

            if (second == nTotal)
            {
                Debug.Log(Time.time + "计时器结束了!");
                //这个时候应当直接弹出失败的界面,表示游戏结束!
                //todo
            }
            while (second < nTotal)
            {
                if (bPauseCount == false)
                {
                    Debug.Log(Time.time + " now, second:" + second.ToString());
                    nPresentScon  = nTotal - second; //剩余时间
                    nCountScon    = second;
                    time_lab.text = ToolsFunction.TimeFormat(nPresentScon);
                    second++;
                    //如果没有暂定才会返回
                }
                yield return(new WaitForSeconds(1f));  //每秒返回一次
            }
        }
 /// <summary>
 /// 点击游戏设置按钮
 /// </summary>
 /// <param name="go"></param>
 public void OnSettingBtn(GameObject go)
 {
     ToolsFunction.Log(this.gameObject, "点击了查看设置按钮");
     SubViewNow = OpenView("SettingView");  //打开设置面板
     SubViewNow.GetComponent <SettingView>().HandleAfteerOpenView();
     //Singleton<SettingView>.Instance.OpenView();   //打开设置的面板
 }
示例#5
0
    ///<summary>用于更新角色的运动状态</summary>
    // Update is called once per frame
    void Update()       //用于监听对人物的控制事件
    {
        UpdateAction(); //更新角色动作

        //!problem这个问题暂时搁浅
        ///身体倾斜控制水平位移
        ///f键:向左偏移
        ///g键:向右偏移
        if (Input.GetKeyDown("f") && State.OFFSET_CURRENT != State.OFFSET_LEFT)  //向左偏移,当POS_CURRENT == POS_LEFT的时候表示已经到了最左边了
        {
            transform.localPosition -= 0.3f * ToolsFunction.OffsetPosiion(DataConst.MeDisplay, 0);
        }
        if (Input.GetKeyDown("g") && State.OFFSET_CURRENT != State.OFFSET_RIGHT) //向右偏移
        {
            transform.localPosition += 0.3f * ToolsFunction.OffsetPosiion(DataConst.MeDisplay, 1);
        }

        if (false == State.OFFSET_IDLE && false == State.KEEP_IDLE) //表示没有撞到墙, 并且没有撞到障碍物
        {
            transform.Translate(vDirection / nRate);                //暂时设定为100
        }


        if (Input.GetKeyDown("t"))  //用于测试的按钮
        {
            Rectangle rec = new Rectangle(1, 1, 1, 1);
            Debug.Log(Time.time + " rectangle side: " + rec.X_Min);
            Debug.Log(Time.time + " rectangle side: " + rec.X_Max);
        }
    }
    /// <summary>
    /// 怪物的触发器,碰到人的时候,就让人静止了,但是如果人打斗的话,就可以解锁动作
    /// </summary>
    /// <param name="other"></param>
    public void OnTriggerEnter(Collider other)
    {
        if ("MeDisplay(Clone)" == other.gameObject.name)
        {
            ToolsFunction.Log(this.gameObject, "Spider现在撞到人了");
            nAnimIndex    = 1000; //设定一个值很大的量表示进入战斗状态, 只要碰到了人就开始战斗
            RoleAnimation = other.gameObject.GetComponent <Animation>();
            int i = 0;

            if (true == State.ON_FIGHT)
            {
                this.GetComponent <BoxCollider>().enabled = false;   //禁用触发器
                ToolsFunction.Log(this.gameObject, "执行次数:" + i);

                i++;
                SpiderAnimation.Play(MonsterAnim.AnimFight);
            }
            else
            {
                State.KEEP_IDLE = true;
                //我还没有攻击就撞到了蜘蛛,这个时候要播放被大的动画,毁掉函数中继续播放攻击动作
                //!!!!!!!!!!!
                other.gameObject.GetComponent <Animation>().Play(State.ANIM_DEMAGE); //播放受打击的动作
                other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject);
                ToolsFunction.AddScore(-DataConst.SCORE_SPIDER / 2);
            }
        }
    }
示例#7
0
        /// <summary>
        /// 查询方法--无参数
        /// </summary>
        /// <param name="cmdText">sql命令</param>
        /// <param name="cmdType">命令类型</param>
        /// <returns>返回json数据</returns>
        public static string QryData(string cmdText, CommandType cmdType)
        {
            //实例化数据库连接
            SqlConnection con = new SqlConnection(connectString);

            try
            {
                //打开连接
                con.Open();
                //适配器
                SqlDataAdapter da = new SqlDataAdapter(cmdText, con);
                //命令类型
                da.SelectCommand.CommandType = cmdType;
                //实例化数据集
                DataSet ds = new DataSet();
                //填充到数据集
                da.Fill(ds, "data");
                //转换为json数据
                string dsString = ToolsFunction.dataSetToJson(ds);
                //返回数据集
                return(dsString);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
            finally
            {
                //关闭数据库连接
                con.Close();
            }
        }
示例#8
0
 /// <summary>
 /// 怪物的触发器,碰到人的时候,就让人静止了,但是如果人打斗的话,就可以解锁动作
 /// </summary>
 /// <param name="other"></param>
 public void OnTriggerEnter(Collider other)
 {
     if ("MeDisplay(Clone)" == other.gameObject.name)
     {
         if (true == State.ON_FIGHT)
         {
             //ToolsFunction.Log(this.gameObject.name, "人打斗了。当前龙碰到人了");
             if (hitCount == 3)   //打够了3次才会把龙打死
             {
                 dragonAnimation.Play("fly death");
             }
             else
             {
                 State.KEEP_IDLE           = true;
                 other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject);
             }
             hitCount++;
         }
         else
         {
             State.KEEP_IDLE = true;
             other.gameObject.GetComponent <Animation>().Play(State.ANIM_DEMAGE); //播放受打击的动作
             other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject);
             ToolsFunction.AddScore(-DataConst.SCORE_DRAGON / 2);
         }
     }
 }
示例#9
0
 public void DestroyMe()
 {
     //销毁自己
     ToolsFunction.AddScore(DataConst.SCORE_GOLD);
     Destroy(this.gameObject);
     //ObjectManager.HindObj(DataConst.PRE_GOLD);   //隐藏对象当作销毁
     Debug.Log("当前的分数: " + DataConst.SCORE_TOTAL);
 }
// Usage

        /// <summary>
        /// 点击了查看记录的按钮
        /// </summary>
        /// <param name="go"></param>
        public void OnRecordBtn(GameObject go)
        {
            ToolsFunction.Log(this.gameObject, "点击了查看记录按钮");
            //CloseView();  //关闭当前界面

            SubViewNow = OpenView("RecordView");
            SubViewNow.GetComponent <RecordView>().HandleAfteerOpenView();
            //Singleton<RecordView>.Instance.OpenView();  //打开游戏记录的界面
        }
 /// <summary>
 /// 怪物死亡动画播放完death动画的时候回调的函数
 ///
 /// </summary>
 public void DeathCallback()
 {
     //用于怪物的死亡销毁对象
     Destroy(this.gameObject);                          //销毁对象
     //ObjectManager.HindObj(DataConst.PRE_SPIDER);  //隐藏对象,当作销毁
     this.GetComponent <BoxCollider>().enabled = false; //禁用触发器
     State.KEEP_IDLE = false;                           //静止状态复位\
     ToolsFunction.AddScore(DataConst.SCORE_MONSTER);   //加分
 }
示例#12
0
 /// <summary>
 /// 箱子被打击,播放完死亡动作后回调的函数
 /// </summary>
 public void  DeathCallBack()
 {
     Debug.Log("Box  的回调函数被调用了");
     golds.SetActive(true);   //激活金币堆
     State.KEEP_IDLE = false;
     //分数增加
     ToolsFunction.AddScore(DataConst.SCORE_BOX);
     Debug.Log("当前的分数: " + DataConst.SCORE_TOTAL);
 }
        /// <summary>
        /// 点击了退出游戏
        /// </summary>
        /// <param name="go"></param>
        public void OnQuitBtn(GameObject go)
        {
            ToolsFunction.Log(this.gameObject, "点击了退出游戏按钮");

            Application.Quit();  //关闭应用程序
            //还是要做保存记录的操作!!!!!!

            //todo
            //CloseView();
        }
    /// <summary>
    /// 死亡动画播放后的回调函数
    /// </summary>
    public void DeathCallback()
    {
        Debug.Log("蜘蛛要死亡了!");
        Destroy(this.gameObject);
        State.KEEP_IDLE = false;
        RoleAnimation.Play(State.ANIM_RUN);  //恢复跑步状态

        ToolsFunction.AddScore(DataConst.SCORE_SPIDER);
        //攻击动画要复位
    }
        /// <summary>
        /// 点击了开始游戏按钮正式进入游戏
        /// </summary>
        /// <param name="go"></param>
        public void OnStartBtn(GameObject go)
        {
            ToolsFunction.Log(this.gameObject, "点击了开始游戏按钮");
            //进入就播放倒计时的动画啊

            CloseView();                                                 //关闭当前界面
            SubViewNow = OpenView("MainView");
            SubViewNow.GetComponent <MainView>().HandleAfteerOpenView(); //打开界面后处理的操作
            //Singleton<MainView>.Instance.OpenView();   //打开游戏的主界面
        }
示例#16
0
 /// <summary>
 /// MeDisplay的触发器函数,主要用于滑绳的碰撞检测产生金币
 /// </summary>
 /// <param name="other"></param>
 public void OnTriggerEnter(Collider other)
 {
     otherCollider = other;  // 当前碰到的物体
     ToolsFunction.CreateGold(DataConst.MeDisplay, other);
     //以下调用产生怪物的函数
     //这个函数暂时屏蔽
     //解锁偏移锁定
     ToolsFunction.UnLockOffset(otherCollider);
     //检测障碍物和当前所处的游戏阶段
     ToolsFunction.BlockJudge(other.gameObject.name);
 }
示例#17
0
 /// <summary>
 /// 死亡动画播放反比的回调函数
 /// </summary>
 private void DeathCallback()
 {
     //显示死亡的特效
     EMonsterDie.StartPlay(this.gameObject.transform.localPosition + new Vector3(0, 1.5f, 0));
     this.GetComponent <BoxCollider>().enabled = false; //禁用触发器
     //ObjectManager.HindObj(DataConst.PRE_DRAGON);  //隐藏对象当作销毁
     State.KEEP_IDLE = false;                           //静止状态复位
     ToolsFunction.AddScore(DataConst.SCORE_DRAGON);    //加分
     hitCount = 0;
     Destroy(this.gameObject);                          //最后销毁对象
 }
示例#18
0
        //初始化控件的时候使用,子类重写,只在创建对象的时候执行一次

        //唤醒函数
        void Awake()
        {
            UIRoot = GameObject.Find("UI(Clone)");  //UI的根节点
            //将子界面全部加入到界面队列
            GameObject go = new GameObject();

            for (int i = 0; i < ViewName.Length; i++)
            {
                go = ToolsFunction.FindChild(UIRoot, ViewName[i]);
                SubView.Add(go);
            }
        }
 /// <summary>
 /// 呈现游戏记录
 /// </summary>
 public void ShowRecord()
 {
     ToolsFunction.Log(this.gameObject, "开始显示游戏记录" + RecordTb.RecList.Count);
     //首先对成绩单列表排序
     RecordTb.RecList.Sort(delegate(RecordTb.RecordTb_1 a, RecordTb.RecordTb_1 b) { return(b.score.CompareTo(a.score)); });
     for (int i = 0; i < RecordTb.RecList.Count; i++)
     {
         recList[i].score.text = (i + 1).ToString() + ". " + RecordTb.RecList[i].score; // (i * 1000).ToString();
         recList[i].time.text  = RecordTb.RecList[i].time;                              // (i * 20).ToString();
         recList[i].go.gameObject.SetActive(true);
     }
 }
示例#20
0
 //点击了退出按钮
 private void OnbtnQuit(GameObject go)
 {
     ToolsFunction.Log(this.gameObject, "点击了退出按钮");
     //这里调用保存游戏的分数和时间
     State.KEEP_IDLE = true;
     CloseView();           //关闭当前界面
     OpenView("AwardView"); //打开启动界面
     RecordTb.SaveRecord(); //保存游戏记录
     //保存游戏当中的设置
     XmlReadDoc.SaveSetting(SettingTb.Element[SettingTb.INDEX_MUSIC], SettingTb.Element[SettingTb.INDEX_HINT_TIP], SettingTb.Element[SettingTb.INDEX_SPEED], SettingTb.Element[SettingTb.INDEX_QUALITY]);
     //CMySql.UpdateSetting(SettingTb.Element[SettingTb.INDEX_MUSIC], SettingTb.Element[SettingTb.INDEX_HINT_TIP], SettingTb.Element[SettingTb.INDEX_SPEED], SettingTb.Element[SettingTb.INDEX_QUALITY]);
 }
 //保存游戏记录到数据库中
 public static void SaveRecord()
 {
     string sTime = System.DateTime.Now.ToShortDateString() + ","+System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString();
     RecordTb.record.score = DataConst.SCORE_TOTAL.ToString();
     RecordTb.record.time = sTime;
     RecordTb.record.cost = ToolsFunction.TimeFormat(MainView.nCountScon);//MainView.time_lab.text;   //时间标签此时的时间
     RecordTb.record.level = ToolsFunction.GetLevel(DataConst.SCORE_TOTAL, DataConst.BLOCK_COUNT,MainView.nCountScon);  //根据总分数获得游戏等级
     RecordTb.RecList.Add(RecordTb.record);  //把当前数据存到结构中
     string[] param = { DataConst.SCORE_TOTAL.ToString(), sTime, RecordTb.record.cost, RecordTb.record.level.ToString() };   //写入的参数
     //CMySql.WriteDB(DataConst.TB_RECORD, param);
     XmlReadDoc.SaveRecord(param); //保存游戏记录
 }
示例#22
0
        //设置基本信息
        private void InitSetting()
        {
            ToolsFunction.Log(this.gameObject, "在打开界面之后");
            ToolsFunction.Log(this.gameObject, "音乐:" + SettingTb.Element[SettingTb.INDEX_MUSIC]);
            ToolsFunction.Log(this.gameObject, "提示:" + SettingTb.Element[SettingTb.INDEX_HINT_TIP]);
            ToolsFunction.Log(this.gameObject, "速度:" + SettingTb.Element[SettingTb.INDEX_SPEED].ToString());
            ToolsFunction.Log(this.gameObject, "记录:" + SettingTb.Element[SettingTb.INDEX_QUALITY].ToString());

            toggleMusic.value   = SettingTb.Element[SettingTb.INDEX_MUSIC] == "1" ? true : false;
            toggleMaintip.value = SettingTb.Element[SettingTb.INDEX_HINT_TIP] == "1"?true:false;
            sliderSpeed.value   = float.Parse(SettingTb.Element[SettingTb.INDEX_SPEED]) / ((float)2);
            sliderQuality.value = float.Parse(SettingTb.Element[SettingTb.INDEX_QUALITY]);
        }
    /// <summary>
    /// 怪物的普通动作完毕之后的回调函数,默认回调下一个动画
    /// </summary>
    //public void ActionEndCallback()
    //{
    //    Debug.Log("Spider的一个动画已经播放完了");
    //    //第一次被执行是idle动画完毕后
    //    if (nAnimIndex < MonsterAnim.AnimNormal.Length)
    //    {
    //        ToolsFunction.Log(this.gameObject, "要播放Spider下一个normal动作");
    //        int n = Random.Range(0, MonsterAnim.AnimNormal.Length - 1);
    //        SpiderAnimation.Play(MonsterAnim.AnimNormal[n]);
    //        //nAnimIndex++;
    //    }
    //    else  //表示撞到了,开始播放第一个攻击动作
    //    {
    //        ToolsFunction.Log(this.gameObject, "准备播放第一个受击动作");
    //        SpiderAnimation.Play(MonsterAnim.AnimAttack[0]);
    //    }
    //}


    /// <summary>
    /// 怪物攻击动作完毕之后的回调函数
    /// </summary>
    public void AttackEndCallback()
    {
        if (nAttack >= MonsterAnim.AnimAttack.Length) //表示所有攻击动画已经播放完毕,播放死亡动画
        {
            nAttack = 0;                              //置0,重新开始播放打斗序列动画
        }
        else
        {
            ToolsFunction.Log(this.gameObject, "Spider下一个打斗动作");
            SpiderAnimation.Play(MonsterAnim.AnimAttack[nAttack]);
            nAttack++;
        }
    }
示例#24
0
 /// <summary>
 /// 音乐开关的处理
 /// </summary>
 private void ControlMusicBtn()
 {
     ToolsFunction.Log(this.gameObject, "当前音乐按钮的背景图片:" + MusicBg.spriteName);
     if ("play_music" == MusicBg.spriteName)
     {
         MusicBg.spriteName = "no_music";
         Common.MUSIC_BG.Pause();  //关闭音乐,其实是音乐暂停,再次点击会继续播放
     }
     else if ("no_music" == MusicBg.spriteName)
     {
         MusicBg.spriteName = "play_music";
         Common.MUSIC_BG.Play();  //结束音乐
     }
 }
示例#25
0
 //打开界面之后处理的一些工作
 public override void HandleAfteerOpenView()
 {
     base.HandleAfteerOpenView();
     //重读设置界面的内容
     ToolsFunction.Log(this.gameObject.name, "执行了HandleAfterOpenView函数");
     //SettingTb.Element = CMySql.GetOneColumnTab("settingtb");
     XmlReadDoc.ReadSetting();
     if (toggleMusic)  //在组件找到的情况下
     {
         InitSetting();
     }
     //StartCoroutine(InitSettingFunc());
     //InitSetting();
 }
 /// <summary>
 /// 怪物的触发器,碰到人的时候,就让人静止了,但是如果人打斗的话,就可以解锁动作
 /// </summary>
 /// <param name="other"></param>
 public void OnTriggerEnter(Collider other)
 {
     if ("MeDisplay(Clone)" == other.gameObject.name)
     {
         if (true == State.ON_FIGHT)
         {
             monsterAnimator.SetBool("die", true);
             //这里要播放一个捡金币的动画
         }
         else
         {
             State.KEEP_IDLE           = true;
             other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject);
             ToolsFunction.AddScore(-DataConst.SCORE_MONSTER / 2);
         }
     }
 }
示例#27
0
 /// <summary>
 ///左边的墙撞到了人,人不能继续左移
 /// </summary>
 /// <param name="other"></param>
 public void OnTriggerEnter(Collider other)
 {
     if ("MeDisplay(Clone)" == other.gameObject.name)   //碰到了玩家
     {
         //Debug.Log(Time.time + "left 人和墙壁的夹角:" + ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject));
         int angle = ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject);
         if (ToolsFunction.BetweenTwo(angle, -5, 5) || ToolsFunction.BetweenTwo(angle, 175, 185))   //表示MeDisplay不是偏移过去的
         {
             State.OFFSET_CURRENT = State.OFFSET_LEFT;
         }
         else
         {
             State.OFFSET_IDLE         = true; //则最终为idle,旋转的时候解锁,但是left什么时候解锁??
             other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject);
         }
     }
 }
示例#28
0
 /// <summary>
 /// 绑定在宝箱上的触发器,执行了动作就打开宝箱
 /// </summary>
 /// <param name="other"></param>
 public void OnTriggerEnter(Collider other)
 {
     if ("MeDisplay(Clone)" == other.gameObject.name)
     {
         State.KEEP_IDLE = true;
         if (true == State.ON_FIGHT)
         {
             BoxAnimator.SetBool("die", true);
             //这里要播放一个捡金币的动画
             this.GetComponent <BoxCollider>().enabled = false;                                       //禁用触发器
             MeController.SetAction(other.gameObject.GetComponent <Animation>(), State.ANIM_PICK_UP); //播放捡东西的动作
         }
         else
         {
             other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject);
             ToolsFunction.AddScore(-DataConst.SCORE_BOX / 2); //加分
         }
     }
 }
示例#29
0
 /// <summary>
 /// 右边的墙壁碰到了人,不能继续右移
 /// </summary>
 /// <param name="other"></param>
 public void OnTriggerEnter(Collider other)
 {
     if ("MeDisplay(Clone)" == other.gameObject.name)   //碰到了玩家
     {
         //要判断当前两个对象的夹角
         Debug.Log(Time.time + "right 人和墙壁的夹角:" + ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject));
         int angle = ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject);
         if (ToolsFunction.BetweenTwo(angle, -5, 5) || ToolsFunction.BetweenTwo(angle, 175, 185))   //表示MeDisplay不是偏移过去的
         {
             State.OFFSET_CURRENT = State.OFFSET_RIGHT;
         }
         else   //表示跑步撞到墙上的,
         {
             //向后偏移
             State.OFFSET_IDLE         = true;
             other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject);
         }
     }
 }
示例#30
0
 public void OnTriggerEnter(Collider other)
 {
     if ("MeDisplay(Clone)" == other.collider.gameObject.name)
     {
         State.KEEP_IDLE = true;
         if (true == State.ON_JUMP)  //在跳的过程中
         {
             Vector3 v = (ToolsFunction.EqualFloat(other.transform.eulerAngles.y, 90) == true ? new Vector3(73, 2.3f, 57) : new Vector3(25, 2.3f, 11));
             MeController.MoveTo(other.gameObject, v, 2f);
             other.gameObject.GetComponent <Animation>().Play(State.ANIM_HANDS_UP);
             ToolsFunction.AddScore(DataConst.SCORE_LINE);//加分
         }
         else
         {
             other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject); //现在人就是往后退了,然后应该会重新检测吧!!!!
             ToolsFunction.AddScore(-DataConst.SCORE_LINE / 2);                         //减分
         }
     }
 }