Ejemplo n.º 1
1
        public Dog(mouseHelp mouse, AppDJ appDJ)
        {
            this.appDJ = appDJ;
            this.mouse = mouse;
            screenHeight = 480;
            screenWidth = 800;

            fetch = new Fetch(this, this.mouse, this.appDJ);
            water = new Water(this, this.mouse, this.appDJ);
            food = new Food(this, this.mouse, this.appDJ);
            tug = new Tug(this, this.mouse, this.appDJ);

            statThirst = 1.0f;
            statHygiene = 1.0f;
            statHunger = 1.0f;
            statEntertainment = 1.0f;
            statHappiness = 1.0f;
            myActivity = activity.dogIdle;
            myAnimate = animate.dogSitting;
            aniX = 0;
            aniY = 0;
            myFPS = 0;
            FPS = 12;
            returnHome = false;
            tugBool = false;

            dogX = (int)((float)screenWidth * .51);
            dogY = (int)((float)screenHeight * .54);
            dogZ = 0.5f;
            dogScale = 1.0f;
            dogRec = new Rectangle(0, 0, 200, 200);
            dogRot = 0.0f;
            origin = new Vector2(dogX, dogY);
            dogPos = new Vector2(dogX, dogY);
            returnSpeedX = 2;
            returnSpeedY = 1;
            returnSpeedS = .005f;
        }
Ejemplo n.º 2
0
    public void Start()
    {
//        if(sending)
        client   = new UdpClient("192.168.1.253", 7001);
        ball     = this.GetComponent <model>();
        animator = this.GetComponent <animate>();
    }
Ejemplo n.º 3
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (tugBool == true)
            {
                returnSpeedS = .1f;
            }
            else
            {
                returnSpeedS = .005f;
            }
            // This will have the dog return to the start position if called.
            if (returnHome == true)
            {
                appDJ.drinkOn = false;
                appDJ.foodOn = false;

                if (dogPos.X != origin.X || dogPos.Y != origin.Y || dogScale != 1.0)
                {
                    appDJ.runningOn = true;
                    if (dogPos.X <= origin.X + returnSpeedX && dogPos.X >= origin.X - returnSpeedX)
                    {
                        dogPos.X = origin.X;
                        myAnimate = Dog.animate.dogSitting;
                    }
                    else if (dogPos.X >= origin.X)
                    {
                        dogPos.X -= returnSpeedX;
                        myAnimate = Dog.animate.dogRunLeft;
                    }
                    else if (dogPos.X <= origin.X)
                    {
                        dogPos.X += returnSpeedX;
                        myAnimate = Dog.animate.dogRunRight;
                    }

                    if (dogPos.Y <= origin.Y + returnSpeedY && dogPos.Y >= origin.Y - returnSpeedY)
                    {
                        dogPos.Y = origin.Y;

                    }
                    else if (dogPos.Y >= origin.Y)
                    {
                        dogPos.Y -= returnSpeedY;
                        myAnimate = Dog.animate.dogRunAway;

                    }
                    else if (dogPos.Y <= origin.Y)
                    {
                        dogPos.Y += returnSpeedY;
                        myAnimate = Dog.animate.dogRunTowards;

                    }

                    if (dogScale <= 1.0f + returnSpeedS && dogScale >= 1.0f - returnSpeedS)
                    {
                        dogScale = 1.0f;

                    }
                    else if (dogScale >= 1.0f)
                    {
                        dogScale -= returnSpeedS;

                    }
                    else if (dogScale <= 1.0f)
                    {
                        dogScale += returnSpeedS;

                    }

                }
                else
                {
                    appDJ.runningOn = false;
                    returnHome = false;
                    tugBool = false;
                }
            }
            else
            {
                // This will draw the proper objects depending on what activity is running
                switch (myActivity)
                {
                    case Dog.activity.dogFetch:
                        fetch.Draw(spriteBatch);
                        break;

                    case Dog.activity.dogTug:
                        tug.Draw(spriteBatch);
                        break;

                    case Dog.activity.dogFood:
                        food.Draw(spriteBatch);
                        break;

                    case Dog.activity.dogWater:
                        water.Draw(spriteBatch);
                        break;

                    case Dog.activity.dogIdle:
                        myAnimate = Dog.animate.dogSitting;
                        break;

                }
            }

            // This draws the dog depending on what animation should be shown on the sprite sheet currently
            switch (myAnimate)
            {
                case Dog.animate.dogSitting:
                    aniY = 0;
                    spriteBatch.Draw(dogContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogRunAway:
                    aniY = 200;
                    spriteBatch.Draw(dogContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogRunTowards:
                    aniY = 400;
                    spriteBatch.Draw(dogContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogRunRight:
                    aniY = 600;
                    spriteBatch.Draw(dogContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogRunLeft:
                    aniY = 600;
                    spriteBatch.Draw(dogContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.FlipHorizontally, dogZ);
                    break;

                case Dog.animate.dogEatRight:
                    aniY = 800;
                    spriteBatch.Draw(dogContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogEatLeft:
                    aniY = 1000;
                    spriteBatch.Draw(dogContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogTug:
                    aniY = 0;
                    spriteBatch.Draw(tugContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogTugRightUp:
                    aniY = 200;
                    spriteBatch.Draw(tugContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogTugLeftUp:
                    aniY = 400;
                    spriteBatch.Draw(tugContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogTugRightDown:
                    aniY = 600;
                    spriteBatch.Draw(tugContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;

                case Dog.animate.dogTugLeftDown:
                    aniY = 800;
                    spriteBatch.Draw(tugContainer, dogPos, dogRec, Color.White, dogRot, new Vector2(100, 100), dogScale, SpriteEffects.None, dogZ);
                    break;
            }
        }