Example #1
0
    // Spawn drones from each start location to each destination location
    void SpawnDrones()
    {
        //FIXME: This is an ugly fix for not spawning on each other
        Vector3 space = new Vector3(0, 0, 70);

        for (int j = 0; j < drones_per_location; j++)
        {
            for (int i = 0; i < spawn_locations.Length; i++)
            {
                GameObject droneInstance = (GameObject)Instantiate(drone, spawn_locations[i].position + (space * j), spawn_locations[i].rotation);
                droneInstance.tag = "Npc";
                if (TeamHelper.IsSameTeam(gameObject.layer, 8))
                {
                    droneInstance.layer = 8;
                }
                else
                {
                    droneInstance.layer = 11;
                }

                // Propagate layer
                TeamHelper.PropagateLayer(droneInstance, droneInstance.layer);
                GameObject triggerObject = droneInstance.transform.FindChild("Trigger").gameObject;
                triggerObject.layer = 3;

                droneInstance.GetComponent <GunSwitcher>().LayerChanged();

                DroneBehaviour behav = droneInstance.GetComponent <DroneBehaviour>();
                behav.target = destination[i];

                this.networkSyncDroneSpawn(droneInstance);
            }
        }
    }
    private GameObject[] SpawnWave()
    {
        GameObject[] newWave = new GameObject[WavePrefabs.Length];

        for (int i = 0; i < WavePrefabs.Length; i++)
        {
            newWave[i]       = (GameObject)Instantiate(WavePrefabs[i], gameObject.transform.position, gameObject.transform.rotation);
            newWave[i].tag   = "Npc";
            newWave[i].layer = gameObject.layer;
            DroneBehaviour behav = newWave[i].GetComponent <DroneBehaviour>();
            behav.target = DroneTarget;
        }

        return(newWave);
    }
 void OnTriggerEnter(Collider Obj)
 {
     // Check if this is a drone
     if (Obj.gameObject.tag == "Npc")
     {
         DroneBehaviour s = Obj.gameObject.GetComponent <DroneBehaviour>();
         GameObject     p = ships[0];
         if (TeamHelper.IsSameTeam(int.Parse(p.layer.ToString()), int.Parse(Obj.gameObject.layer.ToString())))
         {
             Transform newTarget = ships[1].transform.FindChild("DroneDestination");
             s.target = newTarget;
         }
         else
         {
             Transform newTarget = ships[0].transform.FindChild("DroneDestination");
             s.target = newTarget;
         }
     }
 }
Example #4
0
    void OnCollisionEnter2D(Collision2D hitInfo)
    {
        //Debug.Log((1 << hitInfo.gameObject.layer) +" : "+ targetMask.value);
        if (((1 << hitInfo.gameObject.layer) & targetMask.value) > 0)
        {
            Debug.Log(hitInfo.transform.name + " is caught by bird");

            PlayerMovement player = hitInfo.transform.gameObject.GetComponent <PlayerMovement>();
            if (player)
            {
                player.Die(PlayerMovement.DieReason.Caught);
            }

            DroneBehaviour drone = hitInfo.transform.gameObject.GetComponent <DroneBehaviour>();
            if (drone)
            {
                drone.Die(PlayerMovement.DieReason.Caught);
            }
            //hitInfo.gameObject.GetComponent<BreakableEffect>().Break();
        }
    }