Пример #1
0
    private void OnTriggerEnter(Collider other)
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius, tankMask);

        for (int i = 0; i < colliders.Length; i++)
        {
            Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();

            if (!targetRigidbody)
            {
                continue;
            }

            targetRigidbody.AddExplosionForce(explosionForce, transform.position, explosionRadius);

            Tank_Data targetHealth = targetRigidbody.GetComponent <Tank_Data>();

            if (!targetHealth)
            {
                continue;
            }

            float damage = CalculateDamage(targetRigidbody.position);

            targetHealth.TakeDamage(damage);
        }
    }
Пример #2
0
    public void ScanForPlayer()

    {
        target = FindObjectOfType <Turret>().gameObject;

        data = FindObjectOfType <Tank_Data>(); //Grabs object with TankData script
    }
Пример #3
0
    public float destroyDuration; //How long until bullet gets destroyed


    private void Awake()
    {
        //Goes through each one and finds the components
        shoot = FindObjectOfType <Shoot>();
        timer = FindObjectOfType <Timer>();
        data  = FindObjectOfType <Tank_Data>();
    }
Пример #4
0
    public override void OnApply(GameObject obj, GameObject source = null)

    {
        if (colSource != null)
        {
            source = colSource;
        }



        Tank_Data temp = source.GetComponent <Tank_Data>();

        resetVal = temp.rapidFireVal;

        temp.rapidFireVal = val;

        if (temp.shotsPerSecond > (temp.shotsPerSecond = temp.shotsPerSecond - (temp.rapidFireVal / 10)))

        {
            var tempVal = temp.rapidFireVal / 10;

            temp.shotsPerSecond = 1 - tempVal;
        }

        ImpController.controller.canRapidFire = true;
    }
Пример #5
0
    public void Setup()
    {
        tank_DataRef     = instance.GetComponent <Tank_Data>();
        firingRef        = instance.GetComponent <Firing>();
        canvasGameObject = instance.GetComponentInChildren <Canvas>().gameObject;

        tank_DataRef.playerNumber = playerNumber;
        firingRef.playerNumber    = playerNumber;

        coloredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(playerColor) + ">PLAYER " + playerNumber + "</color>";

        MeshRenderer[] renderers = instance.GetComponentsInChildren <MeshRenderer>();

        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = playerColor;
        }
    }
Пример #6
0
    public override void OnRemove(GameObject obj, GameObject source = null)

    {
        if (colSource != null)
        {
            source = colSource;
        }



        Tank_Data temp = source.GetComponent <Tank_Data>();

        temp.rapidFireVal = resetVal;

        temp.shotsPerSecond = temp.rapidFireVal;

        ImpController.controller.canRapidFire = false;
    }
Пример #7
0
 // Start is called before the first frame update
 void Start()
 {
     target = FindObjectOfType <Turret>().gameObject;
     data   = FindObjectOfType <Tank_Data>();
     //grabs both turret script and tank data script.
 }
Пример #8
0
 private void Start()
 {
     tf   = GetComponent <Transform>(); //Grab our tranform and tank data
     data = GetComponent <Tank_Data>();
 }
Пример #9
0
    public Tank_Data data; //And our tank data

    // Start is called before the first frame update
    void Start()
    {
        tf   = GetComponent <Transform>();         //Grab our transform
        data = GetComponentInParent <Tank_Data>(); //Grab the tank data that is located in our parent gameobject
    }