예제 #1
0
    void Awake()
    {
        instance = this;

#if !UNITY_EDITOR
        forceEditorLowRes = false;
#endif

        if (GameObjectsPool.IsLowRes || forceEditorLowRes)
        {
            targetTileBreakEffectPrefab    = lowTileBreakEffectPrefab;
            targetTileBreakEffectMaterials = lowTileBreakEffectMaterials;
        }
        else
        {
            targetTileBreakEffectPrefab    = tileBreakEffectPrefab;
            targetTileBreakEffectMaterials = tileBreakEffectMaterials;
        }

        // Setup each type of tile break effect for each require material type and cache the particle system instances based on the material.
        for (int i = 0; i < tileBreakEffectMaterials.Length; i++)
        {
            TileBreakEffectController breakEffectInstance = (Instantiate(targetTileBreakEffectPrefab) as GameObject).GetComponent <TileBreakEffectController>();
            breakEffectInstance.UpdateTileRenderersMaterial(targetTileBreakEffectMaterials[i]);

            ParticleSystemManager.Instance.CacheParticleSystem(breakEffectInstance.gameObject, true);

            // Add particle system to objects pool.
            objectsPool.Add(tileBreakEffectMaterials[i], breakEffectInstance.gameObject);
        }
    }
예제 #2
0
        public static void InitWorld()
        {
            GameObjectsPool.Clear();
            Stats.CansEatten = 0;
            creationTime     = DateTime.Now;

            var topWall = new Wall(
                new Vector(0, View.Height + 10),
                new Vector(View.Width, View.Height + 10));

            var bottomWall = new Wall(
                new Vector(0, -10),
                new Vector(View.Width, -10));

            var leftWall = new Wall(
                new Vector(-10, View.Height),
                new Vector(-10, 0));

            var RightWall = new Wall(
                new Vector(View.Width + 10, View.Height),
                new Vector(View.Width + 10, 0));

            GameObjectsPool.Add(topWall);
            GameObjectsPool.Add(bottomWall);
            GameObjectsPool.Add(leftWall);
            GameObjectsPool.Add(RightWall);

            var can = new PetrolCan();

            can.Translate(new Vector(200, 200));
            GameObjectsPool.Add(can);
            SpawnCar();
        }
예제 #3
0
	void Awake()
	{
		instance = this;
		
#if !UNITY_EDITOR
		forceEditorLowRes = false;
#endif
		
		if ( GameObjectsPool.IsLowRes || forceEditorLowRes )
		{
			targetTileBreakEffectPrefab = lowTileBreakEffectPrefab;
			targetTileBreakEffectMaterials = lowTileBreakEffectMaterials;
		}
		else
		{
			targetTileBreakEffectPrefab = tileBreakEffectPrefab;
			targetTileBreakEffectMaterials = tileBreakEffectMaterials;
		}
		
		// Setup each type of tile break effect for each require material type and cache the particle system instances based on the material.
		for(int i = 0; i < tileBreakEffectMaterials.Length; i++)
		{
			TileBreakEffectController breakEffectInstance = (Instantiate(targetTileBreakEffectPrefab) as GameObject).GetComponent<TileBreakEffectController>();
			breakEffectInstance.UpdateTileRenderersMaterial(targetTileBreakEffectMaterials[i]);

			ParticleSystemManager.Instance.CacheParticleSystem(breakEffectInstance.gameObject, true);
			
			// Add particle system to objects pool.
			objectsPool.Add(tileBreakEffectMaterials[i], breakEffectInstance.gameObject);
		}
			
	}
예제 #4
0
        public RocketLauncher(IRocketLauncherOwner rocketLauncherOwner)
        {
            _rocketLauncherOwner = rocketLauncherOwner;

            _cachedRocketsPool       = rocketLauncherOwner.RocketsPool;
            _cachedOwnerTransform    = rocketLauncherOwner.RocketLauncherOwner.transform;
            _spendTimeFromLastAttack = rocketLauncherOwner.ReloadDelayInSeconds;
        }
예제 #5
0
        private static void SpawnCar()
        {
            var car = new Car();

            car.Translate(new Vector(100, 100));
            GameObjectsPool.Add(car);
            currentCar = car;
        }
 private void Start()
 {
     for (int i = 0; i < poolTemplates.Count; i++)
     {
         var gameObjectsPool = new GameObjectsPool(poolTemplates[i].TemplatePrefab, poolTemplates[i].AmountToPool, poolTemplates[i].TemplateTagName);
         pools.Add(poolTemplates[i].TemplateTagName, gameObjectsPool);
     }
 }
예제 #7
0
 internal PlayerController(
     IPlayerInput input, GameObject camera, IManagedPerson managedPerson)
 {
     _managedPerson = managedPerson;
     _input         = input;
     _camera        = camera.GetComponent <Camera>();
     _pathMarkPool  = new GameObjectsPool <PathMarksFabric>(
         new PathMarksFabric(), _marksPoolSize);
 }
예제 #8
0
    private GameObjectsPool GetPullByPrefab(GameObject prefab)
    {
        if (!_pools.ContainsKey(prefab))
        {
            GameObjectsPool pool = Instantiate(GameObjectsPool);
            pool.Prefab = prefab;
            _pools.Add(prefab, pool);
        }

        return(_pools[prefab]);
    }
예제 #9
0
        private static void LoadSave()
        {
            var save =
                JsonSerializer.Deserialize <GameSave>(File.ReadAllText("save.json"));

            StartNewGame();
            GameObjectsPool.Clear();
            GameObjectsPool.AddRange(save.cans);
            GameObjectsPool.AddRange(save.cars);
            GameObjectsPool.AddRange(save.cones);

            Stats.CansEatten = save.cansEatten;
            creationTime     = save.creation;

            View.InitSlips(new Bitmap(Image.FromFile("slips.bmp")));
        }
예제 #10
0
    public void AddCompanyIndicator(IIndicator indicator)
    {
        if (_companyPools.Count < _currentPoolIndex + 1)
        {
            return;
        }
        GameObjectsPool    pool      = _companyPools[_currentPoolIndex];
        GameObject         indObject = pool.GetInstance();
        IndicatorContainer ic        = indObject.GetComponent <IndicatorContainer>();

        if (ic != null)
        {
            ic.InitContainer(indicator);
            _currentPoolIndex++;
            _currentPoolIndex = _currentPoolIndex % _companyPools.Count;
        }
    }
예제 #11
0
 public void Initialize()
 {
     _bombsPool =
         new GameObjectsPool <BombFabricTemplate>(
             new BombFabricTemplate(), _poolSize);
 }