示例#1
0
    public static void DeleteBoid(BoidComp Boy)
    {
        if (!Instance.Boids.Contains(Boy))
        {
            return;
        }
        Instance.Boids.Remove(Boy);
        Rigidbody rb = Boy.gameObject.AddComponent <Rigidbody>();

        rb.useGravity = false;
        rb.velocity   = Random.onUnitSphere * 15;
        Vector3 dir = (Boy.transform.position - Player.Instance.transform.position).normalized;

        rb.AddForce(dir * 1000.0f);
        Boy.gameObject.layer = 2;
        Boy.GetComponentInChildren <Animator>().enabled = false;
        foreach (var mr in Boy.GetComponentsInChildren <MeshRenderer>())
        {
            mr.material.EnableKeyword("_EMISSION");
            mr.material.SetColor("_EmissionColor", Color.black);
        }
        var weapon = Boy.GetComponentInChildren <EnemyWeapon>();

        if (weapon)
        {
            weapon.enabled = false;
        }
        Destroy(Boy);
    }
示例#2
0
 public static void Spawn(Vector3 Point, float SpawnRadius, int NumBoids, Transform Target = null)
 {
     for (int i = 0; i < NumBoids; i++)
     {
         BoidComp Boy = Instantiate(Instance.BoidPrefab, Point + Random.insideUnitSphere * SpawnRadius, Random.rotation).GetComponent <BoidComp>();
         Boy.Target = Target;
         Instance.Boids.Add(Boy);
     }
 }