Example #1
0
        // create the fire properties
        public FireModel GenerateFireModel(Client player)
        {
            Random randomNum = new Random();
            bool   gasPowerd = true;

            int maxChildren = randomNum.Next(10, 25);
            int gas         = randomNum.Next(1, 3);
            int fireAmount  = randomNum.Next(20, 40);

            player.SendChatMessage("gas random:" + gas);

            if (gas > 1)
            {
                gasPowerd = true;
            }
            else
            {
                gasPowerd = false;
            }

            // select random house from list
            Vector3 HousePos = HouseList[randomNum.Next(0, HouseList.Count)];

            FireModel model = new FireModel(HousePos.X, HousePos.Y, HousePos.Z, maxChildren, fireAmount, gasPowerd);

            return(model);
        }
Example #2
0
        // Create the fire
        public FireModel BuildFire(Client player)
        {
            // create a firemodel (setting fire properties)
            FireModel fireModel = GenerateFireModel(player);

            // Create a blip where the fire starts
            NAPI.ClientEvent.TriggerClientEvent(player, "BlipFireLocation", fireModel.xPos, fireModel.yPos, fireModel.zPos);

            // get all players online
            List <Client> allCurrentPlayers = NAPI.Pools.GetAllPlayers();

            int count = 0;

            Random amount = new Random();

            // start the fire foreach online player
            foreach (Client playerOnline in allCurrentPlayers)
            {
                while (count < fireModel.AmountFires)
                {
                    // check the position if its reachable for the player
                    // We also add a random number to the position so we can spread the fire
                    NAPI.ClientEvent.TriggerClientEvent(player, "CheckIfReachable", new Vector3(fireModel.xPos, fireModel.yPos, fireModel.zPos), fireModel.xPos + amount.Next(5, 20), fireModel.yPos + amount.Next(5, 20), fireModel.zPos + amount.Next(0, 1), fireModel.maxChilderen, fireModel.gasPowerd);
                    count++;
                }
            }
            // Send a notification to the player with the fire properies
            NAPI.Notification.SendNotificationToPlayer(player, "Fire Strenght:" + fireModel.maxChilderen + Environment.NewLine + "Gas powerd:" + fireModel.gasPowerd, false);

            return(fireModel);
        }
Example #3
0
        public void EnlightendHexagon(Map map)
        {
            for (int index = 0; index < fireModels.Length; ++index)
            {
                float randomBonus = randomValue.Next(0, 100);
                fireModels[index] = new FireModel(Logic.Vars_Func.getTorchFireModel(), 0.01f + randomBonus / 3000);
                map.Fires.Add(fireModels[index]);
            }

            for (int i = 0; i < 6; ++i)
            {
                Vector2 neighbor = neighbors[i];
                map.getHexagonAt(neighbor).isEnlightend = true;
                map.getHexagonAt(neighbor).lightPower  += 0.1f;

                for (int j = 0; j < 6; ++j)
                {
                    Vector2 secondDegreeNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                    map.getHexagonAt(secondDegreeNeighbor).isEnlightend = true;
                    map.getHexagonAt(secondDegreeNeighbor).lightPower  += 0.07f;
                    for (int k = 0; k < 6; ++k)
                    {
                        Vector2 thirdDegreeNeighbor = map.getHexagonAt(secondDegreeNeighbor).Neighbors[k];
                        map.getHexagonAt(thirdDegreeNeighbor).isEnlightend = true;
                        map.getHexagonAt(thirdDegreeNeighbor).lightPower  += 0.05f;
                        if (map.getHexagonAt(thirdDegreeNeighbor).lightPower > 0.7f)
                        {
                            map.getHexagonAt(thirdDegreeNeighbor).lightPower = 0.7f;
                        }
                    }
                    if (map.getHexagonAt(secondDegreeNeighbor).lightPower > 0.7f)
                    {
                        map.getHexagonAt(secondDegreeNeighbor).lightPower = 0.7f;
                    }
                }
                if (map.getHexagonAt(neighbor).lightPower > 0.7f)
                {
                    map.getHexagonAt(neighbor).lightPower = 0.7f;
                }
            }
            isStartLight = true;
            isEnlightend = true;
            lightPower  += 0.3f;
            if (lightPower > 0.9f)
            {
                lightPower = 0.9f;
            }
        }
Example #4
0
        public async Task <Result> FireEmp(FireModel model)
        {
            var user = await _userManager.FindByIdAsync(model.Id);

            if (model.IsInService)
            {
                var su = ctx.ServiceUsers.Single(su => su.UserId == model.Id);
                ctx.ServiceUsers.Remove(su);
            }
            else
            {
                var cu = ctx.CompanyUsers.Single(cu => cu.UserId == model.Id);
                ctx.CompanyUsers.Remove(cu);
            }
            await ctx.SaveChangesAsync();

            return(new Result()
            {
                Successful = true
            });
        }
Example #5
0
        public void StartMission(Client sender)
        {
            // if the player stand on colshape and has atJob data
            if (NAPI.Data.HasEntityData(sender, "atJob"))
            {
                // get the job data from the player
                string jobName = NAPI.Data.GetEntityData(sender, "atJob");

                switch (jobName)
                {
                case "FireDepartment":

                    // set the player skin to fireman
                    sender.SetSkin(PedHash.Fireman01SMY);

                    // give fire extinguiser
                    sender.GiveWeapon(WeaponHash.FireExtinguisher, 9999);

                    // if the player dont have JobVehicle data then create the vehicle
                    if (!NAPI.Data.HasEntityData(sender, "JobVehicle"))
                    {
                        // create the firetruck
                        Vehicle jobVeh = VehicleHandler.VehicleHandler.CreateVehicle(sender, VehicleHash.FireTruck, VehSpawnPos, VehSpawnRotation, 123, 123, "Fire_Deprt");
                        // set the vehicle data on the player
                        NAPI.Data.SetEntityData(sender, "JobVehicle", jobVeh);
                    }
                    // create the fire for all online players
                    FireModel fireModel = BuildFire(sender);
                    // Start the fires alive update timer (javascript)
                    NAPI.ClientEvent.TriggerClientEvent(sender, "FiresAliveTimer", fireModel.xPos, fireModel.yPos, fireModel.zPos);
                    // Set the fire model data to the player (fireman)
                    NAPI.Data.SetEntityData(sender, "FireModel", fireModel);
                    break;

                // if job is not FireDepartment then do noting
                default:
                    break;
                }
            }
        }