コード例 #1
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            itemSelected = HelperUtilities.GetComponentInMousePosition <Item>(itemLayers);
            if (!itemSelected)
            {
                return;
            }

            itemSelected?.Select();
        }
        else if (Input.GetMouseButton(0))
        {
            if (!itemSelected)
            {
                return;
            }

            itemSelected.Drag();
        }
        else if (Input.GetMouseButtonUp(0) || !Application.isFocused)
        {
            if (!itemSelected)
            {
                return;
            }

            itemSelected.Release();
            itemSelected = null;
        }
    }
コード例 #2
0
    public void Move(Vector3 dir)
    {
        Vector3 newScale = HelperUtilities.CloneVector3(transform.localScale);
        Vector3 newPos   = HelperUtilities.CloneVector3(transform.position);

        float delX;

        if (dir.x < 0)
        {
            delX       = -MoveSpeed;
            newScale.x = Mathf.Abs(newScale.x);
        }
        else if (dir.x > 0)
        {
            delX       = MoveSpeed;
            newScale.x = -Mathf.Abs(newScale.x);
        }
        else
        {
            delX = 0;
        }

        newPos.x += delX;

        transform.position   = Vector3.Lerp(transform.position, newPos, Time.fixedDeltaTime);
        transform.localScale = newScale;
    }
コード例 #3
0
    IEnumerator PlaySpecialAttackSequence()
    {
        explosionParticleSystem.Play();
//        yield return new WaitForSeconds(1f);

        CharacterCombatController characterCombatController = owner.GetComponent <CharacterCombatController>();

        float duration = HelperUtilities.Remap(spiritUsed, 0, characterCombatController.maxSpirit,
                                               0, explosionDuration);

        float force = HelperUtilities.Remap(spiritUsed, 0, characterCombatController.maxSpirit,
                                            0, explosionForce);

        float radius = HelperUtilities.Remap(spiritUsed, 0, characterCombatController.maxSpirit, 0, explosionRadius);


        ParticleSystem.MainModule psMain = BurningGroundParticleSystem.main;
        psMain.duration          = duration;
        growBurningGround        = true;
        burningGroundTargetScale = Vector3.one * radius;
        BurningGroundParticleSystem.gameObject.SetActive(true);

        for (int i = 0; i < projectileSpawnPoints.Length; i++)
        {
            ThrowExplosionProjectile(projectileSpawnPoints[i], force, radius);
            yield return(new WaitForSeconds(0.1f));
        }

        while (BurningGroundParticleSystem && BurningGroundParticleSystem.isPlaying)
        {
            yield return(new WaitForSeconds(duration));
        }

        Destroy(gameObject);
    }
コード例 #4
0
    // Start is called before the first frame update
    //public void OnObjectSpawn()
    void OnEnable()
    {
        //material
        //materialColor = this.gameObject.GetComponent<Renderer>().material;
        //set crate color
        //SpawnColor();

        //SetMaterial();
        //set crate timer
        if (CrateManager.Instance != null)
        {
            timer = CrateManager.Instance.duration;

            //set UI values
            float currentSliderValue = HelperUtilities.Remap(timer, 0, CrateManager.Instance.duration, 0, 1);
            durationSlider.value           = currentSliderValue;
            durationSliderBackground.value = durationSlider.value;
            durationFill.color             = Color.Lerp(minDurationColor, maxDurationColor, (float)currentSliderValue / CrateManager.Instance.duration);
        }

        //
        delivered = false;

        transform.rotation = originalRotation;
        GetComponent <Rigidbody>().useGravity  = true;
        GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
        power = PowerUp.None;
    }
コード例 #5
0
    public static Sequence DOFade(this GameObject obj, float endValue, float duration)
    {
        Sequence mySequence = DOTween.Sequence();

        mySequence.SetUpdate(true);

        List <Graphic> graphics = new List <Graphic>(obj.GetComponentsInChildren <Graphic>(true));

        foreach (var graphic in graphics)
        {
            float remappedEndValue  = endValue;
            var   graphicFadeHelper = graphic.GetComponent <GraphicFadeHelper>();
            if (graphicFadeHelper && graphicFadeHelper.enabled)
            {
                graphicFadeHelper.RefreshIfNeeded();
                remappedEndValue = HelperUtilities.Remap(endValue, 0, 1, graphicFadeHelper.minOpacity,
                                                         graphicFadeHelper.maxOpacity);
            }

            var graphicTween = graphic.DOFade(remappedEndValue, duration);
            mySequence.Insert(0, graphicTween);
            mySequence.PrependCallback(() => graphic.DOKill(true));
        }

        mySequence.SetTarget(obj);

        return(mySequence);
    }
コード例 #6
0
    public void Resume()
    {
        Time.timeScale = 1;

        HelperUtilities.UpdateCursorLock(true);
        HideScreen(pauseCanvas.gameObject);
    }
コード例 #7
0
    public void Pause()
    {
        Time.timeScale = 0;

        HelperUtilities.UpdateCursorLock(false);
        ShowScreen(pauseCanvas.gameObject);
    }
コード例 #8
0
    public void Show()
    {
        Time.timeScale = 0;
        HelperUtilities.UpdateCursorLock(false);

        RefreshTaskReports();
        ShowScreen(canvas);
    }
コード例 #9
0
        private byte[] FindTemplatePath(SessionInfo session, SerTemplate template)
        {
            var inputPath         = Uri.UnescapeDataString(template.Input.Replace("\\", "/"));
            var inputPathWithHost = inputPath.Replace("://", ":/Host/");
            var originalSegments  = inputPathWithHost.Split('/');
            var templateUri       = new Uri(inputPathWithHost);
            var normalizePath     = HelperUtilities.NormalizeUri(inputPath);

            if (normalizePath == null)
            {
                throw new Exception($"The input path '{template.Input}' is not correct.");
            }
            var normalizeSegments = normalizePath.Split('/');
            var libaryName        = originalSegments.ElementAtOrDefault(originalSegments.Length - 2) ?? null;

            if (templateUri.Scheme.ToLowerInvariant() == "content")
            {
                var contentFiles = GetLibraryContent(session.QlikConn.CurrentApp, libaryName);
                logger.Debug($"There {contentFiles?.Count} content library found...");
                var filterFile = contentFiles.FirstOrDefault(c => c.EndsWith(normalizeSegments.LastOrDefault()));
                if (filterFile != null)
                {
                    var data = DownloadFile(filterFile, session.Cookie);
                    template.Input = $"{Guid.NewGuid()}{Path.GetExtension(filterFile)}";
                    return(data);
                }
                else
                {
                    throw new Exception($"No content library path found.");
                }
            }
            else if (templateUri.Scheme.ToLowerInvariant() == "lib")
            {
                var allConnections = session.QlikConn.CurrentApp.GetConnectionsAsync().Result;
                var libResult      = allConnections.FirstOrDefault(n => n.qName == libaryName) ?? null;
                if (libResult == null)
                {
                    throw new Exception($"The QName '{libaryName}' for lib path was not found.");
                }
                var libPath = libResult?.qConnectionString?.ToString();
                var relPath = originalSegments?.LastOrDefault() ?? null;
                if (String.IsNullOrEmpty(relPath))
                {
                    throw new Exception($"The relative filename for lib path '{relPath}' was not found.");
                }
                var fullLibPath = $"{libPath}{relPath}";
                if (!File.Exists(fullLibPath))
                {
                    throw new Exception($"The input file '{fullLibPath}' was not found.");
                }
                template.Input = Uri.EscapeDataString(Path.GetFileName(fullLibPath));
                return(File.ReadAllBytes(fullLibPath));
            }
            else
            {
                throw new Exception($"Unknown Scheme in input Uri path '{template.Input}'.");
            }
        }
コード例 #10
0
    public void SetTutorialTimer(float time)
    {
        timer = time;

        float currentSliderValue = HelperUtilities.Remap(timer, 0, CrateManager.Instance.duration, 0, 1);

        durationSlider.value           = currentSliderValue;
        durationSliderBackground.value = durationSlider.value;
        durationFill.color             = Color.Lerp(minDurationColor, maxDurationColor, (float)currentSliderValue / CrateManager.Instance.duration);
    }
コード例 #11
0
ファイル: HUDManager.cs プロジェクト: BFLowther/Fulcrum-2
    void UpdateTimer()
    {
        int secsLeft = (int)GameManager.Instance.TimeLeft;
        int minsLeft = secsLeft / 60;

        secsLeft %= 60;

        timerText.text = HelperUtilities.GetFormattedValue(minsLeft) + ":" +
                         HelperUtilities.GetFormattedValue(secsLeft);
    }
コード例 #12
0
    new void Awake()
    {
        base.Awake();

        Time.timeScale = 1;

        HelperUtilities.UpdateCursorLock(true);

        curParentsDistance = initialParentsDistance;
    }
コード例 #13
0
        public void ThenTheReportResultDxfShouldMatchTheFromTheRepository(string resultName)
        {
            //Note: to create the expected base64 string in the response repo, use Postman to 'Send and Download' a request and get the response as a zip file.
            //Then use an online encoder to get the Base64 string e.g. https://www.browserling.com/tools/file-to-base64
            var expectedResultAsBinary = GetResponseHandler.ResponseRepo[resultName]["dxfData"].ToObject <byte[]>();
            var expectedResult         = Encoding.Default.GetString(HelperUtilities.Decompress(expectedResultAsBinary));
            var actualResult           = Encoding.Default.GetString(HelperUtilities.Decompress(GetResponseHandler.ByteContent));

            Assert.True(expectedResult == actualResult, "Expected DXF file does not match actual");
        }
コード例 #14
0
    public void EnableEndScreen()
    {
        GameManager.Instance.hasEnded = true;
        HelperUtilities.UpdateCursorLock(false);
        endPanel.SetActive(true);
        //levelEnd.displayGears();


        levelEnd.CheckFinalScore();
    }
コード例 #15
0
        public void ThenTheReportResultCsvShouldMatchTheFromTheRepository(string resultName)
        {
            var expectedResultAsBinary = GetResponseHandler.ResponseRepo[resultName]["exportData"].ToObject <byte[]>();
            var expectedResult         = Encoding.Default.GetString(HelperUtilities.Decompress(expectedResultAsBinary));
            var actualResult           = Encoding.Default.GetString(HelperUtilities.Decompress(GetResponseHandler.ByteContent));

            var expSorted = HelperUtilities.SortCsvFile(expectedResult).ToList();
            var actSorted = HelperUtilities.SortCsvFile(actualResult).ToList();

            HelperUtilities.CompareExportCsvFiles(actSorted, expSorted);
        }
コード例 #16
0
    void Move()
    {
        if (inputDash && !isDashing && availableDash >= totalDash && LevelManager.Instance._isPlaying)
        {
            StartDashing();
        }

        Vector2 movement = new Vector2(inputHorizontal * walk, 0);

        if (isDashing)
        {
            movement       = HelperUtilities.CloneVector3(dashVector);
            availableDash -= Time.fixedDeltaTime;
            if (availableDash < 0)
            {
                StopDashing();
            }
        }

        if (!isDashing)
        {
            if (availableDash < totalDash)
            {
                availableDash += dashReplenish;
            }
        }

        if (LevelManager.Instance._isPlaying)
        {
            transform.Translate(movement * Time.fixedDeltaTime);
        }

        Vector3 newScale = HelperUtilities.CloneVector3(transform.localScale);

        if (movement.x > 0.0)
        {
            facingRight = true;
        }
        if (movement.x < 0.0)
        {
            facingRight = false;
        }
        if (movement.x > 0.0f && facingRight)
        {
            newScale.x = Mathf.Abs(newScale.x);
        }
        else if (movement.x < 0.0f && !facingRight)
        {
            newScale.x = Mathf.Abs(newScale.x) * -1;
        }

        isWalking            = Math.Abs(movement.x) > 0;
        transform.localScale = newScale;
    }
コード例 #17
0
    public void Explode(CharacterModel owner, float spiritUsed)
    {
        this.owner      = owner;
        this.spiritUsed = spiritUsed;

        CharacterCombatController characterCombatController = owner.GetComponent <CharacterCombatController>();

        damage = HelperUtilities.Remap(this.spiritUsed, 0, characterCombatController.maxSpirit, 0, damage);

        AudioManager.instance.PlayEffect(AudioManager.AudioData.Explosion, transform, volume);
        StartCoroutine(PlaySpecialAttackSequence());
    }
コード例 #18
0
    public override void Attack(Transform spawnPosition, Vector3 targetPosition, string enemyTag, float attack)
    {
        Projectile projectileInstance = Instantiate(Projectile, spawnPosition.position, Quaternion.identity);

        projectileInstance.EnemyTag = enemyTag;
        projectileInstance.Attack   = attack;
        HelperUtilities.LookAt2D(projectileInstance.transform, targetPosition, -90);
        projectileInstance.Rigidbody2D.AddForce(projectileInstance.transform.up * ShootForce);

        HelperUtilities.LookAt2D(projectileInstance.transform, targetPosition, 0);
        projectileInstance.DestroyOnCollision = true;
        Destroy(projectileInstance.gameObject, TimeToDestroy);
    }
コード例 #19
0
    void Awake()
    {
        charController = GetComponent <CharacterController>();
        playerModel    = GetComponent <PlayerModel>();
        playerDash     = GetComponent <PlayerDash>();

        HelperUtilities.UpdateCursorLock(true);

        movementVector = Vector3.zero;
        charController.detectCollisions = true;

        initialSpeed            = speed;
        maxHazardEffectDuration = hazardEffectDuration;
    }
コード例 #20
0
    void TryJump()
    {
        if (isDashing)
        {
            return;
        }

        if (grounded && inputJump)
        {
            Vector3 velocity = HelperUtilities.CloneVector3(PM.rb2d.velocity);
            velocity.y       = 0;
            PM.rb2d.velocity = velocity;
            PM.rb2d.AddForce(Vector2.up * jump);
        }
    }
コード例 #21
0
    public void AttachCharacter(CharacterModel incomingCharacterModel)
    {
        characterModel = incomingCharacterModel;
        image.sprite   = characterModel.CharacterInfo.image;

        CharacterHealthController characterHealthController = characterModel.GetComponent <CharacterHealthController>();

        characterHealthController.onHealthChanged += (oldHealth, health) =>
        {
            healthSlider.value = HelperUtilities.Remap(health, 0, characterHealthController.maxHealth,
                                                       healthSlider.minValue, healthSlider.maxValue);
        };

        characterCombatController = characterModel.GetComponent <CharacterCombatController>();
    }
コード例 #22
0
ファイル: HUDManager.cs プロジェクト: BFLowther/Fulcrum-2
        private void UpdateStatMeter(Image statImage, float statValue, bool animate)
        {
            float lerpDeadzone = 0.005f;

            if (statImage)
            {
                float target = HelperUtilities.Remap(statValue, 0, GameManager.Instance.maxStatValue, 0, 1);

                float lerpSpeed = animate && (Mathf.Abs(target - statImage.fillAmount) > lerpDeadzone)
                    ? Time.deltaTime * SliderSpeed
                    : 1;

                statImage.fillAmount = Mathf.Lerp(statImage.fillAmount, target, lerpSpeed);
            }
        }
コード例 #23
0
    public void CalculateTaskStatuses()
    {
        rearrangeObjectsTask.CalculateTaskStatus();
        fixObjectsTask.CalculateTaskStatus();
        trashCleaningTask.CalculateTaskStatus();
        hideFriendsTask.CalculateTaskStatus();

        score  = 0;
        score += HelperUtilities.Remap(rearrangeObjectsTask.objectsOutOfPlace, bestRearrangeLeft, worstRearrangeLeft, rearrangeWeight,
                                       0);
        score += HelperUtilities.Remap(fixObjectsTask.objectsNotFixed, bestUnfixedLeft, worstUnfixedLeft, fixWeight, 0);
        score += HelperUtilities.Remap(trashCleaningTask.trashNotThrown, bestTrashLeft, worstTrashLeft, trashWeight, 0);
        score += HelperUtilities.Remap(hideFriendsTask.friendsNotHidden, bestFriendsLeft, worstFriendsLeft, friendsWeight, 0);

        score = Mathf.Clamp01(score);
    }
コード例 #24
0
 public void PauseToggle()
 {
     GameManager.Instance.isPaused = !GameManager.Instance.isPaused;
     if (Time.timeScale == 0.0f)
     {
         Time.timeScale = 1.0f;
         HelperUtilities.UpdateCursorLock(true);
         pausePanel.SetActive(false);
     }
     else
     {
         Time.timeScale = 0.0f;
         HelperUtilities.UpdateCursorLock(false);
         pausePanel.SetActive(true);
     }
 }
コード例 #25
0
    // Update is called once per frame
    void Update()
    {
        if (characterCombatController)
        {
            spiritSlider.value = HelperUtilities.Remap(characterCombatController.spirit, 0,
                                                       characterCombatController.maxSpirit, spiritSlider.minValue, spiritSlider.maxValue);

            if (characterCombatController.spirit > characterCombatController.minSpiritConsumption)
            {
                spiritSlider.interactable = true;
            }
            else
            {
                spiritSlider.interactable = false;
            }
        }
    }
コード例 #26
0
        public void Start()
        {
            try
            {
                cts = new CancellationTokenSource();
                var configPath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "config.hjson");
                if (!File.Exists(configPath))
                {
                    var exampleConfigPath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "config.hjson.example");
                    if (File.Exists(exampleConfigPath))
                    {
                        File.Copy(exampleConfigPath, configPath);
                    }
                    else
                    {
                        throw new Exception($"config file {configPath} not found.");
                    }
                }

                logger.Debug($"Read conncetor config file from '{configPath}'.");
                var json = HjsonValue.Load(configPath).ToString();
                ConfigObject = JObject.Parse(json);

                // Check to generate certifiate and private key if not exists
                var certFile = ConfigObject?.connection?.credentials?.cert?.ToString() ?? null;
                certFile = HelperUtilities.GetFullPathFromApp(certFile);
                if (!File.Exists(certFile))
                {
                    var privateKeyFile = ConfigObject?.connection?.credentials?.privateKey.ToString() ?? null;
                    privateKeyFile = HelperUtilities.GetFullPathFromApp(privateKeyFile);
                    if (File.Exists(privateKeyFile))
                    {
                        privateKeyFile = null;
                    }

                    CreateCertificate(certFile, privateKeyFile);
                }

                // Wait for connection to Qlik
                CheckQlikConnection(json);
            }
            catch (Exception ex)
            {
                logger.Fatal(ex, "Service could not be started.");
            }
        }
コード例 #27
0
        public IWebDriver BrowserReady(IWebDriver webDriver, HelperUtilities utils, UserData usrData)
        {
            bool testPassed = false;

            string findThis = "Sign in with Microsoft";

            string pageText = string.Empty;

            Size viewPortSize = new Size(1650, 1000);

            string startPage = @"https://www.google.com/";

            utils.RandomPause(1);

            webDriver.Navigate().GoToUrl(startPage);

            utils.RandomPause(1);

            webDriver.Manage().Window.Size = viewPortSize;

            utils.RandomPause(1);

            webDriver.Navigate().GoToUrl(usrData.ClientUrl);

            var wait = new WebDriverWait(webDriver, new TimeSpan(0, 0, 30));

            var element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("RememberLogin")));

            utils.RandomPause(1);

            pageText = webDriver.PageSource;

            testPassed = utils.PageIsReady(webDriver, pageText, findThis);

            if (testPassed)
            {
                // resultWas.PassCount++;
            }
            else
            {
                // resultWas.FailCount++;
            }

            return(webDriver);
        }
    public override void Attack(Transform spawnPosition, Vector3 targetPosition, string enemyTag, float attack)
    {
        float rotation = -75;

        for (int i = 0; i < 3; i++)
        {
            Projectile projectileInstance = Instantiate(Projectile, spawnPosition.position, Quaternion.identity);
            projectileInstance.EnemyTag = enemyTag;
            projectileInstance.Attack   = (float)Math.Round(attack / 2f, 2);
            HelperUtilities.LookAt2D(projectileInstance.transform, targetPosition, rotation);
            projectileInstance.Rigidbody2D.AddForce(projectileInstance.transform.up * ShootForce);

            HelperUtilities.LookAt2D(projectileInstance.transform, targetPosition, 0);
            projectileInstance.DestroyOnCollision = true;
            Destroy(projectileInstance.gameObject, TimeToDestroy);
            rotation -= 15;
        }
    }
コード例 #29
0
    void DecreaseCrateTimer()
    {
        //lower crate timer
        timer -= Time.deltaTime;

        //set UI values
        float currentSliderValue = HelperUtilities.Remap(timer, 0, CrateManager.Instance.duration, 0, 1);

        durationSlider.value           = currentSliderValue;
        durationSliderBackground.value = durationSlider.value;
        durationFill.color             = Color.Lerp(minDurationColor, maxDurationColor, currentSliderValue);

        //call explode when timer = 0;
        if (timer <= 0 && !delivered)
        {
            PlayerModel playerMod = null;
            playerMod = transform.GetComponentInParent <PlayerModel>();
            if (playerMod != null)
            {
                if (TutorialManager.Instance == null)
                {
                    playerMod.Fail();
                }
                else
                {
                    if (TutorialManager.Instance.currentObjective > 0)
                    {
                        playerMod.TutorialFail();
                    }
                }
            }
            else
            {
                GameManager.Instance.subScore(1);
                CrateManager.Instance.Explode();
                CrateManager.Instance.spawnLocationStatus[CrateManager.Instance.currentSpawnedItems[this.gameObject]] = false;
                CrateManager.Instance.currentSpawnedItems.Remove(this.gameObject);

                gameObject.SetActive(false);
            }
        }
    }
コード例 #30
0
    void RefreshAllUnderwaterCreatureData()
    {
        _allUnderwaterCreatureData.Clear();

        var allUnderwaterCreatureList = HelperUtilities.GetAllResources <UnderwaterCreatureData>();

        foreach (var underwaterCreatureData in allUnderwaterCreatureList)
        {
            if (!_allUnderwaterCreatureData.ContainsKey(underwaterCreatureData.ID))
            {
                _allUnderwaterCreatureData.Add(underwaterCreatureData.ID, underwaterCreatureData);
            }
            else
            {
                Debug.LogError($"Duplicate Underwater Creature ID found: {underwaterCreatureData.ID}");
                Debug.LogError(
                    $"Conflicting data: {_allUnderwaterCreatureData[underwaterCreatureData.ID].name}, {underwaterCreatureData.name}");
            }
        }
    }