Example #1
0
    public void MoveModel(Character Model)
    {
        if (usergui.state != 0)
        {
            return;
        }
        if (boat.left != Model.left)
        {
            return;
        }
        Vector3 dst;
        CCMove  ccMove = null;

        if (Model.onGround)
        {
            dst = boat.JoinBoat(Model);
            if (dst != Vector3.zero)  //不一定船上有空位
            {
                if (Model.left)
                {
                    leftside.LeaveLand(Model.id);
                }
                else
                {
                    rightside.LeaveLand(Model.id);
                }
                Model.LeaveLand();
                Model.JoinBoat(boat);
                ccMove = CCMove.GetSSAction(dst);
                var actionManager = ((FirstController)SSDirector.GetInstance().CurrentSceneController).actionManager;
                actionManager.RunAction(Model.obj, ccMove, (CCActionManager)actionManager);
                //Model.move.MoveToPosition(dst);
            }
        }
        else
        {
            Model.LeaveBoat();
            boat.leaveBoat(Model.id);
            if (Model.left)
            {
                Model.JoinLand(leftside);
                dst = leftside.JoinLand(Model);
            }
            else
            {
                Model.JoinLand(rightside);
                dst = rightside.JoinLand(Model);
            }
            //Model.move.MoveToPosition(dst);
            ccMove = CCMove.GetSSAction(dst);
            var actionManager = ((FirstController)SSDirector.GetInstance().CurrentSceneController).actionManager;
            actionManager.RunAction(Model.obj, ccMove, (CCActionManager)actionManager);
            usergui.state = CheckGameOver();
        }
    }
Example #2
0
 static void Init()
 {
     tetriminoMap     = null;
     bot              = IntPtr.Zero;
     inputs           = new Queue <int>();
     currentInput     = -1;
     prevGameState    = 0;
     framesSinceSpawn = 0;
     lineClears       = new int[4];
     move             = new CCMove();
     currentLevel     = 0;
 }
Example #3
0
    /// <summary>
    /// CCFunction
    ///
    ///  Z轴移动
    ///
    /// 从开始点移动到目标点
    ///
    /// 注意 : 只适用于场景物体 如要UI使用 请使用 Text image 或 RectTransform MaskableGraphic 等
    /// </summary>
    public static CCAction Move(this Transform t, Vector3 startPos, Vector3 endPos, float time)
    {
        if (t == null)
        {
            Debug.LogError("传入Transform 为空请检查 ");
            return(null);
        }

        CCMove action = CCMove.Create(startPos, endPos, time);

        t.RunAction(action);
        return(action);
    }
Example #4
0
        public async Task <resmove> Post()
        {
            resmove res = new resmove();
            //res.hold = true;
            //Console.WriteLine("-------" + 0 + "----");
            //Console.WriteLine("-------" + res.hold + "----");
            //res.moves = new string[] { "Left", "Left" };
            //Console.WriteLine(res.moves[0]);
            //return res;
            CCMove temp = await bot.CC.nextMove();

            if (temp.nodes == 999999999)
            {
                return(null);
            }
            res.hold = (temp.hold != 0);
            int cnt = 0;

            for (int i = 0; i < temp.movement_count; ++i)
            {
                unsafe
                {
                    if (temp.movements[i] == 4)
                    {
                        cnt++;
                    }
                }
            }
            res.moves = new string[temp.movement_count + 0 * cnt];
            Console.WriteLine("temp.movement_count" + (int)temp.movement_count);
            string[] tepl = { "Left", "Right", "Cw", "Ccw", "SonicDrop" };
            for (int i = 0, j = 0; i < temp.movement_count; ++i, ++j)
            {
                unsafe
                {
                    string fin = tepl[temp.movements[i]];
                    if (temp.movements[i] == 4)
                    {
                        for (int _ = 0; _ < 0; ++_)
                        {
                            res.moves[j++] = fin;
                        }
                    }

                    res.moves[j] = fin;

                    Console.WriteLine(fin);
                }
            }
            return(res);
        }
Example #5
0
 public static extern bool cc_poll_next_move(IntPtr bot, out CCMove move);
Example #6
0
        public async Task <CCMove> nextMove()
        {
            //Thread.Sleep(500);

            CCMove crash = new CCMove();

            crash.nodes = 999999999;
            CCMove cCMove = new CCMove();

            while (!acv || piececnt <= idx + 11 || addnext || reset)
            {
                Console.WriteLine(6); Console.WriteLine("end " + end); Console.WriteLine("piececnt " + piececnt); Thread.Sleep(50); if (end)
                {
                    calumove = false; return(crash);
                }
            }
            calumove = true;
            IntPtr ptrmove = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CCMove)));

            coldclearcore.cc_request_next_move(ptrBot, (uint)garbage);

            int a;

            if (end)
            {
                calumove = false;  return(crash);
            }
            Console.WriteLine(1);
            if (end)
            {
                calumove = false; return(crash);
            }

            await Task.Run(() => {
                while ((a = coldclearcore.cc_poll_next_move(ptrBot, ptrmove)) != 0)
                {
                    Console.WriteLine(2);
                    Console.WriteLine("piececnt" + piececnt);

                    Thread.Sleep(50);
                    if (end)
                    {
                        Console.WriteLine(4); calumove = false; break;
                    }
                }
            });

            if (end)
            {
                calumove = false; return(crash);
            }
            Console.WriteLine(3);
            cCMove = (CCMove)Marshal.PtrToStructure(ptrmove, typeof(CCMove));
            Console.WriteLine(3.1);
            Console.WriteLine("mnc " + (int)cCMove.movement_count);
            //Console.WriteLine("------" + cCMove.movement_count);
            calumove = false;
            idx++;
            Configuration config1 = System.Configuration.ConfigurationManager.OpenExeConfiguration("ColdCleartetr.exe");

            pbs = 60.0 / int.Parse(config1.AppSettings.Settings["bpm"].Value);
            if (end)
            {
                calumove = false; return(crash);
            }
            if (starttime == -1)
            {
                starttime = DateTime.Now.Ticks;
            }
            else
            {
                long   nowtime = DateTime.Now.Ticks;
                double spend   = (nowtime - starttime) / 10000.0;
                if (pbs * idx * 1000 > spend)
                {
                    Thread.Sleep((int)((pbs * idx) * 1000 - spend));
                }
            }
            if (end)
            {
                calumove = false; return(crash);
            }
            return(cCMove);
        }
Example #7
0
    //

    // Use this for initialization
    void Start()
    {
        boostBattery = boostBatteryMax;
        motor        = GetComponent <CCMove>();
    }