Example #1
0
    public void HandleBlenderFilling()
    {
        Debug.Log(GameValues.BlenderFilledPoints);
        BlenderProcent = 100f / 60f * (float)GameValues.BlenderFilledPoints;// / 60 * 100f ;

        fillingBarPointsText.text = GameValues.BlenderFilledPoints + "  / 60";

        BlenderCatch blenderCatch = GameObject.FindObjectOfType <BlenderCatch>();

        if (blenderCatch.smoothPoints > 20 && blenderCatch.smoothPoints < 40)
        {
            totalBlendPointsText.text = "SP: " + GameValues.BlenderFilledPoints * 2;
        }
        else if (blenderCatch.smoothPoints > 40)
        {
            totalBlendPointsText.text = "SP: " + GameValues.BlenderFilledPoints * 4;
        }
        else
        {
            totalBlendPointsText.text = "SP: " + GameValues.BlenderFilledPoints;
        }


        float calcTemp = (325 / 100) * BlenderProcent;

        fillingBarCurrentY = fillingBarEmptyY + calcTemp;

        fillingBarRect.localPosition = new Vector3(0, fillingBarCurrentY, 0);
    }
Example #2
0
    public void DoDamage(float pain)
    {
        GameValues.BlenderFilledPoints = 0;
        fillingBarPointsText.text      = (float)GameValues.BlenderFilledPoints + "  / 60";
        totalBlendPointsText.text      = "SP:0";


        BlenderCatch blenderCatch = GameObject.FindObjectOfType <BlenderCatch>();

        blenderCatch.smoothPoints = 0;
        blenderCatch.Blend();

        if (currentHealth > 0)
        {
            CurrentHealth -= pain;
        }
        else
        {
            GameOver gameOver = GameObject.FindObjectOfType <GameOver>();
            gameOver.DieGame();
        }

        if (currentHealth < 33 && currentHealth > 0)
        {
            if (!blenderSmoke33.gameObject.active)
            {
                blenderSmoke33.gameObject.SetActive(true);
            }
        }
        else if (currentHealth < 66 && currentHealth > 33)
        {
            if (!blenderSmoke66.gameObject.active)
            {
                blenderSmoke66.gameObject.SetActive(true);
            }
        }
    }
Example #3
0
    private void AutoMove()
    {
        if ((GameValues.AutoMoveX || GameValues.AutoMoveY) && !isHoldingObject)
        {
            //bool isAboveBlender = false;
            Monster monster = null;

            // GameObject monsterGo = null;
            //if(targetMonster == null)
            targetMonster = EUtils.GetNearestObject(waveSpawner.SpawnedMonsters, transform.position);

            RaycastHit[] hit;
            if (targetMonster != null)
            {
                //BlenderCatch blender = GameObject.FindObjectOfType<BlenderCatch>();
                Defendable defendAble = GameObject.FindObjectOfType <Defendable>();
                //Vector3 castPosition = new Vector3(transform.position.x, transform.position.y + (EUtils.GetObjectCollUnitSize(gameObject).y), transform.position.z);
                hit = Physics.RaycastAll(targetMonster.transform.position, -Vector3.up /* * 0.5f*/, float.MaxValue);
                //Debug.DrawRay(castPosition, transform.forward * attackDistance, Color.red);
                // Debug.Log(hit.Length);
                for (int i = 0; i < hit.Length; i++)
                {
                    Defendable blenderCatch = hit[i].collider.GetComponent <Defendable>();
                    if (blenderCatch != null)
                    {
                        targetMonster = null;
                        return;
                    }
                }
                monster = targetMonster.GetComponent <Monster>();
            }

            if (GameValues.AutoMoveX)
            {
                if (monster != null)
                {
                    Ray        monsterRay = new Ray(monster.transform.position, -Vector3.up);
                    RaycastHit monsterHit;

                    if (!monster.isInBlender && !monster.isStunned)
                    {
                        Vector3 targetPosition = new Vector3(monster.transform.position.x, transform.position.y, transform.position.z);
                        transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                    }
                }
            }
            if (GameValues.AutoMoveY)
            {
                if (monster != null)
                {
                    //Vector3.Distance(transform.position, monster.transform.position) < 1)
                    //if (!monster.isInBlender && transform.position.x == monster.transform.position.x)

                    if (!monster.isInBlender && !monster.isStunned && Mathf.Abs(transform.position.x - monster.transform.position.x) < 1)
                    {
                        Vector3 targetPosition = new Vector3(transform.position.x, monster.transform.position.y, transform.position.z);
                        transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                    }
                }
            }
            if (GameValues.AutoGrab)
            {
                if (monster != null)
                {
                    if (!monster.isInBlender && !monster.isStunned && Vector3.Distance(transform.position, monster.transform.position) < 1)
                    {
                        VisualSqueeze(monster.minPressure + 4);
                    }
                }
            }
        }
        else if ((GameValues.AutoMoveX || GameValues.AutoMoveY) && isHoldingObject)
        {
            BlenderCatch blender = GameObject.FindObjectOfType <BlenderCatch>();//EUtils.GetNearestObject(waveSpawner.SpawnedMonsters, transform.position);
            if (GameValues.AutoMoveX)
            {
                //if (blender != null && /*transform.position.y == blender.transform.position.y + 7.50f*/)
                if (blender != null && Mathf.Abs(transform.position.y - blender.transform.position.y) > 5.50f)
                {
                    Vector3 targetPosition = new Vector3(blender.transform.position.x, transform.position.y, transform.position.z);
                    transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                }
            }
            if (GameValues.AutoMoveY)
            {
                if (blender != null)
                {
                    Vector3 targetPosition = new Vector3(transform.position.x, blender.transform.position.y + 5.75f, transform.position.z);
                    transform.position = Vector3.MoveTowards(transform.position, targetPosition, 10 * Time.deltaTime);
                }
            }
            if (GameValues.AutoGrab)
            {
                if (blender != null)
                {
                    //if (transform.position.y == blender.transform.position.y + 7.50f && Mathf.Abs(transform.position.x - blender.transform.position.x) < 1)
                    if (Mathf.Abs(transform.position.y - blender.transform.position.y) > 5.50f && Mathf.Abs(transform.position.x - blender.transform.position.x) < 0.5f)
                    {
                        VisualSqueeze(1);
                    }
                }
            }
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (GameValues.ISPAUSED)
        {
            return;//Do nothing while paused
        }
        //Controls Auto
        AutoMove();
        //pressure
        float openPressure  = Input.GetAxis("RTrigger");
        float closePressure = Input.GetAxis("LTrigger");

        if (Input.GetKey(KeyCode.Q))
        {
            openPressure = 1;
        }
        if (Input.GetKey(KeyCode.E))
        {
            closePressure = 1;
        }


        if (!isHoldingObject && holdingBonusObject == null)
        {
            Vector3 position = new Vector3(transform.position.x, transform.position.y + 2, transform.position.z + 2);
            // RaycastHit[] hit = Physics.RaycastAll(position, transform.forward /* * 0.5f*/, float.MaxValue);
            Ray        ray = new Ray(position, transform.forward);
            RaycastHit hit;
            //Debug.DrawRay(position, (transform.forward * 50), Color.red);

            // Debug.Log((squeezePressure * 100 > 20 && squeezePressure * 100 < 50) + ":" + GameValues.SMOOTHYPOINTS);
            if (/*squeezePressure * 100 > 20 &&*/ closePressure > 0 /* && squeezePressure * 100 < 50*/)
            {
                if (Physics.Raycast(ray, out hit, 20))
                {
                    // Debug.Log(hit.collider);
                    if (hit.collider.gameObject == forkBonusBtn)
                    {
                        BlenderCatch blender = GameObject.FindObjectOfType <BlenderCatch>();
                        if (GameValues.SMOOTHYPOINTS >= 10)
                        {
                            holdingBonusObject = GameObject.Instantiate(forkBonus.gameObject) as GameObject;
                            holdingBonusObject.collider.enabled   = false;
                            holdingBonusObject.transform.parent   = this.transform;
                            holdingBonusObject.transform.position = transform.position;
                            isHoldingObject           = true;
                            GameValues.SMOOTHYPOINTS -= 10;
                            blender.smoothyText.text  = GameValues.SMOOTHYPOINTS.ToString();
                        }

                        //Debug.Log("fork");
                    }
                    else if (hit.collider.gameObject == knifeBonusBtn)
                    {
                        BlenderCatch blender = GameObject.FindObjectOfType <BlenderCatch>();
                        if (GameValues.SMOOTHYPOINTS >= 20)
                        {
                            holdingBonusObject = GameObject.Instantiate(knifeBonus.gameObject) as GameObject;
                            holdingBonusObject.collider.enabled   = false;
                            holdingBonusObject.transform.parent   = this.transform;
                            holdingBonusObject.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - 2);
                            isHoldingObject = true;

                            GameValues.SMOOTHYPOINTS -= 20;
                            blender.smoothyText.text  = GameValues.SMOOTHYPOINTS.ToString();

                            SoundManager.Instance.PlaySound(grabClip, transform.position, SoundManager.SoundTypes.EFFECT);
                        }
                        //Debug.Log("Knife");
                    }
                }
            }
        }
        else if (holdingBonusObject != null)
        {
            if (/*squeezePressure * 100 < 20 &&*/ openPressure > 0 && holdingBonusObject != null)
            {
                holdingBonusObject.collider.enabled = true;
                holdingBonusObject.transform.parent = null;
                holdingBonusObject.AddComponent <Rigidbody>();
                holdingBonusObject.rigidbody.freezeRotation = true;// <3 saves some time
                //holdingBonusObject.transform.position = transform.position;
                holdingBonusObject = null;
                isHoldingObject    = false;
                SoundManager.Instance.PlaySound(releaseClip, transform.position, SoundManager.SoundTypes.EFFECT);
            }
        }

        if (useStick)
        {
            transform.Translate((Input.GetAxis("Horizontal") * 10) * Time.deltaTime, (Input.GetAxis("Vertical") * 10) * Time.deltaTime, 0);
            if (transform.position.y < minHeight)
            {
                transform.position = new Vector3(transform.position.x, minHeight, transform.position.z);
            }
            if (transform.position.y > maxHeight)
            {
                transform.position = new Vector3(transform.position.x, maxHeight, transform.position.z);
            }

            if (transform.position.x < minWidth)
            {
                transform.position = new Vector3(minWidth, transform.position.y, transform.position.z);
            }
            if (transform.position.x > maxWidth)
            {
                transform.position = new Vector3(maxWidth, transform.position.y, transform.position.z);
            }
        }
        else
        {
            if (!GameValues.AutoMoveX)
            {
                if (openPressure > closePressure)
                {
                    transform.Translate(openPressure * 10 * Time.deltaTime, 0, 0);
                }
                else if (openPressure < closePressure)
                {
                    transform.Translate(-closePressure * 10 * Time.deltaTime, 0, 0);
                }
            }
            if (!GameValues.AutoMoveY)
            {
                if (openPressure > closePressure)
                {
                    transform.Translate(0, openPressure * 10 * Time.deltaTime, 0);
                }
                else if (openPressure < closePressure)
                {
                    transform.Translate(0, -closePressure * 10 * Time.deltaTime, 0);
                }
            }
        }

        if (useController && !GameValues.AutoGrab)
        {
            Squeezing(openPressure, closePressure);
        }
        //While holding a object check if the pressure is below minumum if so let it go.
        // Also check if the pressure is above maximum if so Kill the holding object.
        if (isHoldingObject)
        {
            Debug.Log(holdingObject.fruitSize);
            if (holdingObject != null && !holdingObject.isInBlender)
            {
                if (squeezePressure * 100 < holdingObject.minPressure)
                {
                    //Raycast
                    bool blenderIsFull = false;
                    // Defendable defendAble = GameObject.FindObjectOfType<Defendable>();

                    RaycastHit[] hit = Physics.RaycastAll(holdingObject.transform.position, -Vector3.up /* * 0.5f*/, float.MaxValue);
                    for (int i = 0; i < hit.Length; i++)
                    {
                        BlenderCatch blenderCatch = hit[i].collider.GetComponent <BlenderCatch>();
                        if (blenderCatch != null)
                        {
                            Monster monster = holdingObject.GetComponent <Monster>();
                            if (blenderCatch.smoothPoints + monster.fruitSize > blenderCatch.maxSmoothPoints)
                            {
                                blenderIsFull = true;
                            }

                            break;
                        }
                    }
                    if (!blenderIsFull)
                    {
                        holdingObject.transform.localPosition = new Vector3(holdingObject.pickUpHandPosition.x, holdingObject.pickUpHandPosition.y, 0);
                        holdingObject.transform.parent        = null;
                        isHoldingObject = false;
                        holdingObject.LetGo();
                        holdingObject.Stun(1);
                        holdingObject = null;

                        SoundManager.Instance.PlaySound(releaseClip, transform.position, SoundManager.SoundTypes.EFFECT);
                    }
                    else
                    {
                        holdingObject.transform.localPosition = new Vector3(holdingObject.pickUpHandPosition.x - 4, holdingObject.pickUpHandPosition.y, 0);
                        holdingObject.transform.parent        = null;
                        isHoldingObject = false;
                        holdingObject.LetGo();
                        holdingObject.Stun(1);
                        holdingObject = null;
                        SoundManager.Instance.PlaySound(releaseClip, transform.position, SoundManager.SoundTypes.EFFECT);
                        Debug.Log("Blender is full!!!!!!!!");
                    }
                }
                else if (squeezePressure * 100 > holdingObject.maxPressure)
                {
                    holdingObject.transform.localPosition = new Vector3(holdingObject.pickUpHandPosition.x, holdingObject.pickUpHandPosition.y, 0);
                    holdingObject.transform.parent        = null;
                    isHoldingObject = false;
                    holdingObject.Die();
                    holdingObject = null;
                    //GameValues.SCORE--;
                }
            }
        }
        //Debug.Log(squeezePressure * 100);
    }