示例#1
0
        private void Awake()
        {
#if !UNITY_EDITOR
            Camera.main.orthographicSize *= 2.0f;
#endif

            SpaceUtil.Init();

            SpaceLarge.Init();
            SpaceSmall.Init();

            PlayButton.Init();
            Title.Init();

            Title.PositionY = SpaceUtil.WorldMap.Top.y - Title.BoxMap.Height;

            Vector2 buttonSize     = PlayButton.ButtonSize;
            Vector2 buttonSizeHalf = buttonSize * 0.5f;

            PlayButton.PositionY    = SpaceUtil.WorldMap.Center.y + buttonSizeHalf.y + ButtonOffsetHalf;
            OptionsButton.PositionY = SpaceUtil.WorldMap.Center.y - buttonSizeHalf.y - ButtonOffsetHalf;

            PlayVeryEasy.PositionY = SpaceUtil.WorldMap.Center.y + ((buttonSize.y + ButtonOffset) * 2);
            PlayEasy.PositionY     = SpaceUtil.WorldMap.Center.y + (buttonSize.y + ButtonOffset);
            PlayMedium.PositionY   = SpaceUtil.WorldMap.Center.y;
            PlayHard.PositionY     = SpaceUtil.WorldMap.Center.y - (buttonSize.y + ButtonOffset);
            PlayVeryHard.PositionY = SpaceUtil.WorldMap.Center.y - ((buttonSize.y + ButtonOffset) * 2);

            SetPlayAndOptionButtonsEnabled(true);
            SetDifficultyButtonsEnabled(false);
        }
示例#2
0
文件: IFSUtil.cs 项目: kaclr/Doodle
        public static string ModifyIFSVersion(string srcIFSPath, BuildTarget buildTarget, string newVersion)
        {
            var newIFSPath = Path.Combine(SpaceUtil.NewTempDir(), NssHelper.GetStandardIFSName(buildTarget, newVersion));

            ModifyIFSVersion(srcIFSPath, newIFSPath, newVersion);
            return(newIFSPath);
        }
    public override void TakeInput()
    {
        if (channels.target)
        {
            float d;
            Plane canvasPlane = new Plane(canvas.transform.forward, canvas.transform.position);

            Vector3 aimDir;
            bool    canPredict = SpaceUtil.PredictPosition(channels.target.body, body, proj.launchSpeed, out aimDir);

            if (canPredict)
            {
                Ray  ray = new Ray(cam.transform.position, aimDir);
                bool b   = canvasPlane.Raycast(ray, out d);

                if (b)
                {
                    transform.position = ray.GetPoint(d);
                }
            }

            Vector2 s = canvas.sizeDelta;

            Vector2 v = rect.anchoredPosition + (s / 2);

            image.enabled = v.x > 0 && v.y > 0 && v.x < s.x && v.y < s.y;
        }
        else
        {
            image.enabled = false;
        }
    }
示例#4
0
        public void Fire(float fireStrategyOverflowDt)
        {
            if (gameObject.activeSelf && FireTimer.Activated)
            {
                var bullets = PoolManager.Instance.BulletPool.GetMany <OthelloBullet>(Level, FirePosition, Level);

                float offsetX = -(BulletSpread * (Level - 1) * 0.5f);
                for (int i = 0; i < bullets.Length; i++)
                {
                    OthelloBullet bullet = bullets[i];
                    bullet.OthelloDamage = Damage;

                    bullet.PositionX += offsetX;

                    bullet.RunFrame(fireStrategyOverflowDt, fireStrategyOverflowDt);

                    if (!SpaceUtil.PointIsInBounds(bullet.transform.position))
                    {
                        bullet.RunTask(GameTaskFunc.DeactivateSelf(bullet));
                    }

                    offsetX += BulletSpread;
                }

                FireTimer.TouchTimer();
            }
        }
示例#5
0
文件: IFSUtil.cs 项目: kaclr/Doodle
        public static void ModifyIFSVersion(string srcIFSPath, string outIFSPath, string newVersion)
        {
            InitInner();

            if (!File.Exists(srcIFSPath))
            {
                throw new ArgumentException($"Can't find '{nameof(srcIFSPath)}' in path '{srcIFSPath}'!", nameof(srcIFSPath));
            }
            if (!ClientVersion.IsVersionValid(newVersion))
            {
                throw new ArgumentException($"'{newVersion}' is not a valid version!", nameof(newVersion));
            }

            var ifsDir = SpaceUtil.NewTempPath();

            UnpackIFS(srcIFSPath, ifsDir);

            // 修改所有平台的版本号
            foreach (var buildTarget in Enum.GetValues(typeof(BuildTarget)))
            {
                var versionJsonPath = Path.Combine(ifsDir, $"AssetBundles/{ClientVersion.GetVersionFileName((BuildTarget)buildTarget)}");
                if (File.Exists(versionJsonPath))
                {
                    ClientVersion.ModifyVersion(versionJsonPath, newVersion);
                }
            }

            if (PathUtil.Exists(outIFSPath))
            {
                PathUtil.RemovePath(outIFSPath);
            }
            PackIFS(ifsDir, outIFSPath);
        }
        private void Awake()
        {
#if !UNITY_EDITOR
            Camera.main.orthographicSize *= 2.0f;
#endif

            SpaceUtil.Init();

            SpaceLarge.Init();
            SpaceSmall.Init();

            //BackButton.Init();
            Title.Init();

            Title.PositionY = SpaceUtil.WorldMap.Top.y - Title.BoxMap.Height;
            //BackButton.PositionY = SpaceUtil.WorldMap.Center.y;

            MusicVolumeSlider.Init();
            SoundEffectVolumeSlider.Init();

            Vector3 sliderOffset = new Vector3(0, OptionMargin);

            float   musicY        = Title.transform.position.y - sliderOffset.y;
            float   musicX        = SpaceUtil.WorldMap.Right.x - MusicVolumeSlider.WidthHalf;
            Vector3 musicPosition = new Vector3(musicX, musicY); // Title.transform.position - sliderOffset;
            MusicVolumeSlider.SetPosition(musicPosition);

            float   soundEffectY        = Title.transform.position.y - (sliderOffset.y * 2);
            float   soundEffectX        = musicPosition.x;
            Vector3 soundEffectPosition = new Vector3(soundEffectX, soundEffectY);
            SoundEffectVolumeSlider.SetPosition(soundEffectPosition);

            var canvas = ToggleGore.GetComponentInParent <Canvas>();
            canvas.transform.position = Vector3.zero;

            float   toggleGoreY        = Title.transform.position.y - (sliderOffset.y * 3);
            float   toggleGoreX        = musicPosition.x;
            Vector3 toggleGorePosition = new Vector3(toggleGoreX, toggleGoreY);
            ToggleGore.transform.position = toggleGorePosition;

            ToggleGore.isOn = PlayerPrefsUtil.GetBoolFromPrefs(PlayerPrefsUtil.ToggleGoreKey, false);


            //ToggleGore.transform.position = Vector3.zero;

            Vector3 cornerOffset = BackButtonMargin + BackButton.ButtonSize.ScaleX(-1.0f);
            BackButton.transform.position = SpaceUtil.WorldMap.BottomRight + cornerOffset;

            MusicVolumeSlider.Value       = PlayerPrefs.GetInt(PlayerPrefsUtil.MusicVolumeKey, 100);
            SoundEffectVolumeSlider.Value = PlayerPrefs.GetInt(PlayerPrefsUtil.SoundEffectVolumeKey, 100);

            if (!MusicManager.MusicManagerInstance.InitCalled)
            {
                MusicManager.Init();
            }

            InitPlaylists();
        }
示例#7
0
        private void FireRandomSentinel()
        {
            var sentinels = SentinelPool.Where(x => SpaceUtil.SpriteIsInBounds(x));

            if (RandomUtil.TryGetRandomElement(sentinels, out PlayerBullet bullet))
            {
                FireSentinelForward(bullet);
            }
        }
示例#8
0
    private void FireAtTarget()
    {
        Vector3 aim;

        if (SpaceUtil.PredictPosition(channels.target.body, self.body, projectile.launchSpeed, out aim))
        {
            channels.aim    = transform.position + aim * 1000;
            channels.firing = true;
        }
    }
示例#9
0
        private Vector3 RandomRainPosition(Pickup pickup)
        {
            Vector2 size   = pickup.Size;
            float   spawnX = SpaceUtil.RandomWorldPositionX(size.x);
            float   spawnY = SpaceUtil.WorldMap.Top.y + (size.y * 0.5f);

            Vector3 ret = new Vector3(spawnX, spawnY);

            return(ret);
        }
示例#10
0
        public static void DebugTestSmite()
        {
            Vector3 startPosition  = Player.Instance.FirePosition;
            Vector3 targetPosition = SpaceUtil.WorldPositionUnderMouse();

            var enemy = GameManager.Instance._DebugEnemy;

            //SmiteJointBullet.StartSmite(startPosition, targetPosition, 10);
            SmiteJointBullet.StartSmite(startPosition, enemy);
        }
示例#11
0
        public void CreateRaindrop(Vector3 position, int damage)
        {
            if (SpaceUtil.PointIsInBounds(position))
            {
                var raindrop = (RaindropBullet)MonsoonPool.Get();
                raindrop.transform.position = position;
                raindrop.RaindropDamage     = damage;

                raindrop.OnSpawn();

                raindrop.PlayFireSound();
            }
        }
示例#12
0
    // Update is called once per frame
    void Update()
    {
        body.velocity = velocity;

        if (projectile && timer.Use())
        {
            Projectile proj = Instantiate(projectile, transform.position, transform.rotation).GetComponent <Projectile>();

            Vector3 dir;
            if (SpaceUtil.PredictPosition(target, body, proj.launchSpeed, out dir))
            {
                proj.Fire(dir);
                proj.velocity += body.velocity;
            }
        }
    }
示例#13
0
        private void InitWithoutDependencies()
        {
#if UNITY_EDITOR
            Camera.main.orthographicSize *= 1.25f;
#else
            Camera.main.orthographicSize *= 2.0f;
#endif

            SaveUtil.InitializeSave();

            SpaceUtil.Init();

            // _ColorManager is a prefab field, and doesn't need initialized.
            _PoolManager.Init(in _ColorManager);

            WeaponResetTimer = new FrameTimer(InitialWeaponTime);
            WeaponRainTimer  = new LoopingFrameTimer(WeaponRainTime);

            OneUpRainTimer = new LoopingFrameTimer(OneUpRainTime);
            OneUpRainTimer.TimeUntilActivation = InitialOneUpRainDelay;

            _PowerupMenu.Init();
            _PowerupMenu.transform.position += new Vector3(0, 0, 0);

            VictimWasAutomatic = true;

            _GameOverGUI.Init();
            _Scoreboard.Init();

            SoundManager.Init(_AudioSource);
            SpriteBank.Init();
            NotificationManager.Init(_Notification);

            DefaultBullet.StaticInit();
            //DefaultExtraBullet.StaticInit();
            DefaultBulletBuffs.Init();

            _ParticleManager.Init();

#if !UNITY_EDITOR
            CanGameOver = true;
#else
            CanGameOver = false;
#endif
        }
示例#14
0
        public static BuildAppResult BuildApk(
            string unityExePath,
            string nssUnityProj,
            BuildMode buildMode,
            bool prepareProject,
            string sdkRoot,
            string ndkRoot,
            string jdkRoot,
            string versionJsonPath  = null,
            VerLine verLine         = VerLine.DB,
            PackageType packageType = PackageType.Normal,
            BuildOption buildOption = BuildOption.None,
            string toolsDir         = "../Tools",
            string outputDir        = "Output",
            int svnRev = -1)
        {
            ModifyMacro(nssUnityProj, buildMode, packageType, buildOption);

            var result = new BuildAppResult();

            result.defaultTDir = ModifyDefaultLaunch(nssUnityProj, verLine, buildMode);

            var unityExe       = new Executable(unityExePath);
            var unityArguments = $"-batchmode -quit -logFile \"{SpaceUtil.GetPathInTemp("log.log", true)}\" -projectPath \"{nssUnityProj}\" -executeMethod \"NssIntegration.BuildProcedure.Entry\" -l \"{SpaceUtil.GetPathInTemp("log2.log", true)}\"";

            if (prepareProject)
            {
                unityArguments += $" PrepareProject {buildMode} {BuildTarget.Android} \"{versionJsonPath}\" {packageType} {buildOption} \"{toolsDir}\"";
            }
            unityArguments += $" BuildApk {buildMode} \"{sdkRoot}\" \"{ndkRoot}\" \"{jdkRoot}\" {verLine} {packageType} {buildOption} \"{toolsDir}\" \"{outputDir}\" {svnRev}";
            unityExe.Execute(unityArguments);

            var apks = Directory.GetFiles(outputDir, "*.apk");

            if (apks.Length != 1)
            {
                throw new NssIntegrationException($"'{outputDir}'中有{apks.Length}个apk文件,不合理!");
            }
            result.appPath    = apks[0];
            result.appVersion = ClientVersion.New(versionJsonPath).ToString();

            return(result);
        }
示例#15
0
        public static void ModifyMacro(string nssUnityProj, BuildMode buildMode, PackageType packageType, BuildOption buildOption)
        {
            Logger.Log("开始修改客户端宏文件...");

            var mcsPath = Path.Combine(nssUnityProj, "Assets/mcs.rsp");

            if (!File.Exists(mcsPath))
            {
                throw new ArgumentException($"Can't find mcs.rsp in '{nssUnityProj}'!", nssUnityProj);
            }

            MCS mcs = new MCS(mcsPath);

            mcs.ModifyItemByBuildMode(buildMode);

            if (packageType == PackageType.Experience)
            {
                mcs.TryAddItem("-define:NSS_EXPERIENCE");
            }
            if (buildOption == BuildOption.AI)
            {
                mcs.TryAddItem("-define:AVATAR_AI_ENABLE");
            }

            mcs.Serialize(mcsPath);

            Logger.Log("修改后的宏文件:");
            Logger.Log(File.ReadAllText(mcsPath));

            var sha1FilePath = SpaceUtil.GetPathInPersistent("MCSSha1");
            var newSha1      = FileUtil.ComputeSHA1(mcsPath);

            if (!File.Exists(sha1FilePath) || File.ReadAllText(sha1FilePath) != newSha1)
            {// 宏变了,要删除dll,强制重编
                Logger.Log("宏变了,删除旧的DLL...");
                DirUtil.ClearDir(Path.Combine(nssUnityProj, "Library/ScriptAssemblies"));
            }
            File.WriteAllText(sha1FilePath, newSha1);
        }
示例#16
0
        /// <summary>
        /// Fires the Sentinel currently directly in front of the player.
        /// </summary>
        private void FireBestSentinel()
        {
            const float FullCircle        = 360f;
            const float RightAngle        = 90f;
            const float HalfSentinelAngle = FullCircle / NumSentinel * 0.5f;

            float angleDegrees = (FullCircle + RightAngle + HalfSentinelAngle);

            angleDegrees -= (Rotation.Angle * Mathf.Rad2Deg);
            angleDegrees %= FullCircle;

            int index = (int)(angleDegrees * NumSentinel / FullCircle);

            index = Mathf.Clamp(index, 0, NumSentinel - 1);

            PlayerBullet sentinel = SentinelPool[index];

            if (SpaceUtil.SpriteIsInBounds(sentinel))
            {
                FireSentinelForward(sentinel);
            }
        }
示例#17
0
        static void Main(string[] args)
        {
            SpaceUtil.SetTempSpace("temp");

            var logFile = SpaceUtil.GetPathInTemp($"NssIntegrationStart_{DateTime.Now.ToString("yyyyMMddhhmmss")}.log");

            Logger.SetLogFile("NssIntegrationStart", new LogFile(logFile));
            Logger.BeginMuteConsoleOutput();

            CLApp.Init("NssIntegration");

            var envConfigPath = SpaceUtil.GetPathInBase($"Config{Path.DirectorySeparatorChar}EnvConfig.json");
            Dictionary <string, string> dicEnvConfig = null;

            if (File.Exists(envConfigPath))
            {
                JsonSerializer jsonSerializer = new JsonSerializer();
                dicEnvConfig = (Dictionary <string, string>)jsonSerializer.Deserialize(new StreamReader(envConfigPath), typeof(Dictionary <string, string>));
            }

            // 初始化各种工具类
            SvnUtil.Init(() => GetEnv(envConfigPath, dicEnvConfig, "SvnBin"));
            ApkTool.Init(() => GetEnv(envConfigPath, dicEnvConfig, "ApkTool"));
            IntegrationServer.Init(() => GetEnv(envConfigPath, dicEnvConfig, "IntegrationServerAddress"));
            IFSUtil.Init(() => GetEnv(envConfigPath, dicEnvConfig, "IIPS"));

            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "AssemblyApk"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "PrepareUniqueVersionJson"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "ModifyMacro"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "BuildApk"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildEntry), "UnpackIFS"));
            CLApp.AddCommand(NewMethodCommand(typeof(BuildEntry), "Build"));

            Logger.SetLogFile("NssIntegrationStart", null);
            Logger.EndMuteConsoleOutput();

            CLApp.Launch(args);
        }