Exemplo n.º 1
0
        /// <summary>
        /// A method to call the level directly with an id
        /// </summary>
        /// <param name="id">id of the level that should be spawned </param>
        public void SpawnLevel(int id)
        {
            var level = GameObject.Find("Level");

            Destroy(level);
            foreach (var ballsandpaddles in Instantiated)
            {
                Destroy(ballsandpaddles);
            }
            var powerUps = GameObject.FindGameObjectsWithTag("PowerUp");

            foreach (var powerUp in powerUps)
            {
                Destroy(powerUp);
            }
            Instantiated.Clear();
            SpawnPaddleAndBall();
            if (id == 8)
            {
                GetComponent <LevelSpawner>().LoadLevel(GetComponent <LevelSpawner>().GenerateRandomLevel(5, 2, 5));
            }
            else
            {
                GetComponent <LevelSpawner>().LoadLevel(id);
            }
        }
Exemplo n.º 2
0
 void Generate()
 {
     Debug.Log(recursiveChildren);
     Debug.Log(recursiveChildren.Length);
     if (transform.childCount == 0 && recursiveChildren != null && recursiveChildren.Length > 0)
     {
         Random.seed = (int)System.DateTime.Now.Ticks;
         var randumber = Random.Range(0, recursiveChildren.Length);
         var child     = recursiveChildren[randumber];
         if (child != null)
         {
             var existingChild = (GameObject)Instantiate(child, transform.position, transform.rotation);
             existingChild.transform.parent = transform;
             var childSpawners = existingChild.GetComponentsInChildren <Instantiate>();
             foreach (var Instantiated in childSpawners)
             {
                 Debug.Log(TreeSize.ToString() + " Size, should do at most" + recursiveLevelSize.ToString());
                 if (TreeSize >= recursiveLevelSize)
                 {
                     Instantiated.children = recursiveEndPieces;
                 }
                 Instantiated.parent = this;
             }
             foreach (var Instantiated in childSpawners)
             {
                 if (recursiveGenerateInEditor)
                 {
                     Debug.Log("Child, do something!");
                     Instantiated.Generate();
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Spawns the ball and the paddle at the starting position
        /// </summary>
        public void SpawnPaddleAndBall()
        {
            _paddle = Instantiate(PaddlePrefab, new Vector3(0, -4.5f, 0), transform.rotation);
            Instantiated.Add(_paddle);
            var ball = CreateBallAt(new Vector3(0, -4.1f, 0));

            ball.GetComponent <BallPhysics>().BallBoundToPaddle = true;
            Instantiated.Add(ball);
        }
Exemplo n.º 4
0
        private void Update()
        {
            if (NumberOfDestructibleTiles > 0)
            {
                return;
            }
            foreach (var ballsandpaddles in Instantiated)
            {
                Destroy(ballsandpaddles);
            }
            var powerUps = GameObject.FindGameObjectsWithTag("PowerUp");

            foreach (var powerUp in powerUps)
            {
                Destroy(powerUp);
            }
            Instantiated.Clear();
            SpawnPaddleAndBall();
            GetComponent <LevelSpawner>().SpawnNextLevel();
        }
Exemplo n.º 5
0
        internal void ClearCacheValue(object obj)
        {
            lock (Instantiated)
            {
                foreach (var instance in Instantiated)
                {
                    if (instance.Target is string)
                    {
                        ((string)instance.Target).DestroyString();
                    }
                    else
                    {
                        // todo: Destroy reference
                        //var gcAlloc = GCHandle.Alloc(instance.Target, GCHandleType.Weak);
                        //var size = Marshal.SizeOf(instance.Target);

                        //unsafe
                        //{
                        //    var gcPtr = (int*) ((IntPtr) gcAlloc).ToPointer();
                        //    for (int i = 0; i < size; i++)
                        //    {
                        //        gcPtr[i] = 0;
                        //    }
                        //}
                    }
                }
                Instantiated.Clear();

                if (!HasCache)
                {
                    return;
                }
                var cacheProperty = GetCacheProperty(obj);
                cacheProperty.NullField(obj);
            }
        }
Exemplo n.º 6
0
 public static void ObjectSString() => Instantiated.Max(Instantiated.Max((SString)"abc", (SString)"acd"), (SString)"aab");
Exemplo n.º 7
0
 public static void InstantiatedSString() => Instantiated.MaxSString(Instantiated.MaxSString((SString)"abc", (SString)"acd"), (SString)"aab");
Exemplo n.º 8
0
 public static void ObjectSInt() => Instantiated.Max(Instantiated.Max((SInt)1, (SInt)3), (SInt)2);
Exemplo n.º 9
0
 public static void InstantiatedSInt() => Instantiated.MaxSInt(Instantiated.MaxSInt((SInt)1, (SInt)3), (SInt)2);
Exemplo n.º 10
0
 public static void InstantiatedCString() => Instantiated.Max(Instantiated.Max((CString)"abc", (CString)"acd"), (CString)"aab");
Exemplo n.º 11
0
 public static void InstantiatedCInt() => Instantiated.Max(Instantiated.Max((CInt)1, (CInt)3), (CInt)2);
Exemplo n.º 12
0
        /// <summary>
        /// Get the instance of the contract
        /// </summary>
        /// <returns></returns>
        public object GetInstance()
        {
            // Set the isntance type to Single if it was never resolved before
            if (InstanceType == InstanceType.SingleOnResolve)
            {
                InstanceType = InstanceType.Single;
            }

            // Create a placeholder instance
            object instance = Instance;

            // Flag to determine if instaiated by Jedi
            bool jediInstantiated = false;

            try
            {
                // Lock if it is a singleton
                if (InstanceType == InstanceType.Single)
                {
                    _instantiationLock.Wait();
                }

                // Run the factory method only if the instance is null
                // and the instance was not provided
                if (instance == null && _instanceProvided == false)
                {
                    // Check if the contract must be resolved from a chain contractr
                    if (From != null)
                    {
                        instance = From.GetInstance();
                    }
                    // Check if the contract must be resolved from a method
                    else if (Method != null)
                    {
                        instance = Method();
                    }
                    // Instantiate
                    else
                    {
                        instance = Instantiate();

                        // Set the Jedi Instantiated flag
                        jediInstantiated = true;
                    }
                }
            }
            finally
            {
                if (InstanceType == InstanceType.Single)
                {
                    // Set the instance
                    Instance = instance;

                    // Release Lock if it is a singleton
                    _instantiationLock.Release();
                }
            }

            // If the instance was Jedi instantiated
            if (jediInstantiated)
            {
                // Inject the instance
                _container.Inject(instance);

                // Invoke the on instantiated method
                Instantiated?.Invoke();
            }

            return(instance);
        }
            public override void ApplyTo(GameObject block, Master master, bool asPreview)
            {
                Instantiated <UnityEngine.VFX.VisualEffect> vfx = master.prefabs.thrustVFX.Instantiate(block.transform);

                SendToPrefabEditors(master, block, vfx.component, asPreview, this);
            }
Exemplo n.º 14
0
 /// <summary>Implementation of <see cref="IManager{TManaged}.AllSetup()"/>.</summary>
 public override void OnSetup()
 {
     //Create Canvas and EventSystem.
     Canvas = Master.prefabs.canvas.Instantiate(transform);
     Events = Master.prefabs.events.Instantiate(transform);
 }