예제 #1
0
 void _Despawn()
 {
     if (explosionObject != null)
     {
         PoolingSystem.Despawn(explosionObject);
     }
 }
예제 #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (falling)
        {
            parachute.gameObject.SetActive(false);
            falling = false;
        }

        TankController controller = collision.gameObject.GetComponent <TankController>();

        if (controller != null)
        {
            controller.currentWeapon.superWeaponType = type;
            if (collision.gameObject.CompareTag("TankPlayer"))
            {
                TurnController.INSTANCE.SuperWeaponButton_SetActive(true);
                TreasureBoxSpawner.PickLeftTreasure();
            }
            else
            {
                TreasureBoxSpawner.PickRightTreasure();
            }

            PoolingSystem.Despawn(gameObject);
        }
    }
예제 #3
0
 void DespawnIfNotHitAnything()
 {
     if (gameObject.activeSelf)
     {
         PoolingSystem.Despawn(gameObject);
     }
 }
예제 #4
0
    public override void OnCollisionEnter2D(Collision2D collision)
    {
        explosionObject = PoolingSystem.Spawn(explosionPrefab, transform.position);
        DespawnExplosionAfterDelay(2f);
        CheckForEnemiesAndDealDamage();

        PoolingSystem.Despawn(gameObject);
    }
예제 #5
0
    void FireworkExplode()
    {
        explosionObject = PoolingSystem.Spawn(explosionPrefab, transform.position);
        DespawnExplosionAfterDelay(4f);
        AudioController.INSTANCE.PlayAudio(AudioClipType.FIREWORK);

        PoolingSystem.Despawn(gameObject);
    }
예제 #6
0
 public override void OnCollisionEnter2D(Collision2D collision)
 {
     base.OnCollisionEnter2D(collision);
     if (lineObject != null && xMarkObject != null)
     {
         PoolingSystem.Despawn(lineObject);
         PoolingSystem.Despawn(xMarkObject);
     }
 }
        void OnTriggerEnter2D(Collider2D collision)
        {
            if (collision.CompareTag(Tags.Destroyer))
            {
                _poolSystem.Despawn(PooledObjectStats, transform);
            }

            if (collision.CompareTag(Tags.Ground) || collision.CompareTag(Tags.Wall))
            {
                if (_isIllusion)
                {
                    _isIllusion = false;
                    _poolSystem.Despawn(PooledObjectStats, transform);
                }
                else
                {
                    MakeItStuck();
                }
            }
        }
예제 #8
0
    public override void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.GetComponent <BananaEmitter>() == null)
        {
            explosionObject = PoolingSystem.Spawn(explosionPrefab, transform.position);
            CheckForEnemiesAndDealDamage();
            DespawnExplosionAfterDelay(2f);

            PoolingSystem.Despawn(gameObject);
        }
    }
예제 #9
0
    public override void OnCollisionEnter2D(Collision2D collision)
    {
        explosions[countOfHits] = PoolingSystem.Spawn(explosionPrefab, transform.position);

        DespawnExplosionAfterDelay(2f);
        countOfHits++;

        CheckForEnemiesAndDealDamage();
        if (countOfHits == MAX_COUNT_OF_HITS - 1)
        {
            PoolingSystem.Despawn(gameObject);
        }
    }
예제 #10
0
 private void _Despawn()
 {
     PoolingSystem.Despawn(gameObject);
     ScreenOpacity.INSTANCE.MakeSmoothNormal(2f);
 }
예제 #11
0
    /// <summary>
    /// updates info when the mouse is dragging to call functions to place Objects and update TileTypes
    /// </summary>
    void UpdateTileDrag()
    {
        //stop if moving existing Objects
        if (isMoving)
        {
            return;
        }
        //stop if over UI
        if (EventSystem.current.IsPointerOverGameObject() && !isDragging)
        {
            return;
        }
        //start drag
        if (Input.GetMouseButtonDown(0))           //left mouse button
        {
            dragStartPos = currFramePos;
            isDragging   = true;
        }
        //x vars
        float start_x = dragStartPos.x;
        float end_x   = currFramePos.x;

        if (end_x < start_x)
        {
            float temp = end_x;
            end_x   = start_x;
            start_x = temp;
        }
        //y vars
        float start_y = dragStartPos.z;
        float end_y   = currFramePos.z;

        if (end_y < start_y)
        {
            float temp = end_y;
            end_y   = start_y;
            start_y = temp;
        }
        //remove old drag previews
        while (dragPreviews.Count > 0)
        {
            GameObject go = dragPreviews[0];
            dragPreviews.RemoveAt(0);
            PoolingSystem.Despawn(go);
        }
        //display a preview of the drag area
        Quaternion rot = Quaternion.identity;

        rot.eulerAngles = new Vector3(90f, 0f, 0f);
        if (bmc.isTileBuildingMode == false)
        {
            if (bmc.RotLevel % 2 == 0)
            {
                end_y = start_y;
            }
            else if (bmc.RotLevel % 2 == 1)
            {
                end_x = start_x;
            }
        }
        if (Input.GetMouseButton(0))        //left mouse button
        {
            for (int x = Mathf.RoundToInt(start_x); x <= Mathf.RoundToInt(end_x); x++)
            {
                for (int y = Mathf.RoundToInt(start_y); y <= Mathf.RoundToInt(end_y); y++)
                {
                    Tile t = WorldController.Instance.World.GetTileAt(x, y, bmc.ActiveFloor);
                    if (t != null)
                    {
                        //display the building hint on top of the tile pos
                        GameObject go = PoolingSystem.Spawn(cursorPrefab, new Vector3(x, 2.75f * bmc.ActiveFloor, y), rot);
                        go.transform.SetParent(dragPreviewParent.transform, true);
                        dragPreviews.Add(go);
                    }
                }
            }
        }
        //end drag
        if (Input.GetMouseButtonUp(0))           //left mouse button
        {
            if (bmc.isTileBuildingMode == true)
            {
                bmc.BuildTile(Mathf.RoundToInt(start_x), Mathf.RoundToInt(end_x), Mathf.RoundToInt(start_y), Mathf.RoundToInt(end_y));
            }
            else
            {
                bmc.BuildObject(start_x, end_x, start_y, end_y);
            }
            isDragging = false;
        }
    }
예제 #12
0
 /// <summary>
 /// updates whether the user is moving objects
 /// </summary>
 void UpdateObjectMovement()
 {
     //stop if dragging out new Objects
     if (isDragging)
     {
         return;
     }
     //stop if over UI
     if (EventSystem.current.IsPointerOverGameObject() && !isMoving)
     {
         return;
     }
     //attempt to find object
     if (Input.GetMouseButtonDown(1) && !isMoving)           //right mouse button
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 100))
         {
             Debug.Log(hit.transform.name);
             if (hit.transform.tag == "Object")
             {
                 currSelectedGameObj    = hit.transform.gameObject;
                 bmc.RotLevel           = 0;
                 prevCurrSelectedObjRot = (int)currSelectedGameObj.transform.rotation.eulerAngles.y / 90;
                 do
                 {
                     currSelectedGameObj = currSelectedGameObj.transform.parent.gameObject;
                 } while(currSelectedGameObj.transform.IsChildOf(oc.objParent[bmc.ActiveFloor].transform) == false);
                 if (oc.objGameObjMap.ContainsValue(currSelectedGameObj))
                 {
                     foreach (GameObject go in buttonToggles)
                     {
                         if (go.activeSelf)
                         {
                             PoolingSystem.Despawn(go);
                         }
                     }
                     Renderer[] renderers = currSelectedGameObj.GetComponentsInChildren <Renderer> ();
                     for (int i = 0; i < renderers.Length; i++)
                     {
                         GameObject go = PoolingSystem.Spawn(buttonPrefab, new Vector3(35f, 584.5f - (30f * i), 0f), Quaternion.identity);
                         go.transform.SetParent(buttonToggleParent.transform, true);
                         buttonToggles.Add(go);
                         go.transform.GetChild(0).GetComponent <ToggleColorState>().SetActive();
                         go.transform.GetChild(0).GetComponent <ToggleColorState>().SetConnectedObj(renderers[i].gameObject);
                     }
                 }
             }
             else if (hit.transform.tag == "Tile")
             {
                 GameObject hitObj = hit.transform.gameObject;
                 if (tc.tileGameObjMap.ContainsValue(hitObj))
                 {
                     if (tc.tileGameObjMap.Keys.ToArray()[tc.tileGameObjMap.Values.ToList().IndexOf(hitObj)].Type != TileType.Empty || tc.tileGameObjMap.Keys.ToArray()[oc.objGameObjMap.Values.ToList().IndexOf(currSelectedGameObj)].Type != TileType.Grid)
                     {
                         currSelectedTileGameObj = hitObj;
                         foreach (GameObject go in buttonToggles)
                         {
                             if (go.activeSelf)
                             {
                                 PoolingSystem.Despawn(go);
                             }
                         }
                     }
                     Renderer[] renderers = hitObj.GetComponents <SpriteRenderer> ();
                     for (int i = 0; i < renderers.Length; i++)
                     {
                         GameObject go = PoolingSystem.Spawn(buttonPrefab, new Vector3(35f, 584.5f - (30f * i), 0f), Quaternion.identity);
                         go.transform.SetParent(buttonToggleParent.transform, true);
                         buttonToggles.Add(go);
                         go.transform.GetChild(0).GetComponent <ToggleColorState>().SetActive();
                         go.transform.GetChild(0).GetComponent <ToggleColorState>().SetConnectedObj(renderers[i].gameObject);
                     }
                 }
             }
         }
         if (currSelectedGameObj != null)
         {
             oc.prevRotLevel = (int)(currSelectedGameObj.transform.rotation.eulerAngles.y / 90);
             oc.prevDiffPos  = new Vector3(0, 0, 0);
         }
         isMoving = true;
     }
     //move objects
     if (currSelectedGameObj != null)
     {
         if (oc.objGameObjMap.ContainsValue(currSelectedGameObj))
         {
             currSelectedObj = oc.objGameObjMap.Keys.ToArray()[oc.objGameObjMap.Values.ToList().IndexOf(currSelectedGameObj)];
             int rot = currSelectedObj.GetRotLevel();
             if (rot != prevCurrSelectedObjRot + bmc.RotLevel)
             {
                 rot += bmc.RotLevel;
             }
             Object.MoveObject(currSelectedObj, currFramePos, rot);
         }
         else
         {
             Debug.Log("UpdateObjectMovement: The objGameObjMap does not contain the current selected object!");
         }
     }
     //place Object
     if (Input.GetMouseButtonUp(0))           //left mouse button
     {
         if (currSelectedObj != null)
         {
             currSelectedObj.UpdateNeighbors(currSelectedObj);
         }
         currSelectedGameObj = null;
         isMoving            = false;
     }
 }
예제 #13
0
 private void _DespawnFireEffectObjectAfterDelay()
 {
     PoolingSystem.Despawn(fireEffectObject);
 }
예제 #14
0
    public void ExecutePoison()
    {
        tank.RecieveDamage(poisonDamage);
        poisonHitObject = PoolingSystem.Spawn(PoolManager.INSTANCE.poisonHitPrefab, tank.transform.position);

        // despawn object in delay using Tween
        poisonedObject.transform.DOShakePosition(0.01f, 0, 0, 0).SetDelay(3f).OnComplete(() => PoolingSystem.Despawn(poisonHitObject));
        poisonTurnsLeft--;

        if (poisonTurnsLeft == 0)
        {
            Vector3 pos = tank.transform.position;
            pos.y += 0.2f;
            pos.x -= 1.5f;

            var text = PoolingSystem.Spawn(PoolManager.INSTANCE.GetDamageTextPrefab(), pos);
            text.GetComponent <DamageText>().SetEffect("-POISONED");

            DamageOverTurn.poisonToDelete = this;
        }
    }
예제 #15
0
 private void _Despawn()
 {
     PoolingSystem.Despawn(gameObject);
 }
예제 #16
0
 private void Despawn()
 {
     PoolingSystem.Despawn(explosions[explosionToDestroy]);
     explosionToDestroy++;
 }
예제 #17
0
 void DespawnCurrObjectAndExplosion()
 {
     PoolingSystem.Despawn(gameObject);
     PoolingSystem.Despawn(hitEffect);
 }