예제 #1
0
        public void excuteDelegate()
        {
            mDelegate mydelegate = new mDelegate(HellowWord);

            mydelegate("China");

            //Action是无返回值的泛型委托。
            //Action 表示无参,无返回值的委托
            //Action<int,string> 表示有传入参数int,string无返回值的委托
            //Action<int,string,bool> 表示有传入参数int,string,bool无返回值的委托
            //Action<int,int,int,int> 表示有传入4个int型参数,无返回值的委托
            //Action至少0个参数,至多16个参数,无返回值。
            Action <string> action = HellowWord;

            action("American");

            //Func是有返回值的泛型委托
            //Func<int> 表示无参,返回值为int的委托
            //Func<object,string,int> 表示传入参数为object, string 返回值为int的委托
            //Func<object,string,int> 表示传入参数为object, string 返回值为int的委托
            //Func<T1,T2,,T3,int> 表示传入参数为T1,T2,,T3(泛型)返回值为int的委托
            //Func至少0个参数,至多16个参数,根据返回值泛型返回。必须有返回值,不可void
            Func <string, bool> func = HellowChina;

            func("China");

            //predicate 是返回bool型的泛型委托
                   //predicate<int> 表示传入参数为int 返回bool的委托
                   //Predicate有且只有一个参数,返回值固定为bool
                   //List.Find

            //Conparison  List.Sort
        }
예제 #2
0
        protected void openFile()
        {
            mDelegate dcUpdateStatus = new mDelegate(updateStatus);

            this.Invoke(dcUpdateStatus, "Opening file");

            try
            {
                fStream = new FileStream(filePath, FileMode.Open);
                bReader = new BinaryReader(fStream);
                bWriter = new BinaryWriter(fStream);
            }
            catch (IOException ioEx)
            {
                MessageBox.Show("There was an error opening the file. Make sure it is not in use.", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //get file length/number of textures
            FileInfo fInfo;

            fInfo      = new FileInfo(filePath);
            fileLength = (ulong)fInfo.Length;

            //number of textures = (filelength - header(4096)) / (256 * 256 * 2)
            totalTextures = (uint)(fileLength - 4096) / (256 * 256 * 2) - 1;

            updateTexDropdown();
            enableControls();
            this.Invoke(dcUpdateStatus, "Ready");
        }
예제 #3
0
        private void displayCurrentTexture()
        {
            mDelegate dcUpdateStatus = new mDelegate(updateStatus);

            this.Invoke(dcUpdateStatus, "Reading texture");
            //updateStatus("Reading texture: " + cboCurrentTexture.SelectedText);
            bufferImage  = getTexture((long)(4096 + (currentTextureIndex * 256 * 256 * 2)));
            imageUpdated = true;
            //updateStatus("Ready");
            this.Invoke(dcUpdateStatus, "Ready");
        }
예제 #4
0
        private void exportCurrent()
        {
            mDelegate dcUpdateStatus = new mDelegate(updateStatus);

            this.Invoke(dcUpdateStatus, "Exporting current texture");
            try
            {
                bufferImage.Save(exportPath, System.Drawing.Imaging.ImageFormat.Png);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error saving the file. Try a different location and/or filename.", "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Invoke(dcUpdateStatus, "Ready");
        }
예제 #5
0
    public void PayTest()
    {
        StartTime = Time.time;
        spaceRect = currentStatus.space.rect;
        jungleRect = currentStatus.jungle.rect;
        japanRect = currentStatus.japan.rect;
        vikingRect = currentStatus.viking.rect;

        mDel += MoveSpace;
        mDel += MoveJungle;
        mDel += MoveJapan;
        mDel += MoveViking;

        space.depth = screenStatuses[testingInt].space.renderingOrder;
        jungle.depth = screenStatuses[testingInt].jungle.renderingOrder;
        japan.depth = screenStatuses[testingInt].japan.renderingOrder;
        viking.depth = screenStatuses[testingInt].viking.renderingOrder;

        StartCoroutine(MotionDuration());
    }
예제 #6
0
        private void exportAll()
        {
            mDelegate       dcUpdateStatus = new mDelegate(updateStatus);
            controlDelegate cDisable       = new controlDelegate(disableControls);
            controlDelegate cEnable        = new controlDelegate(enableControls);

            this.Invoke(cDisable);

            int    iEA, jEA;
            Bitmap tempBitmap;

            for (iEA = 0; iEA <= totalTextures; iEA++)
            {
                this.Invoke(dcUpdateStatus, "Exporting texture " + iEA + " of " + totalTextures);
                tempBitmap = getTexture((long)(4096 + (iEA * 256 * 256 * 2)));
                tempBitmap.Save(exportPath + "\\Texture-" + zeroFill(iEA.ToString(), 5) + ".PNG", System.Drawing.Imaging.ImageFormat.Png);
            }
            this.Invoke(cEnable);
            this.Invoke(dcUpdateStatus, "Ready");
        }
예제 #7
0
 IEnumerator MotionDuration()
 {
     yield return new WaitForSeconds(2f);
     mDel -= MoveSpace;
     mDel -= MoveJungle;
     mDel -= MoveJapan;
     mDel -= MoveViking;
     currentStatus = GetCurrentStatus();
     testingInt++;
 }
예제 #8
0
        private void importTexture()
        {
            mDelegate dcUpdateStatus = new mDelegate(updateStatus);

            disableControls();
            mnuOpenFile.Enabled = false;
            this.Invoke(dcUpdateStatus, "Importing replacement texture");

            Bitmap tempBitmap;

            tempBitmap = new Bitmap(importPath);
            if ((tempBitmap.Size.Width != 256) || (tempBitmap.Size.Height != 256))
            {
                MessageBox.Show("You MUST use a PNG image that is 256x256 pixels", "Incorrect File Format", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int    iGT, jGT;
            ushort a, r, g, b, pixelData;
            int    aFactor, rFactor, gFactor, bFactor;
            Color  colour;

            aFactor = 1;
            rFactor = 3;
            gFactor = 3;
            bFactor = 3;

            colour = new Color();

            fStream.Seek(4096 + (currentTexture * 256 * 256 * 2), SeekOrigin.Begin);

            for (iGT = 0; iGT <= 255; iGT++)
            {
                for (jGT = 0; jGT <= 255; jGT++)
                {
                    colour = tempBitmap.GetPixel(jGT, iGT);
                    a      = (ushort)(colour.A >> aFactor);
                    r      = (ushort)(colour.R >> rFactor);
                    g      = (ushort)(colour.G >> gFactor);
                    b      = (ushort)(colour.B >> bFactor);

                    a <<= 15;
                    r <<= 10;
                    g <<= 5;

                    pixelData = (ushort)(a | r | g | b);

                    bWriter.Write(pixelData);
                }
            }

            this.Invoke(dcUpdateStatus, "Loading rewritten texture");

            cboCurrentTexture.SelectedIndex = (int)currentTexture;

            bufferImage = getTexture(4096 + (currentTexture * 256 * 256 * 2));

            imageUpdated = true;

            enableControls();
            mnuOpenFile.Enabled = true;
            this.Invoke(dcUpdateStatus, "Ready");
        }
예제 #9
0
        private void importAll()
        {
            mDelegate       dcUpdateStatus = new mDelegate(updateStatus);
            controlDelegate cDisable       = new controlDelegate(disableControls);
            controlDelegate cEnable        = new controlDelegate(enableControls);

            this.Invoke(cDisable);

            DirectoryInfo directoryInfo = new DirectoryInfo(importPath);

            FileInfo[] fileInfos = directoryInfo.GetFiles("*.png", SearchOption.TopDirectoryOnly);
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("Texture-([0-9]+).(PNG)");
            System.Collections.Generic.SortedDictionary <uint, string> dictionary = new System.Collections.Generic.SortedDictionary <uint, string>();
            uint highestID = 0;

            foreach (FileInfo fileInfo in fileInfos)
            {
                if (regex.IsMatch(fileInfo.Name))
                {
                    string[] tokens = regex.Split(fileInfo.Name);
                    if (tokens.Length == 4 && UInt32.TryParse(tokens[1], out uint index))
                    {
                        dictionary.Add(index, fileInfo.Name);
                        if (index > highestID)
                        {
                            highestID = index;
                        }
                    }
                }
            }

            if (dictionary.Count > 0)
            {
                totalTextures    = highestID;
                fStream.Position = 0;

                int    iEA, jEA;
                Bitmap tempBitmap = null;

                for (iEA = 0; iEA <= totalTextures; iEA++)
                {
                    this.Invoke(dcUpdateStatus, "Exporting texture " + iEA + " of " + totalTextures);

                    if (dictionary.ContainsKey((uint)iEA))
                    {
                        tempBitmap = new Bitmap(Path.Combine(importPath, dictionary[(uint)iEA]));
                        if ((tempBitmap.Size.Width != textureWidth) || (tempBitmap.Size.Height != textureHeight))
                        {
                            tempBitmap.Dispose();
                            tempBitmap = new Bitmap(textureWidth, textureHeight);
                        }
                    }
                    else
                    {
                        tempBitmap = new Bitmap(textureWidth, textureHeight);
                    }

                    int    iGT, jGT;
                    ushort a, r, g, b, pixelData;
                    int    aFactor, rFactor, gFactor, bFactor;
                    Color  colour;

                    aFactor = 1;
                    rFactor = 3;
                    gFactor = 3;
                    bFactor = 3;

                    colour = new Color();

                    fStream.Seek(getTextureOffset(iEA), SeekOrigin.Begin);

                    for (iGT = 0; iGT < textureHeight; iGT++)
                    {
                        for (jGT = 0; jGT < textureWidth; jGT++)
                        {
                            colour = tempBitmap.GetPixel(jGT, iGT);
                            a      = (ushort)(colour.A >> aFactor);
                            r      = (ushort)(colour.R >> rFactor);
                            g      = (ushort)(colour.G >> gFactor);
                            b      = (ushort)(colour.B >> bFactor);

                            a <<= 15;
                            r <<= 10;
                            g <<= 5;

                            pixelData = (ushort)(a | r | g | b);

                            bWriter.Write(pixelData);
                        }
                    }

                    tempBitmap.Dispose();
                }

                fileLength = fStream.Length;

                fStream.Seek(2, SeekOrigin.Begin);
                bWriter.Write((ushort)dictionary.Count);
                fStream.Seek(0, SeekOrigin.Begin);

                //bufferImage = getTexture(getTextureOffset(currentTexture));
                //imageUpdated = true;
            }

            this.Invoke(cEnable);
            this.Invoke(dcUpdateStatus, "Ready");
        }
예제 #10
0
    void AddNextStep(Cinematic_Type type)
    {
        //Removes the previous step.
        if (currentStep > 0)
        {
            switch (sceneCinematics[(int)type][currentStep - 1].type)
            {
                case Movement_Type.WAIT:
                    mDel -= Wait;
                    break;
                case Movement_Type.MOVELERP:
                    mDel -= MoveLerp;
                    break;
                case Movement_Type.MOVESLERP:
                    mDel -= MoveSlerp;
                    break;
                case Movement_Type.SETPOSITION:
                    mDel -= SetPosition;
                    break;
                case Movement_Type.SETROTATION:
                    mDel -= SetRotation;
                    break;
                case Movement_Type.END:
                    break;
            }
        }
        if (currentStep >= stepsIntro.Count)
        {
            return;
        }
        Camera_Move nextStep = sceneCinematics[(int)type][currentStep];

        //Select the next step to add.
        switch (nextStep.type)
        {
            case Movement_Type.WAIT:
                mDel += Wait;
                break;
            case Movement_Type.MOVELERP:
                startTime = Time.time;
                movementDuration = nextStep.duration;
                stepStartPOS = new Vector3(transform.position.x, transform.position.y, transform.position.z);
                stepEndPOS = nextStep.position;
                endRotation = nextStep.rotation;
                startRotation = transform.rotation;
                mDel += MoveLerp;
                break;
            case Movement_Type.MOVESLERP:

                startTime = Time.time;
                movementDuration = nextStep.duration;
                stepStartPOS = new Vector3(transform.position.x, transform.position.y, transform.position.z);
                stepEndPOS = nextStep.position;
                endRotation = nextStep.rotation;
                startRotation = transform.rotation;
                mDel += MoveSlerp;

                break;
            case Movement_Type.SETPOSITION:
                transform.position = nextStep.position;
                transform.rotation = nextStep.rotation;
                mDel += SetPosition;
                break;
            case Movement_Type.SETROTATION:
                transform.rotation = nextStep.rotation;
                mDel += SetRotation;
                break;
            case Movement_Type.END:
                break;
        }

        currentStep++;
        //Delay the next step by current step duration.
        StartCoroutine(Clock(nextStep.duration, type));
    }