コード例 #1
0
ファイル: Form1.cs プロジェクト: kmtompkins3/CritterForm
        //hunger decreaing over time
        private void HungerDecreaseThread()
        {
            try
            {
                while (true)
                {
                    Random rnd          = new Random();
                    int    RandomHunger = rnd.Next(1, 6);

                    if (Hunger < 150 && Hunger >= 5)
                    {
                        switch (RandomHunger)
                        {
                        case 1:
                            Hunger = Hunger - 0;
                            HungerBar.Invoke((MethodInvoker)(() => HungerBar.Value = Hunger));
                            break;

                        case 2:
                            Hunger = Hunger - 1;
                            HungerBar.Invoke((MethodInvoker)(() => HungerBar.Value = Hunger));
                            break;

                        case 3:
                            Hunger = Hunger - 2;
                            HungerBar.Invoke((MethodInvoker)(() => HungerBar.Value = Hunger));
                            break;

                        case 4:
                            Hunger = Hunger - 3;
                            HungerBar.Invoke((MethodInvoker)(() => HungerBar.Value = Hunger));
                            break;

                        case 5:
                            Hunger = Hunger - 4;
                            HungerBar.Invoke((MethodInvoker)(() => HungerBar.Value = Hunger));
                            break;

                        case 6:
                            Hunger = Hunger - 5;
                            HungerBar.Invoke((MethodInvoker)(() => HungerBar.Value = Hunger));
                            break;
                        }
                    }
                    if (Hunger < 25)
                    {
                        WarningBox.Text = "Your critter is starving";
                    }
                    Thread.Sleep(3000);
                }
            }
            catch (ThreadAbortException tbe)
            {
                HungerDecrease.Abort();//ends thread
            }
            catch (InvalidOperationException tbe)
            {
                HungerDecrease.Abort();
            }
        }
コード例 #2
0
ファイル: DadItem.cs プロジェクト: reviloj/Dream-State
    private static int canvasSortOrder = 100;                                       // Sort order for canvas

    public static void eat(DadCell cell, ClickItem item)
    {
        HungerBar hunger = GameObject.FindObjectOfType <HungerBar>();

        hunger.AddHunger(item.value);
        cell.RemoveItem();
    }
コード例 #3
0
    private void Start()
    {
        playerHunger = GetComponent <HungerBar>();
        phc          = GetComponent <PlayerHandComponent>();
        pmc          = GetComponent <PlayerMoveComponent>();

        ActivatePlayer();
    }
コード例 #4
0
 private void Start()
 {
     hunger = maxHunger;
     bar    = hungerBar.GetComponent <HungerBar>();
     bar.SetHunger(hunger, maxHunger);
     lastHungerDecreaseTime = Time.time;
     movementController     = player.GetComponent <PlayerMovement>();
 }
コード例 #5
0
 private void Start()
 {
     hb = FindObjectOfType <HungerBar>();
     if (!hb)
     {
         Debug.LogError("No hunger bar found in scene!!");
     }
 }
コード例 #6
0
ファイル: Player.cs プロジェクト: juanagustin0504/RepeaTroll
    private void Awake()
    {
        _hungerScript = FindObjectOfType <HungerBar>();
        attackScript  = GetComponent <PlayerAttack>();
        _animator     = GetComponent <Animator>();

        _animator.SetBool("Die", false);
        //_attackPoint = gameObject.GetComponent<Transform>();
        // _enemy = GameObject.FindObjectOfType<Enemy>().transform;
    }
コード例 #7
0
ファイル: HungerBar.cs プロジェクト: ciderxx/KumchukPJ
 void Awake()
 {
     if (instance)
     {
         Debug.Log("다중 인스턴스 감시 : 주의 바람");
     }
     else
     {
         instance = this;
     }
 }
コード例 #8
0
    //-------------------------------------------------------------------
    // Metodos
    //-------------------------------------------------------------------

    // Use this for initialization
    void Start()
    {
        gameManagerReference = GameManager.instance;
        playerRigidbody      = this.GetComponent <Rigidbody2D>();
        canMove              = true;
        playAttentionSound   = false;
        playerAnimator       = GetComponent <Animator>();
        playerSpriteRenderer = GetComponent <SpriteRenderer>();
        canRadio             = true;
        hungerBarReference   = gameManagerReference.hungerBarRefrence;
        coldBarReference     = gameManagerReference.coldBarReference;
        interfaz             = FindObjectOfType <UIManager>();
    }
コード例 #9
0
 // Use this for initialization
 void Start()
 {
     mainCamera        = FindObjectOfType <MainCamera>();
     screenMessage     = FindObjectOfType <OnScreenText>();
     hungerBar         = FindObjectOfType <HungerBar>();
     inspectionButtons = GameObject.FindGameObjectsWithTag("InspectionButton");
     HideInspectionOptions();
     mushroomCountText         = GameObject.FindGameObjectWithTag("MushroomCountText").GetComponent <Text>();
     levelInfo                 = FindObjectOfType <CurrentLevelInfo>();
     desiredMushroom           = levelInfo.desiredMushroom;
     levelInfo.mushroomCount   = 0;
     levelInfo.pickedMushrooms = new Dictionary <MushroomScript.MushroomName, int>();
 }
コード例 #10
0
    // Use this for initialization
    void Start()
    {
        reloj = duracionRealDia;
        StartCoroutine(pasoDelTiempo());
        // Inicializa la luz que funciona como el sol en el Juego buscandola por Tag
        GameObject solGameObject = GameObject.FindWithTag("Sol");

        sol = solGameObject.GetComponent <Light>();
        //Iniciliza la pantalla de Game Over buscandola por nombre
        gameOverScreen = GameObject.Find("GameOverScreen");
        gameOverScreen.SetActive(false);
        // Inicializa la referencial al player buscando por Tag
        player = GameObject.FindWithTag("Player");
        // Inicializa la referencia a la barra de temperatura buscando el objeto que tiene el script de esta barra
        coldBarReference = FindObjectOfType <ColdBar>();
        // Inicializa la referencia a la barra de hambre buscando el objeto que tiene el script de esta barra
        hungerBarRefrence = FindObjectOfType <HungerBar>();
    }
コード例 #11
0
        private async void FriendDepressed()
        {
            await DisplayAlert("Depressed", "Your friend has left you", "New Friend");

            friend.Xp = 0;
            friend.CurrentFriendState = FriendState.happy;
            HealthLabel.Text          = "100";
            ResetTimer();

            hunger = 0.5;
            energy = 0.5;
            mood   = 0.5;

            HungerBar.ProgressTo(hunger, 400, Easing.Linear);
            EnergyBar.ProgressTo(energy, 400, Easing.Linear);
            MoodBar.ProgressTo(mood, 400, Easing.Linear);

            updateUI();
        }
コード例 #12
0
        void sleepFriendTapped(System.Object sender, System.EventArgs e)
        {
            friend.giveSleep();

            hunger -= 0.013;
            HungerBar.ProgressTo(hunger, 400, Easing.Linear);
            energy += 0.019;
            EnergyBar.ProgressTo(energy, 400, Easing.Linear);
            mood += 0.016;
            MoodBar.ProgressTo(mood, 400, Easing.Linear);
            if (health < 100)
            {
                health += 10;
            }
            HealthLabel.Text = health.ToString();

            ResetTimer();
            updateUI();
        }
コード例 #13
0
        void partyFriendTapped(System.Object sender, System.EventArgs e)
        {
            friend.giveParty();

            hunger -= 0.013;
            HungerBar.ProgressTo(hunger, 400, Easing.Linear);
            energy -= 0.01;
            EnergyBar.ProgressTo(energy, 400, Easing.Linear);
            mood += 0.019;
            MoodBar.ProgressTo(mood, 400, Easing.Linear);
            if (health > 0)
            {
                health -= 2;
            }
            else if (health == 0)
            {
                DisplayAlert("Healt declined!", "Your friend is sick.", "Start over");
            }
            HealthLabel.Text = health.ToString();

            ResetTimer();
            updateUI();
        }
コード例 #14
0
        public GamePage BindData()
        {
            App.SlowWriter.Target = StoryBlock;
            /* LOCATION NAME */
            Binding BindingName = new Binding("CurrentLocationName")
            {
                Source = App.LocationViewModel
            };

            StoryHeader.SetBinding(ContentControl.ContentProperty, BindingName);

            /* LOCATION IMAGE */
            Binding BindingImage = new Binding("CurrentLocationImage")
            {
                Source = App.LocationViewModel
            };

            StoryImage.SetBinding(Image.SourceProperty, BindingImage);

            /* LOCATION FILTER */
            Binding BindingSliderFilter = new Binding("BackgroundOptionsIntTransparent")
            {
                Source = App.PlayerViewModel.Player
            };

            FilterSlider.SetBinding(Slider.ValueProperty, BindingSliderFilter);
            Binding BindingSliderColor = new Binding("BackgroundOptionsIntBlue")
            {
                Source = App.PlayerViewModel.Player
            };

            ColorSlider.SetBinding(Slider.ValueProperty, BindingSliderColor);

            /* PLAYER'S HEALTH BAR */
            Binding BindingHealth = new Binding("HealthBarValue")
            {
                Source = App.PlayerViewModel
            };                                                                                      // value bind
            Binding BindingBarsWidth = new Binding("HealthThirstHungerBarWidth")
            {
                Source = App.PlayerViewModel
            };                                                                                                     // bar width bind
            Binding BindingHealthText = new Binding("HealthBarString")
            {
                Source = App.PlayerViewModel
            };                                                                             // text value bind

            HealthBar.SetBinding(ProgressBar.ValueProperty, BindingHealth);                // value bind
            HealthBar.SetBinding(ProgressBar.WidthProperty, BindingBarsWidth);             // bar width bind - same for health, thirst and hunger
            HealthBarString.SetBinding(ContentControl.ContentProperty, BindingHealthText); // text value bind

            /* PLAYER'S ENERGY BAR */
            Binding BindingEnergy = new Binding("EnergyBarValue")
            {
                Source = App.PlayerViewModel
            };                                                                                      // value bind
            Binding BindingEneryWidth = new Binding("EnergyBarWidth")
            {
                Source = App.PlayerViewModel
            };                                                                                           // bar width bind
            Binding BindingEnergyText = new Binding("EnergyBarString")
            {
                Source = App.PlayerViewModel
            };                                                                             // text value bind

            EnergyBar.SetBinding(ProgressBar.ValueProperty, BindingEnergy);                // value bind
            EnergyBar.SetBinding(ProgressBar.WidthProperty, BindingEneryWidth);            // bar width bind
            EnergyBarString.SetBinding(ContentControl.ContentProperty, BindingEnergyText); // text value bind

            /* PLAYER'S HUNGER BAR */
            Binding BindingHunger = new Binding("HungerBarValue")
            {
                Source = App.PlayerViewModel
            };                                                                                      // value bind
            Binding BindingHungerText = new Binding("HungerBarString")
            {
                Source = App.PlayerViewModel
            };                                                                             // text value bind

            HungerBar.SetBinding(ProgressBar.ValueProperty, BindingHunger);                // value bind
            HungerBar.SetBinding(ProgressBar.WidthProperty, BindingBarsWidth);             // bar width bind - same for health, thirst and hunger
            HungerBarString.SetBinding(ContentControl.ContentProperty, BindingHungerText); // text value bind

            /* PLAYER'S THIRST BAR */
            Binding BindingThirst = new Binding("ThirstBarValue")
            {
                Source = App.PlayerViewModel
            };                                                                                      // value bind
            Binding BindingThirstText = new Binding("ThirstBarString")
            {
                Source = App.PlayerViewModel
            };                                                                             // text value bind

            ThirstBar.SetBinding(ProgressBar.ValueProperty, BindingThirst);                // value bind
            ThirstBar.SetBinding(ProgressBar.WidthProperty, BindingBarsWidth);             // bar width bind - same for health, thirst and hunger
            ThirstBarString.SetBinding(ContentControl.ContentProperty, BindingThirstText); // text value bind

            /* CHECK ALIVE */
            timer.Interval = new TimeSpan(0, 0, 0, 0, 333);
            timer.Tick    += (sender, args) => { CheckAlive(); };
            timer.Start();
            return(this);
        }
コード例 #15
0
 void Start()
 {
     _audioSource.clip = _audioClip;
     _hungerScript     = GameObject.FindObjectOfType <HungerBar>();
     _scoreScript      = GameObject.FindObjectOfType <GameScore>();
 }