public HumanDelete(int originNum, int objectNum, string humanName, Vector3 pos, Vector3 rot, Vector3 scale, List <AniBarDelete> A, List <AniBarVoiceDelete> AA, HumanItem hu)
 {
     this._originNum        = originNum;
     this._objectNum        = objectNum;
     this._humanName        = humanName;
     this._pos              = pos;
     this._rot              = rot;
     this._scale            = scale;
     this.aniBarDelete      = A;
     this.aniBarVoiceDelete = AA;
     this._humanItem        = hu;
 }
Exemple #2
0
    /*
     * date 2020.01.20
     * author skyde47
     * desc
     * 기존 CheckUI함수는 clickedItem에 종속적이여서 히스토리에서는 NULL Reference Exception으로 사용불가능
     * 따라서 히스토리용 새로운 함수 작성
     */

    public void ForHistoryCheckUI(HumanItem _change, int _changeNum)
    {
        //shirt
        if (_changeNum == 1)
        {
            for (int i = 0; i < _shirtButtons.transform.GetChild(0).GetChild(0).childCount; i++)
            {
                if (_change._shirt.name.Equals(_shirtButtons.transform.GetChild(0).GetChild(0).GetChild(i).gameObject.name))
                {
                    _shirtButtons.transform.GetChild(0).GetChild(0).GetChild(i).GetChild(1).GetComponent <Image>().sprite = _check;
                }
                else
                {
                    _shirtButtons.transform.GetChild(0).GetChild(0).GetChild(i).GetChild(1).GetComponent <Image>().sprite = null;
                }
            }
        }
        //pant
        else if (_changeNum == 2)
        {
            for (int i = 0; i < _pantButtons.transform.GetChild(0).GetChild(0).childCount; i++)
            {
                if (_change._pant.name.Equals(_pantButtons.transform.GetChild(0).GetChild(0).GetChild(i).gameObject.name))
                {
                    _pantButtons.transform.GetChild(0).GetChild(0).GetChild(i).GetChild(1).GetComponent <Image>().sprite = _check;
                }
                else
                {
                    _pantButtons.transform.GetChild(0).GetChild(0).GetChild(i).GetChild(1).GetComponent <Image>().sprite = null;
                }
            }
        }
        //shoes
        else
        {
            for (int i = 0; i < _shoesButtons.transform.GetChild(0).GetChild(0).childCount; i++)
            {
                if (_change._shoes && _change._shoes.name.Equals(_shoesButtons.transform.GetChild(0).GetChild(0).GetChild(i).gameObject.name))
                {
                    _shoesButtons.transform.GetChild(0).GetChild(0).GetChild(i).GetChild(1).GetComponent <Image>().sprite = _check;
                }
                else if (!_change._shoes && _shoesButtons.transform.GetChild(0).GetChild(0).GetChild(i).gameObject.name.Equals("tookOff"))
                {
                    _shoesButtons.transform.GetChild(0).GetChild(0).GetChild(i).GetChild(1).GetComponent <Image>().sprite = _check;
                }
                else
                {
                    _shoesButtons.transform.GetChild(0).GetChild(0).GetChild(i).GetChild(1).GetComponent <Image>().sprite = null;
                }
            }
        }
    }
    /* 슬롯이 클릭되었을 때 */
    public void OnClickSlot()
    {
        _thisHuman     = _clickedItemControl._clickedItem;
        _thisHumanItem = _clickedItemControl._clickedHumanItem;

        if (_isLeft) //왼손이면
        {
            _hand = _clickedItemControl._clickedItem.item3d.transform.GetChild(0).GetChild(1).GetChild(0).GetChild(2).GetChild(0).GetChild(0).GetChild(1).GetChild(0).GetChild(0).GetChild(0);

            if (_thisHumanItem._leftHandItem != null) //이미 왼손에 handitem을 들고있는 경우
            {
                _itemName = _thisHumanItem._leftHandItem.itemName;
                HistoryController.pushHandHist(_thisHuman._originNumber, _thisHuman._objectNumber, _isLeft, _itemName, _thisHumanItem._leftHandItem);
                if (!_thisHumanItem._leftHandItem.itemName.Equals(_thisItem.itemName)) //이미 들고있는 물건과 착용하려는 물건이 같지않은 경우
                {
                    GameObject dObj = _hand.Find(_thisHumanItem._leftHandItem.itemName).gameObject;
                    Destroy(dObj);
                    _thisHumanItem._leftHandItem = _thisItem;
                }
                else
                {
                    GameObject dObj = _hand.Find(_thisHumanItem._leftHandItem.itemName).gameObject;
                    Destroy(dObj);
                    _thisHumanItem._leftHandItem = null;
                    return;
                }
            }
            else
            {
                _itemName = "null";
                HistoryController.pushHandHist(_thisHuman._originNumber, _thisHuman._objectNumber, _isLeft, _itemName, _thisHumanItem._leftHandItem);
                _thisHumanItem._leftHandItem = _thisItem;
            }
        }
        else //오른손이면
        {
            _hand = _clickedItemControl._clickedItem.item3d.transform.GetChild(0).GetChild(1).GetChild(0).GetChild(2).GetChild(0).GetChild(0).GetChild(2).GetChild(0).GetChild(0).GetChild(0);

            if (_thisHumanItem._rightHandItem != null) //이미 왼손에 handitem을 들고있는 경우
            {
                _itemName = _thisHumanItem._rightHandItem.itemName;
                HistoryController.pushHandHist(_thisHuman._originNumber, _thisHuman._objectNumber, _isLeft, _itemName, _thisHumanItem._rightHandItem);
                if (!_thisHumanItem._rightHandItem.itemName.Equals(_thisItem.itemName))
                {
                    GameObject dObj = _hand.Find(_thisHumanItem._rightHandItem.itemName).gameObject;
                    Destroy(dObj);
                    _thisHumanItem._rightHandItem = _thisItem;
                }
                else
                {
                    GameObject dObj = _hand.Find(_thisHumanItem._rightHandItem.itemName).gameObject;
                    Destroy(dObj);
                    _thisHumanItem._rightHandItem = null;
                    return;
                }
            }
            else
            {
                _itemName = "null";
                HistoryController.pushHandHist(_thisHuman._originNumber, _thisHuman._objectNumber, _isLeft, _itemName, _thisHumanItem._rightHandItem);
                _thisHumanItem._rightHandItem = _thisItem;
            }
        }

        /* 실제로 handitem을 생성하는 과정 */

        GameObject _handObjectClone = Instantiate(_thisItem.item3d);               //객체 생성

        _handObjectClone.name = _thisItem.itemName;                                //이름 지정
        _handObjectClone.transform.SetParent(_hand);                               //손을 부모로 설정
        _handObjectClone.transform.localRotation = Quaternion.Euler(Vector3.zero); //로컬 회전값을 손 회전값과 동일하게 변경

        //각 객체에 따라 객체의 위치 조정
        if (_clickedItemControl._clickedItem._originNumber == 2001) //Man
        {
            _localPos = _handObjectClone.transform.GetComponentInChildren <HandItem>()._manRightPos;
        }
        else if (_clickedItemControl._clickedItem._originNumber == 2002) //Woman
        {
            _localPos = _handObjectClone.transform.GetComponentInChildren <HandItem>()._womanRightPos;
        }
        else if (_clickedItemControl._clickedItem._originNumber == 2000) //Daughter
        {
            _localPos = _handObjectClone.transform.GetComponentInChildren <HandItem>()._daughterRightPos;
        }
        else if (_clickedItemControl._clickedItem._originNumber == 2003) //Woongin
        {
            _localPos = _handObjectClone.transform.GetComponentInChildren <HandItem>()._woonginPos;
        }
        else
        {
            _localPos = _hand.transform.GetChild(2).transform.position; //세번째 손가락 위치로 지정
        }

        _handObjectClone.transform.localPosition = _localPos;

        if (_isLeft)
        {
            //왼손일 경우 좌우 반전
            Vector3 _tmp = _handObjectClone.transform.localScale;
            _tmp.z *= -1;
            _handObjectClone.transform.localScale = _tmp;

            //앞 뒤 반전
            _tmp   = _handObjectClone.transform.localPosition;
            _tmp.z = -_tmp.z;
            _handObjectClone.transform.localPosition = _tmp;
        }

        //_handObjectClone.transform.localPosition = _localPos;

        //_handObjectClone.transform.localRotation = Quaternion.Euler(_handObjectClone.transform.localRotation * (_clickedItemControl._clickedItem.item3d.transform.forward.normalized * (-1)));

        //Debug.Log("HandSlot 96 : " + (_hand.transform.position - _clickedItemControl._clickedItem.item3d.transform.position).normalized);
        //Debug.Log("HandSlot 93 : "+_clickedItemControl._clickedItem.item3d.transform.forward.normalized*(-1));
    }
        private void RefreshStats()
        {
            /* finally proper way how to use object approach */

            if (empRepo == null && dpmRepo == null && salRepo == null)
            {
                return; //protection //needed - initialized in ctor
            }

            people = HumanItem.MakeHumans(empRepo.GetAll().ToList(), dpmRepo.GetAll().ToList(), salRepo.GetAll().ToList());

            tbStats.Clear();
            tbStats.AppendText("Number of employees: " + people.Count() + "\r\n");
            tbStats.AppendText("Employees per departments: \r\n");

            /*var query = people.SelectMany(x => x.NameDpm).GroupBy(s => s).Select(g => new { Namedpm = g.Key, Count = g.Count() });
             * foreach (var result in query) //LAMBDA is not working, idea: return count of employees peer departements
             * {
             *  tbStats.AppendText(String.Format("  Name: {0}, Count: {1}\r\n", result, result.Count));
             * }*/

            Dictionary <string, int> emploPerDeparts = new Dictionary <string, int>();

            foreach (HumanItem hu in people)
            {
                try
                {
                    emploPerDeparts.Add(hu.NameDpm, 0);
                }
                catch
                { }
                finally
                {
                    emploPerDeparts[hu.NameDpm] += 1;
                }
            }
            foreach (KeyValuePair <string, int> kvp in emploPerDeparts)
            {
                tbStats.AppendText(String.Format("  > {0}, employees: {1}\r\n", kvp.Key, kvp.Value)); //should be sorted
            }

            //average salary per months
            DateTime oldest = DateTime.Now;
            DateTime newest = DateTime.MinValue; //.ToString(dateTimeFormats)

            foreach (HumanItem hi in people)
            {
                foreach (SoloSalary ss in hi.ListSalaries)
                {
                    if (ss.validFrom < oldest)
                    {
                        oldest = ss.validFrom;
                    }
                    if (ss.validUntil > newest)
                    {
                        newest = ss.validUntil;
                    }
                }
            }

            tbSalaStats.AppendText(String.Format("Salaries from {0} to {1}\r\n", oldest.ToString(dateTimeFormat), newest.ToString(dateTimeFormat))); //should be sorted

            //income per month
            if (salariesPerMonth == null)
            {
                salariesPerMonth = new Dictionary <DateTime, List <double> >();
            }

            foreach (DateTime dt in monthsBetween(oldest, newest))
            {
                foreach (HumanItem hi in people)
                {
                    foreach (SoloSalary ss in hi.ListSalaries)
                    {
                        if ((dt > ss.validFrom) && (dt < ss.validUntil))
                        {
                            try
                            {
                                salariesPerMonth.Add(dt, new List <Double>());
                            }
                            catch
                            {
                                //if datetime already exist
                            }
                            finally
                            {
                                salariesPerMonth[dt].Add(ss.Amount);
                            }
                        }
                    }
                }
            }

            foreach (KeyValuePair <DateTime, List <double> > kvp in salariesPerMonth)
            {
                double average = 0;
                if (kvp.Value.Count > 0)
                {
                    average = kvp.Value.Average();
                }

                tbSalaStats.AppendText(String.Format("  > {0}, average €: {1}\r\n", kvp.Key.ToString("MM.yyyy"), Math.Round(average, 2)));
            }
        }
    /* 놓은 장소에 물체 생성하는 과정*/
    private void ReleaseIfClicked()
    {
        if (Input.GetMouseButtonDown(0))
        {
            /* 마우스 작업상태 -> false 로 전환해준다! */
            UIController._isMouseUsed = false;

            /* 벽 밖에 포인터를 갖다대면, 그 위치로 조정 못하도록 */
            /* 내부에서만 */
            if (_inDoor.activeSelf == true)
            {
                _clickedItemSize = _placableGameObject.transform.GetChild(0).GetComponent <Collider>().bounds.size;
                if (point.x + _clickedItemSize.x / 2 > _vec3.x)
                {
                    _placableGameObject.transform.position = new Vector3(_vec3.x - _clickedItemSize.x / 2, _placableGameObject.transform.position.y, _placableGameObject.transform.position.z);
                }
                if (point.x - _clickedItemSize.x / 2 < -_vec3.x)
                {
                    _placableGameObject.transform.position = new Vector3(-_vec3.x + _clickedItemSize.x / 2, _placableGameObject.transform.position.y, _placableGameObject.transform.position.z);
                }
                if (point.z + _clickedItemSize.z / 2 > _vec3.z)
                {
                    _placableGameObject.transform.position = new Vector3(_placableGameObject.transform.position.x, _placableGameObject.transform.position.y, _vec3.z - _clickedItemSize.z / 2);
                }
            }

            /* 본체의 위치 - 중심점을 만들기 위하여 사용한 객체가 아니라 실제 객체*/
            _placableGameObject = _placableGameObject.transform.GetChild(0).gameObject;

            /* 설치한 오브젝트의 layer를 Default로 변경, 이걸 해야 클릭을 하든 뭘 하든 할 수가 있음 */
            _placableGameObject.layer = LayerMask.NameToLayer("Default");

            /* 재조정하는 물체인지 아닌지 판별 */
            /* 새로 위치를 잡는 아이템인 경우 */
            if (!_reLocateSwi)
            {
                /*생성된 오브젝트에 ItemObject라는 스크립트 추가*/
                _placableGameObject.AddComponent <ItemObject>();

                /* 빠른 연결을 위한 캐싱 작업 */
                ItemObject _tmp = _placableGameObject.GetComponent <ItemObject>();

                /* 만들어진 객체가 사람 일때 -> HumanItem.cs 추가 생성 */
                if (_placableItem._originNumber >= 2000 && _placableItem._originNumber < 3000)
                {
                    /* _tmpItem을 새로 선언해 주고 연결해준다. */
                    HumanItem _tmpHuman = new HumanItem("Idle", _itemListControl._humanDBIndex);

                    /* 추가한 ItemObject에 현재 Item의 정보를 담음 */
                    _tmp._thisHuman = _tmpHuman;

                    /* 생성한 사람 객체를 ItemListControl.cs에 있는 HumanList에 저장. ItemListControl.cs 의 _dataBaseHumanItem 변수와 관련 */
                    _itemListControl.AddHumanDB(_tmpHuman);
                }

                /* _tmpItem을 새로 선언해 주고 연결해준다. */
                /*사람객체를 생성할때는 오브젝트 넘버를 사람넘버에서 따와서 넣어준다.*/
                Item _tmpItem;
                if (_placableItem._originNumber >= 2000 && _placableItem._originNumber < 2005)
                {
                    _tmpItem = new Item(_placableItem.itemName, _itemListControl._humanDBIndex, _placableItem._originNumber, _placableGameObject);
                }
                else
                {
                    _tmpItem = new Item(_placableItem.itemName, _itemListControl._itemDBIndex, _placableItem._originNumber, _placableGameObject);
                }


                /* 추가한 ItemObject에 현재 Item의 정보를 담음 */
                _tmp._thisItem = _tmpItem;

                if (_placableItem._originNumber < 2000 || _placableItem._originNumber > 2005) //사람이 아닐때
                {
                    /* 생성한 객체를 ItemListControl.cs에 있는 List에 저장. ItemListControl.cs 의 _dataBaseItem 변수와 관련 */
                    _itemListControl.AddDB(_tmpItem);
                }
                else
                {
                    _itemListControl.AddHuman(_tmpItem);

                    /*
                     *   History
                     *   date   : 2020-02-10
                     *   author : skyde47
                     *   desc : HumanItem 갱신
                     */

                    HumanItem _tmpHuman = _tmp._thisHuman;
                    Transform _quick    = _tmpItem.item3d.transform.Find("shirt");
                    //shirt의 자식 객체를 탐색하며 활성화되어있는 객체 저장
                    for (int i = 0; i < _quick.childCount; i++)
                    {
                        if (_quick.GetChild(i).gameObject.activeSelf)
                        {
                            _tmpHuman._shirt     = _quick.GetChild(i).gameObject;
                            _tmpHuman._shirtName = _tmpHuman._shirt.name;
                        }
                    }
                    //pant의 자식 객체를 탐색하며 활성화되어있는 객체 저장
                    _quick = _tmpItem.item3d.transform.Find("pant");
                    for (int i = 0; i < _quick.childCount; i++)
                    {
                        if (_quick.GetChild(i).gameObject.activeSelf)
                        {
                            _tmpHuman._pant     = _quick.GetChild(i).gameObject;
                            _tmpHuman._pantName = _tmpHuman._pant.name;
                        }
                    }
                    //shoes의 자식 객체를 탐색하며 활성화되어있는 객체 저장
                    if (_tmpItem.item3d.transform.Find("shoes").GetChild(0).gameObject.activeSelf) //현재 발 상태가 normal
                    {
                        _quick = _tmpItem.item3d.transform.Find("shoes");
                        for (int i = 0; i < _quick.GetChild(0).childCount; i++)
                        {
                            //normal의 자식객체를 탐색하며 활성화된 객체의 경우 저장
                            if (_quick.GetChild(0).GetChild(i).gameObject.activeSelf)
                            {
                                _tmpHuman._shoes     = _quick.GetChild(0).GetChild(i).gameObject;
                                _tmpHuman._shoesName = _tmpHuman._shoes.name;
                            }
                        }
                    }
                    else //abnormal
                    {
                        _quick = _tmpItem.item3d.transform.Find("shoes");
                        for (int i = 0; i < _quick.GetChild(1).childCount; i++)
                        {
                            //normal의 자식객체를 탐색하며 활성화된 객체의 경우 저장
                            if (_quick.GetChild(1).GetChild(i).gameObject.activeSelf)
                            {
                                _tmpHuman._shoes     = _quick.GetChild(1).GetChild(i).gameObject;
                                _tmpHuman._shoesName = _tmpHuman._shoes.name;
                            }
                        }
                    }
                }


                /* Item의 생성번호를 부여 */
                if (_placableItem._originNumber >= 2000 && _placableItem._originNumber < 2005)
                {
                    _tmp.GetComponent <ItemObject>()._thisItem._objectNumber = _itemListControl._humanDBIndex;
                    HistoryController.pushObjectCreateHist(_placableGameObject, _placableItem._originNumber, _itemListControl._humanDBIndex);
                }
                else
                {
                    _tmp.GetComponent <ItemObject>()._thisItem._objectNumber = _itemListControl._itemDBIndex;
                    HistoryController.pushObjectCreateHist(_placableGameObject, _placableItem._originNumber, _itemListControl._itemDBIndex);
                }


                /* 윤곽선 안보이게 처리! */
                //_placableGameObject.GetComponent<Outline>().enabled = false;

                if (_placableItem._originNumber >= 2000 && _placableItem._originNumber < 2005)
                {
                    /* 스몰 스케줄러에 각 Item 값을 채워줌. */
                    Item      temp     = _tmp.GetComponent <ItemObject>()._thisItem;
                    Transform smallBar = _smallScheduler.transform.Find(temp.itemName + temp._objectNumber);
                    smallBar.GetComponent <SmallSchedulerBar>()._object = _tmpItem;
                }
            }
            /* 위치를 재조정하는 아이템인 경우 */
            else
            {
                _reLocateSwi = false;

                /* 윤곽선 보이게 처리! -> 위치 재조정 해도 클릭된 아이템은 여전하므로 */
                //_placableGameObject.GetComponent<Outline>().enabled = true;

                /* Sprite 이미지가 해당 위치로 이동하도록 설정 */
                _SpriteObject.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y + 30.0f, Input.mousePosition.z);

                _SpriteObject.SetActive(true);

                ///* 위치 설정 하는 객체가 사람일 경우 줌 인 필요! */
                //if (_placableItem._originNumber >= 2000 && _placableItem._originNumber < 3000)
                //{
                //    Static.STATIC.cameraMoveAroun.CameraZoomIn(_placableGameObject.transform.position);
                //}
            }

            _placableGameObject.GetComponent <ItemObject>()._humanInitPosition = point;
            _placableGameObject.GetComponent <ItemObject>()._humanInitRotation = _placableGameObject.transform.rotation.eulerAngles;

            /* 위치 조정을 마쳤으면 이제 null 선언으로 끊어준다. */
            _placableGameObject = null;
            _placableItem       = null;
        }

        /*
         * History
         * date   : 2018-11-26
         * author : Lugup
         * 내  용 : Item Relocate... 하는 스크립트였으나
         * 실행시 : 클릭한 객체의 위치를 기존의 위치에서 새로운 위치로 조정함
         * 취소시 : 클릭했던 객체의 위치를 새로운 위치에서 기존의 위치로 조정
         *
         */
    }
 public void AddHumanDB(HumanItem item)
 {
     //_dateBaseHumanItem.Add(item);
 }