public Animal CreateAnimal(BindableBase mainContext, ICategory baseContext)
        {
            MainViewModel context = (MainViewModel)mainContext;

            Animal animal = null;

            switch (context.SelectedSpecies)
            {
            case Species.Raccoon:
                animal = new Raccoon(
                    context.Name,
                    int.Parse(context.Age),
                    context.Gender,
                    ((MammalViewModel)(baseContext)).IsDomesticated,
                    ((RaccoonViewModel)(baseContext.SelectedSpeciesControl)).Type);
                break;

            case Species.Donkey:
                animal = new Donkey(
                    context.Name,
                    int.Parse(context.Age),
                    context.Gender,
                    ((MammalViewModel)(baseContext)).IsDomesticated,
                    int.Parse(((DonkeyViewModel)(baseContext.SelectedSpeciesControl)).Stubbornness));
                break;
            }

            return(animal);
        }
Esempio n. 2
0
        public MoveWithKeyboardForm()
        {
            InitializeComponent();
            xRaccoon1 = 200;
            yRaccoon1 = 100;
            xRaccoon2 = 600;
            yRaccoon2 = 100;

            xActive       = xRaccoon1 - 2;
            yActive       = yRaccoon1 - 2;
            currentActive = Raccoon.First;

            pen = new Pen(Color.Black, 2f);
        }
Esempio n. 3
0
        private void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if (e.KeyChar.Equals(Convert.ToChar(9)))
            {
                if (currentActive == Raccoon.First)
                {
                    xActive       = xRaccoon2 - 2;
                    yActive       = yRaccoon2 - 2;
                    currentActive = Raccoon.Second;
                }
                else if (currentActive == Raccoon.Second)
                {
                    xActive       = xRaccoon1 - 2;
                    yActive       = yRaccoon1 - 2;
                    currentActive = Raccoon.First;
                }
            }

            // Up
            if (e.KeyChar.Equals(Convert.ToChar(119))) //W
            {
                if (currentActive == Raccoon.First)
                {
                    yRaccoon1 -= 10;
                }
                else if (currentActive == Raccoon.Second)
                {
                    yRaccoon2 -= 10;
                }
                yActive -= 10;
            }

            // Down
            if (e.KeyChar.Equals(Convert.ToChar(115))) // S
            {
                if (currentActive == Raccoon.First)
                {
                    yRaccoon1 += 10;
                }
                else if (currentActive == Raccoon.Second)
                {
                    yRaccoon2 += 10;
                }
                yActive += 10;
            }

            // Left
            if (e.KeyChar.Equals(Convert.ToChar(97))) // A
            {
                if (currentActive == Raccoon.First)
                {
                    xRaccoon1 -= 10;
                }
                else if (currentActive == Raccoon.Second)
                {
                    xRaccoon2 -= 10;
                }
                xActive -= 10;
            }

            // Right
            if (e.KeyChar.Equals(Convert.ToChar(100))) // D
            {
                if (currentActive == Raccoon.First)
                {
                    xRaccoon1 += 10;
                }
                else if (currentActive == Raccoon.Second)
                {
                    xRaccoon2 += 10;
                }
                xActive += 10;
            }

            Invalidate();
        }
Esempio n. 4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        CarController          car = other.GetComponent <CarController>();
        HealthPackController   hp  = other.GetComponent <HealthPackController>();
        ValueDoublerController vd  = other.GetComponent <ValueDoublerController>();
        SpeedBoostController   sd  = other.GetComponent <SpeedBoostController>();
        Raccoon rac = other.GetComponent <Raccoon>();


        if (car != null)
        {
            //blinking = true;
            car.Collision();
            if (health > 0)
            {
                health -= car.getDamage();
                money  += car.getValue() * moneyModifier;
                gameObject.GetComponent <ParticleSystem>().Play();

                if (car.getDamage() < 0)
                {
                    gameObject.GetComponents <AudioSource>()[1].Play();
                }
                else
                {
                    gameObject.GetComponents <AudioSource>()[0].Play();
                }

                if (health < 0)
                {
                    health = 0;
                }

                if (health > 100)
                {
                    health = 100;
                }
                HealthBar.value = health;
                if (car.speed < 0)
                {
                    hitLeft = true;
                }
                else
                {
                    hitRight = true;
                }
            }
        }
        else if (rac != null)
        {
            if (this.transform.position.x < rac.transform.position.x)
            {
                hitLeft = true;
            }
            else
            {
                hitRight = true;
            }
        }
        else if (vd != null)
        {
            moneyModifier = 2;
            moneyTimer    = 5f;
        }
        else if (sd != null)
        {
            gameObject.GetComponent <KeyInput>().SetMoveSpeed(20f);
            speedTimer = 5f;
        }
        else if (hp != null && health < 100)
        {
            health         += 10;
            HealthBar.value = health;
        }
    }