Exemple #1
0
    void miningEvent(int hitpoints, GameObject sender, GameObject reciever)
    {
        cutOff = false;

        if (reciever == this.gameObject)
        {
            unitAgent tempUnit = sender.GetComponent <unitAgent> ();
            if (tempUnit._type == unitAgent.Type.miner)
            {
                float rand = Random.Range(0, 10);
                if (rand < debrisRate)
                {
                    GameObject  temp      = Instantiate(debris, transform.position, Random.rotation);
                    debrisLogic tempLogic = temp.GetComponent <debrisLogic> ();
                    tempLogic.Target      = sender;
                    temp.transform.parent = transform;
                    Vector3 randScale = new Vector3(rand / debrisScale, rand / debrisScale, rand / debrisScale);
                    temp.transform.localScale = temp.transform.localScale + randScale;
                }
                resourceValue = (resourceValue - hitpoints);
                if (resourceValue > 50)
                {
                    transform.localScale -= new Vector3(0.02f, 0.02f, 0.02f);
                    Debug.Log("Damage Recieved");
                }
                if (resourceValue < 50 && resourceValue > 2)
                {
                    //float mini = (float)hitpoints / resourceReset;
                    int i = 1;
                    transform.localScale -= new Vector3(0.03f, 0.03f, 0.03f);
                    if (i == 1)
                    {
                        var myBounds = new GraphUpdateObject(GetComponent <Collider> ().bounds);
                        AstarPath.active.UpdateGraphs(myBounds);
                        i++;
                    }
                }
                if (resourceValue <= 0)
                {
                    onDamage();
                    onDeplete();
                }
            }
        }
    }
Exemple #2
0
    void emitDebris()
    {
        int   i    = 0;
        float rand = Random.Range(0, 10);

        repeat = (int)rand;
        while (i < repeat)
        {
            GameObject  temp      = Instantiate(debris, transform.position, Random.rotation);
            debrisLogic tempLogic = temp.GetComponent <debrisLogic> ();
            tempLogic.speed = 10 * ((rand / 5) + 1);
            tempLogic.timer = 1 / ((rand / 3) + 1);
            Vector3 randScale = new Vector3(rand / 500, rand / 500, rand / 500);
            temp.transform.localScale = temp.transform.localScale + randScale;
            i++;
        }
        if (resourceValue <= 0)
        {
            onDeplete();
        }
    }