コード例 #1
0
 public static void Invoke_cb_newAnimationState(PhysicalInteractable physicalInteractable, string state)
 {
     if (cb_newAnimationState != null)
     {
         cb_newAnimationState(physicalInteractable, state);
     }
 }
コード例 #2
0
    // Draw Line


    public void CreateLine(PhysicalInteractable physicalInteractable)
    {
        GameObject lineObj = new GameObject("frameline_" + physicalInteractable.identificationName);

        lineObj.transform.SetParent(this.transform);

        LineRenderer lr = lineObj.AddComponent <LineRenderer> ();

        //lr.loop = true;
        //lr.positionCount = 4;
        lr.widthMultiplier = 0.1f;


        List <Vector3> positionList = Utilities.EditorGetPhysicalInteractableFrameBounds(physicalInteractable);

        Debug.Log("center" + positionList [0]);


        Vector3[] posArray = new Vector3[4];


        for (int i = 1; i < positionList.Count; i++)
        {
            posArray [i - 1] = positionList [i] + positionList [0] + new Vector3(physicalInteractable.currentGraphicState.frameOffsetX, physicalInteractable.currentGraphicState.frameOffsetY, -5);
        }


        lr.SetPositions(posArray);

        lineContainer.Add(lineObj);
    }
コード例 #3
0
 public static void Invoke_cb_playerHitPhysicalInteractable(PhysicalInteractable physicalInt)
 {
     if (cb_playerHitPhysicalInteractable != null)
     {
         cb_playerHitPhysicalInteractable(physicalInt);
     }
 }
コード例 #4
0
    // ------ FRAME SIZE ------ //


    public void ChangeInteractableFrameWidth(float width, PhysicalInteractable interactable)
    {
        width = Mathf.Abs(width);
        interactable.currentGraphicState.frameExtents.x = width;

        EventsHandler.Invoke_cb_tileLayoutChanged();
    }
コード例 #5
0
    public void ChangeInteractableFrameHeight(float height, PhysicalInteractable interactable)
    {
        height = Mathf.Abs(height);
        interactable.currentGraphicState.frameExtents.y = height;

        EventsHandler.Invoke_cb_tileLayoutChanged();
    }
コード例 #6
0
    // Sorting order //

    public static void SetPISortingOrder(PhysicalInteractable myPI, GameObject obj)
    {
        // sorting order

        SpriteRenderer[] sr_list = obj.GetComponentsInChildren <SpriteRenderer> ();

        for (int i = 0; i < sr_list.Length; i++)
        {
            sr_list[i].sortingOrder = i + (-myPI.y * 10) + (int)myPI.layerOffset;             //FIXME

            if (myPI.walkable == true)
            {
                sr_list[i].sortingOrder = (int)-(myPI.y + myPI.mySize.y) * 10;
            }

            if (myPI.aboveFrame == true)
            {
                sr_list[i].sortingLayerName = Constants.aboveFrame_layer;
            }
            else
            {
                sr_list[i].sortingLayerName = Constants.furniture_character_layer;
            }
        }
    }
コード例 #7
0
    // ------- GRAPHIC STATE ------- //


    public void ChangeInteractableCurrentGraphicState(string state, PhysicalInteractable interactable)
    {
        foreach (GraphicState graphicState in interactable.graphicStates)
        {
            Debug.Log(graphicState.graphicStateName + "=>" + state);
            if (graphicState.graphicStateName == state)
            {
                Debug.Log("found state");

                // clean previous graphic state

                EditorRoomManager.instance.room.ChangePIInTiles(interactable, graphicState);
                interactable.currentGraphicState = graphicState;

                // go to animation state

                GameObject obj      = GetPhysicalInteractableGameObject(interactable);
                Animator   animator = obj.GetComponent <Animator> ();
                animator.PlayInFixedTime(state);

                EventsHandler.Invoke_cb_tileLayoutChanged();
                return;
            }
        }

        Debug.LogError("I shouldn't be here.");
    }
コード例 #8
0
    public void SetPhysicalInteractableFrame(PhysicalInteractable myPhysicalInt, Tile tile)
    {
        if (myPhysicalInt.myInteractionList.Count == 0)
        {
            return;
        }


        if (currentPhysicalInteractableFrame != null)
        {
            return;
        }

        currentPhysicalInteractable = myPhysicalInt;

        currentPhysicalInteractableFrame = Instantiate(FurnitureFramePrefab);


        List <Vector3> positionsList = Utilities.GetPhysicalInteractableFrameBounds(myPhysicalInt);

        currentPhysicalInteractableFrame.GetComponent <RectTransform> ().anchoredPosition = positionsList [0];

        currentPhysicalInteractableFrame.transform.FindChild("FramePiece_DL").GetComponent <RectTransform> ().anchoredPosition = positionsList [1];
        currentPhysicalInteractableFrame.transform.FindChild("FramePiece_DR").GetComponent <RectTransform> ().anchoredPosition = positionsList [2];
        currentPhysicalInteractableFrame.transform.FindChild("FramePiece_UL").GetComponent <RectTransform> ().anchoredPosition = positionsList [3];
        currentPhysicalInteractableFrame.transform.FindChild("FramePiece_UR").GetComponent <RectTransform> ().anchoredPosition = positionsList [4];
    }
コード例 #9
0
    public void CreateGraphicStatePanel(PhysicalInteractable physicalInteractable, int i = 0)
    {
        if (graphicStateInspectorObject != null)
        {
            return;
        }

        graphicStateInspectorObject = Instantiate(Resources.Load <GameObject> ("Prefabs/Editor/InteractionPanelPrefabs/GraphicStatePanel"));

        panel = graphicStateInspectorObject.transform.Find("Panel");

        graphicStateDropdown = panel.Find("GraphicStateDropdown").GetComponent <Dropdown> ();

        frameExtentsXInput = panel.Find("FrameExtentsXInput").GetComponent <InputField> ();
        frameExtentsYInput = panel.Find("FrameExtentsYInput").GetComponent <InputField> ();
        frameOffsetXInput  = panel.Find("FrameOffsetXInput").GetComponent <InputField> ();
        frameOffsetYInput  = panel.Find("FrameOffsetYInput").GetComponent <InputField> ();

        frameExtentsXPlaceholder = panel.Find("FrameExtentsXInput").Find("Placeholder").GetComponent <Text> ();
        frameExtentsYPlaceholder = panel.Find("FrameExtentsYInput").Find("Placeholder").GetComponent <Text> ();
        frameOffsetXPlaceholder  = panel.Find("FrameOffsetXInput").Find("Placeholder").GetComponent <Text> ();
        frameOffsetYPlaceholder  = panel.Find("FrameOffsetYInput").Find("Placeholder").GetComponent <Text> ();

        changeCoordsToggle = panel.Find("ChangeCoordsToggle").GetComponent <Toggle> ();
        closeButton        = panel.Find("CloseButton").GetComponent <Button> ();

        // OPENING //

        GameObject obj = EditorRoomManager.instance.GetPhysicalInteractableGameObject(physicalInteractable);

        List <string> optionList = Utilities.GetAnimationClipNames(obj);

        if (optionList.Count == 0)
        {
            optionList.Add("default");
        }

        graphicStateDropdown.AddOptions(optionList);
        graphicStateDropdown.value = i;

        frameExtentsXPlaceholder.text = physicalInteractable.currentGraphicState.frameExtents.x.ToString();
        frameExtentsYPlaceholder.text = physicalInteractable.currentGraphicState.frameExtents.y.ToString();

        frameOffsetXPlaceholder.text = physicalInteractable.currentGraphicState.frameOffsetX.ToString();
        frameOffsetYPlaceholder.text = physicalInteractable.currentGraphicState.frameOffsetY.ToString();


        // Listeners

        graphicStateDropdown.onValueChanged.AddListener(ChangeCurrentGraphicState);

        frameExtentsXInput.onEndEdit.AddListener(ChangeFrameWidth);
        frameExtentsYInput.onEndEdit.AddListener(ChangeFrameHeight);

        frameOffsetXInput.onEndEdit.AddListener(ChangeFrameOffsetX);
        frameOffsetYInput.onEndEdit.AddListener(ChangeFrameOffsetY);

        changeCoordsToggle.onValueChanged.AddListener(SetChangeCoordsMode);
        closeButton.onClick.AddListener(DestroyGraphicStatePanel);
    }
コード例 #10
0
    // Setting furniture animation state

    public void SetPIAnimationState(string PI_name, string state, GameObject obj = null)
    {
        //	Debug.Log ("SetPIAnimationState " + PI_name + state);


        if (name_PI_map.ContainsKey(PI_name))
        {
            PhysicalInteractable physicalInteractable = name_PI_map [PI_name];

            if (obj == null)
            {
                obj = PI_gameObjectMap [physicalInteractable];
            }

            Animator animator = obj.GetComponent <Animator> ();

            ChangeCurrentGraphicState(physicalInteractable, state);

            animator.PlayInFixedTime(state);
            Utilities.SetPISortingOrder(physicalInteractable, obj);
        }
        else
        {
            Debug.LogError("I don't have this title name " + PI_name);
        }
    }
コード例 #11
0
 public void CloseFurnitureFrame()
 {
     if (currentPhysicalInteractableFrame != null)
     {
         Destroy(currentPhysicalInteractableFrame.gameObject);
         currentPhysicalInteractable = null;
     }
 }
コード例 #12
0
    // Use this for initialization

    public void Initialize()
    {
        EventsHandler.cb_playerHitPhysicalInteractable   += SelectPhysicalInteractable;
        EventsHandler.cb_playerLeavePhysicalInteractable += CloseFurnitureFrame;

        EventsHandler.cb_keyPressedDown += BrowseInteractions;

        currentPhysicalInteractable = null;
    }
コード例 #13
0
ファイル: Room.cs プロジェクト: Stavu/TheSplitting3
    // When changing a graphic state - change physical interactable tiles

    public void ChangePIInTiles(PhysicalInteractable physicalInteractable, GraphicState newState)
    {
        //Debug.Log ("ChangePIInTiles");

        List <Tile> oldTiles;

        if (physicalInteractable.CurrentGraphicState().coordsList.Count > 0)
        {
            //Debug.Log ("get list from coords");
            oldTiles = GetMyTiles(MyGrid, physicalInteractable.CurrentGraphicState().coordsList);
        }
        else
        {
            //Debug.Log ("get list from size");
            oldTiles = GetMyTiles(MyGrid, physicalInteractable.mySize, physicalInteractable.x, physicalInteractable.y);
        }

        List <Tile> newTiles;

        if (newState.coordsList.Count > 0)
        {
            newTiles = GetMyTiles(MyGrid, newState.coordsList);
        }
        else
        {
            newTiles = GetMyTiles(MyGrid, physicalInteractable.mySize, physicalInteractable.x, physicalInteractable.y);
        }

        if (physicalInteractable is Furniture)
        {
            foreach (Tile oldTile in oldTiles)
            {
                oldTile.myFurniture = null;
            }

            foreach (Tile newTile in newTiles)
            {
                newTile.myFurniture = (Furniture)physicalInteractable;
            }
        }

        if (physicalInteractable is Character)
        {
            foreach (Tile oldTile in oldTiles)
            {
                oldTile.myCharacter = null;
            }

            foreach (Tile newTile in newTiles)
            {
                newTile.myCharacter = (Character)physicalInteractable;
            }
        }

        EventsHandler.Invoke_cb_tileLayoutChanged();
    }
コード例 #14
0
    // PI tiles

    public void SetPICoords(Tile tile)
    {
        Coords coords = new Coords(tile.x, tile.y);

        PhysicalInteractable chosenPhysicalInteractable = InspectorManager.instance.GetChosenPI();

        for (int i = 0; i < chosenPhysicalInteractable.currentGraphicState.coordsList.Count; i++)
        {
            if ((chosenPhysicalInteractable.currentGraphicState.coordsList[i].x == coords.x) && (chosenPhysicalInteractable.currentGraphicState.coordsList[i].y == coords.y))
            {
                chosenPhysicalInteractable.currentGraphicState.coordsList.RemoveAt(i);
                tile.myFurniture = null;
                tile.myCharacter = null;
                EventsHandler.Invoke_cb_tileLayoutChanged();

                return;
            }
        }

        // Get furniture out of old tiles if there wasn't a coords list before

        if (chosenPhysicalInteractable.currentGraphicState.coordsList.Count == 0)
        {
            List <Tile> oldTileList = EditorRoomManager.instance.room.GetMyTiles(EditorRoomManager.instance.room.MyGrid, chosenPhysicalInteractable.mySize, chosenPhysicalInteractable.x, chosenPhysicalInteractable.y);

            foreach (Tile oldTile in oldTileList)
            {
                if (chosenPhysicalInteractable is Furniture)
                {
                    oldTile.myFurniture = null;
                }

                if (chosenPhysicalInteractable is Character)
                {
                    oldTile.myCharacter = null;
                }
            }
        }

        chosenPhysicalInteractable.currentGraphicState.coordsList.Add(coords);

        if (chosenPhysicalInteractable is Furniture)
        {
            tile.myFurniture = (Furniture)chosenPhysicalInteractable;
        }

        if (chosenPhysicalInteractable is Character)
        {
            tile.myCharacter = (Character)chosenPhysicalInteractable;
        }

        EventsHandler.Invoke_cb_tileLayoutChanged();
    }
コード例 #15
0
ファイル: Utilities.cs プロジェクト: Stavu/TheSplitting3
    public static void SetPISortingOrder(PhysicalInteractable myPI, GameObject obj)
    {
        // sorting order

        SpriteRenderer[] sr_list = obj.GetComponentsInChildren <SpriteRenderer> ();
        //Debug.Log ("length" + obj.transform.childCount);


        for (int i = 0; i < obj.transform.childCount; i++)
        {
            obj.transform.GetChild(i).GetComponent <SpriteRenderer> ().sortingOrder = i + (-myPI.y * 10);
        }
    }
コード例 #16
0
ファイル: PI_Handler.cs プロジェクト: Stavu/TheSplitting3
    public void AddPIToMap(PhysicalInteractable physicalInteractable, GameObject obj, string name)
    {
        PI_gameObjectMap.Add(physicalInteractable, obj);
        name_PI_map.Add(name, physicalInteractable);

        if (physicalInteractable is Player)
        {
            Player player = (Player)physicalInteractable;

            if (PlayerManager.instance.playerGameObjectMap.ContainsKey(player) == false)
            {
                PlayerManager.instance.playerGameObjectMap.Add(player, obj);
            }
        }
    }
コード例 #17
0
ファイル: PI_Handler.cs プロジェクト: Stavu/TheSplitting3
    // Change Current Graphic State

    public void ChangeCurrentGraphicState(PhysicalInteractable physicalInteractable, string state)
    {
        ActionBoxManager.instance.CloseFurnitureFrame();

        foreach (GraphicState graphicState in physicalInteractable.graphicStates)
        {
            //Debug.Log ("state " + state + " name " + graphicState.graphicStateName);

            if (graphicState.graphicStateName == state)
            {
                RoomManager.instance.myRoom.ChangePIInTiles(physicalInteractable, graphicState);
                physicalInteractable.currentGraphicState = graphicState;
                GameManager.userData.AddAnimationState(physicalInteractable.identificationName, state);
            }
        }
    }
コード例 #18
0
    // Change Current Graphic State

    public void ChangeCurrentGraphicState(PhysicalInteractable physicalInteractable, string state)
    {
        //Debug.Log ("change current graphic state " + physicalInteractable.identificationName + " " + state);

        ActionBoxManager.instance.CloseFurnitureFrame();

        foreach (GraphicState graphicState in physicalInteractable.graphicStates)
        {
            if (graphicState.graphicStateName == state)
            {
                Room room = RoomManager.instance.myRoom;

                // get the associated grids
                List <Grid> grids = new List <Grid>();

                if (physicalInteractable is Furniture)
                {
                    Furniture furn = (Furniture)physicalInteractable;

                    if (room.myFurnitureList.Contains(furn))
                    {
                        grids.Add(room.myGrid);
                    }

                    if (room.myMirrorRoom != null)
                    {
                        if (room.myMirrorRoom.myFurnitureList_Shadow.Contains(furn))
                        {
                            grids.Add(room.myMirrorRoom.shadowGrid);
                        }

                        if (room.myMirrorRoom.myFurnitureList_Persistant.Contains(furn))
                        {
                            grids.Clear();                              // maybe this is unnecessary, but whatever
                            grids.Add(room.myGrid);
                            grids.Add(room.myMirrorRoom.shadowGrid);
                        }
                    }
                }

                RoomManager.instance.myRoom.ChangePIInTiles(physicalInteractable, graphicState, grids);
                physicalInteractable.currentGraphicState = graphicState;
                GameManager.userData.AddAnimationState(physicalInteractable.identificationName, state);
                //Debug.Log ("save state");
            }
        }
    }
コード例 #19
0
    public void SelectPhysicalInteractable(PhysicalInteractable myPhysicalInt)
    {
        if (myPhysicalInt.myInteractionList.Count == 0)
        {
            return;
        }


        if (currentPhysicalInteractableFrame != null)
        {
            return;
        }

        currentPhysicalInteractable = myPhysicalInt;

        currentPhysicalInteractableFrame = CreateFrame(myPhysicalInt);
    }
コード例 #20
0
    public GameObject GetPhysicalInteractableGameObject(PhysicalInteractable physicalInteractable)
    {
        GameObject obj = null;

        if (physicalInteractable is Furniture)
        {
            Furniture furn = (Furniture)physicalInteractable;
            obj = furnitureGameObjectMap [furn];
        }

        if (physicalInteractable is Character)
        {
            Character character = (Character)physicalInteractable;
            obj = characterGameObjectMap [character];
        }

        return(obj);
    }
コード例 #21
0
    public static GameObject CreateFrame(PhysicalInteractable myPhysicalInt, bool inEditor = false)
    {
        GameObject frame = Instantiate(Resources.Load <GameObject>("Prefabs/FurnitureFrameObject"));

        List <Vector3> positionsList;


        positionsList = Utilities.GetPhysicalInteractableFrameBounds(myPhysicalInt, inEditor);

        frame.GetComponent <RectTransform> ().anchoredPosition = positionsList [0];

        frame.transform.Find("FramePiece_DL").GetComponent <RectTransform> ().anchoredPosition = positionsList [1];
        frame.transform.Find("FramePiece_DR").GetComponent <RectTransform> ().anchoredPosition = positionsList [2];
        frame.transform.Find("FramePiece_UL").GetComponent <RectTransform> ().anchoredPosition = positionsList [3];
        frame.transform.Find("FramePiece_UR").GetComponent <RectTransform> ().anchoredPosition = positionsList [4];

        return(frame);
    }
コード例 #22
0
    public void Hide_PI(string PI_name)
    {
        PhysicalInteractable physicalInteractable = name_PI_map [PI_name];

        if (physicalInteractable == null)
        {
            Debug.LogError("can't find PI by name");
            return;
        }

        physicalInteractable.hidden = true;

        if (PI_gameObjectMap.ContainsKey(physicalInteractable))
        {
            Destroy(PI_gameObjectMap [physicalInteractable]);
            PI_gameObjectMap.Remove(physicalInteractable);
        }

        foreach (Tile tile in RoomManager.instance.myRoom.MyGrid.gridArray)
        {
            if (tile.myFurniture == physicalInteractable)
            {
                tile.myFurniture = null;
            }
        }


        if (physicalInteractable is Furniture)
        {
            if (GameManager.userData.hiddenFurnitureList.Contains(PI_name) == false)
            {
                GameManager.userData.hiddenFurnitureList.Add(PI_name);
            }
        }

        if (physicalInteractable is Character)
        {
            if (GameManager.userData.hiddenCharacterList.Contains(PI_name) == false)
            {
                GameManager.userData.hiddenCharacterList.Add(PI_name);
            }
        }
    }
コード例 #23
0
    public void RoomStarter_Hide_Furniture(string PI_name)
    {
        PhysicalInteractable physicalInteractable = RoomManager.instance.getFurnitureByName(PI_name);

        if (physicalInteractable == null)
        {
            Debug.LogError("can't find PI by name");
            return;
        }

        physicalInteractable.hidden = true;

        if (physicalInteractable is Furniture)
        {
            if (GameManager.userData.hiddenFurnitureList.Contains(PI_name) == false)
            {
                GameManager.userData.hiddenFurnitureList.Add(PI_name);
            }
        }
    }
コード例 #24
0
    public void AddPIToMap(PhysicalInteractable physicalInteractable, GameObject obj, string name)
    {
        // FIXME: find out why it crashes here in the starting scene
        try
        {
            PI_gameObjectMap.Add(physicalInteractable, obj);
            name_PI_map.Add(name, physicalInteractable);

            if (physicalInteractable is Player)
            {
                Player player = (Player)physicalInteractable;

                if (PlayerManager.instance.playerGameObjectMap.ContainsKey(player) == false)
                {
                    PlayerManager.instance.playerGameObjectMap.Add(player, obj);
                }
            }
        }
        catch (System.Exception ex)
        {
        }
    }
コード例 #25
0
    public void RoomStarter_Unhide_PI(PhysicalInteractable physicalInteractable)
    {
        physicalInteractable.hidden = false;

        // Remove from hidden list

        if (physicalInteractable is Furniture)
        {
            if (GameManager.userData.hiddenFurnitureList.Contains(physicalInteractable.identificationName) == true)
            {
                GameManager.userData.hiddenFurnitureList.Remove(physicalInteractable.identificationName);
            }
        }

        if (physicalInteractable is Character)
        {
            if (GameManager.userData.hiddenCharacterList.Contains(physicalInteractable.identificationName) == true)
            {
                GameManager.userData.hiddenCharacterList.Remove(physicalInteractable.identificationName);
            }
        }
    }
コード例 #26
0
    public void UnHide_PI(PhysicalInteractable physicalInteractable)
    {
        physicalInteractable.hidden = false;


        if (physicalInteractable is Furniture)
        {
            Furniture furn = (Furniture)physicalInteractable;
            EventsHandler.Invoke_cb_furnitureChanged(furn);
        }

        if (physicalInteractable is Character)
        {
            Character character = (Character)physicalInteractable;
            EventsHandler.Invoke_cb_characterChanged(character);
        }


        // Remove from hidden list

        if (physicalInteractable is Furniture)
        {
            if (GameManager.userData.hiddenFurnitureList.Contains(physicalInteractable.identificationName) == true)
            {
                GameManager.userData.hiddenFurnitureList.Remove(physicalInteractable.identificationName);
            }
        }

        if (physicalInteractable is Character)
        {
            if (GameManager.userData.hiddenCharacterList.Contains(physicalInteractable.identificationName) == true)
            {
                GameManager.userData.hiddenCharacterList.Remove(physicalInteractable.identificationName);
            }
        }


        RoomManager.instance.myRoom.CreateRoomInteractables();
    }
コード例 #27
0
ファイル: Utilities.cs プロジェクト: Stavu/TheSplitting3
    public static List <Vector3> GetPhysicalInteractableFrameBounds(PhysicalInteractable myPhysicalInt)
    {
        // declerations

        Vector2 frameBounds = myPhysicalInt.CurrentGraphicState().frameExtents;

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

        SpriteRenderer sr = PI_Handler.instance.PI_gameObjectMap [myPhysicalInt].GetComponentInChildren <SpriteRenderer>();

        Vector3 center = sr.bounds.center + new Vector3(myPhysicalInt.currentGraphicState.frameOffsetX, myPhysicalInt.currentGraphicState.frameOffsetY, 0);

        // center

        positions.Add(center);

        // positioning frame pieces

        if (frameBounds == Vector2.zero)
        {
            frameBounds = sr.bounds.extents;
        }

        //down left
        positions.Add(new Vector3(-frameBounds.x, -frameBounds.y, 0));

        //down right
        positions.Add(new Vector3(frameBounds.x, -frameBounds.y, 0));

        //up left
        positions.Add(new Vector3(-frameBounds.x, frameBounds.y, 0));

        //up right
        positions.Add(new Vector3(frameBounds.x, frameBounds.y, 0));



        return(positions);
    }
コード例 #28
0
    public void SubmitInteraction()
    {
        // create interaction

        Interaction interaction;

        interaction = loadedInteraction;

        PhysicalInteractable currentPhysicalInteractable = null;

        if (InspectorManager.instance.chosenFurniture != null)
        {
            currentPhysicalInteractable = InspectorManager.instance.chosenFurniture;
        }
        else if (InspectorManager.instance.chosenCharacter != null)
        {
            currentPhysicalInteractable = InspectorManager.instance.chosenCharacter;
        }

        // If this is a new interaction, add to interaction list

        if (currentPhysicalInteractable != null)
        {
            if (currentPhysicalInteractable.myInteractionList.Contains(interaction) == false)
            {
                currentPhysicalInteractable.myInteractionList.Add(interaction);
            }
        }

        DestroyInteractionPanel();


        // Refreshing inspector

        InspectorManager.physicalInteractableInspector.DestroyInspector();
        InspectorManager.physicalInteractableInspector.CreateInspector(currentPhysicalInteractable);
    }
コード例 #29
0
    // ----- SUBINTERACT ----- //



    public void SubInteract()
    {
        //Debug.Log ("subinteract");

        switch (interactionType)
        {
        case "showMonologue":

            InteractionManager.instance.DisplayText(Utilities.CreateSentenceList(PlayerManager.myPlayer, textList), isImportant);

            break;


        case "showDialogue":

            InteractionManager.instance.DisplayDialogueOption(this.dialogueOptionTitle);

            break;


        case "showDialogueTree":

            DialogueTree dialogueTree = GameManager.gameData.nameDialogueTreeMap [this.dialogueTreeName];

            if (dialogueTree.currentConversation == null)
            {
                if (dialogueTree.conversationList.Count == 0)
                {
                    Debug.LogError("There are no conversations");
                }

                dialogueTree.currentConversation = dialogueTree.conversationList [0];
            }

            DialogueManager.instance.ActivateDialogueTree(dialogueTree);

            break;


        case "PlayAnimation":

            PI_Handler.instance.SetPIAnimationState(targetFurniture, animationToPlay);
            EventsHandler.Invoke_cb_inputStateChanged();

            break;


        case "PlayAnimationOn":

            PI_Handler.instance.SetPIAnimationState(targetFurniture, animationToPlayOn);
            EventsHandler.Invoke_cb_inputStateChanged();

            break;


        case "PlaySound":

            SoundManager.Invoke_cb_playSound(soundToPlay, numberOfPlays);
            EventsHandler.Invoke_cb_inputStateChanged();

            break;


        case "StopSound":

            SoundManager.Invoke_cb_stopSound(soundToStop);
            EventsHandler.Invoke_cb_inputStateChanged();

            break;


        case "PlayCutscene":

            Debug.Log("subinteract" + "play cut scene");

            CutsceneManager.instance.PlayCutscene(cutsceneToPlay);

            break;


        case "moveToRoom":

            InteractionManager.instance.MoveToRoom(destinationRoomName, entrancePoint);

            break;


        case "intoShadows":

            Debug.Log("into shadows");

            InteractionManager.instance.ChangeShadowState(true);

            break;


        case "outOfShadows":

            Debug.Log("out of shadows");

            InteractionManager.instance.ChangeShadowState(false);
            InteractionManager.instance.ResetRoom(RoomManager.instance.myRoom.myName);

            break;


        case "pickUpItem":

            InteractionManager.instance.PickUpItem(inventoryItem);
            ActionBoxManager.instance.CloseFurnitureFrame();

            EventsHandler.Invoke_cb_inputStateChanged();

            break;


        case "removeItem":

            InteractionManager.instance.RemoveItem(itemToRemove);
            ActionBoxManager.instance.CloseFurnitureFrame();

            EventsHandler.Invoke_cb_inputStateChanged();

            break;


        case "useItem":

            InteractionManager.instance.OpenInventory_UseItem(ActionBoxManager.instance.currentPhysicalInteractable);

            break;


        case "changeConversation":


            Debug.Log("change conversation");
            DialogueManager.instance.SetConversation(conversationName);

            break;


        case "endDialogueTree":

            DialogueManager.instance.DestroyDialogueTree();

            break;


        case "showInventoryText":

            InteractionManager.instance.DisplayInventoryText(textList);

            break;


        case "changeInventoryItemBigPicture":

            //InteractionManager.instance.ChangeInventoryItemBigPicture (fileName);

            break;


        case "combine":

            InteractionManager.instance.OpenInventory_CombineItem();

            break;


        case "addEvent":

            GameManager.userData.AddEventToList(eventToAdd);

            break;


        case "removeEvent":

            GameManager.userData.RemoveEventFromList(eventToRemove);

            break;


        case "switchPlayer":

            PlayerManager.instance.SwitchPlayer(newPlayer);
            break;


        case "hidePI":


            PI_Handler.instance.Hide_PI(PItoHide);
            break;



        case "showPI":

            PhysicalInteractable tempPI = RoomManager.instance.getFurnitureByName(PItoShow);

            PI_Handler.instance.UnHide_PI(tempPI);
            break;

        case "special":

            InteractionManager.instance.SpecialInteraction(specialSubInt);

            break;
        }
    }
コード例 #30
0
    public void CreatePIGameObject(PhysicalInteractable myPhysicalInteractable)
    {
        // if the furniture has an identification name, use it as the name. If it doesn't, use the file name.

        bool   useIdentifiactionName = ((myPhysicalInteractable.identificationName != null) && (myPhysicalInteractable.identificationName != string.Empty));
        string PI_name = useIdentifiactionName ? myPhysicalInteractable.identificationName : myPhysicalInteractable.fileName;

        // for an active player, we do not calculate a position
        // it is done by the MoveToRoom function
        // for inactive players and other PIs we do
        if ((myPhysicalInteractable is Player) == false)
        {
            myPhysicalInteractable.myPos = new Vector3(myPhysicalInteractable.x + myPhysicalInteractable.mySize.x / 2, myPhysicalInteractable.y, 0);
        }
        if (myPhysicalInteractable is Player)
        {
            Player player = (Player)myPhysicalInteractable;

            if (player.isActive == false)
            {
                myPhysicalInteractable.myPos = new Vector3(myPhysicalInteractable.x + myPhysicalInteractable.mySize.x / 2, myPhysicalInteractable.y, 0);
            }
        }

        GameObject     obj = null;
        SpriteRenderer sr  = null;

        // Animated Object

        if (GameManager.stringPrefabMap.ContainsKey(myPhysicalInteractable.fileName))
        {
            obj      = Instantiate(GameManager.stringPrefabMap [myPhysicalInteractable.fileName]);
            obj.name = myPhysicalInteractable.identificationName;

            sr = obj.GetComponentInChildren <SpriteRenderer> ();
            string state = GameManager.userData.GetAnimationState(myPhysicalInteractable.identificationName);

            PI_Handler.instance.AddPIToMap(myPhysicalInteractable, obj, PI_name);

            if (state != string.Empty)
            {
                PI_Handler.instance.SetPIAnimationState(myPhysicalInteractable.identificationName, state, obj);
            }

            AnimationEvent animationEvent = obj.GetComponent <AnimationEvent> ();

            if (animationEvent != null)
            {
                animationEvent.physicalInteractable = myPhysicalInteractable;
            }

            if (myPhysicalInteractable is Player)
            {
                PlayerObject playerObj = obj.AddComponent <PlayerObject> ();

                Player player = (Player)myPhysicalInteractable;

                if (player.isActive == true)
                {
                    PlayerManager.instance.playerObject = playerObj;
                }
            }
        }
        else
        {
            // if not animated object (furniture)

            obj = new GameObject(myPhysicalInteractable.fileName);
            GameObject childObj = new GameObject("Image");
            childObj.transform.SetParent(obj.transform);

            PI_Handler.instance.AddPIToMap(myPhysicalInteractable, obj, PI_name);

            sr        = childObj.AddComponent <SpriteRenderer>();
            sr.sprite = Resources.Load <Sprite> ("Sprites/Furniture/" + myPhysicalInteractable.fileName);
        }

        obj.transform.SetParent(this.transform);
        if (myPhysicalInteractable is Furniture)
        {
            Furniture furn = (Furniture)myPhysicalInteractable;
            obj.transform.localScale = furn.imageFlipped ? new Vector3(-1, 1, 1) : new Vector3(1, 1, 1);
        }

        if (myPhysicalInteractable is Character)
        {
            Character character = (Character)myPhysicalInteractable;
            obj.transform.localScale = character.imageFlipped ? new Vector3(-1, 1, 1) : new Vector3(1, 1, 1);
        }

        if (myPhysicalInteractable is Player)
        {
            obj.transform.position = myPhysicalInteractable.myPos;
        }
        else
        {
            obj.transform.position = new Vector3(myPhysicalInteractable.myPos.x + myPhysicalInteractable.offsetX, myPhysicalInteractable.myPos.y + 0.5f + myPhysicalInteractable.offsetY, myPhysicalInteractable.myPos.z);
        }


        // sorting order

        Utilities.SetPISortingOrder(myPhysicalInteractable, obj);
//
//		if (myPhysicalInteractable.walkable == true)
//		{
//			sr.sortingOrder = (int) -(myPhysicalInteractable.y + myPhysicalInteractable.mySize.y) * 10;
//		}
//
//		if (myPhysicalInteractable.aboveFrame == true)
//		{
//			sr.sortingLayerName = Constants.aboveFrame_layer;
//		}
//		else
//		{
//			sr.sortingLayerName = Constants.furniture_character_layer;
//		}
    }