public override void PlayGame(object data)
    {
        Debug.Log("Game Core goto PlayGame");

        var c = SimplePool.Spawn(postItem, new Vector2(0, 5), Quaternion.identity);

        SoundManager.Play("dropItem");
        //UIPerfectToast.instance.Show("LET'S GO!!!");
    }
Esempio n. 2
0
    /// <summary>
    /// 生成冬季平台
    /// </summary>
    private void SpawnWinterPlatform(int ranObstacleDir)
    {
        int index = Random.Range(0, vars.winterPlarformGroup.Count);
        //GameObject go = Instantiate(vars.winterPlarformGroup[index]);
        GameObject go = SimplePool.Spawn(vars.winterPlarformGroup[index]);

        go.transform.position = platformSpawnPosition;
        go.GetComponent <PlatformScript>().Init(selectSprite, fallTime, ranObstacleDir);
    }
    // =================================================================================

    protected override void Awake()
    {
        _pPool = new SimplePool <GameObject>(OnCreateItem, OnDestroyItem, 0);

        if (pTransformParents == null)
        {
            pTransformParents = transform;
        }
    }
Esempio n. 4
0
    protected override void OnAwake()
    {
        confirmButton.onClick.AddListener(Confirm);
        clearButton.onClick.AddListener(Clear);
        var pool = itemCellsParent.FindOrCreate("Caches");

        ZetanUtility.SetActive(pool, false);
        caches = new SimplePool <ItemSlot>(itemCellPrefab, poolRoot: pool);
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        currDespawnTime += Time.deltaTime;

        if (currDespawnTime >= despawnTime)
        {
            SimplePool.Despawn(gameObject);
        }
    }
Esempio n. 6
0
        public void Init()
        {
            playerModel = GameController_Reactive.Instance.PlayerModel;

            rb          = GetComponent <Rigidbody>();
            audioSource = GetComponent <AudioSource>();

            SimplePool.Preload(boltPrefab, boltsContainer, 10);
        }
Esempio n. 7
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        SoundManager.Play("boom");
        var a = Instantiate(explosion, new Vector3(this.transform.position.x - 0.25f, this.transform.position.y - 0.85f, 0), Quaternion.identity);

        GameCoreManager.coreManager.earthWake = true;
        Debug.Log("hahi");
        SimplePool.Despawn(this.gameObject);
    }
Esempio n. 8
0
        private void OnTriggerEnter(Collider other)
        {
            if (Hit != null)
            {
                Hit.Invoke();
            }

            SimplePool.Despawn(other.gameObject);
        }
Esempio n. 9
0
    AudioSource NewSource()
    {
        GameObject go = SimplePool.Spawn(AudioClipPlayerPrefab, Vector3.zero, Quaternion.identity);

        go.transform.parent = this.transform;
        AudioSource src = go.GetComponent <AudioSource>();

        return(src);
    }
Esempio n. 10
0
    public void MiningTask(GameObject go, Vector3 position)
    {
        var info = GameData.Instance.rawmaterialWorkloadDic[MenuType.Mining];

        view.onUpdateWorload?.Invoke(info.Workload);

        var result = TaskHandler.Instance.taskSystem.EnqueueTask(() =>
        {
            Task task = new MiningTask.Excavate
            {
                TargetPosition = position,
                Name           = "采矿",
                PrefabGame     = go,
                Parent         = go.transform.parent.gameObject,
                Workload       = info.Workload,
                ExcavateAction = (MiningTask.Excavate currentTask) =>
                {
                    var currentWorkload = currentTask.Workload;
                    FunctionUpdater.Create(() =>
                    {
                        currentWorkload -= Time.deltaTime;

                        view.onUpdateWorload?.Invoke(info.Workload);

                        go.transform.parent.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, currentWorkload);

                        PlayerController.Instance.PlayMining(true);

                        if (currentWorkload <= 0f)
                        {
                            SimplePool.Despawn(go);

                            GameObject newGo = SimplePool.Spawn(ResourcesManager.LoadPrefab("Prefabs/General_Stone"), go.transform.parent.position, Quaternion.identity);
                            newGo.transform.SetParent(go.transform.parent, false);
                            newGo.transform.position = go.transform.parent.position;

                            PlayerController.Instance.PlayMining(false);

                            WorkerTaskAI.Instance.FinishTheWork();

                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                }
            };
            return(task);
        });

        if (result)
        {
            SimplePool.Despawn(go);
        }
    }
Esempio n. 11
0
 public void InitBulletInControl(Vector3 DirecShot, Vector3 AngleShoot, float Velocity, float SpeedMoveTween, float Damage)
 {
     currentBullet = SimplePool.Spawn(prefabBullet, shotPos.position, Quaternion.identity);
     currentBullet.SetBulletControl(this);
     currentBullet.transform.SetParent(transform);
     currentBullet.SetBaseBulletVelocity(DirecShot, AngleShoot, Velocity, SpeedMoveTween);
     currentBullet.SetBulletDame(Damage);
     currentBulletQuantity++;
 }
Esempio n. 12
0
 private void CleanUpDragPreviews()
 {
     while (dragPreviewGameObjects.Count > 0)
     {
         GameObject go = dragPreviewGameObjects[0];
         dragPreviewGameObjects.RemoveAt(0);
         SimplePool.Despawn(go);
     }
 }
Esempio n. 13
0
    void SpawnEnemyPickup()
    {
        GameObject prefab = (Random.Range(0, 2) == 0) ? enemyPrefab : pickupPrefab;
        float      xPos   = (Random.Range(0, 2) == 0) ? leftLane : rightLane;
        Vector3    pos    = new Vector3(xPos, Camera.main.ScreenToWorldPoint(new Vector3(xPos, Screen.height)).y, 0);
        GameObject obj    = SimplePool.Spawn(prefab, pos, Quaternion.identity) as GameObject;

        obj.transform.SetParent(transform);
    }
Esempio n. 14
0
        void OnTriggerExit(Collider other)
        {
            if (!other.CompareTag("Boundary"))
            {
                return;
            }

            SimplePool.Despawn(gameObject);
        }
Esempio n. 15
0
    void OnCollisionEnter2D(Collision2D other)
    {
        PuckSpeedLimiter puck = other.transform.GetComponentInParent <PuckSpeedLimiter>();

        if (puck != null)
        {
            SimplePool.Spawn(impactVFXPrefab, (Vector3)(other.contacts[0].point) + Vector3.back);
        }
    }
Esempio n. 16
0
 private void Fracture()
 {
     for (int i = 0; i < FracturePieces; i++)
     {
         var piece   = SimplePool.Spawn(MeteorFragments, gameObject.transform.position, gameObject.transform.rotation);
         var pieceRB = piece.GetComponent <Rigidbody2D>();
         pieceRB.velocity = Random.onUnitSphere * FragmentSpeed;
     }
 }
 protected void InitBullet(Vector3 shootPosition, Vector3 shootDirection, float bulletVelocity, float bulletDamage)
 {
     currentBullet = SimplePool.Spawn(bulletPrefab, shootPosition, Quaternion.identity);
     currentBullet.BulletController(this);
     currentBullet.transform.SetParent(transform);
     currentBullet.SetBulletVelocity(Vector3.Normalize(shootDirection) * bulletVelocity);
     currentBullet.SetBulletDamage(bulletDamage);
     currentBulletQuantity++;
 }
Esempio n. 18
0
    public void SpawnGuest(int fixFloor = 99)
    {
        int currentFloor = Random.Range(0, HotelController.Instance.hotel.floors.Count);


        int   targetFloor    = currentFloor;
        float maxWaitingTime = Random.Range(50f, 120f);

        // maxWaitingTime = Random.Range(1, 2f);


        while (targetFloor == currentFloor)
        {
            targetFloor = Random.Range(0, HotelController.Instance.hotel.floors.Count);
        }

        if (fixFloor != 99)
        {
            currentFloor = fixFloor;
            targetFloor  = 1;
        }


        Guest guest = new Guest(currentFloor, targetFloor, maxWaitingTime);

        GameObject guestGO = SimplePool.Spawn(guestPrefab, Vector3.zero, Quaternion.identity);


        guestGO.transform.SetParent(worldTransform);
        guestGO.transform.position    = new Vector3(4.5f, (float)currentFloor, 0f);
        guestGO.transform.localScale  = new Vector3(0.8f, 0.8f, 0.8f);
        guestGO.transform.eulerAngles = new Vector3(0f, 90f, 0f);
        guestGO.GetComponent <FaceCanvas>().hud.gameObject.SetActive(true);
        guestGO.SetActive(true);

        guests.Add(guest);
        guestGameObjects.Add(guestGO);

        guestToGameObjectMap.Add(guest, guestGO);
        gameObjectToGuestMap.Add(guestGO, guest);

        guestGO.transform.DOMove(new Vector3(Random.Range(-1.8f, 1.2f), guestGO.transform.position.y, Random.Range(-0.5f, 1.5f)), Random.Range(2f, 3f))
        .OnComplete(() => GuestReadyForLift(guest, guestGO));

        guestGO.name = "Guest";

        FaceCanvas hud = guestGO.GetComponent <FaceCanvas>();

        hud.targetFloorText.text = HotelController.Instance.GetFloor(targetFloor).shortName;
        guest.hud = hud;
        UpdatePatienceBar(guest);

        guestCount[currentFloor]++;
        UpdateLeftPanel(currentFloor);

        spawnGap = Mathf.Max(minSpawnGap, spawnGap - spawnReduce);
    }
Esempio n. 19
0
    void Awake()
    {
        t = gameObject.GetComponent <Transform>();

        if (!SimplePool.PoolExists(projectilePrefab.name))
        {
            SimplePool.CreatePool(projectilePrefab);
        }
    }
 void CleanDragPreview()
 {
     while (dragHighlightCellObjects.Count > 0)
     {
         GameObject obj = dragHighlightCellObjects [0];
         dragHighlightCellObjects.RemoveAt(0);
         SimplePool.Despawn(obj);
     }
 }
Esempio n. 21
0
 private void Awake()
 {
     GameManager.Set(this);
     pixelsPerScreenPixel   = (int)(45f / Camera.main.orthographicSize);
     visualChunkContainer   = GameObject.FindGameObjectWithTag("Container").transform;
     colliderChunkContainer = GameObject.FindGameObjectWithTag("Container").transform;
     lightChunkContainer    = GameObject.FindGameObjectWithTag("Container").transform;
     SimplePool.Preload(colliderChunkPrefab, colliderChunkContainer, 2000);
 }
Esempio n. 22
0
 private void CleanupProjectileImages()
 {
     for (int i = projectileImages.Count - 1; i >= 0; i--)
     {
         projectileImages[i].transform.SetParent(unusedImageParent);
         SimplePool.Despawn(projectileImages[i].gameObject);
         projectileImages.RemoveAt(i);
     }
 }
 public override void OnBulletDespawn()
 {
     currentBulletQuantity--;
     if (currentBulletQuantity <= 0)
     {
         rotateTween.Kill();
         SimplePool.Despawn(gameObject);
     }
 }
Esempio n. 24
0
 protected override void Start()
 {
     base.Start();
     tileHighlights = new GameObject[numHighlights];
     for (int i = 0; i < numHighlights; i++)
     {
         tileHighlights[i] = SimplePool.Spawn(tileHighlightPrefab, Vector3.zero, Quaternion.identity);
     }
 }
Esempio n. 25
0
 void SpawnSpeechBubble()
 {
     if (specificCurrentUser != null)
     {
         GameObject userBubble = SimplePool.Spawn(prefabUserSpeechBubble);
         userBubble.transform.SetParent(userBubblesContainer);
         userBubble.transform.position = transform.position + userBubbleOffset;
         userBubble.GetComponent <UserSpeechBubble>().InitUserBubble(specificCurrentUser);
     }
 }
    Contagion AddContagion(GameObject targetRoot, float massNerf = 1)
    {
        Contagion  result  = targetRoot.gameObject.AddComponent <Contagion>();
        GameObject effects = SimplePool.Spawn(contagionPrefab);

        effects.transform.SetParent(targetRoot.transform, false);
        result.Initialize(duration, massNerf, this, effects.GetComponent <ContagionEffects>());
        contagions.Add(result);
        return(result);
    }
Esempio n. 27
0
 public void ClearPreviews()
 {
     // Clean up old drag previews
     while (dragPreviewGameObjects.Count > 0)
     {
         GameObject go = dragPreviewGameObjects[0];
         dragPreviewGameObjects.RemoveAt(0);
         SimplePool.Despawn(go);
     }
 }
Esempio n. 28
0
        IEnumerator LoadSceneAsync(int sceneIndex)
        {
            SimplePool.Reset();
            var operation = SceneManager.LoadSceneAsync(sceneIndex);

            while (!operation.isDone)
            {
                yield return(null);
            }
        }
Esempio n. 29
0
    public BaseEnemy Spawn(int targetHealth, int targetMoveSpeed)
    {
        BaseEnemy enemyClone = SimplePool.Spawn(enemyPrefab.gameObject).GetComponent <BaseEnemy>();

        enemyClone.Initialize(targetHealth, targetMoveSpeed);
        enemyClone.transform.SetParent(transform);
        enemyClone.transform.localPosition    = Vector3.zero;
        enemyClone.transform.localEulerAngles = Vector3.zero;
        return(enemyClone);
    }
        public override void OnCast()
        {
            GameObject _prefab = Resources.Load(string.Format(CONSTANT.PathFormatProjectilePrefabs, projectile)) as GameObject;
            GameObject obj     = SimplePool.Spawn(_prefab, parent.sourceUnit.ShootPosition);

            obj.transform.SetParent(BattleManager.Instance.transform);
            //obj.transform.position = shootpoint;

            obj.GetComponent <IndieProjectileObject>().FlyToTarget(parent.sourceUnit.CurrentTarget, ProjectOnHit, speed);
        }
Esempio n. 31
0
    /// <summary>
    /// Initialize this enemy and set its movement to the target direction.
    /// </summary>
    /// <param name="direction">Which direction should we be traveling in at the start.</param>
    /// <param name="pool">The optional pool to release this enemy too. Using this can increase performance.</param>
    public void Initialize(Vector3 direction, SimplePool pool = null)
    {
        animator.SetBool("Dead", false);
        gameObject.layer = enemyLayer;

        movement.Direction = direction;
        movement.speed = initialSpeed;
        movement.Lock = false;

        // Reset death events if necessary
        if (deathTrigger != null)
        {
            deathTrigger.Pool = pool;
            deathTrigger.OnInitialize();
        }
    }
Esempio n. 32
0
		/// <summary> Initializes the Velocity parser pool.
		/// This still needs to be implemented.
		/// </summary>
		private void initializeParserPool()
		{
			int numParsers = GetInt(RuntimeConstants.PARSER_POOL_SIZE, RuntimeConstants.NUMBER_OF_PARSERS);

			parserPool = new SimplePool<Parser.Parser>(numParsers);

			for(int i = 0; i < numParsers; i++)
			{
				parserPool.put(CreateNewParser());
			}
		}
Esempio n. 33
0
 public void Start()
 {
     Instance = this;
 }