Esempio n. 1
0
        // GET api/values
        public string Get()
        {
            var predictions       = NetworkLogic.JustTipFullSeason();
            var simplePredictions = SimplePrediction.Convert(predictions);

            return(simplePredictions.ToJson());
        }
Esempio n. 2
0
        public IEnumerable <string> Get()
        {
            var predictions       = NetworkLogic.JustTipFullSeason();
            var simplePredictions = SimplePrediction.Convert(predictions);
            var json = simplePredictions.Select(JsonConvert.SerializeObject);

            return(json);
        }
Esempio n. 3
0
    void Start()
    {
        Debug.Log("PlayerScript started");
        rb = GetComponent <Rigidbody2D>();

        NetworkLogic = GetComponent <NetworkLogic>();

        //Loads scene on the server.
        NetworkLogic.CmdLoadScene("WaitingRoom");
    }
Esempio n. 4
0
    void Start()
    {
        Debug.Log("The Waiting room script started.");

        NetworkLogic = GameObject.Find("GameStatus").GetComponent <GameStatus>().MainHero.GetComponent <NetworkLogic>();

        // Button's event.
        GameObject.Find("Canvas/UI/Ready").GetComponent <Button>().onClick.AddListener(delegate
        {
            Debug.Log("Button 'ready' pressed.");
            if (IsReady == false)
            {
                // Changes status.
                GameObject.Find("UI/CurrentStatus").GetComponent <Text>().text = "You are ready";

                SendReadyToBeginMessage();
                if (ReadyCount == 2) // if 2 players are ready.
                {
                    Debug.Log("IT'S TIME TO CHANGE LEVEL");
                    NetworkLogic.CmdLoadScene("Level (0)");
                }
            }
        });
    }
Esempio n. 5
0
 public void Dispose()
 {
     GameLogic.Dispose();
     NetworkLogic.Dispose();
 }
Esempio n. 6
0
 public void StartRoom()
 {
     GameLogic.Start();
     NetworkLogic.Start();
 }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        if (m == null)
        {
            m = gen.currentMaze();
            RandomPlacement();
        }
        if (isLocalPlayer)
        {
            if (!setup)
            {
                gameObject.tag = "MyPlayer";
                SpriteObj.SetActive(false);
                CamHolder.SetActive(true);
            }

#if UNITY_ANDROID
            if (Input.touches.Length > 0)
            {
                Touch t = Input.GetTouch(0);
                if (t.phase == TouchPhase.Began)
                {
                    //save began touch 2d point
                    firstPressPos = new Vector2(t.position.x, t.position.y);
                }

                if (t.phase == TouchPhase.Ended)
                {
                    //save ended touch 2d point
                    secondPressPos = new Vector2(t.position.x, t.position.y);

                    //create vector from the two points
                    currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);

                    //normalize the 2d vector
                    currentSwipe.Normalize();

                    //swipe upwards
                    if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
                    {
                        //Debug.Log("up swipe");
                        CmdDoMovement(true, false, false, false);
                    }
                    //swipe down
                    if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
                    {
                        //Debug.Log("down swipe");
                        CmdDoMovement(false, true, false, false);
                    }
                    //swipe left
                    if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
                    {
                        //Debug.Log("left swipe");
                        CmdDoMovement(false, false, true, false);
                    }
                    //swipe right
                    if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
                    {
                        //Debug.Log("right swipe");
                        CmdDoMovement(false, false, false, true);
                    }
                }
                CheckSeen();
            }
#endif


            bool up    = Input.GetKeyDown(KeyCode.UpArrow);
            bool down  = Input.GetKeyDown(KeyCode.DownArrow);
            bool left  = Input.GetKeyDown(KeyCode.LeftArrow);
            bool right = Input.GetKeyDown(KeyCode.RightArrow);
            if (up || down || left || right)
            {
                Debug.Log("Move Command");
                CmdDoMovement(up, down, left, right);
            }
            CheckSeen();
        }
        else
        {
            if (!setup)
            {
                gameObject.tag = "OtherPlayer";
                SpriteObj.SetActive(true);
            }
        }

        if (isLocalPlayer && Input.GetKeyDown(KeyCode.Space))       // || Input.GetKeyDown(KeyCode.Mouse0))
        {
            CmdShoot();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            GameObject   obj = GameObject.Find("NetworkManager");
            NetworkLogic log = obj.GetComponent <NetworkLogic>();
            log.StopHost();
            log.StopClient();
            SceneManager.LoadScene(0);
        }
    }
Esempio n. 8
0
 void NetworkStateChange(NetworkLogic.ConnectState newState)
 {
 }