Example #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        _tree   = collision.gameObject.GetComponent <Treead>();
        _golire = collision.gameObject.GetComponent <Golire>();
        _anger  = collision.gameObject.GetComponent <Anger>();
        _breeze = collision.gameObject.GetComponent <Breeze>();

        if (collision.gameObject.layer == 13 || collision.gameObject.layer == 14)
        {
            if (collision.gameObject.name == "Treead" || collision.gameObject.name == "Treead(Clone)")
            {
                if (this.transform.position.x > _tree.transform.position.x)
                {
                    _tree.transform.Translate(new Vector2(-2, 0));
                }
                if (this.transform.position.x < _tree.transform.position.x)
                {
                    _tree.transform.Translate(new Vector2(2, 0));
                }
                _tree._burnTime = 0f;
            }
            if (collision.gameObject.name == "Golire" || collision.gameObject.name == "Golire(Clone)")
            {
                Debug.Log("You'r not burning anymore!");
                _golire.extinguished = true;
            }
            if (collision.gameObject.name == "Breeze" || collision.gameObject.name == "Breeze(Clone)")
            {
                _breeze.Damage(30);
            }
        }
        if (collision.gameObject.layer == 14)
        {
            if (collision.gameObject.name == "Anger")
            {
                _anger.Damage(30);
                _anger._canRegen = false;
            }
        }

        if (collision.gameObject.layer == 12)
        {
            Destroy(collision.gameObject);
        }

        Destroy(this.gameObject);

        _windParticle.Play();
        _windParticle.transform.parent = null;
        Destroy(_windParticle, 3.0f);
    }
Example #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        _tree   = collision.gameObject.GetComponent <Treead>();
        _golire = collision.gameObject.GetComponent <Golire>();
        _breeze = collision.gameObject.GetComponent <Breeze>();
        _anger  = collision.gameObject.GetComponent <Anger>();
        _player = collision.gameObject.GetComponent <PlayerStats>();
        _shaker = collision.gameObject.GetComponent <Shake>();


        if (collision.gameObject.layer == 13 || collision.gameObject.layer == 14)
        {
            if (collision.gameObject.name == "Treead" || collision.gameObject.name == "Treead(Clone)")
            {
                _tree.Damage(50);
                _tree._burnTime = 4f;
                _tree.afterBurn();
            }
            if (collision.gameObject.name == "Golire" || collision.gameObject.name == "Golire(Clone)")
            {
                Debug.Log("Burn again!");
                _golire.extinguished = false;
            }
            if (collision.gameObject.name == "Breeze" || collision.gameObject.name == "Breeze(Clone)")
            {
                _breeze.Damage(50);
            }
        }
        if (collision.gameObject.layer == 14)
        {
            if (collision.gameObject.name == "Anger")
            {
                _anger.Damage(50);
                _anger._canRegen = false;
            }
        }

        if (collision.gameObject.layer == 9)
        {
            _player.Damage(50);
            _player._canRegen = false;
            //_anger.Damage(50);
            //_anger._canRegen = false;
            Shake.canShake = true;
        }
        Destroy(this.gameObject);

        _fireParticle.Play();
        _fireParticle.transform.parent = null;
        Destroy(_fireParticle, 2.0f);
    }
Example #3
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        _tree   = collision.gameObject.GetComponent <Treead>();
        _golire = collision.gameObject.GetComponent <Golire>();
        _anger  = collision.gameObject.GetComponent <Anger>();
        _breeze = collision.gameObject.GetComponent <Breeze>();

        if (collision.gameObject.layer == 13)
        {
            if (collision.gameObject.name == "Treead")
            {
                _tree.Damage(10 * Time.deltaTime);
            }
            if (collision.gameObject.name == "Golire")
            {
                Debug.Log("Burn again!");
                _golire.extinguished = false;
            }
            if (collision.gameObject.name == "Breeze")
            {
                _breeze.Damage(10 * Time.deltaTime);
            }
        }
        if (collision.gameObject.layer == 14)
        {
            if (collision.gameObject.name == "Anger")
            {
                _anger.Damage(10 * Time.deltaTime);
                _anger._canRegen = false;
            }
        }


        if (collision.gameObject.layer == 8)
        {
            Destroy(this.gameObject);
        }
    }
Example #4
0
        public static void Initialize()
        {
            var mod = ModContent.GetInstance <TerrariaAmbience>();

            // var loader = Instance;

            if (!Main.dedServ)
            {
                MorningCrickets         = !Directories.ExistsInSFXReplace("forest_morning") ? mod.GetSound(Directories.ForestMorning) : GetSoundFromPath(SFXReplacePath + "/forest_morning.wav");
                MorningCricketsInstance = MorningCrickets.CreateInstance();
                MorningCrickets.Name    = "Morning Crickets";
                DayCrickets             = !Directories.ExistsInSFXReplace("forest_day") ? mod.GetSound(Directories.ForestDay) : GetSoundFromPath(SFXReplacePath + "/forest_day.wav");
                DayCricketsInstance     = DayCrickets.CreateInstance();
                DayCrickets.Name        = "Daytime Crickets";
                EveningCrickets         = !Directories.ExistsInSFXReplace("forest_evening") ? mod.GetSound(Directories.ForestEvening) : GetSoundFromPath(SFXReplacePath + "/forest_evening.wav");
                EveningCricketsInstance = EveningCrickets.CreateInstance();
                EveningCrickets.Name    = "Evening Crickets";
                NightCrickets           = !Directories.ExistsInSFXReplace("forest_night") ? mod.GetSound(Directories.ForestNight) : GetSoundFromPath(SFXReplacePath + "/forest_night.wav");
                NightCricketsInstance   = NightCrickets.CreateInstance();
                NightCrickets.Name      = "Night Crickets";

                DesertAmbience         = !Directories.ExistsInSFXReplace("desert_crickets") ? mod.GetSound(Directories.Desert) : GetSoundFromPath(SFXReplacePath + "/desert_crickets.wav");
                DesertAmbienceInstance = DesertAmbience.CreateInstance();
                DesertAmbience.Name    = "Desert Animals";

                CampfireCrackle         = mod.GetSound(Directories.Campfire);
                CampfireCrackleInstance = CampfireCrackle.CreateInstance();
                CampfireCrackle.Name    = "Campfire Embers";

                CavesAmbience         = !Directories.ExistsInSFXReplace("ug_drip") ? mod.GetSound(Directories.CavernLayer) : GetSoundFromPath(SFXReplacePath + "/ug_drip.wav");
                CavesAmbienceInstance = CavesAmbience.CreateInstance();
                CavesAmbience.Name    = "Caves";

                SnowBreezeDay         = !Directories.ExistsInSFXReplace("snowfall_day") ? mod.GetSound(Directories.SnowDay) : GetSoundFromPath(SFXReplacePath + "/snowfall_day.wav");
                SnowBreezeDayInstance = SnowBreezeDay.CreateInstance();
                SnowBreezeDay.Name    = "Daytime Snowfall";

                SnowBreezeNight         = !Directories.ExistsInSFXReplace("snowfall_night") ? mod.GetSound(Directories.SnowNight) : GetSoundFromPath(SFXReplacePath + "/snowfall_night.wav");
                SnowBreezeNightInstance = SnowBreezeNight.CreateInstance();
                SnowBreezeNight.Name    = "Night Snowfall";

                CrimsonRumbles         = !Directories.ExistsInSFXReplace("crimson_rumbles") ? mod.GetSound(Directories.Crimson) : GetSoundFromPath(SFXReplacePath + "/crimson_rumbles.wav");
                CrimsonRumblesInstance = CrimsonRumbles.CreateInstance();
                CrimsonRumbles.Name    = "Crimson Rumbles";

                CorruptionRoars         = !Directories.ExistsInSFXReplace("corruption_roars") ? mod.GetSound(Directories.Corruption) : GetSoundFromPath(SFXReplacePath + "/corruption_roars.wav");
                CorruptionRoarsInstance = CorruptionRoars.CreateInstance();
                CorruptionRoars.Name    = "Corruption Roars";

                DayJungle             = !Directories.ExistsInSFXReplace("jungle_day") ? mod.GetSound(Directories.JungleDay) : GetSoundFromPath(SFXReplacePath + "/jungle_day.wav");
                DaytimeJungleInstance = DayJungle.CreateInstance();
                DayJungle.Name        = "Daytime Jungle";
                NightJungle           = !Directories.ExistsInSFXReplace("jungle_night") ? mod.GetSound(Directories.JungleNight) : GetSoundFromPath(SFXReplacePath + "/jungle_night.wav");
                NightJungleInstance   = NightJungle.CreateInstance();
                NightJungle.Name      = "Night Jungle";

                BeachWaves         = !Directories.ExistsInSFXReplace("beach_waves") ? mod.GetSound(Directories.Beach) : GetSoundFromPath(SFXReplacePath + "/beach_waves.wav");
                BeachWavesInstance = BeachWaves.CreateInstance();
                BeachWaves.Name    = "Beach Waves";

                HellRumble         = !Directories.ExistsInSFXReplace("hell_rumble") ? mod.GetSound(Directories.HellLayer) : GetSoundFromPath(SFXReplacePath + "/hell_rumble.wav");
                HellRumbleInstance = HellRumble.CreateInstance();
                HellRumble.Name    = "Hell Rumbling";

                Drip1         = mod.GetSound($"{AmbientPath}/environment/liquid/liquid_drip1");
                Drip2         = mod.GetSound($"{AmbientPath}/environment/liquid/liquid_drip2");
                Drip3         = mod.GetSound($"{AmbientPath}/environment/liquid/liquid_drip3");
                Drip1Instance = Drip1.CreateInstance();
                Drip2Instance = Drip2.CreateInstance();
                Drip3Instance = Drip3.CreateInstance();

                SplashNew         = mod.GetSound($"{AmbientPath}/environment/liquid/entity_splash_light");
                SplashNewInstance = SplashNew.CreateInstance();
                SplashNew.Name    = "Water Splash (Light)";

                LavaStream          = mod.GetSound($"{AmbientPath}/environment/liquid/stream_lava");
                WaterStream         = mod.GetSound($"{AmbientPath}/environment/liquid/stream_water");
                LavaStreamInstance  = LavaStream.CreateInstance();
                WaterStreamInstance = WaterStream.CreateInstance();

                Rain         = !Directories.ExistsInSFXReplace("rain_new") ? mod.GetSound(Directories.Rain) : GetSoundFromPath(SFXReplacePath + "/rain_new.wav");
                RainInstance = Rain.CreateInstance();
                Rain.Name    = "Rain Outside";

                Breeze         = mod.GetSound(Directories.Breeze);
                BreezeInstance = Breeze.CreateInstance();
                Breeze.Name    = "Wind Breeze";

                DayCricketsInstance.IsLooped     = true;
                EveningCricketsInstance.IsLooped = true;
                NightCricketsInstance.IsLooped   = true;
                CampfireCrackleInstance.IsLooped = true;
                DesertAmbienceInstance.IsLooped  = true;
                CavesAmbienceInstance.IsLooped   = true;
                SnowBreezeDayInstance.IsLooped   = true;
                SnowBreezeNightInstance.IsLooped = true;
                CrimsonRumblesInstance.IsLooped  = true;
                CorruptionRoarsInstance.IsLooped = true;
                DaytimeJungleInstance.IsLooped   = true;
                NightJungleInstance.IsLooped     = true;
                BeachWavesInstance.IsLooped      = true;
                HellRumbleInstance.IsLooped      = true;
                RainInstance.IsLooped            = true;
                LavaStreamInstance.IsLooped      = true;
                WaterStreamInstance.IsLooped     = true;
                MorningCricketsInstance.IsLooped = true;
                BreezeInstance.IsLooped          = true;
            }
        }
Example #5
0
        private AuditEntityBase SetAuditEntityFields(Breeze.ContextProvider.EntityInfo entityInfo)
        {
            var entity = (AuditEntityBase)entityInfo.Entity;

            entity.CreatedBy = HttpContext.Current.User.Identity.Name;
            entity.CreatedDate = DateTime.UtcNow;

            return entity;
        }
Example #6
0
        public bool BeforeSaveEntity(Breeze.ContextProvider.EntityInfo entityInfo)
        {
            #region EntityState.Added
            if (entityInfo.EntityState == EntityState.Added)
            {
                if (entityInfo.Entity.GetType().IsSubclassOf(typeof(AuditEntityBase)))
                {
                    SetAuditEntityFields(entityInfo);
                }

                if (entityInfo.Entity.GetType() == typeof(RoleAssignment))
                {
                    if (!IsAuthorizedToCreateRoleAssignment((RoleAssignment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create role assignment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                } 
                else if (entityInfo.Entity.GetType() == typeof(Department))
                {
                    if (!IsAuthorizedToModifyDepartment((Department)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create role assignment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Employment))
                {
                    if (!IsAuthorizedToCreateEmployment((Employment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create employment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Person))
                {
                    if (!IsAuthorizedToCreatePerson((Person)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create person entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }


                }
                else if (entityInfo.Entity.GetType() == typeof(Salary))
                {
                    if (!IsAuthorizedToCreateSalary((Salary)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create salary entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(SpecialSalaryAdjustment))
                {
                    if (!IsAuthorizedToCreateSpecialSalaryAdjustment((SpecialSalaryAdjustment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create special salary adjustment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(User))
                {
                    if (!IsAuthorizedToCreateUser((User)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create user entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else
                {
                    ThrowEntityError("You cannot use this method to create this entity.",
                        "Bad request", HttpStatusCode.BadRequest);
                }
            }
            #endregion

            #region EntityState.Modified
            if (entityInfo.EntityState == EntityState.Modified)
            {
                if (entityInfo.Entity.GetType() == typeof(BaseSalaryAdjustment))
                {
                    if (!IsAuthorizedToUpdateBaseSalaryAdjustment((BaseSalaryAdjustment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to modify base salary adjustment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Department))
                {
                    if (!IsAuthorizedToModifyDepartment((Department)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create role assignment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Employment))
                {
                    if (!IsAuthorizedToUpdateEmployment((Employment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to modify base employment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Person))
                {
                    if (!IsAuthorizedToUpdatePerson((Person)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to modify person entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(RoleAssignment))
                {
                    if (!IsAuthorizedToUpdateRoleAssignment((RoleAssignment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to modify role assignment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Salary))
                {
                    if (!IsAuthorizedToUpdateSalary((Salary)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to modify this salary.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(SpecialSalaryAdjustment))
                {
                    if (!IsAuthorizedToUpdateSpecialSalaryAdjustment((SpecialSalaryAdjustment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to modify this salary.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else
                {
                    ThrowEntityError("You cannot use this method to modify this entity.",
                        "Bad request", HttpStatusCode.BadRequest);
                }
            }
            #endregion

            #region EntityState.Deleted
            if (entityInfo.EntityState == EntityState.Deleted)
            {
                if (entityInfo.Entity.GetType() == typeof(Employment))
                {
                    if (!IsAuthorizedToDeleteEmployment((Employment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to delete this employment.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Department))
                {
                    if (!IsAuthorizedToModifyDepartment((Department)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to create role assignment entities.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(SpecialSalaryAdjustment))
                {
                    if (!IsAuthorizedToDeleteSpecialSalaryAdjustment((SpecialSalaryAdjustment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to modify this salary.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(Role))
                {
                    if (!IsAuthorizedToDeleteRole((Role)entityInfo.Entity))
                    {
                        {
                            ThrowEntityError("You are not authorized to delete this role.",
                                "Unauthorized", HttpStatusCode.Unauthorized);
                        }
                    }
                }
                else if (entityInfo.Entity.GetType() == typeof(RoleAssignment))
                {
                    if (!IsAuthorizedToDeleteRoleAssignment((RoleAssignment)entityInfo.Entity))
                    {
                        ThrowEntityError("You are not authorized to delete this role assignment entity.",
                            "Unauthorized", HttpStatusCode.Unauthorized);
                    }
                }
                else
                {
                    ThrowEntityError("You cannot use this method to delete this entity.",
                        "Bad request", HttpStatusCode.BadRequest);
                }
            }
            #endregion

            return true;
        }