コード例 #1
0
ファイル: Capacitor.cs プロジェクト: Jiedara/ludus-bug
 // Update is called once per frame
 void Update()
 {
     if (player)
     {
         player.AddEnergy(regenerationSpeed * Time.deltaTime);
     }
 }
コード例 #2
0
    private void EnergyBehaviour()
    {
        if (_playerEnergy != null && canBeConsumed)
        {
            float   distance  = Vector3.Distance(_playerEnergy.transform.position, transform.position);
            Vector2 direction = _playerEnergy.transform.position - transform.position;

            if (distance <= _distanceReference)
            {
                _rb.velocity       = direction.normalized * _currentMoveSpeed * Time.deltaTime;
                _currentMoveSpeed += _moveSpeedIncrease;
            }
            else
            {
                _rb.velocity      = new Vector2(0, 0);
                _currentMoveSpeed = _startingMoveSpeed;
            }

            if (distance <= _distanceToMove)
            {
                _playerEnergy.AddEnergy(_energyToAdd);
                _uiManager.UpdateEnergySlider();
                _playerEnergyPoints.AddRemovePoints(_energyPointsValue);
                Destroy(gameObject);
            }
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        device = GetComponent <DeviceReceiver>().GetDevice();

        if (otherPlayer == null)
        {
            return;
        }
        float dist = Vector2.Distance(otherPlayer.position, transform.position);

        if (dist < chargeDistance && !selfHealth.IsDead() && !otherHealth.IsDead())
        {
            PlayerEnergy energyScript = GetComponent <PlayerEnergy> ();
            if (energyScript != null)
            {
                energyScript.AddEnergy(chargeSpeed * Time.deltaTime);
            }
        }
//
//		Debug.Log ("self dead: " + selfHealth.IsDead ().ToString ());
//		Debug.Log ("other dead: " + otherHealth.IsDead ().ToString ());
//		Debug.Log (dist);

        if (!selfHealth.IsDead() && otherHealth.IsDead() && dist < reviveDistance)
        {
            if (hintUI)
            {
                if (hintUI.hint == PlayerHintUI.HintStatus.None ||
                    hintUI.hint == PlayerHintUI.HintStatus.PressB2)
                {
                    hintUI.hint = PlayerHintUI.HintStatus.PressY;
                }
            }
            if ((device != null) && device.Action4.WasPressed)
            {
                otherHealth.Revive();
            }
        }
        else
        {
            if (hintUI)
            {
                if (hintUI.hint == PlayerHintUI.HintStatus.PressY)
                {
                    hintUI.hint = PlayerHintUI.HintStatus.None;
                }
            }
        }
    }
コード例 #4
0
 // what's the deal with passing health and food in through the parameters???
 public void UseItem(string title, int health, int food)
 {
     for (int i = 0; i < inventorySize; i++)      //loop through inventory
     {
         if (items[i] == title)                   //find the matching stack  BUG:
         {
             amountsList[i]--;
             textList[i].text = amountsList[i].ToString();
             playerHealth.AddHealth(health);
             playerEnergy.AddEnergy(food);
             if (amountsList[i] == 0)             //if that slot is now empty, clear it up
             {
                 textList[i].text = "";
                 items[i]         = "";
                 slots[i].GetComponent <Image>().sprite = blankSlot;
             }
         }
     }
 }
コード例 #5
0
ファイル: CoffeeShop.cs プロジェクト: ja003/GDS-Jam-2020
    private void TryHeal()
    {
        var playerHit = Physics2D.CircleCast(healArea.bounds.center, healArea.radius, Vector2.zero, 0, game.Layers.Player);

        if (playerHit)
        {
            Player       player       = playerHit.transform.GetComponent <Player>();
            PlayerEnergy playerEnergy = player.Energy;
            playerEnergy.AddEnergy(healAmount);
            Debug.Log("Heal player " + healAmount);
            player.ThinkBubble.SetReaction(EReaction.Coffee, 0.5f);
            Game.Instance.SoundManager.PlaySound(SoundManager.ESound.eCoffee);
        }
        else
        {
            Game.Instance.SoundManager.StopSound(SoundManager.ESound.eCoffee);
        }

        DoInTime(TryHeal, healFrequency);
    }