예제 #1
0
 // Update is called once per frame
 void Update()
 {
     if (Utils.checkOverlap(coll, petColl))
     {
         petStatus.increaseConditionValue(conditionName, conditionRestoreAmount);
         petStatus.increaseNeediness(needinessIncreaseAmount);
         SoundEffectHandler.player.playRandomNeutralSound();
         //Debug.Log("wosh");
         GameObject.Destroy(gameObject);
     }
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (currentlyHeld && Utils.checkOverlap(coll, petColl))
        {
            float conditionIncrease = conditionRestorePerSecond * Time.deltaTime;
            float needinessIncrease = needinessIncreasePerSecond * Time.deltaTime;

            petStatus.increaseConditionValue(conditionName, conditionIncrease);
            petStatus.increaseNeediness(needinessIncrease);

            if (currentParticle == null)
            {
                currentParticle = Instantiate(BrushParticle,
                                              transform.position + new Vector3(0.5f, 0.5f, -1f),
                                              Quaternion.Euler(0f, 0f, 0f));
                SoundEffectHandler.player.playRandomNeutralSound();
            }
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (!playerHolding)
        {
            if (petHolding)
            {
                // Increase value here
                float additionalValue     = conditionRestorePerSecond * Time.deltaTime;
                float additionalNeediness =
                    needinessIncreasePerSecond * Time.deltaTime;
                petStatus.increaseConditionValue(conditionName, additionalValue);
                petStatus.increaseNeediness(additionalNeediness);

                if (currentParticle == null)
                {
                    Vector2 gamingDisp = Random.insideUnitCircle;
                    currentParticle = Instantiate(GamingParticle,
                                                  transform.position + new Vector3(
                                                      gamingDisp.x, gamingDisp.y, -1f),
                                                  Quaternion.Euler(0f, 0f, 0f));
                    SoundEffectHandler.player.playRandomNeutralSound();
                }

                gamingTimer -= Time.deltaTime;
                if (gamingTimer <= 0)
                {
                    petHolding     = false;
                    faller.enabled = true;
                    faller.setVelocity(Vector3.up * VERTICAL_THROW_SPEED);
                    hspeed = Random.Range(
                        -HORIZONTAL_THROW_EXTENTS, HORIZONTAL_THROW_EXTENTS);
                }
            }
            else if (petCanCatch)
            {
                if (Utils.checkOverlap(coll, petColl))
                {
                    Vector3 petPosition = petColl.transform.position;
                    transform.position = new Vector3(
                        petPosition.x, petPosition.y, transform.position.z);
                    petCanCatch    = false;
                    petHolding     = true;
                    faller.enabled = false;
                    gamingTimer    = Random.Range(
                        MINIMUM_GAMING_TIME, MAXIMUM_GAMING_TIME);
                }
            }
            else
            {
                if (hspeed != 0)
                {
                    transform.position += Vector3.right * hspeed * Time.deltaTime;

                    if ((hspeed < 0 && transform.position.x < -ROOM_EXTENTS) ||
                        (hspeed > 0 && transform.position.x > ROOM_EXTENTS))
                    {
                        transform.position = new Vector3(
                            ROOM_EXTENTS * Mathf.Sign(hspeed), transform.position.y,
                            transform.position.z);
                        hspeed *= -1;
                    }

                    if (transform.position.y <= faller.getThreshold() + 0.5f)
                    {
                        float drag = GROUNDED_DRAG * Time.deltaTime;
                        if (Mathf.Abs(hspeed) < drag)
                        {
                            hspeed = 0;
                        }
                        else
                        {
                            hspeed -= (drag * Mathf.Sign(hspeed));
                        }
                    }
                }
            }
        }
    }