コード例 #1
0
ファイル: Minimap.cs プロジェクト: zwade/Imaginarium
    void Update()
    {
        if (!started)
        {
            started = true;
            GameObject playerBlipInst = Instantiate(playerBlip);
            playerBlipInst.transform.SetParent(this.transform);
            playerBlipInst.transform.localPosition = new Vector3(0, 0, 0);
            PBI = playerBlipInst.GetComponent <RectTransform>();
            PBI.anchoredPosition = new Vector3(0, 0, 0);
            PBI.localScale       = new Vector3(1, 1, 1);

            playerLoc = player.GetComponent <UpdateUI>();

            orbInst   = new RectTransform[orbs.Length];
            orbLocs   = new OrbControl[orbs.Length];
            receptors = new Receptor[orbs.Length];

            for (int i = 0; i < orbs.Length; i++)
            {
                GameObject lInst = Instantiate(orbBlip);
                lInst.transform.SetParent(this.transform);
                lInst.transform.localPosition = new Vector3(0, 0, 0);

                GameObject rInst = Instantiate(receptorBlip);
                rInst.transform.SetParent(this.transform);
                rInst.transform.localPosition = new Vector3(0, 0, 0);


                orbInst[i] = lInst.GetComponent <RectTransform>();
                orbInst[i].anchoredPosition = new Vector3(0, 0, 0);
                orbInst[i].localScale       = new Vector3(1, 1, 1);
                orbLocs[i] = orbs[i].GetComponent <OrbControl>();

                receptors[i] = orbLocs[i].receptor.GetComponent <Receptor>();

                Debug.Log(receptors[i].location.toVector2);

                RectTransform rT = rInst.GetComponent <RectTransform>();
                rT.localScale       = new Vector3(1, 1, 1);
                rT.anchoredPosition = 150 / 90f * receptors[i].location.toVector2;

                lInst.GetComponent <Image>().color = orbLocs[i].color;

                rInst.GetComponent <Image>().color = orbLocs[i].color;
            }
        }

        PBI.anchoredPosition = 150 / 90f * playerLoc.getLocation().toVector2;
        for (int i = 0; i < orbs.Length; i++)
        {
            orbInst[i].anchoredPosition = 150 / 90f * orbLocs[i].getLocation().toVector2;
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Mathf.Abs(destination.Phase - position.Phase) < 0.1)
        {
            position.Phase = destination.Phase;
        }
        else
        {
            position = position & (speed * Time.deltaTime);
        }

        if (Mathf.Abs(destination.Mag - position.Mag) < 0.05)
        {
            //position.Mag = destination.Mag;
        }
        else
        {
            position = position | (speed * .33f * Time.deltaTime * Mathf.Sign(destination.Mag - position.Mag));
        }

        /*
         * if (position != destination) {
         *      float angDist = destination.Phase - position.Phase;
         *      float radDist = destination.Mag - position.Mag;
         *      float scale = 0;
         *      if (Mathf.Abs (angDist) <= 0.02) {
         *              scale = 1f*Mathf.Sign(radDist);
         *      } else if (Mathf.Abs (radDist) <= 0.02) {
         *              scale = .33f*Mathf.Sign (angDist);
         *      } else {
         *              scale = radDist/angDist;
         *      }
         *      position = (position | (speed * scale * Time.deltaTime)) & (speed * Time.deltaTime);
         *      if ((position-destination).Mag < 2*Mathf.Sqrt (Mathf.Pow ((scale),2)+1)*Mathf.Abs(scale)*Time.deltaTime) {
         *              position = destination;
         *      }
         *
         * }
         */
        countText.text        = count.ToString();
        transform.position    = position.toVector3 + transform.position.y * Vector3.up;
        transform.eulerAngles = new Vector3(0, position.Phase * -180 / Mathf.PI, 0);
        if ((position - locManager.getLocation()).Mag < threshold)
        {
            UI.SetActive(true);
        }
        else
        {
            UI.SetActive(false);
        }
        holder.transform.rotation = camera.transform.rotation;

        textScript.text = destination.ToString();

        if (Mathf.Abs((destination - recepScript.location).Mag) < 0.1)
        {
            particles.enableEmission = true;
            isSafe = true;
        }
        else
        {
            particles.enableEmission = false;
            isSafe = false;
        }

        if (position.Mag < 0.1)
        {
            reset();
        }
    }