Ejemplo n.º 1
0
    public override void Interact()
    {
        Debug.Log("Interacting with Pick up item");

        if (item.isLight)
        {
            lightSource.IncreaseLight(item.lightIntensity);
            LightSphereSpawner.canSpawn = true;
            Instantiate(lightSphereBurst, transform.position + offset, transform.rotation);
            GameRecord.SetLightSphere();
            AudioManager.Play("GlassBreak");
            Destroy(gameObject);
        }
        else //is an item that can be put into inventory*/
        {
            if (inventory.AddItem(item))
            {
                action.NewLog("You picked up (1) " + item.itemName);
                AudioManager.Play("Click");
                Destroy(gameObject);
            }
            else
            {
                action.NewLog("Your inventory is full");
            }
        }
    }
Ejemplo n.º 2
0
    public override void Interact()
    {
        if (inventory.CheckItemExists(requiredItem) != -1)
        {
            rockHP--;
            AudioManager.Play("DigRock");
            action.NewLog("You hit the rock with an axe");
            Instantiate(dirtSplatter, transform.position, Quaternion.Euler(Vector3.forward * 90));
        }
        else
        {
            action.NewLog("You need a tool");
        }

        if (rockHP <= 0)
        {
            AudioManager.Play("RockExplode");
            action.NewLog("The rock is broken into pieces...");
            action.NewLog("Your axe is broken");
            inventory.DestroyItem(requiredItem);
            RockSpawner.canSpawn = true;
            Instantiate(stone, transform.position + offset, Quaternion.Euler(Vector3.right * 35));
            Destroy(gameObject);
        }
    }
Ejemplo n.º 3
0
    void Update()
    {
        if (GameRecord.gameStarted)
        {
            if (!isSpeedUp)
            {
                playerStat.moveSpeed = 8.0f;
            }
            else
            {
                speedUpTimeCnt -= Time.deltaTime;
                if (speedUpTimeCnt <= 0)
                {
                    isSpeedUp = false;
                    action.NewLog("Your speed returns back to normal");
                }
            }

            //player's HP will decrease when being attacked by enemy or when the light is too dim
            if (isCaught)
            {
                playerStat.currentHP -= Time.deltaTime;
            }

            if (lightSource.isDim)
            {
                playerStat.currentHP -= Time.deltaTime * 0.5f;
            }

            if (playerStat.currentHP <= 0)
            {
                playerStat.currentHP = 0;
                GameRecord.SetPlayerDied();

                GetComponent <WorldInteraction>().enabled = false;

                Destroy(GetComponent <NavMeshAgent>());
            }

            if (playerStat.currentHP < 19f)
            {
                if (!GameRecord.GetIsHit())
                {
                    GameRecord.SetIsHit();
                    //action.NewLog("Is hit is false");
                }
            }
        }
    }
Ejemplo n.º 4
0
    void UseItem()
    {
        AudioManager.Play("Click");

        if (canUseItem)
        {
            inventory.UseItem(itemSlotNum);
            canUseItem = false;
        }
        else
        {
            action.NewLog("Inventory cooling Down");
        }
    }
Ejemplo n.º 5
0
    void Update()
    {
        //light intensity decrease with time
        if (lightIntensity >= 1.5f)
        {
            lightSource.intensity -= Time.deltaTime * weakenRate;
            lightIntensity         = lightSource.intensity;

            if (lightIntensity >= 4.5f)
            {
                if (isDim)
                {
                    isDim           = false;
                    hasWarnedPlayer = false;
                }
            }
        }

        if (lightIntensity > 10f)
        {
            lightSource.intensity = 10f;
            lightIntensity        = lightSource.intensity;
        }

        if (lightIntensity < 4.5f)
        {
            isDim = true;

            if (!hasWarnedPlayer)
            {
                action.NewLog("The light is getting dim...");
                hasWarnedPlayer = true;
            }
        }

        slider.value = lightIntensity;
    }
Ejemplo n.º 6
0
    public bool UseItem(Item item)
    {
        if (item.isFreeze)
        {
            Debug.Log("Use freeze item");

            if (enemy.GetFrozen(item.freezeTime))
            {
                GameRecord.usedIceStone = true;
                return(true);
            }

            return(false);
        }
        else if (item.isHP)
        {
            Debug.Log("Recover HP");
            player.RecoverHP(item.recoverHP);
            GameRecord.usedApple = true;
            AudioManager.Play("EatApple");
            return(true);
        }
        else if (item.isSpeedUp)
        {
            Debug.Log("Speed up");
            player.SpeedUp(item.newSpeedTime, item.newSpeed);
            GameRecord.usedSpeedUp = true;
            AudioManager.Play("SpeedUp");
            return(true);
        }
        else if (item.isWeapon)
        {
            if (enemy.ReceiveDamage(item.damage))
            {
                return(true);
            }

            return(false);
        }
        else
        {
            action.NewLog("Nothing happens");
            return(false);
        }
    }
Ejemplo n.º 7
0
    private void Update()
    {
        VisibleOrNot();

        if (isFrozen)
        {
            frozenTimeCnt -= Time.deltaTime;

            if (frozenTimeCnt <= 0)
            {
                isFrozen = false;
                anim.SetBool("isFrozen", false);
                action.NewLog("The enemy is no longer frozen");
            }
        }

        if (lightSource.isDim && !isChasing && !isFrozen)
        {
            isVisible = false;
        }
        else
        {
            isVisible = true;
        }

        if (isChasing && !isFrozen)
        {
            if (!playChasingClip)
            {
                audioSource.loop = true;
                audioSource.Play();
                playChasingClip = true;
            }
        }
        else
        {
            audioSource.Stop();

            if (playChasingClip)
            {
                playChasingClip = false;
            }
        }

        PlayAnimation();
    }