Exemplo n.º 1
0
        /*IEnumerator DoSomething ()
         * {
         *  FishData f;
         *  for (int i; i < sof.Length; ++i)
         *  {
         *      f = sof[i];
         *
         *  }
         *              for (int i = 0; i < 300; ++i) {
         *                      fish.FishFactory.RandomFish (this);
         *                      yield return new WaitForSeconds(1);
         *              }
         *      }*/
        IEnumerator refresh()
        {
            int      i = 0;//数组递增
            FishData fd;
            int      gap = 0;

            delay = currentTime - startTime;//获取当前已逝去时间
            while (true)
            {
                fd = sof[i];
                if (fd.delay > delay)
                {
                    gap    = (int)(fd.delay - delay);
                    delay += gap;
                    yield return(new WaitForSeconds(gap / 1000));
                }
                else
                {
                    GameObject test = GameObject.Instantiate((GameObject)SACache.getObjectWithName("model/fish/" + fd.fishID));
                    FishSwim   fs   = test.AddComponent <FishSwim>();
                    fs.setInfo(graph, fd, delay);
                    ++i;
                }
                if (i >= sof.Count || exit)
                {
                    break;//结束
                }
            }
            StopCoroutine("refresh");
        }
Exemplo n.º 2
0
        public void BindAtlas(string name)
        {
            UISprite[] sprites = SAGameObject.GetComponentsInChildren <UISprite>();
            UISprite   sprite;

            for (int i = 0; i < sprites.Length; ++i)
            {
                sprite       = sprites[i];
                sprite.atlas = (UIAtlas)SACache.getObjectWithName(name);
            }
        }
Exemplo n.º 3
0
        void Update()
        {
            Vector3 pos   = Input.mousePosition;
            float   px    = Math.Abs(pos.x) - Screen.width / 2;
            float   py    = pos.y;       // + hhlaf;
            Vector3 q     = c.eulerAngles;
            double  angle = 0;

            if (px == 0)
            {
                if (py > 0)
                {
                    angle = 90;
                }
                if (py < 0)
                {
                    angle = 270;
                }
            }
            else
            {
                double tan = py / px;
                if (px > 0)
                {
                    angle = Math.Atan(tan) * 180 / Math.PI - 90;
                }
                else
                {
                    angle = Math.Atan(tan) * 180 / Math.PI + 90;
                }
            }
            q.z           = (float)angle;
            c.eulerAngles = q;
            if (Input.GetKey(KeyCode.Mouse0))
            {
                if (++ct > mt)
                {
                    ct = 0;
                    GameObject projectile = GameObject.Instantiate((GameObject)SACache.getObjectWithName("model/bullet/" + bullets [UnityEngine.Random.Range(0, bullets.Length)]));
                    projectile.transform.position    = c.position;
                    projectile.transform.eulerAngles = q;
                    projectile.GetComponent <Rigidbody> ().AddForce(projectile.transform.up * 400);
                    projectile.GetComponent <ETFXProjectileScript> ().impactNormal = Vector3.forward;
                }
            }
        }