Ejemplo n.º 1
0
        public static void GetBulletPosAndDir(byte clientSeat, short angle, out Vector3 dir, out Vector3 pos)
        {
            float degree            = angle * ConstValue.InvShortMaxValue * 90;
            BulletStartPosData pd   = Instance.m_BulletPosData[clientSeat];
            Quaternion         q    = Quaternion.Euler(0, 0, degree);
            Vector3            dir3 = q * pd.Dir;
            Vector3            pos3 = dir3 * pd.Length + pd.Center;

            dir.x = dir3.x;
            dir.y = dir3.y;
            dir.z = 0;
            pos.x = pos3.x;
            pos.y = pos3.y;
            pos.z = ConstValue.NEAR_Z + 0.1f;
        }
Ejemplo n.º 2
0
        public static void Init(SceneModel logic)
        {
            Instance            = new SceneRuntime();
            Instance.sceneModel = logic;

            float LAUNCHER_X       = 15.5f;
            float LAUNCHER_X_RIGHT = 10.5f;
            float LAUNCHER_Y       = 11.5f;

            //子弹的位置
            //		3	2
            //		0,	1
            float height          = ConstValue.NEAR_HALF_HEIGHT;
            BulletStartPosData pd = new BulletStartPosData();

            pd.Center = new Vector3(-LAUNCHER_X, -height, 0);
            pd.Pos    = new Vector3(-LAUNCHER_X, -LAUNCHER_Y, 0);
            pd.Dir    = pd.Pos - pd.Center;
            pd.Length = pd.Dir.magnitude;
            pd.Dir   /= pd.Length;
            Instance.m_BulletPosData[0] = pd;

            pd        = new BulletStartPosData();
            pd.Center = new Vector3(LAUNCHER_X_RIGHT, -height, 0);
            pd.Pos    = new Vector3(LAUNCHER_X_RIGHT, -LAUNCHER_Y, 0);
            pd.Dir    = pd.Pos - pd.Center;
            pd.Length = pd.Dir.magnitude;
            pd.Dir   /= pd.Length;
            Instance.m_BulletPosData[1] = pd;

            pd        = new BulletStartPosData();
            pd.Center = new Vector3(LAUNCHER_X_RIGHT, height, 0);
            pd.Pos    = new Vector3(LAUNCHER_X_RIGHT, LAUNCHER_Y, 0);
            pd.Dir    = pd.Pos - pd.Center;
            pd.Length = pd.Dir.magnitude;
            pd.Dir   /= pd.Length;
            Instance.m_BulletPosData[2] = pd;

            pd        = new BulletStartPosData();
            pd.Center = new Vector3(-LAUNCHER_X, height, 0);
            pd.Pos    = new Vector3(-LAUNCHER_X, LAUNCHER_Y, 0);
            pd.Dir    = pd.Pos - pd.Center;
            pd.Length = pd.Dir.magnitude;
            pd.Dir   /= pd.Length;
            Instance.m_BulletPosData[3] = pd;

            //炮台金币的位置
            Instance.GlodPosMapping[0] = new Vector3(-0.54270833f, -0.9461806f, 0.0f);
            Instance.GlodPosMapping[1] = new Vector3(0.938773155f, -0.9461806f, 0.0f);
            Instance.GlodPosMapping[2] = new Vector3(0.917939842f, 0.9458333f, 0.0f);
            Instance.GlodPosMapping[3] = new Vector3(-0.563541651f, 0.9458333f, 0.0f);
            Instance.GlodPosMapping[4] = new Vector3(-0.580940962f, -0.8208333f, 0.0f);
            Instance.GlodPosMapping[5] = new Vector3(0.902314842f, -0.8208333f, 0.0f);


            Vector3 dir1, dir2;

            SceneRuntime.GetBulletPosAndDir(0, 0, out dir1, out LauncherScrStartPos1);
            SceneRuntime.GetBulletPosAndDir(1, 0, out dir2, out LauncherScrStartPos2);
            LauncherScrStartPos1   = Camera.main.WorldToScreenPoint(LauncherScrStartPos1);
            LauncherScrStartPos2   = Camera.main.WorldToScreenPoint(LauncherScrStartPos2);
            LauncherScrStartPos1.z = 0;
            LauncherScrStartPos2.z = 0;

            LauncherViewStartPos1   = Camera.main.ScreenToViewportPoint(LauncherScrStartPos1);
            LauncherViewStartPos2   = Camera.main.ScreenToViewportPoint(LauncherScrStartPos2);
            LauncherViewStartPos1.z = 0;
            LauncherViewStartPos2.z = 0;
        }