Пример #1
0
    public StateGame()
        : base(GAME)
    {
        //Initialize
        m_ScoreCounterTimers	= new List<float>();
        m_HealthCounterTimers	= new List<float>();
        m_HealthChanges			= new List<float>();
        m_EnemyShootTimer		= new List<float>();
        m_Started				= false;
        m_ConsoleLog 			= new string[CONSOLE_MAX_LINE];
        for(int i=0;i<CONSOLE_MAX_LINE;i++) m_ConsoleLog[i] = "";

        //Create backgrounds
        m_Background11 		= new FSprite("clouds") { x = Constants.UNITY_CENTER_X, y = Constants.UNITY_CENTER_Y };
        m_Background12 		= new FSprite("clouds") { x = Constants.UNITY_CANVAS_RIGHT + (Constants.UNITY_CANVAS_WIDTH / 2f) - 1, y = Constants.UNITY_CENTER_Y };
        m_Background22 		= new FSprite("hills") 	{ x = Constants.UNITY_CANVAS_RIGHT + (Constants.UNITY_CANVAS_WIDTH / 2f) - 1 };
        m_Background21 		= new FSprite("hills") 	{ x = Constants.UNITY_CENTER_X };
        m_Background21.y	= Constants.UNITY_CANVAS_BOTTOM + m_Background21.textureRect.height * 0.5f;
        m_Background22.y	= Constants.UNITY_CANVAS_BOTTOM + m_Background22.textureRect.height * 0.5f;
        AddChild(m_Background11);
        AddChild(m_Background12);
        AddChild(m_Background21);
        AddChild(m_Background22);

        //Create components
        m_Exa 			= new Exa();
        m_Enemies		= new FContainer();
        m_EnemyBullets	= new FContainer();
        m_PlayerBullets	= new FContainer();

        AddChild(m_Enemies);
        AddChild(m_Exa);
        AddChild(m_PlayerBullets);
        AddChild(m_EnemyBullets);

        //Create interface
        m_ScoreCounter 		= new FLabel("font", "") { isVisible = false };
        m_ErrorCounter 		= new FLabel("font", "") { isVisible = false };
        m_ScoreOverlay 		= new FSprite("target") { isVisible = false };
        m_HealthOverlay 	= new FSprite("target") { isVisible = false };
        m_HealthGauge 		= new FSprite("gauge") { isVisible = false };
        m_HealthBar 		= new FSprite("rect") { isVisible = false, color = new Color(0, 1, 0, 1) };

        //Add
        AddChild(m_HealthBar);
        AddChild(m_HealthGauge);
        //AddChild(m_ErrorCounter);
        AddChild(m_ScoreCounter);
        AddChild(m_ScoreOverlay);
        AddChild(m_HealthOverlay);

        //Create unity canvas
        m_Unity 	= new FSprite("unity") { x = Futile.screen.halfWidth, y = Futile.screen.halfHeight };
        m_Console 	= new FLabel[CONSOLE_MAX_LINE];
        for(int i=0;i<CONSOLE_MAX_LINE;i++) m_Console[i] = new FLabel("font_console", "") { isVisible = false };

        //Add
        AddChild(m_Unity);
        foreach(FLabel line in m_Console) AddChild(line);
    }
Пример #2
0
        public void VeryLargeResultantExponentsAreSupported()
        {
            var   leftOperand         = new Exa();
            var   rightOperand        = new Tera();
            Int32 multiplication      = leftOperand.Exponent + rightOperand.Exponent;
            var   expectedScaleFactor = Math.Pow(10, multiplication - Normalisers.Largest.Exponent);
            var   resultantOperator   = Normalisers.Get(multiplication);

            Assert.Equal(Normalisers.Largest.Exponent, resultantOperator.Exponent);
        }
Пример #3
0
        public void ReadCallback(IAsyncResult ar)
        {
            String content = String.Empty;
            int    bytesRead;

            string[] AcelVariables;
            int      Idplayer = 0;

            // Retrieve the state object and the handler socket
            // from the asynchronous state object.
            StateObject state   = (StateObject)ar.AsyncState;
            Socket      handler = state.workSocket;
            //Ip Client
            IPEndPoint remoteIpEndPoint = handler.RemoteEndPoint as IPEndPoint;

            try
            {
                // Read data from the client socket.
                bytesRead = handler.EndReceive(ar);

                if (bytesRead > 0)
                {
                    //Transformo los datos a typo string
                    content = Encoding.ASCII.GetString(state.buffer, 0, bytesRead);

                    /************ Decodificacion de datos ********/
                    //Tomo los Datos antes del LF y CF
                    content = content.Split('\n')[0];
                    content = content.Replace("*", "");
                    content = content.Replace(" ", "");

                    //Separo los Daros de X, Y, Z
                    AcelVariables = content.Split('/');

                    if (AcelVariables.Length > 2)
                    {
#if GEN_DEBUG
                        //Decodifico
                        Console.Clear();
                        Console.WriteLine("X " + AcelVariables[0]);
                        Console.WriteLine("Y " + AcelVariables[1]);
                        Console.WriteLine("Z " + AcelVariables[2]);
                        Console.WriteLine("Btn Fire " + AcelVariables[3]);
                        Console.WriteLine("Btn Gas " + AcelVariables[4]);
                        Console.WriteLine("Btn brake " + AcelVariables[5]);
#endif

                        //Adquiero Id del Jugador
                        Idplayer = AcelNetwork.SchClientList(remoteIpEndPoint.Address.ToString(), ref IpClients);

                        //Axes
                        PlyControl[Idplayer].AcelValue[0] = Convert.ToInt32(AcelVariables[0]);
                        PlyControl[Idplayer].AcelValue[1] = Convert.ToInt32(AcelVariables[1]);
                        PlyControl[Idplayer].AcelValue[2] = Convert.ToInt32(AcelVariables[2]);

                        //Botones
                        if (Convert.ToInt32(AcelVariables[3]) == 10)
                        {
                            PlyControl[Idplayer].Buttons[0] = true;
                        }
                        else
                        {
                            PlyControl[Idplayer].Buttons[0] = false;
                        }

                        if (Convert.ToInt32(AcelVariables[4]) == 10)
                        {
                            PlyControl[Idplayer].Buttons[1] = true;
                        }
                        else
                        {
                            PlyControl[Idplayer].Buttons[1] = false;
                        }

                        if (Convert.ToInt32(AcelVariables[5]) == 10)
                        {
                            PlyControl[Idplayer].Buttons[2] = true;
                        }
                        else
                        {
                            PlyControl[Idplayer].Buttons[2] = false;
                        }
                    }

                    if (Ciclo)
                    {
                        handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state);
                    }

                    return;
                }
            }
            catch (Exception Exa)
            {
                Console.WriteLine("ReadCallback" + Exa.ToString());

                //Elimino cliente de la lista
                //AcelNetwork.RmClientList(remoteIpEndPoint.Address.ToString(), ref IpClients);

                if (Ciclo)
                {
                    handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state);
                }

                return;
            }
        }