예제 #1
0
    //metodo che istanzia tutti gli oggetti di cui si ha bisogno per il tutorial
    private void ShowTutorialEmotion(GameObject objectSelected)
    {
        //disattiva il pannello
        facesPanel.SetActive(false);
        SelectableObject sel = objectSelected.GetComponent <SelectableObject>();
        Emotion          emo = sel.GetEmotionType();

        if (emo.ToString() != "Disgusto")
        {
            topText.text = UIEndRoundManager.ChangeTextToRandomColors("Questa e' la " + MinigameManager.ConvertInCorrectText(emo.ToString()));
        }
        else
        {
            topText.text = UIEndRoundManager.ChangeTextToRandomColors("Questo e' il " + MinigameManager.ConvertInCorrectText(emo.ToString()));
        }

        //crea tutti gli elementi
        CreateFace("main", emo.ToString(), new Vector3(0, -0.5f, 0), 1.5f, null, false);
        CreateEmotionString(emo.ToString(), new Vector3(0, -200, 0));
        GameObject face1 = CreateFace("random", emo.ToString(), new Vector3(5.5f, 1f, 0), 1.2f, null, false);

        face1.GetComponent <Avatar>().AssignEmotion(emo);
        GameObject face2 = CreateFace("random", emo.ToString(), new Vector3(5.5f, -2.5f, 0), 1.2f, null, false);

        face2.GetComponent <Avatar>().AssignEmotion(emo);
        CreatePhoto(emo.ToString());
    }
예제 #2
0
	// Update is called once per frame
	void Update () {

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        //Ray ray = myCamera.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit, range)) {

            SelectableObject selected = hit.collider.GetComponent<SelectableObject>();
            if (selected != LastSelected) {
                Unselect();
                if (selected != null)
                    selected.Select();
                LastSelected = selected;
            }

        } else {
            Unselect();
        }

        if (Input.GetButtonDown("Fire1")) {
            if (LastSelected) {
                LastSelected.SendMessage("Interact");
            }
        }
    }
예제 #3
0
        private void Awake()
        {
            _root = transform.GetChild(0).gameObject;

            _initRootPosition      = _root.transform.localPosition;
            _framelessRootPosition = _initRootPosition + _framelessOffset;

            DoorBase         = _root.transform.Find(DoorBaseName).gameObject;
            _doorHandle      = _root.transform.Find(DoorHandleName).gameObject;
            _doorHandleBase1 = _root.transform.Find(DoorHandleBase1Name).gameObject;
            _doorHandleBase2 = _root.transform.Find(DoorHandleBase2Name).gameObject;
            _frames1         = _root.transform.Find(Frames1Name).gameObject;
            _frames2         = _root.transform.Find(Frames2Name).gameObject;
            _nameplate       = _root.transform.Find(NameplateName).gameObject;
            _bellButton      = _root.transform.Find(BellButtonName).gameObject;
            _bellBase        = _root.transform.Find(BellBaseName).gameObject;

            _initBellBasePosition   = _bellBase.transform.localPosition;
            _initBellButtonPosition = _bellButton.transform.localPosition;

            _framelessBellBasePosition   = _initBellBasePosition - _framelessOffset;
            _framelessBellButtonPosition = _initBellButtonPosition - _framelessOffset;

            _pad                   = _root.transform.Find(PadName).gameObject;
            _tape                  = _root.transform.Find(TapeName).gameObject;
            _peephole              = SelectableObject.GetAsChild <SwitchableObject>(_root, PeepholeName);
            _pushableDetails       = transform.GetComponentsInChildren <DoorPushableDetail>();
            _nameplateMatComponent = _nameplate.GetComponent <MeshRenderer>().material;

            Randomize();
        }
예제 #4
0
        public void PathReturnsSameInstanceObjectWasCreatedWith()
        {
            IPath path             = Get <IPath>();
            var   selectableObject = new SelectableObject("wizard", path);

            Assert.AreEqual(path, selectableObject.Path);
        }
예제 #5
0
 public void DeselectObject()
 {
     if (selectedObject)
     {
         selectedObject = null;
     }
 }
예제 #6
0
    public override void Attack(SelectableObject target)
    {
        // prevent attacking self or teammate
        if (target == this || target.team == team || target.IsDead)
        {
            return;
        }

        // can't attack if too far from target
        if (Vector3.Distance(transform.position, target.transform.position) > attackRange)
        {
            return;
        }

        float      dmg = (health / maxHealth) * maxDamage;
        GameObject projectileObject = Instantiate(projectilePrefab, transform.position, Quaternion.Euler(90, 0, 0));

        projectile = projectileObject.GetComponent <Projectile>();
        if (projectile)
        {
            projectile.Launch(target, dmg);
            FinishMove();
        }
        else
        {
            Debug.LogError(name + ": projectile not found");
        }
    }
예제 #7
0
    public void OnPointerClick(PointerEventData eventData)
    {
        mouseClickPosition = eventData.position;
        Messager.SendMassege("Клик по объекту: " + eventData);
        if (!Input.GetKey(KeyCode.RightControl) && !Input.GetKey(KeyCode.LeftControl))
        {
            //DeselectAll(eventData);
        }

        //OnSelect(eventData);
        //mouseClickPosition = eventData.position;
        Vector2 objOnScreen = new Vector2();

        //Utility.WorldToScreenPoint(selectObject.transform.position, out objOnScreen);

        Debug.Log("Позиция объекта: " + objOnScreen);
        foreach (SelectableObject sObj in SelectableObject.AllSelectableObjects)
        {
            if (mouseClickPosition == objOnScreen)
            {
                sObj.SelectObject();
                Debug.Log("Всего выделенных объектов: " + SelectableObject.AllSelectedObjectCount());
            }
        }



        OnSelect(eventData);
    }
    // Draw in all transition arrows
    private void DrawTransitions()
    {
        // Destroy existing transitions
        foreach (Transition transition in transitions)
        {
            Destroy(transition.gameObject);
        }
        transitions.Clear();

        // Build pairs of transitions
        List <Tuple <GameObject, GameObject> > transitionPairs = new List <Tuple <GameObject, GameObject> >();

        GameObject[] musicObjects = Utils.ChildrenOf(GameObject.Find("/Music"));

        // Check objects for transitions to add
        foreach (GameObject musicObject in musicObjects)
        {
            // Check for all selectable objects
            SelectableObject selectableObject = musicObject.GetComponent <SelectableObject>();

            // Check that target exists
            if (selectableObject != null && selectableObject.target != null)
            {
                transitionPairs.Add(new Tuple <GameObject, GameObject>(musicObject, selectableObject.target));
            }
        }

        // Draw transitions
        foreach (Tuple <GameObject, GameObject> transition in transitionPairs)
        {
            CreateTransition(transition.Item1, transition.Item2);
        }
    }
예제 #9
0
파일: Team.cs 프로젝트: tkaczmarz/Dziki
    private void OnLevelWasLoaded(int level)
    {
        GameObject team = GameObject.Find("Team" + nr);

        if (team)
        {
            List <GameObject> troops = new List <GameObject>();
            foreach (Transform child in team.transform)
            {
                troops.Add(child.gameObject);
            }
            foreach (GameObject unit in troops)
            {
                unit.SetActive(true);
                SelectableObject s = unit.GetComponent <SelectableObject>();
                if (s)
                {
                    s.AssignToTeam(this);
                    Troops.Add(s);
                }
            }
        }
        else
        {
            Debug.Log("Team not found!");
        }
    }
예제 #10
0
        public void MainDraw()
        {
            if (Selected != null)
            {
                if (Selected.Dead && !SelectedFamily)
                {
                    Selected = null;
                }
            }
            Draw3D.Graphics.Clear(Color.Gray);
            DrawWorld();
            DrawGUI();

            /*Graphics.DrawString("Camera:" + CameraPos2.X.ToString("0.0") + "," + CameraPos2.Y.ToString("0"), Font, Brushes.Black, 20, 70);
             * Graphics.DrawString("Chunk:" + CameraChunk.X.ToString() + "," + CameraChunk.Y.ToString(), Font, Brushes.Black, 20,90);
             * Vector V;
             * VectorI C;
             * ScreenToWorld(Form1.MousePos.X, Form1.MousePos.Y,out V,out C);
             *
             * Graphics.DrawString("Mouse:" + V.X.ToString("0.0") + "," + V.Y.ToString("0"), Font, Brushes.Black, 20, 110);
             * Graphics.DrawString("Chunk:" + C.X.ToString() + "," + C.Y.ToString(), Font, Brushes.Black, 20, 130);
             *
             * PointF P = WorldToScreen(C, V);
             * Graphics.FillEllipse(Brushes.Blue,P.X-5, P.Y - 5,10,10);*/
        }
예제 #11
0
    protected virtual void SelectObject(SelectableObject newSelection)
    {
        ClearSelectedObject();

        selectedObject = newSelection.objectType;
        ApplicationManager.s_instance.SetSpecialMouseMode((int)ApplicationManager.SpecialCursorMode.ClosedHand);
    }
    private IEnumerator Roam()
    {
        while (true)
        {
            yield return(new WaitForSeconds(UnityEngine.Random.value * 10.0f + 0.5f));

            if (IsInteracting)
            {
                Debug.LogError("Should have stopped this coroutine by now");
            }
            if (UnityEngine.Random.value < 0.2f)
            {
                SelectableObject randomObject = GetRandomAvailableSelectableObject();
                if (randomObject != null)
                {
                    SelectedObject = randomObject;
                    IsInteracting  = true;
                    Interaction randomInteraction = SelectedObject.GetRandomNpcInteraction();
                    SelectedInteraction = randomInteraction;
                    yield return(null);
                }
            }
            Destination = GetRandomLocation();
        }
    }
예제 #13
0
    // Update is called once per frame
    void Repair()
    {
        if (repairingObject != null)
        {
            SelectableObject so = repairingObject.GetComponent <SelectableObject>();
            if (proficiency == so.expertieseNeeded)
            {
                if (proficiency == RepairStrength.Charm)
                {
                    so.health += charm;
                }
                if (proficiency == RepairStrength.Chemical)
                {
                    so.health += chemical;
                }
                if (proficiency == RepairStrength.Engineering)
                {
                    so.health += engineering;
                }
                if (proficiency == RepairStrength.Farming)
                {
                    so.health += chemical;
                }
            }

            so.health += charm * Random.Range(0f, .25f);
            so.health += chemical * Random.Range(0f, .25f);
            so.health += engineering * Random.Range(0f, .25f);
            so.health += chemical * Random.Range(0f, .25f);
            so.health  = Mathf.Clamp(so.health, 0, 100);
        }
    }
예제 #14
0
    public override void initMode(SelectableObject obj)
    {
        cellSelected = obj.getCell();
        Cell    cell   = cellSelected as Cell;
        Bounds  bounds = cell.GetComponent <Collider>().bounds;
        Vector3 anchor = cell.getAnchor();

        selector.transform.position = new Vector3(anchor.x, bounds.max.y + 1, anchor.z);

        if (cellSelected.getBuilding() is Building)
        {
            setSelectorDimensions((cellSelected.getBuilding() as Building).getDimensions());
        }
        else
        {
            GetComponent <GameModeManager>().enableSelectionMode();
        }

        if (cellSelected.getBuilding() != null)
        {
            currentSelection = cellSelected.getBuilding();
            (currentSelection as Building).getCanvas().SetActive(true);
        }
        else
        {
            currentSelection = cellSelected;
        }

        //GameObject [] selectores =GameObject.FindGameObjectsWithTag("SelectorVisual");
        //selectores[0].GetComponent<Renderer>().sharedMaterial.color = Color.blue;
    }
예제 #15
0
 /// <summary>
 /// Removes the roboy part from the selected objects.
 /// </summary>
 /// <param name="obj">SelectableObject component of the roboy part.</param>
 public void RemoveSelectedObject(SelectableObject obj)
 {
     if (m_SelectedParts.Contains(obj))
     {
         m_SelectedParts.Remove(obj);
     }
 }
예제 #16
0
 /// <summary>
 /// Remove a SimObject from the selection.
 /// </summary>
 /// <param name="toRemove">The SelectableObject to remove.</param>
 public void removeSelectedObject(SelectableObject toRemove)
 {
     changedArgs.reset();
     changedArgs.setObjectRemoved(toRemove);
     selectedObjects._removeObject(toRemove);
     fireSelectionChanged();
 }
        private void AddData(IVoxelDataStructure data)
        {
            var selectableData = new SelectableObject <IVoxelDataStructure>(data);

            Data.Add(selectableData);
            selectableData.ObjectSelectionChanged += SelectableData_ObjectSelectionChanged;
        }
예제 #18
0
 /// <summary>
 /// Add a SimObject to the selection.
 /// </summary>
 /// <param name="toSelect">The SelectableObject to add to the selection.</param>
 public void addSelectedObject(SelectableObject toSelect)
 {
     changedArgs.reset();
     changedArgs.setObjectAdded(toSelect);
     selectedObjects._addObject(toSelect);
     fireSelectionChanged();
 }
예제 #19
0
 private void OnHandExit(SelectableObject obj)
 {
     if (obj == this && !selected)
     {
         animator.SetTrigger("PopDown");
     }
 }
예제 #20
0
    void LateUpdate()
    {
        SelectableObject obj  = GameSession.Instance.selectedObject;
        ButtonCard       card = GameSession.Instance.selectedCard;

        if (obj != null)
        {
            // In confirm state
            Vector3 pos      = Camera.main.WorldToScreenPoint(obj.transform.position);
            float   fov      = Camera.main.fieldOfView;
            float   maxFov   = CameraController.maxFov;
            float   fovScale = maxFov / fov;
            guiTexture.pixelInset = new Rect(pos.x - Screen.width / 2f - fovScale * width / 2f,
                                             pos.y - Screen.height / 2f - fovScale * height / 2f,
                                             fovScale * width, fovScale * height);
            if (GameSession.Instance.isDefender && card != null)
            {
                guiTexture.texture = PrefabManager.UIConfirm;
            }
            else
            {
                guiTexture.texture = PrefabManager.UISelected;
            }
        }
        else
        {
            guiTexture.pixelInset = Constants.offScreenRect;
        }
    }
예제 #21
0
 public void OnHandEnter(SelectableObject obj)
 {
     if (obj == this && !selected)
     {
         animator.SetTrigger("PopUp");
     }
 }
예제 #22
0
 public void UpdateSelectedPanel()
 {
     if (currentSelection != null)
     {
         SelectableObject so = currentSelection.GetComponent <SelectableObject>();
         if (so)
         {
             if (repairPanel.activeSelf)
             {
                 selectableObjectPanel.SetActive(false);
             }
             else
             {
                 selectableObjectPanel.SetActive(true);
             }
             selectableObjectTitle.text  = so.title;
             selectableObjectHealth.text = "Health: " + (so.health / 100).ToString("00.00%");
             selectableObjectOutput.text = "Output: " + (so.output / 100).ToString("00.00%");
         }
         else
         {
             selectableObjectPanel.SetActive(false);
         }
     }
     else
     {
         selectableObjectPanel.SetActive(false);
     }
 }
예제 #23
0
    private void OnTouchBegan(Touch touch)
    {
        //TODO Multi selection
        if (existSelection())
        {
            //There is a previous selection so we ignore the incoming touch
            return;
        }

        //Raycast to the world so we can pick an object
        RaycastHit2D raycast = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 0)), Vector3.forward, 1000, LayerFilter);

        if (raycast.collider != null)
        {
            SelectableObject selectedObject = raycast.collider.gameObject.GetComponent <SelectableObject>();

            if (selectedObject != null)
            {
                //adding selection
                selectedObjects.Add(touch.fingerId, new Selection());
                selectedObjects[touch.fingerId].obj        = selectedObject;
                selectedObjects[touch.fingerId].selectorId = touch.fingerId;


                //notify about the selection
                selectedObjects[touch.fingerId].obj.SelectionBegan(raycast.point);
            }
        }
    }
예제 #24
0
 public static void ObjectSelected(SelectableObject obj)
 {
     if (OnUnitSelected != null)
     {
         OnUnitSelected(obj);
     }
 }
예제 #25
0
    private void Update()
    {
        if (player == null)
        {
            if (PlayerController.instance == null)
            {
                return;
            }
            else
            {
                player = PlayerController.instance;
            }
        }
        canvas.enabled = target == null ? false : true;
        if (!canvas.enabled)
        {
            return;
        }

        transform.LookAt(player.diveCameraOrigin.position);

        if (target != null)
        {
            transform.position = player.diveCameraOrigin.position
                                 + (target.Center.position - player.diveCameraOrigin.position).normalized * 2.0f;
        }

        remainingDesplayTime -= Time.deltaTime;
        if (remainingDesplayTime <= 0)
        {
            canvas.enabled = false;
            target         = null;
        }
    }
예제 #26
0
    void CheckObject()
    {
        if (Selected != null)
        {
            Selected.LookAtMe = false;
            ChangePointerColor(Color.white);
        }

        RaycastHit hit;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, Range, LayerMask.GetMask("Selectable")))
        {
            Selected = hit.transform.GetComponent <SelectableObject>();
            if (Selected != null)
            {
                if (Selected.Available)
                {
                    Selected.LookAtMe = true;
                    ChangePointerColor(Color.yellow);

                    if (Input.GetButtonDown("Fire1"))
                    {
                        Selected.Action();
                    }
                }
            }
        }

        void ChangePointerColor(Color col)
        {
            pointer.color = col;
        }
    }
        public void PathReturnsSameInstanceObjectWasCreatedWith()
        {
            IPath path = Get<IPath>();
            var selectableObject = new SelectableObject("wizard", path);

            Assert.AreEqual(path, selectableObject.Path);
        }
예제 #28
0
    //deselects an object
    public void DeselectItem(SelectableObject obj)
    {
        obj.OnDeselect();

        //remove obj
        if (SelectedObjects.Contains(obj))
        {
            SelectedObjects.Remove(obj);
        }

        //exception checking
        if (SelectedObjects.Count > 0)
        {
            if (PrimarySelectable == obj)
            {
                PrimarySelectable = SelectedObjects[SelectedObjects.Count - 1];
            }
            if (SelectedObjects.Count > 1)
            {
                SelectionUI.Instance.ProcessUI(false);
            }
        }
        else
        {
            ClearSelection();
        }
    }
예제 #29
0
        public async Task <CodeExecutor> DelayedCreateObject(CodeExecutor original, SelectableObject selectable)
        {
            var obj = selectable.GetComponent <IObject>();

            if (obj.cloneCount >= 25)
            {
                await Task.Delay(1);
            }

            if (!running)
            {
                return(null);
            }

            var exec = Instantiate(original, scene); //CreateObject(selectable, false, obj, selectable.GetComponent<CodeExecutor>());

            if (obj.lastCloneTime == Time.unscaledTime)
            {
                obj.cloneCount++;
            }
            else
            {
                obj.lastCloneTime = Time.unscaledTime;
                obj.cloneCount    = 1;
            }

            return(exec);
        }
예제 #30
0
 /// <summary>
 /// Add an object to the collection.
 /// </summary>
 /// <param name="toAdd">The object to add.</param>
 internal void _addObject(SelectableObject toAdd)
 {
     if (!selectedObjects.Contains(toAdd))
     {
         selectedObjects.Add(toAdd);
         computeOffsets();
     }
 }
예제 #31
0
        public void AddPoi(PointOfInterest poi)
        {
            var so = new SelectableObject <PointOfInterest>(poi);

            so.ObjectSelectionChanged += So_ObjectSelectionChanged;
            PointsOfInterest.Add(so);
            so.IsSelected = true;
        }
예제 #32
0
 public virtual void OnDeselect()
 {
     if (selected == this)
     {
         selected = null;
         HideWindow();
     }
 }
        public void BecauseOf()
        {
            m_Path = Get<IPath>();
            m_Motion = Get<IMotion>();

            m_Path.GetCurrentMotion(Arg.Any<ulong>()).Returns(m_Motion);

            m_SelectableObject = new SelectableObject(m_TestObjectName, m_Path);
        }
 public void GoToModelView(SelectableObject so)
 {
     //Wylacz widok pokoju
     _rooms[_activeRoom].gameObject.SetActive(false);
     //Wlacz widok modelu, przekaz mu wybrany obiekt oraz wszystkie obietky w tym pokoju
     _modelView.gameObject.SetActive(true);
     _modelView.SetCurrentObject(so);
     _modelView.SetList(_rooms[_activeRoom].Selectables);
 }
예제 #35
0
    public void AddItemOnLoad(SelectableObject item)
    {
        item.take = false;
        items.Add(item);

        if(items.Count > 4) {
            leftArrow.ButtonEnabled = true;
            rightArrow.ButtonEnabled = true;
        }

        DisplayPage();
    }
예제 #36
0
파일: VRCursor.cs 프로젝트: TomTomsn/Assets
    void CheckCollision()
    {
        ShowCursor (true);
        RaycastHit hitInfo;
        MenuIcon.selectedItem = null;
        if (Physics.Raycast(transform.position, cursor.transform.position - transform.position, out hitInfo)){
            if (hitInfo.collider.gameObject.tag == "Screen"){
                ShowCursor(false);
            }
            //Test if the collided object is selectable
            SelectableObject so = hitInfo.collider.gameObject.GetComponent<SelectableObject>();
            if (so == null && lastSelectedSo != null && lastSelectedSo.progressBar)
            {
                lastSelectedSo.progressBar.SetActive(false);
            }

            if (so && !UIController.Instance.menu)
            {
                selectionTimer += Time.deltaTime;
                if (so.selectionTime != 0)
                {
                    so.SetProgress(selectionTimer / so.selectionTime);
                }
                if (selectionTimer >= so.selectionTime)
                {
                    so.SelectionEvent();
                    if (so.selectionTime != 0) so.progressBar.SetActive(false);
                    //Inform the ui controller that a menu has been selected
                    UIController.Instance.SetMenu(so.menuPrefab.gameObject);
                }
            }
            //If it is not a selectable object, test if it is a menu icon
            else
            {
                selectionTimer = 0;
                MenuIcon mi = hitInfo.collider.gameObject.GetComponent<MenuIcon>();
                if (mi)
                {
                    MenuIcon.selectedItem = mi;
                }
            }
            lastSelectedSo = so;
        }
        else if (lastSelectedSo)
        {
            selectionTimer = 0;
            if (lastSelectedSo.progressBar) lastSelectedSo.progressBar.SetActive(false);
        }
    }
예제 #37
0
    public bool SelectObject()
    {
        if (currentSelectedObject == null)
        {
            currentSelectedObject = this;
            OnSelectObject();

            return true;
        }
        else if (currentSelectedObject != this)
        {
            currentSelectedObject.OnDeDelectObject();
            currentSelectedObject = this;
            OnSelectObject();
            return true;
        }
        return false;
    }
예제 #38
0
    public void AddItem(SelectableObject item)
    {
        item.take = false;
        //update item's GUI buttons
        CharController sg = gameObject.GetComponent(typeof(CharController)) as CharController;
        sg.SelectedObject = null;
        sg.SelectedObject = item;
        sg.HoverObject = item;

        items.Add(item);
        SingletonSolution.Instance.AddToGlobalInventory(item);

        if(items.Count > 4) {
            leftArrow.ButtonEnabled = true;
            rightArrow.ButtonEnabled = true;
        }

        DisplayPage();
    }
예제 #39
0
 public void Unselect() {
     if (LastSelected) {
         LastSelected.Unselect();
         LastSelected = null;
     }
 }
예제 #40
0
    public void SetCurrentObject(SelectableObject so)
    {
        //Jesli juz jakis obiekt byl pokazywany to go usunmy
        if(_currentObject != null)
        {
            Destroy(_currentObject);
        }
        if(_currentAdditionalObject != null)
        {
            Destroy(_currentAdditionalObject);
        }
        if(so == null)
        {
            return;
        }
        //Stworzmy obiekt w oparciu o przeslane informacje (obiekt, mesh, rotacja), szablon (pozycje)
        _currentObject = (GameObject)Instantiate(so.gameObject, _modelObject.transform.position, so.transform.rotation);
        ChangeLayerRecursively(_currentObject, _modelObject.layer);
        //Ustawmy rodzica, pozwala zachowac porzadek w hierarchii
        _currentObject.transform.parent = _modelObject.transform.parent;
        //Odkolorujmy meshe
        MeshRenderer mr = _currentObject.GetComponent<MeshRenderer>();
        if (mr != null)
        {
            mr.material.color = Color.white;
        }
        else
        {
            //Jak potrzeba to dzieci tez odkolorujmy
            MeshRenderer[] mrs = _currentObject.GetComponentsInChildren<MeshRenderer>();
            foreach(MeshRenderer tmp in mrs)
            {
                tmp.material.color = Color.white;
            }
        }
        //Ustawmy opis
        _description.text = so.Description;

        if(so.AdditionalObject != null)
        {
            //Obliczamy offset pozycji dodatkowego gameobjectu
            Vector3 offset = so.AdditionalObject.gameObject.transform.position - so.gameObject.transform.position;
            _currentAdditionalObject = (GameObject)Instantiate(so.AdditionalObject, _modelObject.transform.position + offset, so.AdditionalObject.transform.rotation);
            ChangeLayerRecursively(_currentAdditionalObject, _modelObject.layer);
            //Ustawmy rodzica, pozwala zachowac porzadek w hierarchii oraz zachowac wszelkie transformacje typu obiekt etc
            _currentAdditionalObject.transform.parent = _currentObject.transform;
            //Odkolorujmy meshe
            mr = _currentAdditionalObject.GetComponent<MeshRenderer>();
            if (mr != null)
            {
                mr.material.color = Color.white;
            }
            else
            {
                //Jak potrzeba to dzieci tez odkolorujmy
                MeshRenderer[] mrs = _currentAdditionalObject.GetComponentsInChildren<MeshRenderer>();
                foreach (MeshRenderer tmp in mrs)
                {
                    tmp.material.color = Color.white;
                }
            }

            //Jesli ten drugi obiekt tez jest wybieralny to ma opis :)
            //Wiec doklejamy opis tego drugiego obiektu do pierwszego :)
            SelectableObject additionalSO = so.AdditionalObject.GetComponent<SelectableObject>();
            if(additionalSO != null)
            {
                _description.text += "\n\n";
                _description.text += additionalSO.Description;
            }
        }
    }
예제 #41
0
    public void RemoveItem(SelectableObject item)
    {
        items.Remove(item);

        if(items.Count <= 4) {
            leftArrow.ButtonEnabled = false;
            rightArrow.ButtonEnabled = false;
        }

        DisplayPage();
    }
예제 #42
0
    public void SetCurrentObject(SelectableObject obj)
    {
        currentObject = obj;

        if(currentObject == null) {
            buttonEnabled = false;
            gameObject.renderer.material.SetTexture("_MainTex", disabled);
            return;
        }

        switch(type) {
        case ButtonType.talk:
            if(currentObject.talk) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        case ButtonType.take:
            if(currentObject.take) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        case ButtonType.open:
            if(currentObject.open) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        case ButtonType.close:
            if(currentObject.close) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        case ButtonType.enter:
            if(currentObject.enter) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        case ButtonType.combine:
            if(currentObject.combine) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        case ButtonType.observe:
            if(currentObject.observe) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        case ButtonType.use:
            if(currentObject.use) {
                buttonEnabled=true;
                gameObject.renderer.material.SetTexture("_MainTex", enabled);
            }
            break;
        default:
            Debug.Log("Button type has not been set correctly OR button type is not recognized.");
            break;
        }
    }
 // any other methods you need
 public void AddToGlobalInventory(SelectableObject item)
 {
     globalItems.Add(item);
 }
        public void SetUp()
        {
            m_Bus = Substitute.For<IBus>();
            m_Id = new PlayerId();
            m_VesselRepo = Substitute.For<IVesselRepository>();

            m_Repository = new SelectableObjectRepository(m_Bus, m_Id, m_VesselRepo);

            m_Position = new Vector(5, 7);
            m_TestTime = 500;

            m_SelectableObject = CreateSelectableObjectAt(m_Position);

            m_Repository.AddObject(m_SelectableObject);
        }