示例#1
0
 void Start()
 {
     time       = 0.0f;
     mainObject = GameObject.Find("MainObject");
     cManager   = RRConnectionManager.getInstance();
     //RRMessageQueue.getInstance ().AddCallback (Constants.SMSG_AUTH, ResponseLogin);
 }
        // Use this for initialization
        void Start()
        {
            //Canvas Initialization
            gObj      = new GameObject();
            gObj.name = "SelectionCanvas";
            Canvas canvas = gObj.AddComponent <Canvas> ();

            canvas.renderMode = RenderMode.ScreenSpaceOverlay;
            CanvasScaler cs = gObj.AddComponent <CanvasScaler> ();

            cs.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            GraphicRaycaster gRay = gObj.AddComponent <GraphicRaycaster> ();

            //Button stored by position
            spot1 = 0;
            spot2 = 1;

            //Initialize Buttons
            initButtons();

            mainObject = GameObject.Find("MainObject");

            cManager = RRConnectionManager.getInstance();


            //		NetworkRequestTable.init();
            //		NetworkResponseTable.init();

            RRMessageQueue.getInstance().AddCallback(Constants.SMSG_RRSTARTGAME, ResponseRRStartGame);
            RRMessageQueue.getInstance().AddCallback(Constants.SMSG_RRGETMAP, ResponseRRGetMap);

            RequestRRGetMap reqmap = new RequestRRGetMap();

            reqmap.Send();
            cManager.Send(reqmap);
        }
示例#3
0
        public float horizontalCollisions(float deltaY, float deltaX, Vector2 p)
        {
            // Check collisions left and right
            movementStopped = false;

            for (int i = 0; i < 3; i++)
            {
                float dir = Mathf.Sign(deltaX);
                float x   = p.x + c.x + s.x / 2 * dir;
                float y   = p.y + c.y - s.y / 2 + s.y / 2 * i;

                ray = new Ray(new Vector2(x, y), new Vector2(dir, 0));
                Debug.DrawRay(ray.origin, ray.direction);

                if (Physics.Raycast(ray, out hit, Mathf.Abs(deltaX) + skin, collisionMask))
                {
                    // Get Distance between player and ground
                    float dst = Vector3.Distance(ray.origin, hit.point);

                    // Stop player's downwards movement after coming within skin width of a collider
                    if (dst > skin)
                    {
                        deltaX = dst * dir - skin * dir;
                    }
                    else
                    {
                        deltaX = 0;
                    }

                    movementStopped = true;
                    break;
                }
                else if (Physics.Raycast(ray, out hit, Mathf.Abs(deltaX) + skin, collectableMask))
                {
                    string name = hit.collider.gameObject.name.Substring(0, 7);
                    //Debug.Log("!!!Try to pass name: " + name);
                    if (running.isHitItem(name))
                    {
                        Animator animator = hit.collider.gameObject.GetComponent <Animator>();
                        animator.SetBool("eaten", true);
                        //GameObject.Destroy(hit.collider.gameObject);
                    }
                }

                else if (Physics.Raycast(ray, out hit, Mathf.Abs(deltaX) + skin, endFlagMask))
                {
                    if (collider.gameObject.ToString().CompareTo("Player_sprite(Clone)") > 0)
                    {
                        PlayerPrefs.SetInt("Win", -1);
                        PlayerPrefs.SetString("Winning Time", "");

                        GameObject          mainObject = GameObject.Find("MainObject");
                        RRConnectionManager cManager;
                        cManager = RRConnectionManager.getInstance();

                        RequestRREndGame requestRREndGame = new RequestRREndGame();
                        requestRREndGame.Send(Running.completed, Running.time.ToString());
                        cManager.Send(requestRREndGame);

                        doPlayerFinish();
                    }
                }
            }

            return(deltaX);
        }