Example #1
0
    // Update is called once per frame
    void Update()
    {
        RedController cell = null;

        if (dna != null)            // Can reproduce
        {
            if (Time.time > nextReprod)
            {
                Vector3 v3 = transform.position + (Random.insideUnitSphere * dna.transform.localScale.x);
                v3.y       = 1f;
                nextReprod = Time.time + dna.reprodRate();

                try {
                    cell = Instantiate(dna, v3, transform.rotation) as RedController;
                    if (!bodystate)
                    {
                        //Debug.LogError ("BodyState is missing in RedSpawnwer");
                    }
                    cell.setBodyState(bodystate);
                    cell.gameController = gameController;
                }catch (System.Exception) {
                    Debug.LogError(name + " Instantiate failed in RedSpawnwer");
                }

                //Debug.Log("Red Reprod= "+ nextReprod +"{"+ dna.reprodRate() +"} ");
            }
        }
    }
Example #2
0
    // Collider for each object is called.
    // Only organ collision is dealt with here.
    void OnTriggerEnter(Collider other)
    {
        if (stats_health == 0)           // Organ is dead - destroy???
        {
            return;
        }
        // Infect/Attack/Oxygenate everything that enters the trigger
        if (other.tag.Equals("Infection"))           // do battle
        {
            CellController infection = other.GetComponent(typeof(CellController)) as CellController;
            if (!defend(infection))            // if failed to defend, check for specific damage
            {
                damageBody();                  // Organ specific damage to the cell stats
            }
        }
        else if (other.name.Equals("Red"))
        {
            RedController red = other.GetComponent(typeof(RedController)) as RedController;
            //Debug.Log(other.name+" bodyStats "+ red.bodystate.showStats());
            oxygenate(red.power());
        }

        //gameController.updateScore (scoreValue);
    }