コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (quests == null)
     {
         PDC    = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController> ();
         quests = PDC.getQuests();
     }
 }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     numLeft    = GameObject.FindGameObjectWithTag("numLeft").gameObject;
     upObject   = GameObject.FindGameObjectWithTag("up").gameObject;
     numbers    = GameObject.FindGameObjectWithTag("numbers").gameObject;
     downObject = GameObject.FindGameObjectWithTag("down").gameObject;
     PDC        = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController> ();
     intializeSkillPointButtons();
 }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        Button myButton = GetComponent <Button> ();

        myButton.onClick.AddListener(TaskOnClick);

        inventory = GameObject.FindGameObjectWithTag("inventory").gameObject;
        inventory.SetActive(false);

        PDC = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController> ();
    }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        Button myButton = GetComponent <Button> ();

        myButton.onClick.AddListener(TaskOnClick);

        questLog = GameObject.FindGameObjectWithTag("questLog").gameObject;
        questLog.SetActive(false);

        PDC    = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController> ();
        quests = PDC.getQuests();
    }
コード例 #5
0
    float showMessageLen = 3f;     // 5 seconds

    // Use this for initialization
    void Start()
    {
        PDC          = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController> ();
        message      = GetComponent <Text> ();
        message.text = "";

        if (PDC.sceneChange == 1)
        {
            // display message
            print(PDC.relayMessage);
            message.text     = PDC.relayMessage;
            PDC.relayMessage = "";
            PDC.sceneChange  = 0;
        }
    }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }
        DontDestroyOnLoad(this.gameObject);
        //inventory = GameObject.FindGameObjectWithTag ("inventory").gameObject;
        //inventory.SetActive (false);
        //questLog = GameObject.FindGameObjectWithTag ("questLog").gameObject;
        //questLog.SetActive (false);

        collectibles = new List <Collectible> ();
        quests       = new List <Quest> ();
        completed    = new List <int> ();
        for (int i = 0; i < 9; i++)
        {
            completed.Add(0);
        }
    }
コード例 #7
0
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        public void Update()
        {
            //_UpdateApplicationLifecycle();

            Ray        ray;
            RaycastHit hit;

            if (Input.touchCount > 0 && (Input.GetTouch(0)).phase == TouchPhase.Began)
            {
                ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                {
                    if (hit.collider.tag == "R1")
                    {
                        index[0]++;
                        index[0] = index[0] % 4;
                        hit.collider.gameObject.GetComponent <MeshRenderer>().material = mats[index[0]];
                        if (index[0] == 0)
                        {
                            correct[0] = 1;
                        }
                        else
                        {
                            correct[0] = 0;
                        }
                    }
                    else if (hit.collider.tag == "R2")
                    {
                        index[1]++;
                        index[1] = index[0] % 4;
                        hit.collider.gameObject.GetComponent <MeshRenderer>().material = mats[index[1]];
                        if (index[1] == 1)
                        {
                            correct[1] = 1;
                        }
                        else
                        {
                            correct[1] = 0;
                        }
                    }
                    else if (hit.collider.tag == "R3")
                    {
                        index[2]++;
                        index[2] = index[2] % 4;
                        hit.collider.gameObject.GetComponent <MeshRenderer>().material = mats[index[2]];
                        if (index[2] == 2)
                        {
                            correct[2] = 1;
                        }
                        else
                        {
                            correct[2] = 0;
                        }
                    }
                    else if (hit.collider.tag == "R4")
                    {
                        index[3]++;
                        index[3] = index[3] % 4;
                        hit.collider.gameObject.GetComponent <MeshRenderer>().material = mats[index[3]];
                        if (index[3] == 3)
                        {
                            correct[3] = 1;
                        }
                        else
                        {
                            correct[3] = 0;
                        }
                    }
                    if (checkCorrect())
                    {
                        LoadingScreen.SetActive(true);

                        // Persistent Update
                        PersistentDataController PDC = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController>();
                        PDC.addCollectible(3, "Milk", planetSprite);
                        PDC.relayMessage = "You got the milk";
                        PDC.sceneChange  = 1;

                        SceneManager.LoadScene("PeacefulForest", LoadSceneMode.Single);
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        public void Update()
        {
            //_UpdateApplicationLifecycle();

            Ray        ray;
            RaycastHit hit;

            if (Input.touchCount > 0 && (Input.GetTouch(0)).phase == TouchPhase.Began)
            {
                ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                {
                    if (hit.collider.tag == "R1")
                    {
                        if (pattern[curr] == "R1")
                        {
                            curr++;
                        }
                        obj[tries] = hit.collider.gameObject;
                        hit.collider.gameObject.SetActive(false);
                        tries++;
                    }
                    else if (hit.collider.tag == "R2")
                    {
                        if (pattern[curr] == "R2")
                        {
                            curr++;
                        }
                        obj[tries] = hit.collider.gameObject;
                        hit.collider.gameObject.SetActive(false);
                        tries++;
                    }
                    else if (hit.collider.tag == "R3")
                    {
                        if (pattern[curr] == "R3")
                        {
                            curr++;
                        }
                        obj[tries] = hit.collider.gameObject;
                        hit.collider.gameObject.SetActive(false);
                        tries++;
                    }
                    else if (hit.collider.tag == "R4")
                    {
                        if (pattern[curr] == "R4")
                        {
                            curr++;
                        }
                        obj[tries] = hit.collider.gameObject;
                        hit.collider.gameObject.SetActive(false);
                        tries++;
                    }
                    if (tries >= 4)
                    {
                        if (curr >= pattern.Length)
                        {
                            // Persistent Update
                            PersistentDataController PDC = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController>();
                            PDC.addCollectible(2, "Paper", paperSprite);
                            PDC.relayMessage = "You got the piece of paper";
                            PDC.sceneChange  = 1;

                            LoadingScreen.SetActive(true);
                            SceneManager.LoadScene("MysticMountain", LoadSceneMode.Single);
                        }
                        else
                        {
                            // fail scene back
                            PersistentDataController PDC = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController>();
                            PDC.relayMessage = "You failed the puzzle";
                            PDC.sceneChange  = 1;
                            // fail go back
                            SceneManager.LoadScene("MysticMountain", LoadSceneMode.Single);

                            // reset rocks
                            curr  = 0;
                            tries = 0;
                            for (int i = 0; i < obj.Length; i++)
                            {
                                obj[i].SetActive(true);
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
 // Use this for initialization
 void Start()
 {
     persistentDataController = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController> ();
 }
コード例 #10
0
ファイル: WorldController.cs プロジェクト: blaquenkot/ship
    public void Awake()
    {
        NetworkingController.NewSession((_) => {});

        PersistentDataController = Object.FindObjectOfType <PersistentDataController>();
        if (PersistentDataController == null)
        {
            PersistentDataController = Instantiate(PersistentDataControllerPrefab).GetComponent <PersistentDataController>();
        }
        GameOverController.GetComponentInChildren <NewHighscoreController>().PersistentDataController          = PersistentDataController;
        YouWonController.gameObject.GetComponentInChildren <NewHighscoreController>().PersistentDataController = PersistentDataController;

        Volume.sharedProfile.TryGet <ColorAdjustments>(out ColorAdjustments);

        List <Sprite> Pilots = PilotImages.ToList();

        List <Vector2> points = new List <Vector2>();

        for (int i = 0; i < MaxPilots; i++)
        {
            bool    badPosition = true;
            Vector2 position    = Vector2.zero;
            while (badPosition)
            {
                badPosition = false;
                position    = Random.insideUnitCircle.normalized;
                foreach (var point in points)
                {
                    if (Vector2.Distance(point, position) < 0.5f)
                    {
                        badPosition = true;
                        break;
                    }
                }
            }
            points.Add(position);
            GameObject      pilot           = Instantiate(Pilot, position * Random.Range(75f, 175f), transform.rotation, transform.parent);
            GameObject      arrow           = Instantiate(Arrow, Vector2.zero, transform.rotation, transform.parent);
            ArrowController arrowController = arrow.GetComponent <ArrowController>();
            arrowController.Target = pilot;
            int index = Random.Range(0, Pilots.Count);
            arrowController.SetCentralImage(Pilots[index]);
            Pilots.RemoveAt(index);

            PilotController pilotController = pilot.GetComponent <PilotController>();
            pilotController.WorldController = this;
            pilotController.ArrowController = arrowController;

            if (i != 0)
            {
                arrow.SetActive(false);
                InactiveObjectsToActivateOnFirstPilot.Add(arrow);
                pilot.SetActive(false);
                InactiveObjectsToActivateOnFirstPilot.Add(pilot);
            }
            else
            {
                pilot.GetComponentInChildren <CameraController>().ForceCamera(0.01f, IntroTime, 9f);
                GameUIController.BlinkText(4, () => {
                    Camera.main.GetComponent <CinemachineBrain>().m_UpdateMethod      = CinemachineBrain.UpdateMethod.FixedUpdate;
                    Camera.main.GetComponent <CinemachineBrain>().m_BlendUpdateMethod = CinemachineBrain.BrainUpdateMethod.FixedUpdate;
                });

                // The ship should look at the first pilot
                Vector3 relativePos = (pilot.transform.position - ShipController.transform.position).normalized;
                float   z           = Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg;
                ShipController.transform.rotation = Quaternion.Euler(ShipController.transform.rotation.x, ShipController.transform.rotation.y, z);

                arrowController.Blink(2);
            }
        }

        SpaceStation.SetActive(false);
        ArrowController spaceStationArrowController = SpaceStationArrow.GetComponent <ArrowController>();

        spaceStationArrowController.Target = SpaceStation;
        spaceStationArrowController.SetCentralImage(SpaceStationArrowSprite);
        SpaceStationArrow.SetActive(false);
    }
コード例 #11
0
 // Use this for initialization
 void Start()
 {
     PDC = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController>();
     MC  = GameObject.FindGameObjectWithTag("messageController").GetComponent <MessageController> ();
 }
コード例 #12
0
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        public void Update()
        {
            _UpdateApplicationLifecycle();;

            Ray        ray;
            RaycastHit hit;

            if (Input.touchCount > 0 && (Input.GetTouch(0)).phase == TouchPhase.Began)
            {
                ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                {
                    if (hit.collider.tag == "R1")
                    {
                        if (pattern[curr] == "R1")
                        {
                            curr++;
                        }
                        obj[tries] = hit.collider.gameObject;
                        hit.collider.gameObject.SetActive(false);
                        tries++;
                    }
                    else if (hit.collider.tag == "R2")
                    {
                        if (pattern[curr] == "R2")
                        {
                            curr++;
                        }
                        obj[tries] = hit.collider.gameObject;
                        hit.collider.gameObject.SetActive(false);
                        tries++;
                    }
                    else if (hit.collider.tag == "R3")
                    {
                        if (pattern[curr] == "R3")
                        {
                            curr++;
                        }
                        obj[tries] = hit.collider.gameObject;
                        hit.collider.gameObject.SetActive(false);
                        tries++;
                    }
                    if (tries >= 3)
                    {
                        if (curr >= pattern.Length)
                        {
                            LoadingScreen.SetActive(true);

                            // Persistent Update
                            PersistentDataController PDC = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController>();
                            PDC.addCollectible(1, "Trophy", meatBallImage);
                            PDC.relayMessage = "You got the trophy";
                            PDC.sceneChange  = 1;

                            SceneManager.LoadScene("FoggyFactoryBog", LoadSceneMode.Single);
                        }
                        else
                        {
                            // fail scene back
                            PersistentDataController PDC = GameObject.FindGameObjectWithTag("persistentDataController").GetComponent <PersistentDataController>();
                            PDC.relayMessage = "You failed the puzzle";
                            PDC.sceneChange  = 1;
                            SceneManager.LoadScene("FoggyFactoryBog");

                            // reset rocks
                            curr  = 0;
                            tries = 0;
                            for (int i = 0; i < obj.Length; i++)
                            {
                                obj[i].SetActive(true);
                            }
                        }
                    }
                    Score = GameObject.FindGameObjectWithTag("Score");
                    Score.GetComponent <Text>().text = curr.ToString();
                }
            }
        }