Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Fish"))
        {
            //Run this function only on 1 jellyfish
            if (choice == gameController.currentAnswer)
            {
                Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();
                if (physics2DRaycaster != null)
                {
                    physics2DRaycaster.enabled = false;
                }
                Jellyfish[] jellyfishes = FindObjectsOfType <Jellyfish>();
                if (jellyfishes.Length <= 4)
                {
                    gameController.updatePlayerPoint(false);
                    gameController.updatePlayerQuestionData(false);
                    gameController.nextQuestion = true;
                    for (int i = 0; i < jellyfishes.Length; ++i)
                    {
                        jellyfishes[i].anim.SetTrigger("Wrong");
                    }
                }
            }
        }

        if (collision.gameObject.CompareTag("Beam"))
        {
            anim.SetTrigger("Hitted");
        }
    }
        private void AddRaycaster()
        {
            if (M.SelectorCamera)
            {
                DestroyImmediate(M.SelectorCamera.GetComponent <BaseRaycaster>());
                switch (M.ItemRendererType)
                {
                case ItemRenderer.Mesh:
                    PhysicsRaycaster Ph = M.SelectorCamera.gameObject.AddComponent <PhysicsRaycaster>();
                    Ph.eventMask = 32;
                    break;

                case ItemRenderer.Sprite:
                    Physics2DRaycaster Ph2d = M.SelectorCamera.gameObject.AddComponent <Physics2DRaycaster>();
                    Ph2d.eventMask = 32;
                    break;

                case ItemRenderer.Canvas:
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 3
0
    private void Awake()
    {
        if (!Instance)
        {
            Instance = this;
            // DontDestroyOnLoad (this);
        }
        else
        {
            Destroy(this);
        }

        mainCamera      = Camera.main;
        Raycaster       = mainCamera.GetComponent <Physics2DRaycaster> ();
        spells          = FindObjectOfType <Spells> ();
        field           = FindObjectOfType <Field> ();
        buildingManager = FindObjectOfType <BuildingManager> ();
        attackManager   = FindObjectOfType <AttackManager> ();
        castManager     = FindObjectOfType <CastManager> ();
        enemyController = FindObjectOfType <EnemyController> ();
        touchController = FindObjectOfType <TouchController>();
        wizard          = FindObjectOfType <Wizard> ();
        xpPoints        = wizard.GetComponent <XPpoints> ();
        GameController  = FindObjectOfType <GameController> ();
        uIManager       = FindObjectOfType <UIManager> ();
        firePoints      = FindObjectOfType <FirePoints> ();
    }
Ejemplo n.º 4
0
        private void AddRaycaster()
        {
            if (SelectorCamera.objectReferenceValue != null)
            {
                DestroyImmediate(M.SelectorCamera.GetComponent <BaseRaycaster>());

                var IRenderType = (ItemRenderer)ItemRendererType.enumValueIndex;

                switch (IRenderType)
                {
                case ItemRenderer.Mesh:
                    PhysicsRaycaster Ph = M.SelectorCamera.gameObject.AddComponent <PhysicsRaycaster>();
                    Ph.eventMask = 32;
                    break;

                case ItemRenderer.Sprite:
                    Physics2DRaycaster Ph2d = M.SelectorCamera.gameObject.AddComponent <Physics2DRaycaster>();
                    Ph2d.eventMask = 32;
                    break;

                case ItemRenderer.Canvas:
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 5
0
    private void addPhysics2DRaycaster()
    {
        Physics2DRaycaster physics2DRaycaster = GameObject.FindObjectOfType <Physics2DRaycaster>();

        if (physics2DRaycaster == null)
        {
            gameObject.AddComponent <Physics2DRaycaster>();
        }
    }
Ejemplo n.º 6
0
    void restoreInput()
    {
        Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();

        if (physics2DRaycaster != null)
        {
            physics2DRaycaster.enabled = true;
        }
    }
    void addPhysics2DRaycaster()
    {
        Physics2DRaycaster physicsRaycaster = GameObject.FindObjectOfType <Physics2DRaycaster>();

        if (physicsRaycaster == null)
        {
            Camera.main.gameObject.AddComponent <Physics2DRaycaster>();
        }
    }
Ejemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        //used for the OnPointerDown detection
        Physics2DRaycaster physicsRaycaster = GameObject.FindObjectOfType <Physics2DRaycaster>();

        if (physicsRaycaster == null)
        {
            GameObject.FindGameObjectWithTag("MainCamera").gameObject.AddComponent <Physics2DRaycaster>();
        }
    }
Ejemplo n.º 9
0
    void stopAll()
    {
        Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();

        if (physics2DRaycaster != null)
        {
            physics2DRaycaster.enabled = true;
        }
        gameController.stopAll();
    }
Ejemplo n.º 10
0
    // Start is called before the first frame update
    void Start()
    {
        gameController = FindObjectOfType <PearlHunterGameController>();
        mainCamera     = GameObject.Find("Main Camera");
        Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();

        if (physics2DRaycaster != null)
        {
            physics2DRaycaster.enabled = false;
        }
    }
Ejemplo n.º 11
0
    public void checkAnswer()
    {
        Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();

        if (physics2DRaycaster != null)
        {
            physics2DRaycaster.enabled = false;
        }
        Animator fishAnim = gameController.fish.GetComponent <Animator>();

        fishAnim.SetTrigger(triggerFishAnimIndex);
    }
Ejemplo n.º 12
0
    public void beChoosen()
    {
        Animator fishAnim = gameController.fish.GetComponent <Animator>();

        fishAnim.SetTrigger("FalseAnswer");
        Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();

        if (physics2DRaycaster != null)
        {
            physics2DRaycaster.enabled = false;
        }
    }
    void endPracticeFunc()
    {
        StartCoroutine(updatePracticeTimesCoroutine());
        Animator anim = result.GetComponent <Animator>();

        anim.SetTrigger("Finish");
        Invoke("BackToMainMenu", 3.5f);
        GraphicRaycaster graphicRaycaster = canvas.GetComponent <GraphicRaycaster>();

        graphicRaycaster.enabled = false;
        Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();

        if (physics2DRaycaster != null)
        {
            physics2DRaycaster.enabled = false;
        }
    }
Ejemplo n.º 14
0
        public void OnSceneLoad(Scene scene, LoadSceneMode loadSceneMode)
        {
            if (HookCamera.Instance != null)
            {
                PhysicsRaycaster   raycaster3D = HookCamera.Instance.GetComponent <PhysicsRaycaster>();
                Physics2DRaycaster raycaster2D = HookCamera.Instance.GetComponent <Physics2DRaycaster>();

                if (raycaster3D == null)
                {
                    HookCamera.Instance.gameObject.AddComponent <PhysicsRaycaster>();
                }
                if (raycaster2D == null)
                {
                    HookCamera.Instance.gameObject.AddComponent <Physics2DRaycaster>();
                }
            }
        }
Ejemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        cameraMap   = Storage.PlayerController.CameraMap;
        colliderMap = GetComponent <BoxCollider2D>();

        //-------------- Raycast
        ////Fetch the Raycaster from the GameObject (the Canvas)
        m_Raycaster = cameraMap.GetComponent <Physics2DRaycaster>();
        if (m_Raycaster == null)
        {
            Debug.Log("###### Raycaster == null");
        }
        ////Fetch the Event System from the Scene
        //m_EventSystem = GetComponent<EventSystem>();
        m_EventSystem = cameraMap.GetComponent <EventSystem>();
        if (m_EventSystem == null)
        {
            Debug.Log("###### EventSystem == null");
        }
    }
    public static int Raycast(IntPtr l)
    {
        int result;

        try
        {
            Physics2DRaycaster physics2DRaycaster = (Physics2DRaycaster)LuaObject.checkSelf(l);
            PointerEventData   eventData;
            LuaObject.checkType <PointerEventData>(l, 2, out eventData);
            List <RaycastResult> resultAppendList;
            LuaObject.checkType <List <RaycastResult> >(l, 3, out resultAppendList);
            physics2DRaycaster.Raycast(eventData, resultAppendList);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Ejemplo n.º 17
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private void RequireInit()
        {
            if (HookCamera.Instance == null)
            {
                this.RequireCamera();
            }

            if (HookCamera.Instance != null)
            {
                PhysicsRaycaster   raycaster3D = HookCamera.Instance.Get <PhysicsRaycaster>();
                Physics2DRaycaster raycaster2D = HookCamera.Instance.Get <Physics2DRaycaster>();

                if (raycaster3D == null)
                {
                    HookCamera.Instance.gameObject.AddComponent <PhysicsRaycaster>();
                }
                if (raycaster2D == null)
                {
                    HookCamera.Instance.gameObject.AddComponent <Physics2DRaycaster>();
                }
            }
        }
Ejemplo n.º 18
0
    void IsInside()//获取鼠标位置下的物体列表
    {
        GameObject       raycaster        = GameObject.Find("Main Camera");
        PointerEventData pointerEventData = new PointerEventData(EventSystem.current);

        pointerEventData.position = Input.mousePosition;
        Physics2DRaycaster   pr         = raycaster.GetComponent <Physics2DRaycaster>();
        List <RaycastResult> resultlist = new List <RaycastResult>();

        pr.Raycast(pointerEventData, resultlist);
        if (resultlist.Count != 0)
        {
            Count = resultlist.Count;
            if (Count > 10)
            {
                Count = 10;
            }
            for (int i = 0; i < Count; ++i)
            {
                Targetlist[i] = resultlist[i].gameObject;
            }
        }
    }
Ejemplo n.º 19
0
 public PhysicsRaycastSwappingInputSwitch(Physics2DRaycaster physics2DRaycaster)
 {
     this.physics2DRaycaster = physics2DRaycaster;
     turnOffLayerMask        = 1 << LayerMask.NameToLayer("UI");
     turnOnLayerMask         = (1 << LayerMask.NameToLayer("UI")) | (1 << LayerMask.NameToLayer("Gem"));
 }
Ejemplo n.º 20
0
 void Awake()
 {
     camRaycaster = Camera.main.GetComponent <Physics2DRaycaster> ();
     GM           = GameObject.FindObjectOfType <GameManager> ();
 }
Ejemplo n.º 21
0
 private void Start()
 {
     uiShooterArrow     = UiShooterArrow.Create();
     physics2DRaycaster = Camera.main.GetComponent <Physics2DRaycaster>();
 }
Ejemplo n.º 22
0
    void endGame()
    {
        Resources.UnloadUnusedAssets();
        InputField playerInput = FindObjectOfType <InputField>();

        if (playerInput != null)
        {
            if (playerInput.touchScreenKeyboard != null)
            {
                if (playerInput.touchScreenKeyboard.active)
                {
                    playerInput.touchScreenKeyboard.active = false;
                }
            }
        }
        timeText.text = playingTime.ToString();
        GraphicRaycaster graphicRaycaster = canvas.GetComponent <GraphicRaycaster>();

        graphicRaycaster.enabled = false;
        Physics2DRaycaster physics2DRaycaster = mainCamera.GetComponent <Physics2DRaycaster>();

        if (physics2DRaycaster != null)
        {
            physics2DRaycaster.enabled = false;
        }
        //need to plus current score because total score just in round 2
        Player higherScore;
        int    leftScore  = players[0].totalScore + players[0].score;
        int    rightScore = players[1].totalScore + players[1].score;

        if (leftScore > rightScore)
        {
            higherScore = players[0];
        }
        else if (leftScore == rightScore)
        {
            higherScore = null;
        }
        else
        {
            higherScore = players[1];
        }
        if (Prototype.NetworkLobby.MyLobbyManager.s_Singleton.currentRound == 3)
        {
            Prototype.NetworkLobby.MyLobbyManager.s_Singleton.OnServerUpdateLastRoundData();
            //Change score from players to lobby players
            Invoke("UpdateLobbyData", 2.0f);
            if (higherScore != null)
            {
                if (higherScore.isLocalPlayer)
                {
                    StartCoroutine(BackToLobbyScene(true));
                }
                else
                {
                    StartCoroutine(BackToLobbyScene(false));
                }
            }
            else
            {
                StartCoroutine(BackToLobbyScene(false));
            }
        }
        else
        {
            Invoke("nextGame", 1.5f);
        }
        announce.text = "Time's up";
        announce.gameObject.SetActive(true);
    }
Ejemplo n.º 23
0
 private void Start()
 {
     raycaster = GetComponent <Physics2DRaycaster>();
     selectingEnabled.OnValueChanged += ManageRaycaster;
 }