Exemple #1
0
    //----------------------------------------------------------------------------------------------------------------
    // Update is called once per frame

    void Update()
    {
        if (ctunity == null || ctclient == null)
        {
            Debug.Log(name + ", oops no ctunity/ctlient!");
            return;        // async
        }
        if (!ctunity.activePlayer(gameObject))
        {
            return;
        }

        launchInterval = ctclient.getCustom("dt", launchInterval);

        stopWatch += Time.deltaTime;
        if (stopWatch >= launchInterval)
        {
            String missile = ctclient.getCustom("M", Missile);  // optional custom missile
            Ilaunch = ctclient.getCustom("N", Ilaunch);
            Nlaunch = ctclient.getCustom("Nmax", Nlaunch);
            //           Debug.Log(name + ": Nlaunch: " + Nlaunch+", launchInterval: "+launchInterval);

            if (Nlaunch != 0 && Ilaunch >= Nlaunch)
            {
                return;
            }

            ctunity.deployInventory(missile, CTunity.fullName(gameObject) + "/R-" + Ilaunch);
            Ilaunch++;
            ctclient.putCustom("N", Ilaunch);

            stopWatch = 0;
        }
    }
Exemple #2
0
    static internal String custom = null;          // "global" params (shared between objects)

    // Use this for initialization
    void Start()
    {
        ctunity  = GameObject.Find("CTunity").GetComponent <CTunity>();
        ctclient = GetComponent <CTclient>();

        //       if (showHP) int.TryParse(ctclient.getCustom("HP", HP + ""), out HP);
        if (showHP)
        {
            initialHP = HP;         // init to static global value
            int hp = ctclient.getCustom("HP", 0);
//            Debug.Log(name+",startup HP: "+HP+", hp: " + hp + ", custom: " + ctclient.custom);
            if (hp != 0)
            {
                HP        = hp;            // over-ride baked-in if custom present
                initialHP = HP;
            }
            if (HP == 0)
            {
                showHP = false;             // nope
            }
        }

        initialScale = transform.localScale;
        stopWatch    = 0;
        //        Debug.Log(name + ", showHP: " + showHP);
        mainCamera = Camera.main;                   // up front for efficiency
    }
Exemple #3
0
    //----------------------------------------------------------------------------------------------------------------
    // Update is called once per frame
    void FixedUpdate()
    {
        if (rb == null)             // init async?
        {
            rb = GetComponent <Rigidbody>();

            // start with velocity of grandparent (?)
            if (rb != null)
            {
                Rigidbody pprb = transform.parent.transform.parent.gameObject.GetComponent <Rigidbody>();
                if (pprb != null)
                {
                    rb.velocity = pprb.velocity;
                }
            }
        }
        if (!ctunity.activePlayer(gameObject))
        {
            return;
        }

        // save fuel and flightTime with CT
        float fuel       = ctclient.getCustom("Fuel", fuelTime);
        float flightTime = ctclient.getCustom("Age", 0f);

//        Debug.Log(CTunity.fullName(gameObject) + ", fuel: " + fuel + ", fueltime: " + fuelTime+", flightTime: "+flightTime);
        fuel -= Time.deltaTime;         // fuel units = RT sec
        if (fuel < 0)
        {
            fuel = 0;
        }
        flightTime += Time.deltaTime;

        ctclient.putCustom("Fuel", fuel.ToString("0.00"));
        ctclient.putCustom("Age", flightTime.ToString("0.00"));
        if (fuel > 0)
        {
            float noiseX = (float)random.NextDouble() * wobbleFactor;               // bit of uncertainty so rockets don't perfectly "stack"
            float noiseZ = (float)random.NextDouble() * wobbleFactor;
            rb.AddRelativeForce(new Vector3(noiseX, 1f, noiseZ) * ForceFactor);
        }
        else if (flightTime > boomTime)
        {
//			Debug.Log(name + ": BOOM!");
            ctunity.clearObject(gameObject);
        }
    }
Exemple #4
0
    private void Update()
    {
        if (showHP)
        {
            HP = ctclient.getCustom("HP", HP);
        }
        //       Debug.Log(name + ",Update HP: " + HP + ", custom: " + ctclient.custom);

        if (scaleSize && thisCollider != null)
        {
            transform.localScale = Vector3.Lerp(transform.localScale, targetScale, Time.deltaTime * 2f);
        }

        if (showHP && thisCollider != null)
        {
            stopWatch += Time.deltaTime;
            if (stopWatch >= damageInterval)
            {
                doCollision(thisCollider);
                stopWatch = 0;
            }
        }
    }