Beispiel #1
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        var damageScript = collision.gameObject.GetComponent <Damage>();
        var playerScript = collision.gameObject.GetComponent <PlayerController>();

        // Uncomment below to be log spammed about projectile collissions.
        //string scriptType = string.Empty;
        //if (damageScript != null)
        //{
        //    scriptType = " - A damageScript was present.";
        //}
        //else if (playerScript != null)
        //{
        //    scriptType = " - A playerScript was present.";
        //}

        //var enemydebug = firedByEnemy ? " - the projectile was fired by an enemy." : " - the projectile was not fired by an enemy.";
        //scriptType = scriptType + enemydebug;


        if (damageScript != null && !firedByEnemy)
        {
            damageScript.TakeDamage(Damage);
            SimplePool.Despawn(gameObject);
            //Debug.Log("Collided with: " + collision.gameObject.name + " - Despawning: " + gameObject.name + scriptType);
        }
        else if (playerScript != null && firedByEnemy)
        {
            playerScript.TakeDamage(Damage);
            SimplePool.Despawn(gameObject);
            //Debug.Log("Collided with: " + collision.gameObject.name + " - Despawning: " + gameObject.name + scriptType);
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (particle.isStopped)
     {
         SimplePool.Despawn(gameObject);
     }
 }
Beispiel #3
0
 void Update()
 {
     if (transform.position.x <= platformDestroyer.position.x)
     {
         SimplePool.Despawn(transform.parent.gameObject);
     }
 }
    public override void Despawn()
    {
        base.Despawn();

        SimplePool.Despawn(gameObject); //Despawn itself from the pool manager
        gameObject.SetActive(false);
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (!isSetup)
        {
            return;
        }

        if (transform.position.y < playerTransform.position.y - 0.5f)
        {
            if (isGameplayObject)
            {
                gameCS.dropsMissed += 1;
                gameCS.clipToPlay   = gameCS.raindropMiss;
            }
            isSetup = false;
            SimplePool.Despawn(gameObject);
        }

        if (raindropsMoving)
        {
            transform.position = new Vector3(transform.position.x, transform.position.y - (Time.deltaTime * speed), transform.position.z);
        }

        if (isGameplayObject && (myLevel != gameCS.currentLevel))
        {
            isSetup = false;
            SimplePool.Despawn(gameObject);
        }
    }
    void DespawnPlatform()
    {
        StopAllCoroutines();
        GetComponent <Renderer>().enabled = true;

        transform.DetachChildren();

        // Despawn decoration.
        if (decoration != null)
        {
            decoration.transform.position      = Vector3.zero;
            decoration.transform.localPosition = Vector3.zero;

            SimplePool.Despawn(decoration);

            decoration = null;
        }

        // Despawn itself.
        if (gameObject != null)
        {
            SimplePool.Despawn(gameObject);
            //Destroy(gameObject);
        }
    }
Beispiel #7
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "wall")
     {
         SimplePool.Despawn(this.gameObject);
     }
 }
Beispiel #8
0
        // Update is called once per frame
        void Update()
        {
            timeAlive += Time.deltaTime;

            if (DestroysSelf && timeAlive >= actualLifeSpan)
            {
                SimplePool.Despawn(gameObject);
                return;
            }

            if (AlphaFalloff == AlphaFalloff.LINEAR)
            {
                // As the particle gets older, it fades out

                float alpha = Mathf.Clamp01(1.0f - (timeAlive / actualLifeSpan));

                Color newColor = originalColor;
                newColor.a          *= alpha;
                spriteRenderer.color = newColor;
            }
            else if (AlphaFalloff == AlphaFalloff.SQRT)
            {
                // As the particle gets older, it fades out

                float alpha = Mathf.Clamp01(1.0f - (timeAlive / actualLifeSpan));

                alpha = Mathf.Sqrt(alpha);

                Color newColor = originalColor;
                newColor.a          *= alpha;
                spriteRenderer.color = newColor;
            }

            this.transform.Translate(velocity * Time.deltaTime);
        }
Beispiel #9
0
    private void Deactivate()
    {
        foreach (GameObject kvp in kvpGo)
        {
            prfInstalledItemKVPScript kvps = kvp.GetComponent <prfInstalledItemKVPScript>();
            if (ok)
            {
                item.itemParameters.SetString(kvps.k, kvps.v);
            }
            SimplePool.Despawn(kvp);
        }
        if (ok)
        {
            this.item.active        = tglActive.isOn;
            this.item.workCondition = workCondition.Length == 0 ? null : workCondition;
            if (chooseRecipeDrop.interactable && chooseRecipeDrop.options.Count > 0)
            {
                this.item.nextWorkRecipeName = availableRecipes[niceNames[chooseRecipeDrop.value].text];
            }
        }


        gameObject.SetActive(false);
        WorldController.Instance.inputController.SetInputMode(INPUT_MODE.GAME);
        WorldController.Instance.gameState = GAME_STATE.PLAY;
    }
Beispiel #10
0
    public virtual void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "AllyBullet" && transform.parent.tag == "Ennemy" && !(col.gameObject.GetComponent <BaseProjectile>().getPerforant()))          //un ennemi renvoit un projectile du joueur
        {
            col.gameObject.GetComponent <BaseProjectile> ().setDirection(-(col.gameObject.GetComponent <BaseProjectile>().Direction));
            col.gameObject.GetComponent <SpriteRenderer> ().color = Color.red;
            col.gameObject.transform.Rotate(Vector3.forward, 180f);
            col.tag = "EnnemyBullet";
        }

        if (col.tag == "EnnemyBullet" && transform.parent.tag == "Player")          //Le bouclier du joueur ne renvoit pas les projectiles mais les detruit
        {
            if (!(renvoyer))
            {
                SimplePool.Despawn(col.gameObject);
            }
            else
            {
                col.gameObject.GetComponent <BaseProjectile> ().setDirection(-(col.gameObject.GetComponent <BaseProjectile> ().Direction));
                col.gameObject.GetComponent <SpriteRenderer> ().color = Color.red;
                col.gameObject.transform.Rotate(Vector3.forward, 180f);
                col.tag = "AllyBullet";
            }
        }
    }
        public void DestroyRoom()
        {
            foreach (var go in activeTiles.Keys)
            {
                foreach (Transform child in go.transform)
                {
                    SimplePool.Despawn(child.gameObject);
                }

                SimplePool.Despawn(go);
            }

            foreach (var layerGameobject in layerGameobjects.Values)
            {
                Destroy(layerGameobject);
            }


            activeTiles        = new Dictionary <GameObject, Tile>();
            activeTilesReverse = new Dictionary <Tile, GameObject>();
            layerGameobjects   = new Dictionary <TileLayer, GameObject>();
            CurrentRoomName    = "";
            CurrentRoom        = null;
            HasActiveRoom      = false;
        }
Beispiel #12
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "plane")
     {
         SimplePool.Despawn(gameObject);
     }
 }
Beispiel #13
0
 // Update is called once per frame
 void Update()
 {
     if (transform.position.x < platformDestructionPoint.transform.position.x)
     {
         SimplePool.Despawn(gameObject);
     }
 }
Beispiel #14
0
        void MakeExplosion()
        {
            GameObject go = SimplePool.Spawn(ExplosionPrefab, _transform.position, Quaternion.identity);

            WeaponCannon wc = weapon as WeaponCannon;

            Collider2D[] colliders = new Collider2D[25];
            // TODO: could be replaced with ellipse collider
            // damage in center
            int count = Physics2D.OverlapCircleNonAlloc(_transform.position, wc.FullDamageRange, colliders);

            for (int i = 0; i < count; i++)
            {
                ITargetable t = colliders[i].GetComponent <ITargetable>();
                if (t != null)
                {
                    LeanTween.delayedCall(DamageDelay, () => t.Damage(wc.Damage));
                }
                colliders[i] = null;
            }
            // damage in full range
            count = Physics2D.OverlapCircleNonAlloc(_transform.position, wc.SplashDamageRange, colliders);
            for (int i = 0; i < count; i++)
            {
                ITargetable t = colliders[i].GetComponent <ITargetable>();
                if (t != null)
                {
                    LeanTween.delayedCall(DamageDelay, () => t.Damage((int)(wc.Damage * wc.SplashDamageFactor)));
                }
            }

            SimplePool.Despawn(gameObject);
        }
 protected virtual void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.CompareTag("Ground"))
     {
         if (bulletController != null)
         {
             bulletController.OnBulletDespawn();
         }
         if (moveTween != null)
         {
             moveTween.Kill();
         }
         SimplePool.Despawn(gameObject);
     }
     else if (coll.CompareTag(hitTag))
     {
         IActor health = coll.gameObject.GetComponent <IActor>();
         if (health != null)
         {
             health.TakeDamage(bulletDamage);
         }
         if (bulletController != null)
         {
             bulletController.OnBulletDespawn();
         }
         if (moveTween != null)
         {
             moveTween.Kill();
         }
         SimplePool.Despawn(gameObject);
     }
 }
 private void OnGameLoseHandler(object param)
 {
     if (coreManager.wood != null)
     {
         SimplePool.Despawn(coreManager.wood.gameObject);
     }
 }
Beispiel #17
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag != this.shooter.tag)
     {
         SimplePool.Despawn(this.gameObject);
     }
 }
Beispiel #18
0
    private void OnTriggerEnter2D(Collider2D collision2D)
    {
        if (collision2D.CompareTag(groudTag))
        {
            SimplePool.Despawn(gameObject);
            if (bulletControl != null)
            {
                bulletControl.OnEnableDeSpawn();
            }
            if (moveTween != null)
            {
                moveTween.Kill();
            }
        }
        if (collision2D.CompareTag(hitTag))
        {
            IActor health = collision2D.GetComponent <IActor>();
            if (health != null)
            {
                health.TakeDame(bulletDamage);
            }
            SimplePool.Despawn(gameObject);

            if (bulletControl != null)
            {
                bulletControl.OnEnableDeSpawn();
            }
            if (moveTween != null)
            {
                moveTween.Kill();
            }
        }
    }
Beispiel #19
0
    private void UpgradeTile(GameObject toDestroy, Tile destroyTile, GameObject toUpgrade, Tile upgradeTile)
    {
        Vector3 toUpgradePosition = toUpgrade.transform.position;

        tiles.Remove(toDestroy);
        tiles.Remove(toUpgrade);

        SimplePool.Despawn(toDestroy);
        SimplePool.Despawn(toUpgrade);

        // create the upgraded tile
        GameObject newTile = SimplePool.Spawn(tilePrefabs[upgradeTile.power], toUpgradePosition, transform.rotation);

        tiles.Add(newTile);
        Tile tile = newTile.GetComponent <Tile>();

        tile.upgradedThisTurn = true;

        points        += upgradeTile.value * 2;
        scoreText.text = points.ToString();

        TileAnimationHandler tileAnim = newTile.GetComponent <TileAnimationHandler>();

        tileAnim.AnimateUpgrade();
    }
Beispiel #20
0
    void onCollisionHander(Collision2D collision)
    {
        if (collision.gameObject.tag == "ground")
        {
            this.spawnmanager.game.bombMissed(this.eq);
            SimplePool.Despawn(this.gameObject);
        }
        else
        {
            if (collision.gameObject.tag == "tile")
            {
                singleTileBehaviour tile = collision.gameObject.GetComponent <singleTileBehaviour>();
                tile.OnEndDrag(null);

                if (tile.eq.answer == this.eq.answer)
                {
                    this.spawnmanager.game.bombDefused(this.eq);

                    // shot animation
                    animator.Play("balloon_splash");

                    Invoke("postSplash", 0.5f);
                }
            }
        }
    }
Beispiel #21
0
    void UpdateDragging()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }
        if (Input.GetMouseButtonDown(0))
        {
            dragStartPosition = currFramePosition;
        }

        int start_x = Mathf.FloorToInt(dragStartPosition.x);
        int end_x   = Mathf.FloorToInt(currFramePosition.x);

        if (end_x < start_x)
        {
            int tmp = end_x;
            end_x   = start_x;
            start_x = tmp;
        }

        int start_y = Mathf.FloorToInt(dragStartPosition.y);
        int end_y   = Mathf.FloorToInt(currFramePosition.y);

        if (end_y < start_y)
        {
            int tmp = end_y;
            end_y   = start_y;
            start_y = tmp;
        }

        while (dragSelectionPreviewGOs.Count > 0)
        {
            GameObject go = dragSelectionPreviewGOs [0];
            dragSelectionPreviewGOs.RemoveAt(0);
            SimplePool.Despawn(go);
        }

        if (Input.GetMouseButton(0))
        {
            for (int x = start_x; x <= end_x; x++)
            {
                for (int y = start_y; y <= end_y; y++)
                {
                    Tile t = WorldController.Instance.World.GetTileAt(x, y);
                    if (t != null)
                    {
                        GameObject go = SimplePool.Spawn(circleCursorPrefab, new Vector3(x, y, 0), Quaternion.identity);
                        go.transform.SetParent(this.transform, true);
                        dragSelectionPreviewGOs.Add(go);
                    }
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            GameObject.FindObjectOfType <BuildModeController> ().DoBuild(start_x, start_y, end_x, end_y);
        }
    }
Beispiel #22
0
    /// <summary>
    /// 砍伐树木任务
    /// </summary>
    /// <param name="go"></param>
    /// <param name="position"></param>
    public void FellingTreeTask(GameObject go, Vector3 position)
    {
        var info = GameData.Instance.rawmaterialWorkloadDic[MenuType.Felling];

        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(currentWorkload);

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

                        PlayerController.Instance.PlayMining(true);

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

                            GameObject newGo = SimplePool.Spawn(ResourcesManager.LoadPrefab("Prefabs/Log"), 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();

                            // Destroy(currentTask.PrefabGame.transform.parent.gameObject);

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

        if (result)
        {
            SimplePool.Despawn(go);
        }
    }
Beispiel #23
0
    public void MineBlock(Int2 pos, float power)
    {
        Tile block = WorldManager.currentWorld.GetTile(0, pos.x, pos.y);

        if (block.ID == 0)
        {
            return;
        }
        if (!tileHealths.ContainsKey(pos))
        {
            TileBreakManager tileBreak = SimplePool.Spawn(tileBreakPrefab, new Vector3(pos.x, pos.y, -30), Quaternion.identity).GetComponent <TileBreakManager>();
            tileBreak.maxHealth     = ItemDatabase.GetBlock(block).health;
            tileBreak.currentHealth = ItemDatabase.GetBlock(block).health;
            tileBreak.offset        = block.Info;

            tileHealths.Add(pos, tileBreak);
        }
        tileHealths[pos].currentHealth -= power;
        if (tileHealths[pos].currentHealth <= 0)
        {
            GameManager.Get <WorldManager>().DeleteBlock(pos);
            SimplePool.Despawn(tileHealths[pos].gameObject);
            tileHealths.Remove(pos);
        }
    }
Beispiel #24
0
    // Update is called once per frame
    void Update()
    {
        LifeTime += Time.deltaTime;

        if (LifeTime > RandomLifeTime && false == SubParticle)
        {
            SimplePool.Despawn(this.gameObject);
            return;
        }

        if (AlphaFallOff != AlphaTypes.NONE)
        {
            if (AlphaFallOff == AlphaTypes.LINEAR)
            {
                Alpha = Mathf.Clamp01(1.0f - (LifeTime / RandomLifeTime));
            }

            if (AlphaFallOff == AlphaTypes.SQRT)
            {
                Alpha = Mathf.Sqrt(Alpha);
            }

            Color newColor = StartingColor;
            newColor.a          *= Alpha;
            spriteRenderer.color = newColor;
        }

        this.transform.Translate(Velocity * Time.deltaTime);
    }
    protected override void onFire(Vector2 direction)
    {
        ready  = false;
        active = true;

        sfx.Play();

        GameObject spawnedOverlay = SimplePool.Spawn(FogOverlay, Vector2.zero);
        Material   FogMat         = spawnedOverlay.GetComponent <MeshRenderer>().material;
        float      baseRangeMin   = FogMat.GetFloat(Tags.ShaderParams.rangeMin);
        float      baseRangeMax   = FogMat.GetFloat(Tags.ShaderParams.rangeMax);

        StartCoroutine(UpdateVisibility(FogMat));

        Callback.DoLerp((float l) =>
        {
            FogMat.SetFloat(Tags.ShaderParams.rangeMin, baseRangeMin * Mathf.Pow(100, l));
            FogMat.SetFloat(Tags.ShaderParams.rangeMax, baseRangeMax * Mathf.Pow(100, l));
        }, easeTime, this, reverse: true);

        Callback.FireAndForget(() => Callback.DoLerp((float l) =>
        {
            FogMat.SetFloat(Tags.ShaderParams.rangeMin, baseRangeMin * Mathf.Pow(100, l));
            FogMat.SetFloat(Tags.ShaderParams.rangeMax, baseRangeMax * Mathf.Pow(100, l));
        }, easeTime, this).FollowedBy(() =>
        {
            FogMat.SetFloat(Tags.ShaderParams.rangeMin, baseRangeMin);
            FogMat.SetFloat(Tags.ShaderParams.rangeMax, baseRangeMax);
            active = false;
            SimplePool.Despawn(spawnedOverlay);
        }, this), duration, this);
    }
Beispiel #26
0
 private void OnDisable()
 {
     for (int i = 0; i < numHighlights; i++)
     {
         SimplePool.Despawn(tileHighlights[i]);
     }
 }
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("Something hit an enemy4".Colored(Colors.navy));
        Projectile playerBullet = other.gameObject.GetComponent <Projectile>();

        if (playerBullet)
        {
            health -= playerBullet.GetDamage();
            playerBullet.Hit();
            Debug.Log(gameObject.name.Colored(Colors.red).Bold() + " Enemy hit!".Bold().Colored(Colors.red));
            // BEE: if formation = 50 points, diving == 100
            if (isNotInFormation)
            {
                scoreKeeper.Score(100);
            }
            else
            {
                scoreKeeper.Score(50);
            }

            if (health <= 0)
            {
                top    = base.addShotSounds(explosionTop[GalagaHelper.RandomNumber(0, explosionTop.Length)], Random.Range(0.8f, 1.2f));
                bottom = base.addShotSounds(explosionBottom, Random.Range(0.8f, 1.2f));
                top.PlayScheduled(0.3);
                bottom.Play();
                //rend.enabled = false;
                //meshcol.enabled = false;
                GameObject explosionPrefab = Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation) as GameObject;
                Destroy(explosionPrefab, 3.0f);
                //Debug.Log("Enemy1 killed: " + gameObject.name.Colored(Colors.blue) + " Parent: " + gameObject.transform.parent.parent.name.Colored(Colors.blue) + " Position: " + gameObject.transform.parent.name.Colored(Colors.blue));
                this.isEnemyFiring = false;
                DisableEnemy();
                //Invoke("DisableEnemy", spawnDisableTime);
                GalagaHelper.EnemiesKilled += 1;
                if (base.isRandomPicked == true)
                {
                    isRandomPicked    = false;
                    main.isEnemy1Done = true;
                }
                iTween onTween = gameObject.GetComponent <iTween>();
                if (onTween)
                {
                    if (onTween.isRunning)
                    {
                        Debug.Log("Enemy4 Killed during Itween".Colored(Colors.red).Bold());
                        GalagaHelper.isScorpionAttackOn = false;
                        //onTween.isRunning = false;
                        //GalagaHelper.EnemiesSpawned += 1;
                    }
                }
                //if (startScorpionAttack)
                //{
                //    startScorpionAttack = false;
                //}
                SimplePool.Despawn(gameObject);
            }
        }
    }
Beispiel #28
0
 public virtual void OnEnableDeSpawn()
 {
     currentBulletQuantity--;
     if (currentBulletQuantity <= 0)
     {
         SimplePool.Despawn(gameObject);
     }
 }
Beispiel #29
0
 public void DespawnObject(GameObject obj)
 {
     if (SpawnedObjects.Contains(obj))
     {
         SpawnedObjects.Remove(obj);
     }
     SimplePool.Despawn(obj);
 }
Beispiel #30
0
 void clearHitVisuals()
 {
     for (int i = 0; i < hitVisuals.Count; i++)
     {
         SimplePool.Despawn(hitVisuals[i]);
     }
     hitVisuals.Clear();
 }