Пример #1
0
    void Update()
    {
        ChangeStat(Stat.hungry, -1);
        if (stat_hungry_current / stat_hungry < 0.5)
        {
            ChangeStat(Stat.happiness, -1);
        }
        else
        {
            ChangeStat(Stat.happiness, 1);
        }

        if (status != DogStatus.idle)
        {
            return;
        }

        //无目标就搜索目标
        if (target == null)
        {
            target = SearchTarget();
        }

        if (target != null)
        {
            status = DogStatus.busy;
            //有目标向其移动
            StartCoroutine(MoveToTarget(target.transform));
        }
    }
Пример #2
0
        /// <summary>
        /// Retrieves the update information
        /// without logging in using
        /// the SuperDog's GetInfo method.
        /// </summary>
        public string RunDemo()
        {
            string info = "";

            try
            {
                Header();

                Verbose("Retrieving Update Information");

                // now get the update information
                Verbose("Retrieving Information");
                DogStatus status = Dog.GetInfo(defaultScope, Dog.UpdateInfo, VendorCode.Code, ref info);
                ReportStatus(status);

                if (DogStatus.StatusOk == status)
                {
                    Verbose(info.Replace("\n", "\r\n     "));
                }
                else
                {
                    Verbose("");
                }

                Verbose("");
                Footer();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message,
                                                     "Exception",
                                                     System.Windows.Forms.MessageBoxButtons.OK);
            }
            return(info);
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            DogFeature feature = DogFeature.Default;

            using (Dog dog = new Dog(feature))
            {
                DogStatus status = dog.Login(VendorCode.Code, scope);
                if ((null == dog) || !dog.IsLoggedIn())
                {
                    return;
                }
                DogFile file = dog.GetFile(FileId);
                if (!file.IsLoggedIn())
                {
                    // Not logged into a dog - nothing left to do.
                    return;
                }
                int size = 0;
                status = file.FileSize(ref size);
                if (DogStatus.StatusOk != status)
                {
                    return;
                }

                // read the contents of the file into a buffer
                byte[] bytes = new byte[size];
                status = file.Read(bytes, 0, bytes.Length);
                if (DogStatus.StatusOk != status)
                {
                    return;
                }
                this.textBox4.Text = System.Text.Encoding.UTF8.GetString(bytes);
            }
        }
Пример #4
0
        public static string ReadData()
        {
            DogFeature feature = DogFeature.Default;

            using (Dog dog = new Dog(feature))
            {
                DogStatus status = dog.Login(VendorCode.Code, scope);
                if ((null == dog) || !dog.IsLoggedIn())
                {
                    return("请插入加密狗");
                }
                DogFile file = dog.GetFile(FileId);
                if (!file.IsLoggedIn())
                {
                    // Not logged into a dog - nothing left to do.
                    return("加载数据失败");
                }
                int size = 0;
                status = file.FileSize(ref size);
                if (DogStatus.StatusOk != status)
                {
                    return("加载数据失败");
                }

                // read the contents of the file into a buffer
                byte[] bytes = new byte[size];
                status = file.Read(bytes, 0, bytes.Length);
                if (DogStatus.StatusOk != status)
                {
                    return("失败");
                }
                return(System.Text.Encoding.UTF8.GetString(bytes));
            }
        }
Пример #5
0
        /// <summary>
        /// Demonstrates how to use to retrieve a XML containing all available features.
        /// </summary>
        protected void GetInfoDemo()
        {
            string queryFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
                                 "<dogformat root=\"dog_info\">" +
                                 " <feature>" +
                                 "  <attribute name=\"id\" />" +
                                 "  <element name=\"license\" />" +
                                 " </feature>" +
                                 "</dogformat>";

            Verbose("Get Information Demo");

            Verbose("Retrieving Feature Information");

            string info = null;

            DogStatus status = Dog.GetInfo(scope, queryFormat, VendorCode.Code, ref info);

            ReportStatus(status);
            if (DogStatus.StatusOk == status)
            {
                Verbose("Fature Information:");
                Verbose(info.Replace("\n", "\r\n          "));
            }
            else
            {
                Verbose("");
            }
        }
Пример #6
0
        /// <summary>
        /// Demonstrates how to perform a login and a logout
        /// using the default feature.
        /// </summary>
        protected void LoginLogoutDefaultDemo()
        {
            Verbose("Login/Logout Demo with Default Feature (DogFeature.Default)");

            DogFeature feature = DogFeature.Default;

            Verbose("Login:"******"Logout:");
                status = dog.Logout();

                ReportStatus(status);
            }

            // recommended, but not mandatory
            // this call ensures that all resources to SuperDog
            // are freed immediately.
            dog.Dispose();
            Verbose("");
        }
Пример #7
0
        /// <summary>
        /// Demonstrates how to perform a login using the default
        /// feature and how to perform an automatic logout
        /// using the SuperDog's Dispose method.
        /// </summary>
        protected void LoginDisposeDemo()
        {
            DogFeature feature = DogFeature.Default;
            Dog        dog     = new Dog(feature);
            DogStatus  status  = dog.Login(VendorCode.Code, scope);

            dog.Dispose();
        }
Пример #8
0
        public D1100TrackedAsset(byte[] buffer)
        {
            int offset = 0;

            Position = new PositionType(buffer, ref offset);
            Altitude = BitConverter.ToSingle(buffer, offset);
            offset  += 4;

            Time    = new DateTimeOffset(1989, 12, 31, 0, 0, 0, TimeSpan.FromSeconds(0)).AddSeconds(BitConverter.ToUInt32(buffer, offset)).ToLocalTime();
            offset += 4;

            uint status = BitConverter.ToUInt32(buffer, offset);

            offset     += 4;
            DogStatus   = (DogStatus)(status & 0x0f);
            Platform    = (PlatformType)((status >> 4) & 0x1f);
            TrackerType = (TrackerType)((status >> 8) & 0x07);
            StatusFlags = (StatusFlags)((status >> 11) & 0x1f);

            Symbol  = (SymbolType)BitConverter.ToUInt16(buffer, offset);
            offset += 2;

            CollarId = BitConverter.ToUInt16(buffer, offset);
            offset  += 2;

            Color       = buffer[offset++];
            Battery     = buffer[offset++];
            Gps         = buffer[offset++];
            Comm        = buffer[offset++];
            Channel     = buffer[offset++];
            SquelchCode = buffer[offset++];
            Index       = buffer[offset++];

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 37; i++)
            {
                if (buffer[offset + i] == 0)
                {
                    break;
                }
                sb.Append((char)buffer[offset + i]);
            }
            offset    += 37;
            Identifier = sb.ToString();

            sb.Clear();
            for (int i = 0; i < 31; i++)
            {
                if (buffer[offset + i] == 0)
                {
                    break;
                }
                sb.Append((char)buffer[offset + i]);
            }
            offset += 31;
            Message = sb.ToString();
        }
Пример #9
0
        /// <summary>
        /// Demonstrates how to retrieve information from a dog.
        /// </summary>
        protected void SessionInfoDemo(Dog dog)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }

            Verbose("Get Session Information Demo");

            Verbose("Retrieving SuperDog Information");

            // firstly we will retrieve the dog info.
            string    info   = null;
            DogStatus status = dog.GetSessionInfo(Dog.KeyInfo,
                                                  ref info);

            ReportStatus(status);
            if (DogStatus.StatusOk == status)
            {
                Verbose("SuperDog Information:");
                Verbose(info.Replace("\n", "\r\n          "));
            }
            else
            {
                Verbose("");
            }

            Verbose("Retrieving Session Information");

            // next the session info.
            status = dog.GetSessionInfo(Dog.SessionInfo, ref info);
            ReportStatus(status);
            if (DogStatus.StatusOk == status)
            {
                Verbose("Session Information:");
                Verbose(info.Replace("\n", "\r\n          "));
            }
            else
            {
                Verbose("");
            }

            Verbose("Retrieving Update Information");

            // last the update information.
            status = dog.GetSessionInfo(Dog.UpdateInfo, ref info);
            ReportStatus(status);
            if (DogStatus.StatusOk == status)
            {
                Verbose("Update Information:");
                Verbose(info.Replace("\n", "\r\n          "));
            }
            else
            {
                Verbose("");
            }
        }
Пример #10
0
        /// <summary>
        /// Demonstrates how to login using a feature id.
        /// </summary>
        protected Dog LoginDemo(DogFeature feature)
        {
            // create a dog object using a feature
            // and perform a login using the vendor code.
            Dog       dog    = new Dog(feature);
            DogStatus status = dog.Login(VendorCode.Code, scope);

            return(dog.IsLoggedIn() ? dog : null);
        }
Пример #11
0
        /// <summary>
        /// Demonstrates how to perform read and write
        /// operations on a file in SuperDog
        /// </summary>
        protected void ReadWriteDemo(Dog dog, Int32 fileId)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }
            // Get a file object to a file in SuperDog.
            // please note: the file object is tightly connected
            // to its dog object. logging out from a dog also
            // invalidates the file object.
            // doing the following will result in an invalid
            // file object:
            // dog.login(...)
            // DogFile file = dog.GetFile();
            // dog.logout();
            // Debug.Assert(file.IsValid()); will assert
            DogFile file = dog.GetFile(fileId);

            if (!file.IsLoggedIn())
            {
                // Not logged into a dog - nothing left to do.
                return;
            }

            // get the file size
            int       size   = 0;
            DogStatus status = file.FileSize(ref size);

            if (DogStatus.StatusOk != status)
            {
                return;
            }

            // read the contents of the file into a buffer
            byte[] bytes = new byte[size];
            status = file.Read(bytes, 0, bytes.Length);

            if (DogStatus.StatusOk != status)
            {
                return;
            }
            // now let's write some data into the file
            byte[] newBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7 };

            status = file.Write(newBytes, 0, newBytes.Length);
            if (DogStatus.StatusOk != status)
            {
                return;
            }
            // and read them again
            status = file.Read(newBytes, 0, newBytes.Length);
            // restore the original contents
            file.Write(bytes, 0, bytes.Length);
        }
Пример #12
0
        /// <summary>
        /// Performs a logout operation
        /// </summary>
        protected void LogoutDemo(ref Dog dog)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }
            DogStatus status = dog.Logout();

            // get rid of the dog immediately.
            dog.Dispose();
            dog = null;
        }
Пример #13
0
    //吃掉
    void Eat(GameObject _target)
    {
        SoundManager.instance.Play("Eat");

        ChangeStat(Stat.hungry, 200);

        target = null;
        GameManager.instance.interactableobjects.Remove(_target.transform);
        Destroy(_target);

        status = DogStatus.idle;
    }
Пример #14
0
        /// <summary>
        /// Demonstrates how to perform a login and an automatic
        /// logout using C#'s scope clause.
        /// </summary>
        protected void LoginDefaultAutoDemo()
        {
            DogFeature feature = DogFeature.Default;

            // this will perform a logout and object disposal
            // when the using scope is left.
            using (Dog dog = new Dog(feature))
            {
                DogStatus status = dog.Login(VendorCode.Code, scope);
                Console.WriteLine("test");
            }
        }
Пример #15
0
        /// <summary>
        /// Demonstrates how to use to retrieve a XML containing all available features.
        /// </summary>
        protected void GetInfoDemo()
        {
            string queryFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
                                 "<dogformat root=\"dog_info\">" +
                                 " <feature>" +
                                 "  <attribute name=\"id\" />" +
                                 "  <element name=\"license\" />" +
                                 " </feature>" +
                                 "</dogformat>";
            string    info   = null;
            DogStatus status = Dog.GetInfo(scope, queryFormat, VendorCode.Code, ref info);

            Console.WriteLine(info);
        }
Пример #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            DogFeature feature = DogFeature.Default;

            using (Dog dog = new Dog(feature))
            {
                DogStatus status = dog.Login(VendorCode.Code, scope);
                if ((null == dog) || !dog.IsLoggedIn())
                {
                    return;
                }
                DogFile file = dog.GetFile(FileId);
                if (!file.IsLoggedIn())
                {
                    // Not logged into a dog - nothing left to do.
                    return;
                }
                int size = 0;
                status = file.FileSize(ref size);
                if (DogStatus.StatusOk != status)
                {
                    return;
                }

                byte[] newBytes = System.Text.Encoding.UTF8.GetBytes(this.textBox1.Text);//new byte[] { 1, 2, 3, 4, 5, 6, 7 };

                status = file.Write(newBytes, 0, newBytes.Length);
                if (DogStatus.StatusOk != status)
                {
                    return;
                }



                // read the contents of the file into a buffer
                byte[] bytes = new byte[size];
                status = file.Read(bytes, 0, bytes.Length);
                if (DogStatus.StatusOk != status)
                {
                    return;
                }
                this.textBox2.Text = System.Text.Encoding.UTF8.GetString(bytes);
            }
            //textBox3.Text = dapi.WriteData(this.textBox1.Text.Trim());
            //this.textBox2.Text = dapi.ReadDate();
            //textBox3.SelectionStart = textBox3.TextLength;
            //textBox3.ScrollToCaret();
            //textBox3.Refresh();
        }
Пример #17
0
        /// <summary>
        /// Demonstrates how to get current time and date of
        /// a SuperDog when available.
        /// </summary>
        protected void TestTimeDemo(Dog dog)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }

            DateTime  time   = DateTime.Now;
            DogStatus status = dog.GetTime(ref time);

            if (DogStatus.StatusOk == status)
            {
                Console.WriteLine("Time and date is " + time.ToString());
            }
        }
Пример #18
0
        /// <summary>
        /// Demonstrates the usage of the AES encryption and
        /// decryption methods.
        /// </summary>
        protected void EncryptDecryptDemo(Dog dog)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }

            // the string to be encryted/decrypted.
            string text = "SuperDog is great";

            // convert the string into a byte array.
            byte[] data = UTF8Encoding.Default.GetBytes(text);

            // encrypt the data.
            DogStatus status = dog.Encrypt(data);

            if (DogStatus.StatusOk == status)
            {
                text = UTF8Encoding.Default.GetString(data);

                // decrypt the data.
                // on success we convert the data back into a
                // human readable string.
                status = dog.Decrypt(data);

                if (DogStatus.StatusOk == status)
                {
                    text = UTF8Encoding.Default.GetString(data);
                }
            }


            // Second choice - encrypting a string using the
            // native .net API
            text = "Encrypt/Decrypt String";

            status = dog.Encrypt(ref text);

            if (DogStatus.StatusOk == status)
            {
                status = dog.Decrypt(ref text);

                if (DogStatus.StatusOk == status)
                {
                    Console.WriteLine("Decrypted string: \"" + text + "\"");
                }
            }
        }
Пример #19
0
        /// <summary>
        /// Demonstrates how to login into a dog using the
        /// default feature. The default feature is ALWAYS
        /// available in every SuperDog.
        /// </summary>
        protected Dog LoginDefaultDemo()
        {
            DogFeature feature = DogFeature.Default;

            Dog dog = new Dog(feature);

            DogStatus status = dog.Login(VendorCode.Code, scope);

            // Please note that there is no need to call
            // a logout function explicitly - although it is
            // recommended. The garbage collector will perform
            // the logout when disposing the object.
            // If you need more control over the logout procedure
            // perform one of the more advanced tasks.
            return(dog.IsLoggedIn() ? dog : null);
        }
Пример #20
0
        /// <summary>
        /// Demonstrates how to perform a login and a logout
        /// using the default feature.
        /// </summary>
        protected void LoginLogoutDefaultDemo()
        {
            DogFeature feature = DogFeature.Default;
            Dog        dog     = new Dog(feature);
            DogStatus  status  = dog.Login(VendorCode.Code, scope);

            if (DogStatus.StatusOk == status)
            {
                status = dog.Logout();
            }

            // recommended, but not mandatory
            // this call ensures that all resources to SuperDog
            // are freed immediately.
            dog.Dispose();
        }
Пример #21
0
        /// <summary>
        /// Demonstrates how to perform a login using the default
        /// feature and how to perform an automatic logout
        /// using the SuperDog's Dispose method.
        /// </summary>
        protected void LoginDisposeDemo()
        {
            Verbose("Login/Dispose Demo with Default Feature (DogFeature.Default)");

            DogFeature feature = DogFeature.Default;

            Dog dog = new Dog(feature);

            DogStatus status = dog.Login(VendorCode.Code, scope);

            ReportStatus(status);

            Verbose("Disposing object - will perform an automatic logout");
            dog.Dispose();

            Verbose("");
        }
Пример #22
0
        /// <summary>
        /// Demonstrates how to login using a feature id.
        /// </summary>
        protected Dog LoginDemo(DogFeature feature)
        {
            Verbose("Login Demo with Feature: " +
                    feature.FeatureId.ToString());

            // create a dog object using a feature
            // and perform a login using the vendor code.
            Dog dog = new Dog(feature);

            DogStatus status = dog.Login(VendorCode.Code, scope);

            ReportStatus(status);

            Verbose("");

            return(dog.IsLoggedIn() ? dog : null);
        }
Пример #23
0
        /// <summary>
        /// Demonstrates how to retrieve information from a dog.
        /// </summary>
        protected void SessionInfoDemo(Dog dog)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }

            // firstly we will retrieve the dog info.
            string    info   = null;
            DogStatus status = dog.GetSessionInfo(Dog.SessionInfo, ref info);

            // next the session info.
            status = dog.GetSessionInfo(Dog.SessionInfo, ref info);

            // last the update information.
            status = dog.GetSessionInfo(Dog.UpdateInfo, ref info);
        }
Пример #24
0
        /// <summary>
        /// Performs a logout operation
        /// </summary>
        protected void LogoutDemo(ref Dog dog)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }

            Verbose("Logout Demo");

            DogStatus status = dog.Logout();

            ReportStatus(status);

            // get rid of the dog immediately.
            dog.Dispose();
            dog = null;
            Verbose("");
        }
Пример #25
0
        /// <summary>
        /// Demonstrates how to perform a login and an automatic
        /// logout using C#'s scope clause.
        /// </summary>
        protected void LoginDefaultAutoDemo()
        {
            Verbose("Login Demo with Default Feature (DogFeature.Default)");

            DogFeature feature = DogFeature.Default;

            // this will perform a logout and object disposal
            // when the using scope is left.
            using (Dog dog = new Dog(feature))
            {
                DogStatus status = dog.Login(VendorCode.Code, scope);
                ReportStatus(status);

                Verbose("Object going out of scope - System will call Dispose");
            }

            Verbose("");
        }
Пример #26
0
        /// <summary>
        /// Dumps an operation status into the
        /// referenced TextBox.
        /// </summary>
        protected void ReportStatus(DogStatus status)
        {
            FormDogDemo.WriteToTextbox(textHistory,
                                       string.Format("     Result: {0} (DogStatus::{1})\r\n",
                                                     stringCollection[(int)status],
                                                     status.ToString()));

            if (textHistory != null)
            {
                if (DogStatus.StatusOk == status)
                {
                    textHistory.Refresh();
                }
                else
                {
                    textHistory.Parent.Refresh();
                }
            }
        }
Пример #27
0
    IEnumerator ReturnToy()
    {
        animator.SetBool("walking", true);

        //朝玩家走,小于范围则放下球
        while (HorizontalDistance(transform.position, Camera.main.transform.position) > 0.5f)
        {
            Vector3 dir = Camera.main.transform.position - transform.position;
            dir.y = 0;
            transform.Translate(dir.normalized * speed * Time.deltaTime, Space.World);
            yield return(null);
        }

        animator.SetBool("walking", false);
        Discard();
        target = null;

        status = DogStatus.idle;
    }
Пример #28
0
    private void Start()
    {
        state       = DoggoState.ROAMING;
        audioSource = GetComponent <AudioSource>();

        status          = GetComponent <DogStatus>();
        agent           = GetComponent <NavMeshAgent>();
        pb              = GetComponent <PhysicsBehaviour>();
        foodDetector    = GetComponentInChildren <FoodDetector>();
        ballDetector    = GetComponentInChildren <BallDetector>();
        myTransform     = transform;
        playerTransform = FindObjectOfType <Player>().transform;
        animator        = GetComponent <Animator>();

        audioSource.Play();
        spawnDespawnParticleSystem.Play();
        AudioSource.PlayClipAtPoint(spawnClip, transform.position);

        StartCoroutine(BarkRandomly());
    }
Пример #29
0
        /// <summary>
        /// if the id is there then is continue to run the app.
        /// </summary>
        /// <param name="strID"></param>
        /// <returns></returns>
        public bool CheckFeatureID(string strID)
        {
            bool boFalgDog = false;

            if (scope == null)
            {
                scope = defaultScope;
            }
            string queryFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
                                 "<dogformat root=\"dog_info\">" +
                                 " <feature>" +
                                 "  <attribute name=\"id\" />" +
                                 "  <element name=\"license\" />" +
                                 " </feature>" +
                                 "</dogformat>";
            string    info   = null;
            DogStatus status = Dog.GetInfo(scope, queryFormat, VendorCode.Code, ref info);

            if (DogStatus.StatusOk == status)
            {
                Console.WriteLine(info);
                XmlDocument myXmlDoc = new XmlDocument();
                myXmlDoc.LoadXml(info);
                XmlNodeList xn = myXmlDoc.SelectNodes("/dog_info/feature");
                if (xn != null)
                {
                    foreach (XmlNode node in xn)
                    {
                        if (node.Attributes != null)
                        {
                            if (node.Attributes[0].Value.Equals("0"))
                            {
                                boFalgDog = true;
                                break;
                            }
                        }
                    }
                }
            }
            return(boFalgDog);
        }
Пример #30
0
        /// <summary>
        /// Demonstrates how to get current time and date of
        /// a SuperDog when available.
        /// </summary>
        protected void TestTimeDemo(Dog dog)
        {
            if ((null == dog) || !dog.IsLoggedIn())
            {
                return;
            }

            Verbose("Reading Time and Date Demo");

            DateTime  time   = DateTime.Now;
            DogStatus status = dog.GetTime(ref time);

            ReportStatus(status);

            if (DogStatus.StatusOk == status)
            {
                Verbose("Time and date is " + time.ToString());
            }

            Verbose("");
        }