Esempio n. 1
0
    public override void Explode()
    {
        if (this.m_triggered)
        {
            return;
        }
        this.m_triggered = true;
        Collider[] array = Physics.OverlapSphere(base.transform.position, this.m_explosionRadius);
        foreach (Collider collider in array)
        {
            GameObject gameObject = base.FindParentWithRigidBody(collider.gameObject);
            if (gameObject != null)
            {
                int num = base.CountChildColliders(gameObject, 0);
                base.AddExplosionForce(gameObject, 1f / (float)num);
            }
            TNT component = collider.GetComponent <TNT>();
            if (component && !(component is AlienTNT))
            {
                component.Explode();
            }
        }
        Singleton <AudioManager> .Instance.SpawnOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.tntExplosion, base.transform.position);

        WPFMonoBehaviour.effectManager.CreateParticles(this.smokeCloud, base.transform.position - Vector3.forward * 5f, true);
        if (this.extraEffect)
        {
            WPFMonoBehaviour.effectManager.CreateParticles(this.extraEffect, base.transform.position - Vector3.forward * 4f, true);
        }
        base.CheckForTNTAchievement();
        base.StartCoroutine(this.ShineLight());
    }
Esempio n. 2
0
    private void HandleBoomJump()
    {
        Movement();
        if (canJump)
        {
            canJump = !canJump;
            OnPlayerJump?.Invoke(canJump);
            ExplosionAnimator.SetBool("isTriggered", true);
            // Trigger Explosion Sound Here
            BoomJumpSource.Play();
            RB.velocity = new Vector2(RB.velocity.x, 0);
            RB.AddForce(Vector2.up * explosiveForce, ForceMode2D.Impulse);
            // Damage player
            DamagePlayer(explosiveDamage);
        }

        Collider2D[] cols = Physics2D.OverlapCapsuleAll(ExplosionCollider.bounds.center, ExplosionCollider.size, CapsuleDirection2D.Horizontal, 0);
        foreach (Collider2D col in cols)
        {
            if (col.GetComponent <TNT>() != null)
            {
                TNT tnt = col.GetComponent <TNT>();
                tnt.Detonate(true);
            }
        }


        if (PlayerAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1)
        {
            if (!grounded)
            {
                SetState(PlayerStates.IN_AIR);
            }
        }
    }
Esempio n. 3
0
            private IEnumerator ExplosionWait(TNT ignoreSender)
            {
                yield return(new WaitForSeconds(0.1f));

                Collider[] hits = Physics.OverlapSphere(transform.position, explosionRadius, -1);
                for (int i = hits.Length - 1; i > 0; i--)
                {
                    if (hits[i].TryGetComponent(out Rigidbody rb))
                    {
                        //rb.AddExplosionForce(explosionForceMultiplier, transform.position, explosionRadius);
                        var target    = hits[i].transform.position;
                        var direction = (target - transform.position).normalized;
                        rb.AddForce(
                            direction * CalculateExplosionForce(explosionRadius, target) * explosionForceMultiplier,
                            ForceMode.Impulse);
                    }

                    TNT otherTnt = hits[i].GetComponent <TNT>();
                    if (otherTnt != null && otherTnt != this) // otherTnt != this, so it doesnt try to explode its self
                    {
                        if (otherTnt != ignoreSender)
                        {
                            otherTnt.ExplosionWithIgnore(this);
                        }
                    }
                }

                OnExplosion?.Invoke();
            }
Esempio n. 4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Bird bird = collision.collider.GetComponent <Bird>();

        float collisionForce = collision.GetImpactForce();

        if (collisionForce >= 800f)
        {
            if (bird != null)
            {
                Destroy(gameObject);
                explode();
                return;
            }

            TNT tnt = collision.collider.GetComponent <TNT>();
            if (tnt != null)
            {
                return;
            }

            if (collision.contacts[0].normal.y < -0.5)
            {
                Destroy(gameObject);
            }
        }
    }
Esempio n. 5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // if player is within the trigger volume, apply force and damage
        if (collision.GetComponent <CustomPlayerController>() != null)
        {
            CustomPlayerController player = collision.GetComponent <CustomPlayerController>();
            if (player.RB != null)
            {
                Vector2 dir = new Vector2(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y).normalized;

                player.RB.AddForce(dir * explosionForce, ForceMode2D.Impulse);
                player.DamagePlayer(damage);
            }
        }

        if (collision.GetComponent <TNT>() != null)
        {
            TNT tnt = collision.GetComponent <TNT>();

            if (tnt != null && !tnt.hasExploded)
            {
                //tnt.Detonate(true);
                tnt.StartTimer();
            }
        }
    }
Esempio n. 6
0
    public void Explode()
    {
        if (!this.m_triggered)
        {
            this.m_triggered = true;
            Collider[] array = Physics.OverlapSphere(base.transform.position, this.m_explosionRadius);
            foreach (Collider collider in array)
            {
                GameObject gameObject = this.FindParentWithRigidBody(collider.gameObject);
                if (gameObject != null)
                {
                    int num = this.CountChildColliders(gameObject, 0);
                    this.AddExplosionForce(gameObject, 1f / (float)num);
                }
                TNT component = collider.GetComponent <TNT>();
                if (component)
                {
                    component.Explode();
                }
            }
            WPFMonoBehaviour.effectManager.CreateParticles(this.m_smokeCloud, base.transform.position - Vector3.forward * 12f, true);
            Singleton <AudioManager> .Instance.SpawnOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.tntExplosion, base.transform.position);

            base.StartCoroutine(this.ShineLight());
            if (this.OnExplosion != null)
            {
                this.OnExplosion();
            }
        }
    }
Esempio n. 7
0
    void Start()
    {
        bomb    = GameObject.Find("Bomb").GetComponent <TNT>();
        player  = GameObject.Find("Player").GetComponent <Rigidbody> ();
        trigger = GameObject.Find("TrueFalseTrigger").GetComponent <TrueFalse> ();
        camera1 = GameObject.Find("Character/PlayerCam").GetComponent <Camera>();
        camera2 = GameObject.Find("MainCamera1").GetComponent <Camera>();
        camera3 = GameObject.Find("MainCamera2").GetComponent <Camera>();

        camera2.enabled = false;
        camera3.enabled = false;
    }
 private void DestroySingletons()
 {
     TNT.DestroySingleton();
     GameTimer.DestroySingleton();
     Keypad.DestroySingleton();
     KeypadPuzzle.DestroySingleton();
     GameTimer.DestroySingleton();
     Hints.DestroySingleton();
     TextManager.DestroySingleton();
     CommandConsole.DestroySingleton();
     ThoughtsManager.DestroySingleton();
 }
Esempio n. 9
0
 void Start()
 {
     bomb            = GameObject.Find("Bomb").GetComponent <TNT>();
     player          = GameObject.Find("Player").GetComponent <Rigidbody> ();
     trigger         = GameObject.Find("TrueFalseTrigger").GetComponent <TrueFalse> ();
     camera1         = GameObject.Find("Character/PlayerCam").GetComponent <Camera>();
     camera2         = GameObject.Find("MainCamera1").GetComponent <Camera>();
     camera3         = GameObject.Find("MainCamera2").GetComponent <Camera>();
     oculus          = GameObject.Find("Player/Character/OVRCameraController");
     isOculus        = GameObject.Find("Player/Character/OVRCameraController").activeInHierarchy;
     camera2.enabled = false;
     camera3.enabled = false;
 }
Esempio n. 10
0
    /// <summary>
    /// tnt 생성 함수
    /// </summary>
    /// <param name="filePath">생성할 오브젝트 파일 경로</param>
    /// <param name="generatePos">생성 지점</param>
    /// <param name="attacker">공격자 정보</param>
    /// <returns></returns>
    public TNT Generate(string filePath, Vector3 generatePos, Actor attacker)
    {
        GameObject go = GameManager.Instance.GetCurrentSceneManager <InGameSceneManager>().TntCacheManager.Archive(filePath, generatePos);

        // 반환받은 객체가 있는 경우 초기화
        if (go != null)
        {
            TNT newTnt = go.GetComponent <TNT>();
            if (newTnt != null)
            {
                // 데미지 세팅
                BuffData buffData = GameManager.Instance.BuffManager.GetBuffData(WeaponStyle.TNT, BuffType.TntDamage);
                // 레벨을 올렸는지 검사
                if (buffData.currentLevel > 0)
                {
                    Debug.Log("newTnt.OriginValue: " + newTnt.OriginValue);
                    float factor = buffData.currentValue * 0.01f;
                    int   value  = (int)(newTnt.OriginValue * factor);
                    newTnt.Value  = newTnt.OriginValue;
                    newTnt.Value += value;
                }

                // 범위 세팅
                buffData = GameManager.Instance.BuffManager.GetBuffData(WeaponStyle.TNT, BuffType.TntRange);
                // 레벨을 올렸는지 검사
                if (buffData.currentLevel > 0)
                {
                    Debug.Log("newTnt.OriginRange: " + newTnt.OriginRange);
                    float factor = buffData.currentValue * 0.01f;
                    float value  = newTnt.OriginRange * factor;
                    newTnt.Range  = newTnt.OriginRange;
                    newTnt.Range += value;
                }

                // 파일 경로 및 공격자 설정
                newTnt.FilePath = filePath;
                newTnt.attacker = attacker;
            }

            return(newTnt);
        }
        else
        {
            // 반환받을 객체가 없는 경우 추가 생성
            GameManager.Instance.GetCurrentSceneManager <InGameSceneManager>().TntCacheManager.Generate(filePath, Load(filePath), CacheManager.DEFAUT_CACHE_COUNT, transform);
            Generate(filePath, generatePos, attacker);
        }

        return(null);
    }
Esempio n. 11
0
    public virtual void Explode()
    {
        if (!this.m_triggered)
        {
            this.m_triggered = true;
            base.contraption.ChangeOneShotPartAmount(this.m_partType, this.EffectDirection(), -1);
            Collider[] array = Physics.OverlapSphere(base.transform.position, this.m_explosionRadius);
            foreach (Collider collider in array)
            {
                GameObject gameObject = this.FindParentWithRigidBody(collider.gameObject);
                if (gameObject != null)
                {
                    int num = this.CountChildColliders(gameObject, 0);
                    this.AddExplosionForce(gameObject, 1f / (float)num);
                }
                TNT component = collider.GetComponent <TNT>();
                if (component && !(component is AlienTNT))
                {
                    component.Explode();
                }
            }
            Singleton <AudioManager> .Instance.SpawnOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.tntExplosion, base.transform.position);

            WPFMonoBehaviour.effectManager.CreateParticles(this.smokeCloud, base.transform.position - Vector3.forward * 5f, true);
            if (this.extraEffect)
            {
                WPFMonoBehaviour.effectManager.CreateParticles(this.extraEffect, base.transform.position - Vector3.forward * 4f, true);
            }
            this.CheckForTNTAchievement();
            base.contraption.RemovePart(this);
            List <Joint> list = base.contraption.FindPartFixedJoints(this);
            if (list.Count > 0)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    bool flag  = list[j].gameObject == this || list[j].connectedBody == this;
                    bool flag2 = float.IsInfinity(list[j].breakForce);
                    if (!flag2 || flag)
                    {
                        UnityEngine.Object.Destroy(list[j]);
                    }
                }
                base.HandleJointBreak(float.MaxValue, true);
            }
            base.StartCoroutine(this.ShineLight());
        }
    }
Esempio n. 12
0
 public static void DestroySingleton()
 {
     _instance = null;
     Instance  = null;
 }
Esempio n. 13
0
 private void Awake()
 {
     _instance = this;
 }
Esempio n. 14
0
 public void ExplosionWithIgnore(TNT _tnt)
 {
     StartCoroutine(ExplosionWait(_tnt));
 }
Esempio n. 15
0
        public Tile[,] ReadLevel(int levelNumber)
        {
            char[,] chars = LevelData.GetLevel(levelNumber);
            tiles         = new Tile[LevelData.Level_height, LevelData.Level_width];

            for (int y = 0; y < tiles.GetLength(0); y++)
            {
                for (int x = 0; x < tiles.GetLength(1); x++)
                {
                    switch (chars[y, x])
                    {
                    case 'R':
                        Rockford r = new Rockford(Game);
                        Game.Rockford = r;
                        tiles[y, x]   = new Tile(new Empty(r));
                        tiles[y, x].StaticObject.moveableObject          = Game.Rockford;
                        tiles[y, x].StaticObject.moveableObject.Location = tiles[y, x];
                        break;

                    case 'M':
                        tiles[y, x] = new Tile(new Mud(null));
                        break;

                    case 'B':
                        Boulder b = new Boulder(Game);
                        tiles[y, x] = new Tile(new Empty(b));
                        tiles[y, x].StaticObject.moveableObject.Location = tiles[y, x];
                        Game.moveableObjects.Add(b);
                        break;

                    case 'D':
                        Diamond d = new Diamond(Game);
                        tiles[y, x] = new Tile(new Empty(d));
                        tiles[y, x].StaticObject.moveableObject.Location = tiles[y, x];
                        Game.moveableObjects.Add(d);
                        break;

                    case 'W':
                        tiles[y, x] = new Tile(new Wall(null));
                        break;

                    case 'S':
                        tiles[y, x] = new Tile(new SteelWall(null));
                        break;

                    case 'F':
                        Firefly f = new Firefly(Game);
                        tiles[y, x] = new Tile(new Empty(f));
                        tiles[y, x].StaticObject.moveableObject.Location = tiles[y, x];
                        Game.moveableObjects.Add(f);
                        break;

                    case 'E':
                        Exit ex = new Exit(null);
                        Game.Exit          = ex;
                        tiles[y, x]        = new Tile(ex);
                        Game.Exit.Location = tiles[y, x];
                        break;

                    case 'H':
                        HardenedMud h = new HardenedMud(Game);
                        tiles[y, x] = new Tile(new Empty(h));
                        tiles[y, x].StaticObject.moveableObject.Location = tiles[y, x];
                        Game.moveableObjects.Add(h);
                        break;

                    case 'T':
                        TNT e = new TNT(Game);
                        tiles[y, x] = new Tile(new Empty(e));
                        tiles[y, x].StaticObject.moveableObject.Location = tiles[y, x];
                        Game.moveableObjects.Add(e);
                        break;

                    case ' ':
                        tiles[y, x] = new Tile(new Empty(null));
                        break;

                    default:
                        Console.WriteLine("Unknown tile at y: " + y + " x: " + x);
                        break;
                    }
                }
            }
            CreateLinks(tiles);
            return(tiles);
        }
Esempio n. 16
0
        private Tile generateTiles(char[,] lBoard)
        {
            Tile firstTile = null;

            for (int height = 0; height < LevelData.Level_height; height++)
            {
                bool firstOfRow = true;

                for (int width = 0; width < LevelData.Level_width; width++)
                {
                    char tile = lBoard[height, width];
                    Tile newTile;

                    switch (tile)
                    {
                    case 'R':
                        Player player = new Player();
                        newTile = new Floor(_Model, player);
                        player.CurrentLocation = (Floor)newTile;
                        _Controller.SetPlayer(player);
                        break;

                    case 'M':
                        Mud mud = new Mud();
                        newTile             = new Floor(_Model, mud);
                        mud.CurrentLocation = (Floor)newTile;
                        break;

                    case 'B':
                        Boulder boulder = new Boulder();
                        newTile = new Floor(_Model, boulder);
                        boulder.CurrentLocation = (Floor)newTile;
                        break;

                    case 'D':
                        Diamond diamond = new Diamond();
                        newTile = new Floor(_Model, diamond);
                        diamond.CurrentLocation = (Floor)newTile;
                        _Model.AddDiamond();
                        break;

                    case 'W':
                        Wall wall = new Wall();
                        newTile = new Floor(_Model, wall);
                        wall.CurrentLocation = (Floor)newTile;
                        break;

                    case 'S':
                        newTile = new SteelWall();
                        break;

                    case 'F':
                        FireFly fireFly = new FireFly();
                        newTile = new Floor(_Model, fireFly);
                        fireFly.CurrentLocation = (Floor)newTile;
                        _Model.AddFireFly(fireFly);
                        break;

                    case 'E':
                        Exit e = new Exit(_Model);
                        _Model.AddExit(e);
                        newTile = e;
                        break;

                    case 'H':
                        HardenedMud hardenedMud = new HardenedMud();
                        newTile = new Floor(_Model, hardenedMud);
                        hardenedMud.CurrentLocation = (Floor)newTile;
                        break;

                    case 'T':
                        TNT tnt = new TNT();
                        newTile             = new Floor(_Model, tnt);
                        tnt.CurrentLocation = (Floor)newTile;
                        break;

                    default:
                        newTile = new Floor(_Model);
                        break;
                    }

                    if (firstTile != null)
                    {
                        if (firstOfRow)
                        {
                            firstTile.SetTile(newTile, Direction.DOWN);
                            firstOfRow = false;
                        }
                        else
                        {
                            firstTile.SetTile(newTile, Direction.RIGHT);
                        }
                    }
                    else
                    {
                        firstTile  = newTile;
                        firstOfRow = false;
                    }
                }
            }

            return(firstTile);
        }