Exemplo n.º 1
0
    //this is called when the current item is solved
    void DoOnSolve()
    {
        gMan.StoreItem();                      //animation
        hMan.DealDamage(currentItem.sparkJoy); //deal damage to health manager

        //storedItems.Add(currentItem);       //this adds item to all stored items at the end.

        remainingUnsortedObjects--;
        sortedObjectSuccessThreshold--;
        remainingObjectText.text = remainingUnsortedObjects.ToString();
        requiredObjectText.text  = sortedObjectSuccessThreshold.ToString();

        incrementer++;


        //CHECK IF THERE'S ANOTHER ITEM
        if (allItems[incrementer] != null)
        {
            LoadItem(incrementer);
        }

        else
        {
            pileExhausted();
        }
    }
Exemplo n.º 2
0
    public void HitCurrentTarget(float damage)
    {
        if (!currentTarget)
        {
            return;
        }
        HealthManager health = currentTarget.GetComponent <HealthManager>();

        if (health)
        {
            health.DealDamage(damage);
        }
    }
Exemplo n.º 3
0
    private void OnCollisionEnter(Collision collision)
    {
        AdjacentColliderCount += 1;
        if (AdjacentColliderCount > 1)
        {
            _Rigidbody.useGravity = false;
        }
        //float point = collision.GetContact(0).point.y; up-to-date
        float point = collision.contacts[0].point.y;

        //Fall damage
        if (point < transform.position.y - 0.9f)
        {
            float   impact    = (HighestY - transform.position.y);
            float[] threshold = new float[5]
            {
                0.5f,
                1.5f,
                6.5f,
                9.5f,
                18f,
            };
            if (impact > threshold[0])
            {
                //Debug.Log(impact);
            }

            if (threshold[0] <= impact && impact < threshold[1])
            {
                //Debug.Log("Soft Landing");
            }
            else if (threshold[1] <= impact && impact < threshold[2])
            {
                //Debug.Log("Medium Landing");
            }
            else if (threshold[2] <= impact && impact < threshold[3])
            {
                //Hard land sound
                //Debug.Log("Hard Landing");
                int damage = (int)((impact - threshold[2]) / (threshold[3] - threshold[2]) * 10);
                //Debug.Log("Damage Dealt: " + damage);
                healthManager.DealDamage(damage);
            }
            else if (threshold[3] <= impact && impact < threshold[4])
            {
                //Debug.Log("Really Hard Landing");
                int damage = (int)((impact - threshold[2]) / (threshold[3] - threshold[2]) * 10);
                //Debug.Log("Damage Dealt: " + damage);
                healthManager.DealDamage(damage);
            }
            else if (threshold[4] <= impact)
            {
                //Debug.Log("Fatal Landing");
                healthManager.Kill();
            }
            HighestY = transform.position.y;
        }
        else if (point > (transform.position.y + 0.8f))
        {
            Box obj = collision.gameObject.GetComponent <Box>();
            //Debug.Log(Vector3.Dot(collision.rigidbody.velocity.normalized, Vector3.down));
            if (obj != null && obj.Frozen == false && Vector3.Dot(collision.rigidbody.velocity.normalized, Vector3.down) > 0.1f)
            {
                //Possibly Crushed
                int weight = obj.GetStackWeight();
                //Debug.Log(weight);
                int[] threshold = new int[3]
                {
                    1,
                    2,
                    3,
                };
                if (threshold[0] <= weight && weight < threshold[1])
                {
                    //Debug.Log("Small Crush");
                    healthManager.DealDamage(10);
                }
                else if (threshold[1] <= weight && weight < threshold[2])
                {
                    //Debug.Log("Medium Crush");
                    healthManager.DealDamage(15);
                }
                else if (threshold[2] <= weight)
                {
                    //Debug.Log("Crushed");
                    healthManager.Kill();
                }
            }
        }
    }