private void SetupFloor(int floorID)
    {
        if (floorID >= 0 && floorID < _floorObjects.Count)
        {
            GameObject floorObject = _floorObjects[floorID];
            if (floorObject != null)
            {
                floorObject.SetActive(true);
            }
        }
        if (floorID >= 0 && floorID < _floorDatas.Count)
        {
            FloorData floorData = _floorDatas[floorID];
            if (floorData != null)
            {
                RenderSettings.skybox = floorData.Skybox;

                _sunObject.gameObject.transform.position = floorData.SunPosition;
                _sunObject.gameObject.transform.rotation = floorData.SunRotation;
                _sunObject.color     = floorData.SunColor;
                _sunObject.intensity = floorData.SunIntensity;

                _flashlight.Light.intensity      = floorData.LightIntensity;
                _flashlight.CachedLightIntensity = floorData.LightIntensity;
                _flashlight.Light.color          = floorData.LightColor;
                _flashlight.SlerpFactor          = floorData.LightSlerpSpeed;
                _flashlight.LightChangeSpeed     = floorData.LightChangeSpeed;
                _flashlight.LightAngleChange     = floorData.LightAngleChange;
                _flashlight.LightAngleGapChange  = floorData.LightAngleGap;
            }
        }
    }
        public ViewModelMainWindow()
        {
            m_model = new MainModel();

            Floors          = new ObservableCollection <FloorData>();
            CurrentFloor    = new FloorData();
            Elevators       = new ObservableCollection <ElevatorData>();
            CurrentElevator = new ElevatorData();
            EventsLog       = new ObservableCollection <string>();

            // Set starting IDs
            CurrentFloor.ID    = 1;
            CurrentElevator.ID = 1;

            IsBuilded    = false;
            IsShowEvents = true;

            AddFloorCommand       = new RelayCommand(arg => AddFloorHandle());
            DeleteFloorCommand    = new RelayCommand(arg => DeleteFloorHandle());
            ClearFloorsCommand    = new RelayCommand(arg => ClearFloorsHandle());
            AddElevatorCommand    = new RelayCommand(arg => AddElevatorHandle());
            DeleteElevatorCommand = new RelayCommand(arg => DeleteElevatorHandle());
            ClearElevatorsCommand = new RelayCommand(arg => ClearElevatorsHandle());
            BuildCommand          = new RelayCommand(arg => BuildHandle());
            ResetCommand          = new RelayCommand(arg => ResetHandle());
            RunCommand            = new RelayCommand(arg => RunHandle());
        }
Exemple #3
0
    public static HomeData GenerateRandom(int maxTier, int floors, float roomChance = 50)
    {
        List <FloorData> floorDataList = new List <FloorData>();

        for (int i = 0; i < floors; i++)
        {
            FloorData floorData = new FloorData(
                ContentManager.Instance.GetRandomFloorType(Random.Range((int)1, (int)maxTier)),
                ContentManager.Instance.GetRandomWallType(Random.Range((int)1, (int)maxTier))
                );
            for (int j = 0; j < 4; j++)
            {
                if (Random.Range(0, 100) < roomChance)
                {
                    floorData.HomeUpgrades[j] = ContentManager.Instance.GetRandomHomeUpgrade(Random.Range((int)1, (int)maxTier), Random.Range((int)1, (int)maxTier));
                }
            }
            floorDataList.Add(floorData);
            floorData.UpdateStats();
        }
        HomeData home = new HomeData();

        home.Floors = floorDataList;
        return(home);
    }
Exemple #4
0
    public void FloorSetting(int a_nFloor)
    {
        FloorData   first = a_nFloor.GetFloorData();
        List <eNPC> liNPC = new List <eNPC>();

        if (first.bHasDiningRoom == true)
        {
            liNPC.Add(eNPC.DungeonDining);
        }

        if (first.bHasWaeponRoom == true)
        {
            liNPC.Add(eNPC.DungeonWaepon);
        }

        if (first.nNPC != (int)eNPC.None)
        {
            liNPC.Add((eNPC)first.nNPC);
        }

        m_stDungeon.CreateDungeon(first.nID, first.nRoomCount, liNPC);

        // 해당 층별 방아이디나 따로 가질 수 있지만. 대충 프리펩에서 로딩하는 형태라 일단 여기서 세팅

        var node = m_stDungeon.m_mapRoom.GetEnumerator();

        while (node.MoveNext())
        {
            var st = node.Current.Value;
            st.nRoomID = Random.Range(1, 4);             // 프리팹이 1~3개밖에없음
        }
    }
        // нажатие кнопки переключения на следующий этаж
        private void OnStepedUp(object sender, EventArgs args)
        {
            if (FloorPicker.ItemsSource.Count == 0)
            {
                DependencyService.Get <IToast>().Show("Здание не загружено");
                return;
            }

            int?nextlevel = FloorData.CurrentFloor?.Level + 1;

            if (nextlevel == 0)
            {
                nextlevel++;
            }

            Floor Nextfloor = FloorData.GetFloor(nextlevel);

            if (Nextfloor != null)
            {
                FloorData.CurrentFloor   = Nextfloor;
                FloorPicker.SelectedItem = FloorData.CurrentFloor;
            }
            else
            {
                DependencyService.Get <IToast>().Show("Вы на последнем этаже");
            }
        }
Exemple #6
0
    private bool DetectLane(OscMessage message, out FloorData input)
    {
        // Calculate center of pressure
        CenterOfPressure(message, out window[counter]);

        // Upgrade the counter
        counter++;

        // Check if we get the desired number of values
        if (counter == windowSize)
        {
            int i = 0;
            input.x_value = 0;
            input.y_value = 0;
            input.tot     = 0;
            for (; i < windowSize; i++)
            {
                if (window[i].tot > input.tot)
                {
                    input.x_value = window[i].x_value;
                    input.y_value = window[i].y_value;
                    input.tot     = window[i].tot;
                }
            }

            counter = 0;

            return(true);
        }

        input = new FloorData();
        return(false);
    }
Exemple #7
0
    public void Start()
    {
        if (homeData != null)
        {
            Floor prevFloor = null;
            for (int i = 0; i < homeData.Floors.Count; i++)
            {
                FloorData fd    = homeData.Floors[i];
                Floor     floor = GameObject.Instantiate(FloorPrefab, transform).GetComponent <Floor>();
                floor.FloorData  = fd;
                floor.Index      = i;
                floor.FloorLower = prevFloor;
                floor.MyHome     = this;
                Floors.Add(floor);

                if (prevFloor != null)
                {
                    prevFloor.FloorUpper = floor;
                }

                prevFloor = floor;
            }
            prevFloor.RoofSprite = RoofSprite;
        }
    }
Exemple #8
0
    public void UpdateHome()
    {
        if (homeData != null)
        {
            Floor prevFloor = null;
            foreach (Floor f in Floors)
            {
                Destroy(f.gameObject);
            }
            Floors.Clear();

            for (int i = 0; i < homeData.Floors.Count; i++)
            {
                FloorData fd    = homeData.Floors[i];
                Floor     floor = GameObject.Instantiate(FloorPrefab, transform).GetComponent <Floor>();
                floor.FloorData  = fd;
                floor.Index      = i;
                floor.FloorLower = prevFloor;
                Floors.Add(floor);

                if (prevFloor != null)
                {
                    prevFloor.FloorUpper = floor;
                }

                prevFloor = floor;
            }
            prevFloor.RoofSprite = RoofSprite;
        }
    }
    void HandleCallElevatorRequest(CallElevatorRequest rq)
    {
        // Handle it
        FloorData floor = GetFloorData(rq.level);

        if (floor != null)
        {
            bool isSuccess          = floor.ProcessRequest(rq.direction);
            CallElevatorResponse rs = new CallElevatorResponse(isSuccess ? ResultCode.Succeeded : ResultCode.Failed, floor);
            // Send Response to Floor
            SendCallElevatorResponse(rs);

            if (isSuccess)
            {
                // Update Elevator
                UpdateElevator();
            }
        }
        else
        {
            // Send Response to Floor
            CallElevatorResponse response = new CallElevatorResponse(ResultCode.Failed, null);
            SendCallElevatorResponse(response);
        }
    }
Exemple #10
0
    private static ILevelElement InstantiateFloor(FloorData data, Transform parent)
    {
        Floor floor = new Floor();

        floor.InitPos(data.pos);
        return(floor);
    }
    void HandleUpdateElevatorPositionRequest(UpdateElevatorPositionRequest request)
    {
        uint nextFloor = elevatorData.curFloorLevel;

        if (elevatorData.status == ElevatorStatus.MovingDown)
        {
            nextFloor = elevatorData.curFloorLevel - 1;
            FloorController floorController = GetFloorController(nextFloor);
            if (floorController)
            {
                if (request.positionY <= floorController.GetFittedElevatorAnchoredPositionY())
                {
                    elevatorData.curFloorLevel = nextFloor;
                    // Update elevator status
                    SendElevatorStatusResponseToAllFloor();
                }
            }
        }
        else if (elevatorData.status == ElevatorStatus.MovingUp)
        {
            nextFloor = elevatorData.curFloorLevel + 1;
            FloorController floorController = GetFloorController(nextFloor);
            if (floorController)
            {
                if (request.positionY >= floorController.GetFittedElevatorAnchoredPositionY())
                {
                    elevatorData.curFloorLevel = nextFloor;
                    // Update elevator status
                    SendElevatorStatusResponseToAllFloor();
                }
            }
        }

        // Elevator arrived
        if (elevatorData.curFloorLevel == curDestFloor)
        {
            // Remove cur floor from list requesting
            listFloorsRequesting.Remove(curDestFloor);

            // Update floor status using elevator status
            if (elevatorData.status == ElevatorStatus.MovingDown || elevatorData.status == ElevatorStatus.MovingUp)
            {
                FloorData floorData = GetFloorData(elevatorData.curFloorLevel);
                floorData.OnElevatorArrived(curElevatorDirection);

                ElevatorArrivedResponse elevatorArrivedResponse = new ElevatorArrivedResponse(floorData);
                SendElevatorArrivedResponse(elevatorArrivedResponse);
            }

            elevatorData.status = ElevatorStatus.Arrived;
            UpdateElevatorResponse response = new UpdateElevatorResponse(elevatorData, 0);
            SendUpdateElevatorResponse(response);
        }
        else
        {
            UpdateElevatorPositionResponse response = new UpdateElevatorPositionResponse(ResultCode.Succeeded, elevatorData.curFloorLevel);
            SendUpdateElevatorPositionResponse(response);
        }
    }
Exemple #12
0
        private static void LoadFloors(XmlDocument document)
        {
            XmlNodeList entities = document.GetElementsByTagName("floor");

            foreach (XmlElement element in entities)
            {
                string name      = element.GetAttribute("name");
                string shortName = element.GetAttribute("shortname");

                Debug.Log("Loading floor " + name);

                bool unique = VerifyShortName(shortName);
                if (!unique)
                {
                    Debug.LogWarning("Shortname " + shortName + " already exists, aborting");
                    continue;
                }

                Model           model      = null;
                List <string[]> categories = new List <string[]>();
                bool            opening    = false;
                Materials       materials  = null;

                foreach (XmlElement child in element)
                {
                    switch (child.LocalName)
                    {
                    case "model":
                        model = new Model(child, LayerMasks.FloorRoofLayer);
                        break;

                    case "category":
                        categories.Add(child.InnerText.Split('/'));
                        break;

                    case "opening":
                        opening = true;
                        break;

                    case "materials":
                        materials = new Materials(child);
                        break;
                    }
                }

                if (model == null)
                {
                    Debug.LogWarning("No model loaded, aborting");
                }

                FloorData data = ScriptableObject.CreateInstance <FloorData>();
                data.Initialize(model, name, shortName, opening, materials);
                Database.Floors[shortName] = data;
                foreach (string[] category in categories)
                {
                    GuiManager.Instance.FloorsTree.Add(data, category);
                }
            }
        }
Exemple #13
0
 public void OnGetCallElevatorResponse(CallElevatorResponse response)
 {
     if (response.resultCode == ResultCode.Succeeded)
     {
         floorData = response.floorData;
         UpdateUI();
     }
 }
Exemple #14
0
        public async void FloorEditSucess(string resultHostel)
        {
            updateFloorData = new UpdateFloorData();
            FloorModelData  = new FloorData();
            await App.Current.MainPage.DisplayAlert("HMS", resultHostel, "OK");

            OnPropertyChanged("FloorModelData");
        }
Exemple #15
0
 void Awake()
 {
     if (_data == null)
     {
         _data    = new FloorData();
         _data.ID = GetInstanceID();
     }
 }
    public Direction requestableDirection; // Control if this floor can request to go up, down, or not at all

    public FloorData DeepCopy()
    {
        FloorData other = (FloorData)this.MemberwiseClone();

        other.level  = level;
        other.status = status;
        other.requestableDirection = requestableDirection;
        return(other);
    }
Exemple #17
0
    public FloorData getFloorData(int num)
    {
        FloorData fd = null;

        if (!FloorConfigList.TryGetValue(num, out fd))
        {
            fd = null;
        }
        return(fd);
    }
Exemple #18
0
    public Floor(FloorData data)
    {
        this.id          = data.id;
        this.shortName   = data.floorShortName;
        this.description = data.floorDescription;
        this.floorHeight = data.floorHeight;
        this.rooms       = data.rooms;

        HotelController.Instance.CreateFloor(this);
    }
Exemple #19
0
    private void LoadFloor()
    /* Load and Create Floor, floorPlane with material */
    {
        string floorFileJsonName = fileToLoadName[(int)StctType.Floor];

        InitReading(floorFileJsonName);
        Vector3    planePosition = new Vector3(500, 0, 500);
        Quaternion planeRotation = Quaternion.Euler(new Vector3(0, 180, 0));
        Vector3    planeScale    = new Vector3(100, 1, 100);

        JFloor[] floors;
        try
        {
            floors = JsonHelper.FromJson <JFloor>(jsonString);
            Debug.Log("Loading Floor total:" + floors.Length);

            foreach (JFloor floor in floors)
            {
                GameObject emptyobj = new GameObject(structTag[(int)StctType.Floor] + floor.floorID);
                emptyobj.tag = structTag[(int)StctType.Floor];

                // add floor data
                emptyobj.AddComponent <FloorData>();
                FloorData fdt = emptyobj.GetComponent <FloorData>();
                fdt.floorID      = floor.floorID;
                fdt.floorName    = floor.floorName;
                fdt.floorIndex   = Mathf.CeilToInt(floor.floorIndex);
                fdt.fkBuildingID = floor.fkBuildingID;

                //find building parent and set localpos
                FindObjectToAttract(emptyobj, StctType.Building, fdt.fkBuildingID);
                emptyobj.transform.localPosition = new Vector3(Mathf.CeilToInt(floor.floorIndex) * 1000, 0, 0);

                // create plane child
                GameObject plane          = GameObject.CreatePrimitive(PrimitiveType.Plane);
                Transform  planeTransform = plane.transform;
                planeTransform.SetParent(emptyobj.transform);
                planeTransform.localPosition = planePosition;
                planeTransform.localRotation = planeRotation;
                planeTransform.localScale    = planeScale;
                ChangeMat(plane, floor.floorImageName);
            }
        }
        catch (ArgumentException age)
        {
            Debug.Log("Floor Error: " + age.Message);
            readState = ReadState.FloorError;
        }
        catch (System.Exception)
        {
            Debug.Log("Floor Error other exception");
            readState = ReadState.FloorError;
        }
    }
Exemple #20
0
 public void Prune()
 {
     for (int i = Floors.Count - 1; i >= 0; i--)
     {
         FloorData data = Floors[i];
         if (data.Health <= 0)
         {
             Floors.RemoveAt(i);
         }
     }
 }
        private void OnSelectedFloorItem(object sender, ItemTappedEventArgs e)
        {
            FloorData md  = (FloorData)lv_floor.SelectedItem;
            int       cnt = Vm.FloorModelList.IndexOf(md);

            if (cnt >= 0)
            {
                Vm.FloorSelection(cnt);
            }

            ((ListView)sender).SelectedItem = null;
        }
Exemple #22
0
    static FloorTable()
    {
        FloorData data = null;

        data = new FloorData(1, 15, true, true, 0, (int)eNPC.Waepon);
        m_mapFloor.Add(data.nID, data);

        data = new FloorData(2, 12, true, true, 0, (int)eNPC.SkillPoint);
        m_mapFloor.Add(data.nID, data);

        data = new FloorData(3, 3, false, false, (StatTable.nCategoryGap * (int)eStatCategory.Boss) + 1, (int)eNPC.None);
        m_mapFloor.Add(data.nID, data);
    }
Exemple #23
0
    private void Awake()
    {
        _waveController.OnWaveEnded += HandleWaveEnded;
        _floorData = GetComponent <FloorData>();
        _transfomTakeDictionary = new Dictionary <Transform, bool>();
        _userIsActiveDictionaty = new Dictionary <GameObject, bool>();

        foreach (var user in _userInActivity)
        {
            user.SetActive(false);
            _transfomTakeDictionary.Add(user.transform, false);
            _userIsActiveDictionaty.Add(user, false);
        }
    }
    private void Awake()
    {
        curDestFloor         = GameConfig.kFloorInvalid;
        curElevatorDirection = Direction.Down;
        floorData            = new Dictionary <uint, FloorData>();
        for (uint i = 0; i < GameConfig.NumFloor; i++)
        {
            FloorData data = new FloorData(i + 1);
            floorData[data.level] = data;
        }

        elevatorData         = new ElevatorData();
        listFloorsRequesting = new HashSet <uint>();
    }
 /* return gemeobject of cycled floor  if not found return null */
 public GameObject GetNextFloor(string floorName)
 {
     for (int i = 0; i < floorList.Count; i++)
     {
         FloorData fl = floorList[i].GetComponent <FloorData>();
         if (floorName == fl.floorName && i >= floorList.Count - 1)                  // last index return first
         {
             return(floorList[0]);
         }
         else if (floorName == fl.floorName)                                                         //name ard equal return next index
         {
             return(floorList[i + 1]);
         }
     }
     return(null);                                                                                                           //not found return null
 }
    public GameObject GetPreviousFloor(string floorName)
    {
        for (int i = floorList.Count - 1; i >= 0; i--)
        {
            FloorData fl = floorList[i].GetComponent <FloorData>();
            if (floorName == fl.floorName && i <= 0)
            {
                return(floorList[floorList.Count - 1]);
            }
            else if (floorName == fl.floorName)                                                         //name ard equal return previous index

            {
                return(floorList[i - 1]);
            }
        }
        return(null);                                                                                           //not found return null
    }
Exemple #27
0
 /* return gemeobject of cycled floor  if not found return null */
 public GameObject GetNextFloor(string floorName)
 {
     for (int i = 0; i < floorList.Count; i++)
     {
         FloorData fl = floorList[i].GetComponent <FloorData>();
         if (floorName == fl.floorName && i >= floorList.Count - 1)                  // last index return first
         //Debug.Log(i + ">" + (floorList.Count-1) +" is Last index   RETURN " + floorList[0].GetComponent<FloorData>().floorName + " @"+floorList[0].GetComponent<FloorData>().floorIndex);
         {
             return(floorList[0]);
         }
         else if (floorName == fl.floorName)                                                         //name ard equal return next index
         //Debug.Log(i + "=" + fl.floorName +" name equal  RETURN " + floorList[i+1].GetComponent<FloorData>().floorName + " @"+floorList[i+1].GetComponent<FloorData>().floorIndex);
         {
             return(floorList[i + 1]);
         }
     }
     return(null);                                                                                                           //not found return null
 }
Exemple #28
0
    public override void Spawn(FloorData currentFloor, FloorData desiredFloor, ElevatorController elevator, Material material, GameManager gm)
    {
        gm.OnElevatorStoped      += ElevatorStoped;
        gm.OnFloorChanged        += ElevatorMoved;
        gm.OnFailedToGetPosition += HandleCrowdedFloor;
        _gameManager              = gm;

        _elevator                     = elevator;
        _currentFloor                 = currentFloor;
        DesiredFloor                  = desiredFloor;
        MeshRenderer.material         = material;
        _meshRendererRagDoll.material = material;
        _animator                     = GetComponent <UserAnimator>();
        _rigidbody                    = GetComponent <Rigidbody>();
        _uiColorChanger               = FindObjectOfType <UICcolorsChanger>();
        _animator.Run();
        RunToDeath();
    }
    private void FillTilesWithFloor()
    {
        Vector2Int levelSize = level.GetLevelSize();

        for (int x = 0; x < levelSize.x; ++x)
        {
            for (int y = 0; y < levelSize.y; ++y)
            {
                Vector2Int pos  = new Vector2Int(x, y);
                ILevelTile tile = level.GetTileAtPos(pos);

                FloorData floorData = new FloorData(pos);

                ILevelElement floor = LevelElementFactory.InstantiateLevelElement(floorData, transform);
                levelDataManager.AddLevelElement(floor);
            }
        }
    }
Exemple #30
0
 public GameObject GetPreviousFloor(string floorName)
 {
     for (int i = floorList.Count - 1; i >= 0; i--)
     {
         FloorData fl = floorList[i].GetComponent <FloorData>();
         if (floorName == fl.floorName && i <= 0)
         {
             //Debug.Log(i + "<" + 0 +" is First index   RETURN " + floorList[floorList.Count-1].GetComponent<FloorData>().floorName + " @"+floorList[floorList.Count-1].GetComponent<FloorData>().floorIndex);
             return(floorList[floorList.Count - 1]);
         }
         else if (floorName == fl.floorName)                                                         //name ard equal return previous index
         //Debug.Log(i + "=" + fl.floorName +" name equal  RETURN " + floorList[i-1].GetComponent<FloorData>().floorName + " @"+floorList[i-1].GetComponent<FloorData>().floorIndex);
         {
             return(floorList[i - 1]);
         }
     }
     return(null);                                                                                           //not found return null
 }
Exemple #31
0
 public Floor(FloorData data)
 {
     FloorRect = data.FloorRect;
     Rooms = new List<Room>();
     //Debug.Log("RoomCount1: "+data.Rooms.Length);
     foreach (RoomData room in data.Rooms) {
         Room r = new Room(room);
         this.Rooms.Add(r);
     }
     //Debug.Log("RoomCount2: " + this.Rooms.Count);
     Pathways = new List<Pathway>();
     foreach (PathWayData pw in data.Pathways) {
         Pathways.Add(new Pathway(pw));
     }
     BlindMode = data.BlindMode;
     EnemySpawnEnabled = data.EnemySpwanEnabled;
     DetectedMonsterHouse = data.DetectedMonasterHouse;
     ConnectionCheckEnd = false;
 }