Пример #1
0
    void Update()
    {
        //handles world editing if the pause menu is inactive
        if (PauseMenu.GamePaused == false && WorldEditor.WorldEditorActive == true)
        {
            if (Input.GetMouseButton(0))
            {
                if (m_currentTileSprite != TileMap.TileMapObject.TileMapSprite.None)
                {
                    Vector3 vec = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                    vec.z = 0f;

                    m_tileMap.setTileMapSprite(vec, m_currentTileSprite);
                }

                if (destroyObject == false)
                {
                    if (m_currentGameObject.tag != "Default")
                    {
                        Vector3 vec = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                        vec.z = 0f;

                        TileMap.TileMapObject tilemapObject = m_tileMap.GetTileMapObject(vec);

                        if (tilemapObject != null && tilemapObject.containsObject == false)
                        {
                            tilemapObject.passable       = false;
                            tilemapObject.containsObject = true;

                            Vector3 objectpos = tilemapObject.GetWorldPos();
                            objectpos.z = 0;

                            GameObject currentObjectSpawn = Instantiate(m_currentGameObject, objectpos, Quaternion.identity);
                        }
                    }
                }
                else
                {
                    GameObject objectAtMouse = GetObjectAtMousePos();

                    if (objectAtMouse != null)
                    {
                        Destroy(objectAtMouse);

                        Vector3 vec = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                        vec.z = 0f;

                        TileMap.TileMapObject tilemapObject = m_tileMap.GetTileMapObject(vec);

                        tilemapObject.passable       = true;
                        tilemapObject.containsObject = false;
                    }
                }
            }
        }

        //handles character inspection if the pause menu is inactive
        if (PauseMenu.GamePaused == false)
        {
            handleZoom();

            if (Input.GetMouseButton(0))
            {
                if (InspectObject == true)
                {
                    GameObject objectAtMouse = GetObjectAtMousePos();

                    if (objectAtMouse != null)
                    {
                        Debug.Log(objectAtMouse.tag);

                        if (objectAtMouse.tag == "Monster")
                        {
                            if (objectAtMouse.GetComponent <Enemy>() != null)
                            {
                                statsUI.InspectVanilla(objectAtMouse.GetComponent <Enemy>());
                            }
                            else if (objectAtMouse.GetComponent <FSMEnemy>() != null)
                            {
                                statsUI.InspectFSM(objectAtMouse.GetComponent <FSMEnemy>());
                            }
                            else if (objectAtMouse.GetComponent <CNMEnemy>() != null)
                            {
                                statsUI.InspectCNM(objectAtMouse.GetComponent <CNMEnemy>());
                            }
                        }
                    }
                }
            }
        }
    }