Esempio n. 1
0
        static async Task Main(string[] args)
        {
            double temperature, humidity, pressure;
            var    rand = new Random();

            await iotClient.SetDesiredPropertyUpdateCallbackAsync(OnDesiredPropertyChangedAsync, null).ConfigureAwait(false); // callback for Device Twin updates

            await DeviceTwinGetInitialState(iotClient);                                                                       // Get current cloud state of the device twin

            while (true)
            {
                temperature = Math.Round(th.Temperature.DegreesCelsius, 1);
                humidity    = Math.Round(th.Humidity.Percent, 1);
                pressure    = 1000 + rand.Next(0, 200);

                try
                {
                    Console.WriteLine($"Ambient temperature {temperature} and humidity {humidity}");
                    await SendMsgIotHub(temperature, humidity, pressure);

                    roomState = (int)temperature > thermostat ? RoomAction.Cooling : (int)temperature < thermostat ? RoomAction.Heating : RoomAction.Green;
                    await UpdateRoomAction(roomState);
                    await UpdateRoomTemperature(temperature);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("exception msg: " + ex.Message);
                }

                Thread.Sleep(4000); // sleep for 4 seconds
            }
        }
        private static async Task UpdateRoomAction(RoomAction roomState)
        {
            if (roomState != previousRoomState)
            {
                await UpdateDeviceTwin("RoomAction", roomState.ToString());

                previousRoomState = roomState;
            }
        }
        private static async Task OnDesiredPropertyChangedAsync(TwinCollection desiredProperties, object userContext)
        {
            if (desiredProperties.Contains("targetTemperature"))
            {
                double.TryParse(Convert.ToString(desiredProperties["targetTemperature"]), out targetTemperature);
                await UpdateDeviceTwin("targetTemperature", targetTemperature);

                roomState = (int)temperature > targetTemperature ? RoomAction.Cooling : (int)temperature < targetTemperature ? RoomAction.Heating : RoomAction.Green;
                await UpdateRoomAction(roomState);
            }
        }
        static async Task Main(string[] args)
        {
            using (var security = new SecurityProviderSymmetricKey(registrationId, primaryKey, secondaryKey))
                using (var transport = new ProvisioningTransportHandlerMqtt())
                {
                    ProvisioningDeviceClient provClient = ProvisioningDeviceClient.Create(GlobalDeviceEndpoint, idScope, security, transport);
                    var pnpPayload = new ProvisioningRegistrationAdditionalData
                    {
                        JsonData = $"{{ \"modelId\": \"{ModelId}\" }}",
                    };

                    DeviceRegistrationResult result = await provClient.RegisterAsync(pnpPayload);

                    IAuthenticationMethod auth = new DeviceAuthenticationWithRegistrySymmetricKey(result.DeviceId, (security as SecurityProviderSymmetricKey).GetPrimaryKey());

                    using (iotClient = DeviceClient.Create(result.AssignedHub, auth, TransportType.Mqtt))
                    {
                        await iotClient.SetDesiredPropertyUpdateCallbackAsync(OnDesiredPropertyChangedAsync, null).ConfigureAwait(false); // callback for Device Twin updates
                        await DeviceTwinGetInitialState(iotClient);                                                                       // Get current cloud state of the device twin

                        while (true)
                        {
                            if (_temperature.IsAvailable)
                            {
                                try
                                {
                                    temperature = Math.Round(_temperature.Temperature.DegreesCelsius, 2);

                                    Console.WriteLine($"The CPU temperature is {temperature}");

                                    await SendMsgIotHub(iotClient, temperature);

                                    roomState = (int)temperature > targetTemperature ? RoomAction.Cooling : (int)temperature < targetTemperature ? RoomAction.Heating : RoomAction.Green;
                                    await UpdateRoomAction(roomState);

                                    if (temperature > maxTemperature)
                                    {
                                        maxTemperature = temperature;
                                        await UpdateDeviceTwin("maxTempSinceLastReboot", maxTemperature);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("exception msg: " + ex.Message);
                                }
                            }
                            Thread.Sleep(2000); // sleep for 2 seconds
                        }
                    }
                }
        }
        public RoomAction MapCreateRoomActionToRoomAction(CreateRoomActionVm createRoomActionVm, string description, string roomId)
        {
            var roomAction = new RoomAction();

            roomAction.id     = createRoomActionVm.Id;
            roomAction.roomId = roomId;

            roomAction.action                  = new GameAction();
            roomAction.action.actionType       = createRoomActionVm.ActionType;
            roomAction.action.dialogueToOpenId = createRoomActionVm.DialogueToOpenId;
            roomAction.action.roomToNavigateId = createRoomActionVm.RoomToNavigateId;
            roomAction.action.description      = description;

            return(roomAction);
        }
Esempio n. 6
0
        public async Task <ActionResult> Action(string name, RoomAction action)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(RedirectToAction("Index"));
            }

            var room = await db.Rooms.FirstOrDefaultAsync(c => c.Name == name);

            if (room == null)
            {
                return(HttpNotFound());
            }

            var user = await GetApplicationUser();

            if (user == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (room.Owner.Id != user.Id)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            if (RoomManager.GetInstance().GetRoomInfo(room.Id) != null)
            {
                switch (action)
                {
                case RoomAction.StartBroadcast:
                    room.IsLive = true;
                    break;

                case RoomAction.StopBroadcast:
                    room.IsLive = false;
                    break;
                }
            }

            await db.SaveChangesAsync();

            return(RedirectToAction("Details", new { name = name }));
        }
Esempio n. 7
0
        static Room ParserRoom(JObject json)
        {
            List <Direction>  lstDir    = new List <Direction>();
            List <RoomAction> lstAction = new List <RoomAction>();
            Room room = new Room();

            foreach (string dirStr in json.GetValue("dirs").ToString().Split('@'))
            {
                if (!string.IsNullOrEmpty(dirStr))
                {
                    string    dirCode = dirStr.Split('&')[0];
                    string    dirName = dirStr.Split('&')[1];
                    Direction dir     = new Direction()
                    {
                        ChineseName = dirName,
                        EnglishName = dirCode
                    };

                    lstDir.Add(dir);
                }
            }
            foreach (string actionStr in json.GetValue("room_actions").ToString().Split('-'))
            {
                if (!string.IsNullOrEmpty(actionStr))
                {
                    string     code   = actionStr.Split(':')[1];
                    string     name   = actionStr.Split(':')[0];
                    RoomAction action = new RoomAction()
                    {
                        ActionName = name,
                        Action     = code
                    };
                    lstAction.Add(action);
                }
            }
            room.Dirs        = lstDir;
            room.RoomActions = lstAction;
            room.Desc        = json.GetValue("env").ToString();
            room.ShortDesc   = json.GetValue("short").ToString();

            return(room);
        }
Esempio n. 8
0
    void Awake()
    {
        version = Application.version;
        CBUG.Do("Application Version is: " + version + ".");
        currentMenu = Menu.main;
        currentMap  = Map.pillar;
        rmAction    = RoomAction.unset;

        stageName = "Pillar";

        isEast = true;
        bool tempControlsShown = PlayerPrefs.GetInt("isControlsShown", 1) == 1 ? true : false;

        isControlsShown = tempControlsShown;

        myMusicAudio = GetComponent <AudioSource>();
        mySFXAudio   = transform.GetChild(0).GetComponent <AudioSource>();
        PlayMSX(3);
        NameStrengthDict = new Dictionary <string, float>();
        foreach (NameToStrength character in StrengthsList)
        {
            NameStrengthDict.Add(character.Name, character.Power);
        }

        //DontDestroyOnLoad(gameObject); Disabling, we never leave the scene Master is born in.
        AssignPlayerCharacter(0);
        //Cursor.lockState = CursorLockMode.Confined;
        //Cursor.visible = false;

        stageNames = new string[totalUniqueStages] {
            "Pillar", "Void", "Lair"
        };

        if (IsOfflineMode)
        {
            return;
        }
        VersionUI.text = "BETA " + Application.version;
        N = GameObject.FindGameObjectWithTag("Networking").GetComponent <NetworkManager>();
    }
Esempio n. 9
0
        public static void PerformAction(int roomId, Participant participant, RoomAction action, string data)
        {
            using (Trace.Common.scope())
            {
                try
                {
                    // Build request
                    var request = new RestRequest("rooms/{roomId}/actions/{participantId}", Method.PATCH)
                    {
                        RequestFormat = DataFormat.Json
                    };
                    request.AddHeader("Content-Type", "application/json");
                    request.AddUrlSegment("roomId", roomId.ToString());
                    request.AddUrlSegment("participantId", participant.ParticipantId.ToString());
                    request.AddBody(new RoomActionRequest
                    {
                        Action = action,
                        Data   = data
                    });

                    // Call service
                    var response = ExecuteRequest <List <Participant> >(request);

                    // Check response
                    if (!ValidateResponse(response))
                    {
                        throw new Exception("Response data was not valid! Aborting!");
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteEventError(ex, "Exception in PerformAction: " + ex.Message, EventId.GenericError);
                    //return null;
                }
            }
        }
        private static async Task UpdateRoomAction(RoomAction roomState)
        {
            if (roomState != previousRoomState)
            {
                await UpdateDeviceTwin("RoomAction", roomState.ToString());

                previousRoomState = roomState;

                switch (roomState)
                {
                case RoomAction.Cooling:
                    ledMatrix.Fill(Color.Blue);
                    break;

                case RoomAction.Heating:
                    ledMatrix.Fill(Color.Red);
                    break;

                default:
                    ledMatrix.Fill(Color.Green);
                    break;
                }
            }
        }
Esempio n. 11
0
        internal bool PerformAction(int roomId, int participantId, RoomAction action, string actionData)
        {
            using (Trace.Vidyo.scope())
            {
                try
                {
                    // Find participant
                    var participant = GetParticipant(roomId, participantId);
                    if (participant == null)
                    {
                        Trace.Vidyo.note("Failed to find participant with participantId {} for room {}", participantId, roomId);
                        return(false);
                    }

                    // Take action
                    switch (action)
                    {
                    case RoomAction.MuteAudio:
                    {
                        bool doMute;
                        if (!bool.TryParse(actionData, out doMute))
                        {
                            throw new Exception("Failed to parse boolean data: " + actionData + " for action " +
                                                action);
                        }

                        MuteAudio(roomId, participant, doMute);
                        return(true);
                    }

                    case RoomAction.MuteVideo:
                    {
                        bool doMute;
                        if (!bool.TryParse(actionData, out doMute))
                        {
                            throw new Exception("Failed to parse boolean data: " + actionData + " for action " +
                                                action);
                        }

                        MuteVideo(roomId, participant, doMute);
                        return(true);
                    }

                    case RoomAction.MuteBoth:
                    {
                        bool doMute;
                        if (!bool.TryParse(actionData, out doMute))
                        {
                            throw new Exception("Failed to parse boolean data: " + actionData + " for action " +
                                                action);
                        }

                        MuteVideo(roomId, participant, doMute);
                        MuteAudio(roomId, participant, doMute);
                        return(true);
                    }

                    default:
                    {
                        Trace.Vidyo.warning("Unexpected action: " + action);
                        break;
                    }
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    Trace.WriteEventError(ex, "Exception in PerformAction: " + ex.Message, EventId.GenericError);
                    return(false);
                }
            }
        }
Esempio n. 12
0
 public void SetRoomAction(int action)
 {
     rmAction = (RoomAction)action;
 }
    public void PutSpecRoom(Vector3 Pos, Vertex v)
    {
        int vmakeupcorridors = biggestroomhalfsize - 3;
        int hmakeupcorridors = biggestroomhalfsize - 4;

        string s = "";

        for (int i = 3; i >= 0; i--)
        {
            if (v.CheckNeighbour(i))
            {
                s += '1';
            }
            else
            {
                s += '0';
            }
        }



        int index = System.Convert.ToInt32(s, 2);

        var roomobject = Instantiate(ElongatedSpecialRooms[Random.Range(0, ElongatedSpecialRooms.Length)], Pos, new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));

        RoomAction ra = null;

        Transform roomchild = null;

        foreach (Transform child in roomobject.transform)
        {
            foreach (Transform ch in child)
            {
                if (ch.tag == "Room")
                {
                    roomchild = ch;
                }
            }

            if (child.tag == "Room")
            {
                roomchild = child;
            }
        }

        if (roomchild == null)
        {
            throw new System.ArgumentException("Room has no room tag child");
        }



        ra = roomchild.GetComponent <RoomAction>();


        if (ra == null)
        {
            throw new System.ArgumentException("Room has no room action component");
        }

        ra.node = v.jnode;

        for (int i = 0; i < 4; i++)
        {
            if (v.CheckNeighbour(i))
            {
                switch (i)
                {
                case 0:

                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x - 4.0f * SQUARE_SIDE, Pos.y), new Vector2(-1.0f, 0.0f));

                    break;

                case 1:

                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x, Pos.y - 3.0f * SQUARE_SIDE), new Vector2(0.0f, -1.0f));
                    break;

                case 2:

                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x + 4.0f * SQUARE_SIDE, Pos.y), new Vector2(1.0f, 0.0f));
                    break;

                case 3:

                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x, Pos.y + 3.0f * SQUARE_SIDE), new Vector2(0.0f, 1.0f));
                    break;

                default:
                    break;
                }
            }
        }



        RoomObjects.Add(roomobject);

        /*
         *
         *  Hiányzó folyosók lepakolása
         *
         */

        for (int i = 0; i < 4; i++)
        {
            if (v.CheckNeighbour(i))
            {
                switch (i)
                {
                case 0:

                    for (int j = 0; j < hmakeupcorridors + 1; j++)
                    {
                        CorridorObjects.Add(Instantiate(HorCor, new Vector3(Pos.x - (3.0f + j + 1) * SQUARE_SIDE - SQUARE_SIDE / 2, Pos.y, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = horizontalvariations[Random.Range(0, horizontalvariations.Length - 1)];
                    }

                    break;

                case 1:


                    for (int j = 0; j < vmakeupcorridors; j++)
                    {
                        CorridorObjects.Add(Instantiate(VerCor, new Vector3(Pos.x - SQUARE_SIDE / 2, Pos.y - (3.0f + j + 1) * SQUARE_SIDE, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = verticalvariations[Random.Range(0, verticalvariations.Length - 1)];
                    }
                    break;

                case 2:

                    for (int j = 0; j < hmakeupcorridors; j++)
                    {
                        CorridorObjects.Add(Instantiate(HorCor, new Vector3(Pos.x + (4.0f + j + 1) * SQUARE_SIDE - SQUARE_SIDE / 2, Pos.y, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = horizontalvariations[Random.Range(0, horizontalvariations.Length - 1)];
                    }
                    break;

                case 3:

                    for (int j = 0; j < vmakeupcorridors; j++)
                    {
                        CorridorObjects.Add(Instantiate(VerCor, new Vector3(Pos.x, Pos.y + (3.0f + j + 1) * SQUARE_SIDE - SQUARE_SIDE / 2, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = verticalvariations[Random.Range(0, verticalvariations.Length - 1)];
                    }
                    break;

                default:
                    break;
                }
            }
        }
    }
    public void PutNormalRoom(Vector3 Pos, Vertex v, bool enemy = true, bool special = false, bool cross = false)
    {
        if (special)
        {
            enemy = false;
        }

        int makeupcorridors = biggestroomhalfsize - 3;

        string s = "";

        for (int i = 3; i >= 0; i--)
        {
            if (v.CheckNeighbour(i))
            {
                s += '1';
            }
            else
            {
                s += '0';
            }
        }

        int index = System.Convert.ToInt32(s, 2);

        GameObject roomobject = null;

        if (special)
        {
            if (cross)
            {
                roomobject = Instantiate(CrossSpecialRooms[Random.Range(0, CrossSpecialRooms.Length)], Pos, new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
            }
            else
            {
                roomobject = Instantiate(VertSpecialRooms[Random.Range(0, VertSpecialRooms.Length)], Pos, new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
            }
        }
        else
        {
            roomobject = Instantiate(NormalRooms[index - 1], Pos, new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
        }

        RoomAction ra = null;

        Transform roomchild = null;

        foreach (Transform child in roomobject.transform)
        {
            foreach (Transform ch in child)
            {
                if (ch.tag == "Room")
                {
                    roomchild = ch;
                }
            }

            if (child.tag == "Room")
            {
                roomchild = child;
            }
        }

        if (roomchild == null)
        {
            throw new System.ArgumentException("Room has no room tag child");
        }



        ra = roomchild.GetComponent <RoomAction>();


        if (ra == null)
        {
            throw new System.ArgumentException("Room has no room action component");
        }

        ra.node = v.jnode;

        for (int i = 0; i < 4; i++)
        {
            if (v.CheckNeighbour(i))
            {
                switch (i)
                {
                case 0:
                    ///Ezek az ajtók, tudom a szobák rácsméretét, ajtókat annyival arrébb toljuk
                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x - 3.0f * SQUARE_SIDE, Pos.y), new Vector2(-1.0f, 0.0f));
                    if (Random.Range(0, 10) < 2)
                    {
                        Instantiate(HorDoor, new Vector3(Pos.x - 3.0f * SQUARE_SIDE, Pos.y + 0.16f, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
                    }

                    break;

                case 1:

                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x, Pos.y - 3.0f * SQUARE_SIDE), new Vector2(0.0f, -1.0f));
                    if (Random.Range(0, 10) < 2)
                    {
                        Instantiate(VerDoor, new Vector3(Pos.x, Pos.y - 3.0f * SQUARE_SIDE, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
                    }
                    break;

                case 2:

                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x + 3.0f * SQUARE_SIDE, Pos.y), new Vector2(1.0f, 0.0f));
                    if (Random.Range(0, 10) < 2)
                    {
                        Instantiate(HorDoor, new Vector3(Pos.x + 3.0f * SQUARE_SIDE, Pos.y + 0.16f, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
                    }
                    break;

                case 3:

                    ra.node.neighbours[v.GetNeighbour(i).jnode] = new doorData(new Vector2(Pos.x, Pos.y + 3.0f * SQUARE_SIDE), new Vector2(0.0f, 1.0f));
                    if (Random.Range(0, 10) < 2)
                    {
                        Instantiate(VerDoor, new Vector3(Pos.x, Pos.y + 3.0f * SQUARE_SIDE, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
                    }
                    break;

                default:
                    break;
                }
            }
        }

        RoomObjects.Add(roomobject);

        /*
         *
         *  Hiányzó folyosók lepakolása
         *
         */

        for (int i = 0; i < 4; i++)
        {
            if (v.CheckNeighbour(i))
            {
                switch (i)
                {
                case 0:

                    for (int j = 0; j < makeupcorridors; j++)
                    {
                        CorridorObjects.Add(Instantiate(HorCor, new Vector3(Pos.x - (3.0f + j + 1) * SQUARE_SIDE, Pos.y, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = horizontalvariations[Random.Range(0, horizontalvariations.Length - 1)];
                    }

                    break;

                case 1:


                    for (int j = 0; j < makeupcorridors; j++)
                    {
                        CorridorObjects.Add(Instantiate(VerCor, new Vector3(Pos.x, Pos.y - (3.0f + j + 1) * SQUARE_SIDE, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = verticalvariations[Random.Range(0, verticalvariations.Length - 1)];
                    }
                    break;

                case 2:

                    for (int j = 0; j < makeupcorridors; j++)
                    {
                        CorridorObjects.Add(Instantiate(HorCor, new Vector3(Pos.x + (3.0f + j + 1) * SQUARE_SIDE, Pos.y, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = horizontalvariations[Random.Range(0, horizontalvariations.Length - 1)];
                    }
                    break;

                case 3:

                    for (int j = 0; j < makeupcorridors; j++)
                    {
                        CorridorObjects.Add(Instantiate(VerCor, new Vector3(Pos.x, Pos.y + (3.0f + j + 1) * SQUARE_SIDE, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)));
                        CorridorObjects[CorridorObjects.Count - 1].GetComponent <SpriteRenderer>().sprite = verticalvariations[Random.Range(0, verticalvariations.Length - 1)];
                    }
                    break;

                default:
                    break;
                }
            }
        }

        /*
         *
         * Enemys
         *
         */

        if (enemy)
        {
            int enemynum = Random.Range(0, normalroomenemy);

            List <Vector3> posspos = new List <Vector3>();

            posspos.Add(new Vector3(0.0f, 0.0f, 0.0f));
            posspos.Add(new Vector3(1.0f, 0.0f, 0.0f));
            posspos.Add(new Vector3(2.0f, 0.0f, 0.0f));
            posspos.Add(new Vector3(-1.0f, 0.0f, 0.0f));
            posspos.Add(new Vector3(-2.0f, 0.0f, 0.0f));
            posspos.Add(new Vector3(0.0f, 1.0f, 0.0f));
            posspos.Add(new Vector3(0.0f, 2.0f, 0.0f));
            posspos.Add(new Vector3(0.0f, -1.0f, 0.0f));
            posspos.Add(new Vector3(0.0f, -2.0f, 0.0f));
            posspos.Add(new Vector3(1.0f, 1.0f, 0.0f));
            posspos.Add(new Vector3(1.0f, 2.0f, 0.0f));
            posspos.Add(new Vector3(-1.0f, -1.0f, 0.0f));
            posspos.Add(new Vector3(-1.0f, -2.0f, 0.0f));
            posspos.Add(new Vector3(2.0f, 1.0f, 0.0f));
            posspos.Add(new Vector3(-2.0f, -1.0f, 0.0f));
            posspos.Add(new Vector3(-2.0f, 1.0f, 0.0f));
            posspos.Add(new Vector3(2.0f, -1.0f, 0.0f));


            List <enemy> elist = new List <enemy>();

            for (int i = 0; i < enemynum; i++)
            {
                int eind = Random.Range(0, posspos.Count - 1);

                GameObject newGoblin = Instantiate(GoblinPrefab, Pos + posspos[eind] * SQUARE_SIDE + new Vector3(0.0f, 0.16f, 0.0f), new Quaternion(0.0f, 0.0f, 0.0f, 0.0f));
                newGoblin.GetComponent <GameActor>().setMaxHealth(GameplayController.getGameplayOptions().goblinMaxHealth);
                newGoblin.GetComponent <GameActor>().setHealth(GameplayController.getGameplayOptions().goblinMaxHealth);
                elist.Add(newGoblin.GetComponent <enemy>());


                posspos.RemoveAt(eind);
            }

            v.jnode.setEnemies(elist);
        }
    }
Esempio n. 15
0
        public async Task<ActionResult> Action(string name, RoomAction action)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return RedirectToAction("Index");
            }

            var room = await db.Rooms.FirstOrDefaultAsync(c => c.Name == name);
            if (room == null)
            {
                return HttpNotFound();
            }

            var user = await GetApplicationUser();
            if (user == null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            if (room.Owner.Id != user.Id)
                return new HttpStatusCodeResult(HttpStatusCode.Forbidden);

            if (RoomManager.GetInstance().GetRoomInfo(room.Id) != null)
            {
                switch (action)
                {
                    case RoomAction.StartBroadcast:
                        room.IsLive = true;
                        break;
                    case RoomAction.StopBroadcast:
                        room.IsLive = false;
                        break;
                }
            }

            await db.SaveChangesAsync();
            return RedirectToAction("Details", new {name = name});
        }
Esempio n. 16
0
        /// <summary>
        /// Retrieves a single Room object from the Api without querying for all rooms inside the GROHE
        /// account.
        /// </summary>
        /// <param name="inLocation">The Location to look for the room in</param>
        /// <param name="id">The room ID as retrieved by the GROHE Api</param>
        /// <returns>One specific Room</returns>
        public Room getRoom(Location inLocation, int id)
        {
            RoomAction action = apiClient.getAction <RoomAction>();

            return(action.getRoom(inLocation, id));
        }
Esempio n. 17
0
        /// <summary>
        /// A Room is an intermediate organizational structure element inside the GROHE account. It is usually
        /// used to separate multiple appliances in different rooms from each other.
        /// </summary>
        /// <param name="forLocation">The Location to look for rooms in</param>
        /// <returns>The list of saved Rooms in the GROHE account</returns>
        public List <Room> getRooms(Location forLocation)
        {
            RoomAction action = apiClient.getAction <RoomAction>();

            return(action.getRooms(forLocation));
        }