コード例 #1
0
    void Process(Action <string, string> action)
    {
        if (string.IsNullOrEmpty(baseDirectoryPath) || !Directory.Exists(baseDirectoryPath))
        {
            Debug.LogError("missing baseDirectory");
            return;
        }

        for (var i = 0; i < destDirectories.Length; i++)
        {
            if (string.IsNullOrEmpty(destDirectories[i].Path) || !Directory.Exists(destDirectories[i].Path))
            {
                Debug.LogError("missing destDirectory : " + i);
                return;
            }
        }
        AdjustRatio();
        var files = Directory.GetFiles(baseDirectoryPath);

        print(files.Length);
        for (var i = 0; i < destDirectories.Length; i++)
        {
            destDirectories[i].FileNUM = Mathf.FloorToInt((float)files.Length * destDirectories[i].Ratio);
            print(destDirectories[i].FileNUM);
        }

        files = EUtils.Shuffle(files);
        var directoryIndex = 0;
        var num            = 0;

        for (var i = 0; i < files.Length; i++)
        {
            var extension = Path.GetExtension(files[i]);
            if (targetExtensions.Length > 0)
            {
                if (!targetExtensions.Contains(extension))
                {
                    continue;
                }
            }
            var directory = destDirectories[directoryIndex];
            action(files[i], Path.Combine(directory.Path, (num + 1) + extension));
            var progress = (float)i / files.Length;
            EditorUtility.DisplayCancelableProgressBar("Process", "processing...", progress);
            num++;
            if (num >= directory.FileNUM)
            {
                directoryIndex++;
                num = 0;
                if (directoryIndex >= destDirectories.Length)
                {
                    break;
                }
            }
        }
        EditorUtility.ClearProgressBar();
        print("complete");
    }
コード例 #2
0
    float RenderingGroup(float xStart, float yStart)
    {
        float xPos = xStart + 25;
        float yPos = yStart + 25;

        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), EUtils.UnityColoredText("Rendering", headingColor));
        yPos = yPos + sWidthHeight.y;
        //Anti Analysing
        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), "Antialiasing: " + QualitySettings.antiAliasing);
        antiAliasing = GUI.HorizontalSlider(new Rect(xPos + sWidthHeight.x, yPos, sWidthHeight.x, sWidthHeight.y), antiAliasing, 0, maxAntiAliasing);
        if (antiAliasing != QualitySettings.antiAliasing)
        {
            antiAliasing = (int)Mathf.ClosestPowerOfTwo((int)antiAliasing);
            if (antiAliasing == 1)
            {
                antiAliasing = 0;
            }
            QualitySettings.antiAliasing = (int)Mathf.ClosestPowerOfTwo((int)antiAliasing);
        }
        //End anti Analysing
        //Anisotropic Filtering
        yPos = yPos + sWidthHeight.y;
        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), "Anisotropic Filtering: " + QualitySettings.anisotropicFiltering.ToString());

        yPos = yPos + sWidthHeight.y;
        if (GUI.Button(new Rect(xPos, yPos, bWidthHeight.x, bWidthHeight.y), AnisotropicFiltering.Disable.ToString()))
        {
            anisotropicFilt = AnisotropicFiltering.Disable;
        }
        if (GUI.Button(new Rect(xPos + bWidthHeight.x, yPos, bWidthHeight.x, bWidthHeight.y), AnisotropicFiltering.Enable.ToString()))
        {
            anisotropicFilt = AnisotropicFiltering.Enable;
        }
        if (GUI.Button(new Rect(xPos + (bWidthHeight.x * 2), yPos, bWidthHeight.x, bWidthHeight.y), AnisotropicFiltering.ForceEnable.ToString()))
        {
            anisotropicFilt = AnisotropicFiltering.ForceEnable;
        }
        QualitySettings.anisotropicFiltering = anisotropicFilt;
        //End Anisotropic Filtering

        //Texture Quality
        yPos = yPos + bWidthHeight.y;
        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), "Texture Quality(Beter to worse): " + QualitySettings.masterTextureLimit);
        textureQuality = GUI.HorizontalSlider(new Rect(xPos + sWidthHeight.x, yPos, sWidthHeight.x, 25), textureQuality, 0, maxTextureQuality);
        QualitySettings.masterTextureLimit = (int)textureQuality;
        //End Texture Quality

        //Pixel Light Count
        yPos = yPos + sWidthHeight.y;
        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), "Pixel Light Count: " + QualitySettings.pixelLightCount);
        pixelLightCount = GUI.HorizontalSlider(new Rect(xPos + sWidthHeight.x, yPos, sWidthHeight.x, sWidthHeight.y), pixelLightCount, 0, maxPixelLightCount);
        QualitySettings.pixelLightCount = (int)pixelLightCount;
        //End Pixel Light Count
        return(yPos);
    }
コード例 #3
0
        void requestroute_get(LanguageInterpreter sender, FunctionArgs args)
        {
            if (EUtils.CheckArgs(2, args))
            {
                object param  = args.EvaluateParameters()[0];
                object param2 = args.EvaluateParameters()[1];

                /**/

                if (EUtils.CheckArgType(param, typeof(string)))
                {
                    if (EUtils.CheckArgType(param2, typeof(UserFunction)) || EUtils.CheckArgType(param2, typeof(String)))
                    {
                        string relative_path = (string)param;

                        //sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "info: new get request handler [" + relative_path + "]", "detail", "dunno"));

                        if (EUtils.CheckArgType(param2, typeof(UserFunction)))
                        {
                            UserFunction handler = (UserFunction)param2;

                            routedHTTPInterpreterServer.RequestHandlers.Add(relative_path, new RequestHandler(handler, RequestMethod.GET, relative_path));
                        }
                        else
                        {
                            string file = (string)param2;

                            if (!System.IO.File.Exists(file) && !System.IO.Directory.Exists(file))
                            {
                                sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "File or folder non-existent", "The specified file or folder '" + file + "' does not exist.", "Check the file path provided for errors."));
                            }
                            else
                            {
                                routedHTTPInterpreterServer.RequestHandlers.Add(relative_path, new RequestHandler(file, RequestMethod.GET, relative_path));
                            }
                        }
                    }
                    else
                    {
                        sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'UserFunction' or 'String', got '" + param2.GetType().Name + "'.", ""));
                    }
                }
                else
                {
                    sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                }
            }
            else
            {
                sender.Interpreter.HandleException(Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
            }
        }
コード例 #4
0
ファイル: MovementRail.cs プロジェクト: Quget/Interstar
    private void MoveToCatcher(float speed)
    {
        GameObject catcherObject = EUtils.GetNearestObjectOfType <CatchTrigger>(transform.position);

        if (catcherObject != null)
        {
            Vector3 targetPosition = new Vector3(transform.position.x, transform.position.y, catcherObject.transform.position.z);
            if (transform.position != targetPosition)
            {
                transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
            }
        }
    }
コード例 #5
0
    float SoundGroup(float xStart, float yStart)
    {
        float xPos = xStart + 25;
        float yPos = yStart + 25;

        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), EUtils.UnityColoredText("Sound", headingColor));
        yPos = yPos + sWidthHeight.y;
        //masterVolume
        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), "Master Volume: " + (int)(AudioListener.volume * 100));
        masterVolume         = GUI.HorizontalSlider(new Rect(xPos + sWidthHeight.x, yPos, sWidthHeight.x, sWidthHeight.y), masterVolume, 0, maxMasterVolume);
        AudioListener.volume = masterVolume / 100;

        return(yPos);
    }
コード例 #6
0
ファイル: Monster.cs プロジェクト: Quget/Interstar
    // Use this for initialization
    protected override void Start()
    {
        IgnoreCollision();//Ignore all collisions with the same tag
        attackDistance = attackDistance + (EUtils.GetObjectCollUnitSize(gameObject).z / 2);
        if (attackDistance <= 0)
        {
            attackDistance = 0.1f;
        }

        animator = GetComponent <Animator>();
        if (animator != null)
        {
            animationSpeed = animator.speed;
        }
        jumpClip = jumpClips[Random.Range(0, jumpClips.Length)];
        base.Start();
    }
コード例 #7
0
 private void Grab()
 {
     if (holdingObject == null && isDown)
     {
         Ray        ray = new Ray(transform.position, -transform.up);
         RaycastHit hit = new RaycastHit();
         if (Physics.Raycast(ray, out hit, 1f))
         {
             if (hit.collider.GetComponent <PickUps>() != null)
             {
                 holdingObject   = hit.collider.GetComponent <PickUps>();
                 isHoldingObject = true;
                 float addedHeight = (EUtils.GetObjectUnitSize(holdingObject.gameObject).y / 2);
                 holdingObject.transform.position    = new Vector3(transform.position.x, transform.position.y - addedHeight, transform.position.z);
                 holdingObject.transform.parent      = this.transform;
                 holdingObject.rigidbody.isKinematic = true;
             }
         }
     }
 }
コード例 #8
0
    // Use this for initialization

    /*
     * protected override void Start()
     * {
     *  base.Start();
     * }
     * // Update is called once per frame
     * protected override void Update()
     * {
     *  base.Update();
     * }
     */
    //drop a banana peel.
    public void DropPeel()
    {
        //ToDo
        if (peelCount > 0 && !isInBlender)
        {
            Vector3    position = transform.position; //Current position
            RaycastHit hit;                           //For the raycast hit result
            //Raycast down from object position
            if (Physics.Raycast(transform.position, -transform.up, out hit, 10))
            {
                GameObject clone = GameObject.Instantiate(bananaPeel.gameObject, position, transform.rotation) as GameObject; //Drop peel
                Physics.IgnoreCollision(clone.collider, collider);
                position.y = hit.point.y + (EUtils.GetObjectCollUnitSize(clone).y / 2);                                       //Change y position to the hitting y position.
                clone.transform.position = position;
                Debug.Log((EUtils.GetObjectCollUnitSize(clone).y / 2));
            }

            //Clone prefeb object and place it in the game!
            peelCount--;//one less peel to drop
        }
    }
コード例 #9
0
ファイル: FileExtension.cs プロジェクト: Muny/AzLang
        public static void Exists(LanguageInterpreter sender, FunctionArgs args)
        {
            if (EUtils.CheckArgs(1, args))
            {
                object param = args.EvaluateParameters()[0];

                if (EUtils.CheckArgType(param, typeof(string)))
                {
                    args.HasResult = true;
                    args.Result    = File.Exists((string)param);
                }
                else
                {
                    sender.Interpreter.HandleException(new Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                }
            }
            else
            {
                sender.Interpreter.HandleException(Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
            }
        }
コード例 #10
0
ファイル: FileExtension.cs プロジェクト: Muny/AzLang
        public static void Append(LanguageInterpreter sender, FunctionArgs args)
        {
            if (EUtils.CheckArgs(2, args))
            {
                object param  = args.EvaluateParameters()[0];
                object param2 = args.EvaluateParameters()[1];

                if (EUtils.CheckArgType(param, typeof(string)))
                {
                    if (EUtils.CheckArgType(param2, typeof(string)))
                    {
                        string filepath = (string)param;
                        string text     = (string)param2;

                        if (File.Exists(filepath))
                        {
                            args.HasResult = true;
                            File.AppendAllText(filepath, text);
                        }
                        else
                        {
                            sender.Interpreter.HandleException(new Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Error appending to file.", "The specified file does not exist.", ""));
                        }
                    }
                    else
                    {
                        sender.Interpreter.HandleException(new Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param2.GetType().Name + "'.", ""));
                    }
                }
                else
                {
                    sender.Interpreter.HandleException(new Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                }
            }
            else
            {
                sender.Interpreter.HandleException(Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
            }
        }
コード例 #11
0
    float ResolutionGroup(float xStart, float yStart)
    {
        float xPos = xStart + 25;
        float yPos = yStart + 25;

        GUI.Label(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), EUtils.UnityColoredText("Resolutions", headingColor));
        yPos       = yPos + sWidthHeight.y;
        fullScreen = GUI.Toggle(new Rect(xPos, yPos, sWidthHeight.x, sWidthHeight.y), fullScreen, "Full screen");
        yPos       = yPos + sWidthHeight.y;
        float maxHeight = yPos + (Mathf.Floor(Screen.resolutions.Length / 3) * (sWidthHeight.y));

        Resolution[] resolutions = Screen.resolutions;
        for (int i = 0; i < resolutions.Length; i++)
        {
            float newXPos = xPos + (i % 3) * (bWidthHeight.x);
            float newYPos = yPos + (Mathf.Floor(i / 3) * (bWidthHeight.y));
            if (GUI.Button(new Rect(newXPos, newYPos, bWidthHeight.x, bWidthHeight.y), resolutions[i].width + "x" + resolutions[i].height + " " + resolutions[i].refreshRate))
            {
                Screen.SetResolution(resolutions[i].width, resolutions[i].height, fullScreen, resolutions[i].refreshRate);
#if UNITY_WEBPLAYER
                //var unity = document.getElementById('unityPlayer');
                Application.ExternalEval("config.width = " + resolutions[i].width + ";" +
                                         "config.height = " + resolutions[i].height + ";" +
                                         "document.getElementById('unityPlayer').style.width = '" + resolutions[i].width + "px';" +
                                         "document.getElementById('unityPlayer').style.height = '" + resolutions[i].height + "px';" +
                                         "document.getElementsByTagName('embed')[0].width = '" + resolutions[i].width + "px';" +
                                         "document.getElementsByTagName('embed')[0].height = '" + resolutions[i].height + "px';" +
                                         "document.getElementsByTagName('embed')[0].style.width = '" + resolutions[i].width + "px';" +
                                         "document.getElementsByTagName('embed')[0].style.height = '" + resolutions[i].height + "px';" +
                                         "document.getElementsByClassName('content')[0].style.width = '" + resolutions[i].width + "px';"
                                         );
#endif
                optionWindowRect.x = 0;
                optionWindowRect.y = 0;
            }
        }
        return(maxHeight);
    }
コード例 #12
0
ファイル: MovementRail.cs プロジェクト: Quget/Interstar
    //Jupe looks the same as MovementMount.Move but not exactly. Maybe this will be diffrent in the future ? Who knows.
    public void Move(float speed, bool auto = false, bool isHoldingObject = false)
    {
        float diffrenceZ = transform.parent.position.z + (EUtils.GetObjectUnitSize(transform.parent.gameObject).z / 2);//min and max WORLD position.

        // Debug.Log(diffrenceZ + ":" + transform.position.z);
        if (!auto)
        {
            //Just read it. It is to see if the object is out of the moving area!
            if ((transform.position.z < (diffrenceZ + minMaxAddition) && speed > 0) || (transform.position.z > -(diffrenceZ + minMaxAddition) && speed < 0))
            {
                transform.Translate(0, 0, speed * Time.deltaTime);//Moves object forward and backwards.
            }
        }
        else
        {
            //Auto
            if (isHoldingObject)
            {
                MoveToCatcher(speed);
            }
            else
            {
                GameObject nearestObject = EUtils.GetNearestObjectOfType <PickUps>(transform.position);
                if (nearestObject != null)
                {
                    Vector3 targetPosition = new Vector3(transform.position.x, transform.position.y, nearestObject.transform.position.z);
                    if (transform.position != targetPosition)
                    {
                        transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
                    }
                }
                else
                {
                    MoveToCatcher(speed);
                }
            }
        }
    }
コード例 #13
0
    //Jupe looks the same as MovementRail.Move but not exactly. Maybe this will be diffrent in the future ? Who knows.
    public void Move(float speed, bool auto = false, bool isHoldingObject = false)
    {
        float diffrenceX = transform.parent.position.x + (EUtils.GetObjectUnitSize(transform.parent.gameObject).x / 2);//min and max WORLD position.

        if (!auto)
        {
            //For some reason localposition works better here.
            //Just read it. It is to see if the object is out of the moving area!
            if ((transform.localPosition.x < (diffrenceX + minMaxAddition) && speed > 0) || (transform.localPosition.x > -(diffrenceX + minMaxAddition) && speed < 0))
            {
                transform.Translate(speed * Time.deltaTime, 0, 0);//Move object from left to right...
            }
        }
        else
        {
            //Auto
            if (isHoldingObject)
            {
                MoveToCatcher(speed);
            }
            else
            {
                GameObject nearestObject = EUtils.GetNearestObjectOfType <PickUps>(transform.position);
                if (nearestObject != null)
                {
                    Vector3 targetPosition = new Vector3(nearestObject.transform.position.x, transform.position.y, transform.position.z);
                    if (transform.position != targetPosition)
                    {
                        transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
                    }
                }
                else
                {
                    MoveToCatcher(speed);
                }
            }
        }
    }
コード例 #14
0
        void json_stringify(LanguageInterpreter sender, FunctionArgs args)
        {
            if (EUtils.CheckArgs(1, args))
            {
                object param = args.EvaluateParameters()[0];

                if (EUtils.CheckArgType(param, typeof(AnonymousVariableArray)))
                {
                    AnonymousVariableArray array = (AnonymousVariableArray)param;

                    args.HasResult = true;
                    args.Result    = array.SerializeToJSON();
                }
                else
                {
                    sender.Interpreter.HandleException(new Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'AnonymousVariableArray', got '" + param.GetType().Name + "'.", ""));
                }
            }
            else
            {
                sender.Interpreter.HandleException(Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
            }
        }
コード例 #15
0
        void server_ProcessRequest(HttpListenerContext context)
        {
            /*context.Response.AddHeader("Content-Type", "application/x-force-download");
             * context.Response.ContentLength64 = data.Length;*/

            context.Response.StatusCode = 200;



            Interpreter.Interpreter.HandleWrite = (string msg) =>
            {
                writeStrToContext(context, msg);
            };

            Interpreter.Interpreter.HandleNonEvaluatedLine = (string line) =>
            {
                Interpreter.Interpreter.HandleWrite(line);
            };

            Interpreter.Interpreter.HandleException = (AzLang.Exception exception) =>
            {
                //context.Response.OutputStream..writeFailure();

                string msg = "[EXCEPTION] " + exception.File + ":" + exception.Line + "\n  Message: " + exception.Message + "\n  Detail: " + exception.Detail + "\n  Suggestions: " + exception.Suggestions + "\n";

                Console.WriteLine(msg);

                writeStrToContext(context, msg);

                context.Response.OutputStream.Close();

                //Reload();
            };

            Interpreter.Interpreter.NonStockMethods["flush"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                if (context.Response.OutputStream.CanWrite)
                {
                    context.Response.OutputStream.Flush();
                }
            };

            Interpreter.Interpreter.NonStockMethods["status_code"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                args.HasResult = true;

                if (EUtils.CheckArgs(1, args))
                {
                    object param = args.EvaluateParameters()[0];

                    if (EUtils.CheckArgType(param, typeof(int)))
                    {
                        int code = (int)param;

                        context.Response.StatusCode = code;
                    }
                    else
                    {
                        sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'Int32', got '" + param.GetType().Name + "'.", ""));
                    }
                }
                else
                {
                    sender.Interpreter.HandleException(AzLang.Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
                }
            };

            Interpreter.Interpreter.NonStockMethods["web_get_client_ip"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                args.HasResult = true;

                try
                {
                    args.Result = ((IPEndPoint)context.Request.RemoteEndPoint).Address.ToString();
                }
                catch
                {
                }
            };

            Interpreter.Interpreter.NonStockMethods["web_get_client_port"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                args.HasResult = true;
                try
                {
                    args.Result = ((IPEndPoint)context.Request.RemoteEndPoint).Port.ToString();
                }
                catch
                {
                }
            };

            Interpreter.Interpreter.NonStockMethods["get"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                args.HasResult = true;

                if (EUtils.CheckArgs(1, args))
                {
                    object param = args.EvaluateParameters()[0];

                    if (EUtils.CheckArgType(param, typeof(string)))
                    {
                        string get_var = (string)param;

                        if (context.Request.QueryString.AllKeys.Contains(get_var))
                        {
                            args.Result = context.Request.QueryString[get_var];
                        }
                        else
                        {
                            sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Undefined array key.", "The specified GET variable is non-existent.", ""));
                        }
                    }
                    else
                    {
                        sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                    }
                }
                else
                {
                    sender.Interpreter.HandleException(AzLang.Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
                }
            };

            Interpreter.Interpreter.NonStockMethods["cookies_contains"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                args.HasResult = true;

                if (EUtils.CheckArgs(1, args))
                {
                    object param = args.EvaluateParameters()[0];

                    if (EUtils.CheckArgType(param, typeof(string)))
                    {
                        string cookie_name = (string)param;

                        args.Result = context.Request.Cookies[cookie_name] != null;
                    }
                    else
                    {
                        sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                    }
                }
                else
                {
                    sender.Interpreter.HandleException(AzLang.Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
                }
            };

            Interpreter.Interpreter.NonStockMethods["cookies"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                args.HasResult = true;

                if (EUtils.CheckArgs(1, args))
                {
                    object param = args.EvaluateParameters()[0];

                    if (EUtils.CheckArgType(param, typeof(string)))
                    {
                        string cookie_name = (string)param;

                        if (context.Request.Cookies[cookie_name] != null)
                        {
                            args.Result = context.Request.Cookies[cookie_name].Value;
                        }
                        else
                        {
                            sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Undefined array key.", "The specified Cookie name is non-existent.", ""));
                        }
                    }
                    else
                    {
                        sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                    }
                }
                else
                {
                    sender.Interpreter.HandleException(AzLang.Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
                }
            };

            Interpreter.Interpreter.NonStockMethods["header"] = (LanguageInterpreter sender, NCalc.FunctionArgs args) =>
            {
                args.HasResult = true;

                if (EUtils.CheckArgs(2, args))
                {
                    object param  = args.EvaluateParameters()[0];
                    object param2 = args.EvaluateParameters()[1];

                    if (EUtils.CheckArgType(param, typeof(string)))
                    {
                        if (EUtils.CheckArgType(param2, typeof(string)))
                        {
                            string header = (string)param;
                            string value  = (string)param2;

                            context.Response.Headers.Add(header, value);
                        }
                        else
                        {
                            sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                        }
                    }
                    else
                    {
                        sender.Interpreter.HandleException(new AzLang.Exception(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, "Invalid parameter type.", "Function expects parameter of type 'String', got '" + param.GetType().Name + "'.", ""));
                    }
                }
                else
                {
                    sender.Interpreter.HandleException(AzLang.Consts.Exceptions.ParameterCountMismatch(sender.Interpreter.CurrentFile, sender.Interpreter.CurrentLine, 1));
                }
            };

            if (context.Request.Url.AbsolutePath.StartsWith("/_azlang_res/"))
            {
                context.Response.Headers["Cache-Control"] = "max-age=120";

                string req_icon = context.Request.Url.AbsolutePath.Remove(0, 13);

                req_icon = req_icon.Split('.')[0];

                if (File.Exists("Resources/" + req_icon + ".png"))
                {
                    byte[] image = imageToByteArray((Image)ResourceIcon(req_icon));

                    context.Response.OutputStream.Write(image, 0, image.Length);
                }
                else
                {
                    Handle404(context, context.Request.Url.AbsolutePath);
                }
            }
            else
            {
                Dictionary <string, RequestHandler> matches = RequestHandlers.Where(val => val.Key == context.Request.Url.AbsolutePath && val.Value.Method.ToString().ToLower() == context.Request.HttpMethod.ToLower()).ToDictionary(val => val.Key, val => val.Value);

                if (matches.Count > 0)
                {
                    RequestHandler match = matches.First().Value;



                    if (match.Type == HandlerType.UserFunction)
                    {
                        NCalc.FunctionArgs handler_args = new NCalc.FunctionArgs();

                        handler_args.Parameters = new NCalc.Expression[1];

                        handler_args.Parameters[0] = new NCalc.Expression(new RequestContext(context));

                        Interpreter.ExecuteUserFunction(match.HandlerFunction, handler_args);
                    }
                    else if (match.Type == HandlerType.File)
                    {
                        if (File.Exists(match.FilePath))
                        {
                            byte[] bytes = File.ReadAllBytes(match.FilePath);

                            context.Response.OutputStream.Write(bytes, 0, bytes.Length);

                            //writeStrToContext(context, File.ReadAllText(match.FilePath));
                        }
                        else
                        {
                            Handle404(context, match.FilePath);

                            //Interpreter.Interpreter.HandleException(new AzLang.Exception(Interpreter.Interpreter.CurrentFile, Interpreter.Interpreter.CurrentLine, "File '" + match.FilePath + "' is non-existent", "", ""));
                        }
                    }

                    Console.WriteLine(((IPEndPoint)context.Request.RemoteEndPoint).Address.ToString() + ":" + ((IPEndPoint)context.Request.RemoteEndPoint).Port.ToString() + "; request handled: " + match.UriAbsPath + ", method: " + match.Method);
                }
                else
                {
                    Dictionary <string, RequestHandler> dir_matches = RequestHandlers.Where(val => context.Request.Url.AbsolutePath.StartsWith(val.Key) && val.Value.Method.ToString().ToLower() == context.Request.HttpMethod.ToLower() && val.Value.Type == HandlerType.File).ToDictionary(val => val.Key, val => val.Value);

                    if (dir_matches.Count > 0)
                    {
                        RequestHandler dir_match = dir_matches.First().Value;

                        if (Directory.Exists(dir_match.FilePath))
                        {
                            string relative_path = context.Request.Url.AbsolutePath.Remove(context.Request.Url.AbsolutePath.IndexOf(dir_match.UriAbsPath), dir_match.UriAbsPath.Length);

                            if (File.Exists(dir_match.FilePath + relative_path))
                            {
                                byte[] bytes = File.ReadAllBytes(dir_match.FilePath + relative_path);

                                context.Response.OutputStream.Write(bytes, 0, bytes.Length);
                            }
                            else
                            {
                                if (Directory.Exists(dir_match.FilePath + relative_path))
                                {
                                    HandleDirectoryListing(context, dir_match.FilePath + relative_path);
                                }
                                else
                                {
                                    Handle404(context, dir_match.FilePath + relative_path.Remove(0, 1));
                                }
                            }
                        }
                        else
                        {
                            Handle404(context, dir_match.FilePath);
                        }
                    }
                    else
                    {
                        context.Response.StatusCode = 503;

                        writeStrToContext(context, "<h1>Request handler not defined.</h1>The request handler for \"<em>" + context.Request.Url.AbsolutePath + "</em>\" via method <b>" + context.Request.HttpMethod + "</b> is non-existent.");
                    }
                }
            }

            //context.Response.OutputStream.Write(data, 0, data.Length);

            try
            {
                if (context.Response.OutputStream.CanWrite)
                {
                    context.Response.Close();
                }
            }
            catch
            {
            }
        }
コード例 #16
0
ファイル: Monster.cs プロジェクト: Quget/Interstar
    protected virtual void Attack()        //Attack!
    {
        RaycastHit[] hit;                  //Get all objects that we hit
        bool         foundHit     = false; //found a target to hit
        Vector3      castPosition = new Vector3(transform.position.x, transform.position.y + (EUtils.GetObjectCollUnitSize(gameObject).y), transform.position.z);

        hit = Physics.RaycastAll(castPosition, transform.forward /* * 0.5f*/, attackDistance);
        //Debug.DrawRay(castPosition, transform.forward * attackDistance, Color.red);
        // Debug.Log(hit.Length);
        for (int i = 0; i < hit.Length; i++)
        {
            if (hit[i].collider == target.collider)
            {
                //http://docs.unity3d.com/ScriptReference/Time-time.html
                if (Time.time >= nextAttack)              //Is it time to attack?
                {
                    nextAttack = Time.time + attackSpeed; //Set up next attack
                    target.DoDamage(damage);              //Do Attack
                }
                isInAttackRange = true;
                foundHit        = true;
            }
        }
        if (!foundHit)
        {
            isInAttackRange = false;
            nextAttack      = Time.time + attackSpeed; //Setup next attack until we are at our target
        }
    }
コード例 #17
0
ファイル: FormDemo.cs プロジェクト: zj-666/Mac.WeChat
 private void button13_Click(object sender, EventArgs e)
 {
     weChatThread = new XzyWeChatThread(EUtils.EHexToStr(txt_login62.Text), txt_loginName.Text, txt_loginPassword.Text);
 }
コード例 #18
0
    private void AutoMove()
    {
        if ((GameValues.AutoMoveX || GameValues.AutoMoveY) && !isHoldingObject)
        {
            //bool isAboveBlender = false;
            Monster monster = null;

            // GameObject monsterGo = null;
            //if(targetMonster == null)
            targetMonster = EUtils.GetNearestObject(waveSpawner.SpawnedMonsters, transform.position);

            RaycastHit[] hit;
            if (targetMonster != null)
            {
                //BlenderCatch blender = GameObject.FindObjectOfType<BlenderCatch>();
                Defendable defendAble = GameObject.FindObjectOfType <Defendable>();
                //Vector3 castPosition = new Vector3(transform.position.x, transform.position.y + (EUtils.GetObjectCollUnitSize(gameObject).y), transform.position.z);
                hit = Physics.RaycastAll(targetMonster.transform.position, -Vector3.up /* * 0.5f*/, float.MaxValue);
                //Debug.DrawRay(castPosition, transform.forward * attackDistance, Color.red);
                // Debug.Log(hit.Length);
                for (int i = 0; i < hit.Length; i++)
                {
                    Defendable blenderCatch = hit[i].collider.GetComponent <Defendable>();
                    if (blenderCatch != null)
                    {
                        targetMonster = null;
                        return;
                    }
                }
                monster = targetMonster.GetComponent <Monster>();
            }

            if (GameValues.AutoMoveX)
            {
                if (monster != null)
                {
                    Ray        monsterRay = new Ray(monster.transform.position, -Vector3.up);
                    RaycastHit monsterHit;

                    if (!monster.isInBlender && !monster.isStunned)
                    {
                        Vector3 targetPosition = new Vector3(monster.transform.position.x, transform.position.y, transform.position.z);
                        transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                    }
                }
            }
            if (GameValues.AutoMoveY)
            {
                if (monster != null)
                {
                    //Vector3.Distance(transform.position, monster.transform.position) < 1)
                    //if (!monster.isInBlender && transform.position.x == monster.transform.position.x)

                    if (!monster.isInBlender && !monster.isStunned && Mathf.Abs(transform.position.x - monster.transform.position.x) < 1)
                    {
                        Vector3 targetPosition = new Vector3(transform.position.x, monster.transform.position.y, transform.position.z);
                        transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                    }
                }
            }
            if (GameValues.AutoGrab)
            {
                if (monster != null)
                {
                    if (!monster.isInBlender && !monster.isStunned && Vector3.Distance(transform.position, monster.transform.position) < 1)
                    {
                        VisualSqueeze(monster.minPressure + 4);
                    }
                }
            }
        }
        else if ((GameValues.AutoMoveX || GameValues.AutoMoveY) && isHoldingObject)
        {
            BlenderCatch blender = GameObject.FindObjectOfType <BlenderCatch>();//EUtils.GetNearestObject(waveSpawner.SpawnedMonsters, transform.position);
            if (GameValues.AutoMoveX)
            {
                //if (blender != null && /*transform.position.y == blender.transform.position.y + 7.50f*/)
                if (blender != null && Mathf.Abs(transform.position.y - blender.transform.position.y) > 5.50f)
                {
                    Vector3 targetPosition = new Vector3(blender.transform.position.x, transform.position.y, transform.position.z);
                    transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                }
            }
            if (GameValues.AutoMoveY)
            {
                if (blender != null)
                {
                    Vector3 targetPosition = new Vector3(transform.position.x, blender.transform.position.y + 5.75f, transform.position.z);
                    transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                }
            }
            if (GameValues.AutoGrab)
            {
                if (blender != null)
                {
                    //if (transform.position.y == blender.transform.position.y + 7.50f && Mathf.Abs(transform.position.x - blender.transform.position.x) < 1)
                    if (Mathf.Abs(transform.position.y - blender.transform.position.y) > 5.50f && Mathf.Abs(transform.position.x - blender.transform.position.x) < 0.5f)
                    {
                        VisualSqueeze(1);
                    }
                }
            }
        }
    }
コード例 #19
0
ファイル: Kiwi.cs プロジェクト: Quget/Interstar
    public AudioClip bulletAudioClip; //Bullet sound

    /*
     * // Use this for initialization
     * protected override void Start()
     * {
     *  base.Start();
     * }
     * // Update is called once per frame
     * protected override void Update()
     * {
     *  base.Update();
     * }
     */
    protected override void Attack()
    {
        if (isInAttackRange)//Are we in range?
        {
            //Object distance
            //Vector3 targetPosition = new Vector3(target.transform.position.x, transform.position.y, 0);
            //float distance = Vector3.Distance(transform.position, targetPosition);
            //is the current distance lower then the attack distance?
            // Debug.Log(Mathf.Abs(transform.position.x - target.transform.position.x));
            //Debug.Log(distance + ":" + attackDistance);

            //if (distance <= attackDistance)
            //{
            // Debug.Log(Time.time + ":" + nextAttack);
            //http://docs.unity3d.com/ScriptReference/Time-time.html
            if (Time.time >= nextAttack)    //Is it time to attack?
            {
                //Debug.Log("BOOM");
                nextAttack = Time.time + attackSpeed;                                                                                   //Set up next attack
                Vector3 spawnPosition = new Vector3(transform.position.x, transform.position.y + (EUtils.GetObjectCollUnitSize(gameObject).y / 2), transform.position.z);
                Bullet  clone         = GameObject.Instantiate(bullet, spawnPosition, transform.rotation) as Bullet;                    //Clone bullet prefeb

                SoundManager.Instance.PlaySound(bulletAudioClip, transform.position, SoundManager.SoundTypes.EFFECT, false, transform); //Play Sound at some position with soundtype of Effect  not looping and parent of this gameobject.
                clone.Shoot(damage, target);                                                                                            //The bullet goes torwards the target\
            }
            isInAttackRange = true;                                                                                                     //We are in range
            // }
            //else
            //{
            //Debug.Log("NOPE.AVI");
            //isInAttackRange = false;// Not anymore
            //nextAttack = Time.time + attackSpeed; //Setup next attack until we are at our target
            //}
            //spawn particle
        }
        else
        {
            //isInAttackRange = false;// Not anymore
            nextAttack = Time.time + attackSpeed; //Setup next attack until we are at our target
        }
        base.Attack();
    }