public override void Do(GameObjectPair pair)
    {
        var object1 = pair.Item1;
        var object2 = pair.Item2;

        if (object1.CompareTag("Ball") || object2.CompareTag("Ball"))
        {
            Instantiate(explosionObject, object1.transform.position, Quaternion.identity);
        }
    }
Exemple #2
0
    private void PopulateNextWave()
    {
        GameObjectPair newPair = new GameObjectPair();

        newPair.left  = holoOptions[UnityEngine.Random.Range(0, holoOptions.Count)];
        newPair.right = holoOptions[UnityEngine.Random.Range(0, holoOptions.Count)];

        goalList.Add(newPair);
        AddElement(newPair.left);
        AddElement(newPair.right);
        //Debug.Log(toSpawn.Count);
    }
Exemple #3
0
    public static GameObjectCache FromResources(GameObject[] gameObjects)
    {
        BlobAssetReference <GameObjectCacheBlobAsset> reference;

        using (var builder = new BlobBuilder(Allocator.Temp)) {
            ref var root      = ref builder.ConstructRoot <GameObjectCacheBlobAsset>();
            var     clipPairs = builder.Allocate(ref root.GameObjectPairs, gameObjects.Length);

            for (int i = 0; i < gameObjects.Length; i++)
            {
                Debug.Log($"Adding Prefab {gameObjects[i].name} with ID {gameObjects[i].Hash()} to GameObjectCache.");
                clipPairs[i] = new GameObjectPair(gameObjects[i].Hash(), gameObjects[i]);
            }
            reference = builder.CreateBlobAssetReference <GameObjectCacheBlobAsset>(Allocator.Persistent);
            Debug.Log($"{clipPairs.Length} total items in cache");
        }
    public override void Do(GameObjectPair gameObjectPair)
    {
        GameObject self  = gameObjectPair.Item1;
        GameObject other = gameObjectPair.Item2;

        if (!other || !other.gameObject.CompareTag("Player"))
        {
            return;
        }

        // Hit the left Racket?
        if (other.gameObject.name == "Player 1")
        {
            // Calculate hit Factor
            float y = HitFactor(self.transform.position,
                                other.transform.position,
                                other.GetComponent <Collider2D>().bounds.size.y);

            // Calculate direction, make length=1 via .normalized
            Vector2 dir = new Vector2(1, y).normalized;

            // Set Velocity with dir * speed
            self.GetComponent <Rigidbody2D>().velocity = dir * bounceOffSpeed.Value;
        }

        // Hit the right Racket?
        if (other.gameObject.name == "Player 2")
        {
            // Calculate hit Factor
            float y = HitFactor(self.transform.position,
                                other.transform.position,
                                other.GetComponent <Collider2D>().bounds.size.y);

            // Calculate direction, make length=1 via .normalized
            Vector2 dir = new Vector2(-1, y).normalized;

            // Set Velocity with dir * speed
            self.GetComponent <Rigidbody2D>().velocity = dir * bounceOffSpeed.Value;
        }
    }
Exemple #5
0
 public override void Do(GameObjectPair gameObjectPair)
 {
     Debug.Log(gameObjectPair.Item1.name);
     Debug.Log(gameObjectPair.Item2.name);
 }
Exemple #6
0
 public void UpdateCurrentGoal()
 {
     goalList.RemoveAt(0);
     currentGoal = goalList[0];
     spawnHoloPair(goalList[0].left, goalList[0].right);
 }