Exemplo n.º 1
0
    public void PreviewFeedback(FeedbackData _data)
    {
        if (_data.vibrationDataInited)
        {
            VibrationManager.Vibrate(PlayerIndex.One, _data.vibrationData.duration, _data.vibrationData.force, _data.vibrationData.forceCurve);
            VibrationManager.Vibrate(PlayerIndex.Two, _data.vibrationData.duration, _data.vibrationData.force, _data.vibrationData.forceCurve);
        }
        if (_data.soundDataInited)
        {
            SoundManager.PlaySoundInEditor(_data.soundData);
        }
        if (_data.shakeDataInited)
        {
            CameraShaker.ShakeEditorCamera(camera, _data.shakeData.intensity, _data.shakeData.duration, _data.shakeData.frequency, _data.shakeData.intensityCurve);
        }

        if (fxPs != null)
        {
            DestroyImmediate(fxPs.gameObject);
        }
        //Generate FX
        if (_data.vfxDataInited && _data.vfxData.vfxPrefab != null)
        {
            GameObject fx = FXManager.InstantiateFX(_data.vfxData.vfxPrefab, _data.vfxData.offset, false, Vector3.up, _data.vfxData.scaleMultiplier);
            instantiatedObjects.Add(fx);
            fxPs = fx.GetComponent <ParticleSystem>();
            fxPs.useAutoRandomSeed = false;
        }
    }
Exemplo n.º 2
0
 public static void LoadSceneByIndex(int index)
 {
     DestroyDDOL();
     SceneManager.LoadScene(index);
     VibrationManager.CancelAllVibrations();
     Time.timeScale = PlayerPrefs.GetFloat("REU_GameSpeed", i.gameSpeed) / 100;
 }
Exemplo n.º 3
0
 public static void LoadNextScene()
 {
     DestroyDDOL();
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     VibrationManager.CancelAllVibrations();
     Time.timeScale = PlayerPrefs.GetFloat("REU_GameSpeed", i.gameSpeed) / 100;
 }
Exemplo n.º 4
0
    public void ButtonSettingsVibration()
    {
        switch (SaveDataManager.getValue.settingsVibration)
        {
        case SettingsVibration.Off:
            SaveDataManager.getValue.settingsVibration = SettingsVibration.Short;
            break;

        case SettingsVibration.Short:
            SaveDataManager.getValue.settingsVibration = SettingsVibration.Medium;
            break;

        case SettingsVibration.Medium:
            SaveDataManager.getValue.settingsVibration = SettingsVibration.Long;
            break;

        case SettingsVibration.Long:
            SaveDataManager.getValue.settingsVibration = SettingsVibration.Off;
            break;

        default:
            SaveDataManager.getValue.settingsVibration = SettingsVibration.Medium;
            break;
        }
        SaveDataManager.Save();
        VibrationManager.Setup();
        OESettings.instance.UpdateButtonUIVibration();
        VibrationManager.Vibrate();
    }
Exemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 6
0
    void OnGUI()
    {
        GUI.skin.label.fontSize  = 45;
        GUI.skin.label.fontStyle = FontStyle.Bold;
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        GUI.Label(new Rect(0f, 0f, Screen.width, Screen.height * 0.2f), "Android Vibration Plugin");

        GUI.skin.label.fontSize  = 40;
        GUI.skin.label.alignment = TextAnchor.LowerCenter;
        Rect layoutRect = new Rect(Screen.width * 0.05f, Screen.height * 0.2f, Screen.width * 0.9f, Screen.height * 0.6f);

        GUILayout.BeginArea(layoutRect, GUI.skin.box);

        GUILayout.BeginVertical();

        GUILayout.Space(25f);

        GUILayout.Label("Has Vibrator: " + VibrationManager.HasVibrator());

        GUILayout.FlexibleSpace();

        _duration = (int)GUILayout.HorizontalSlider(_duration, 100f, 5000f);
        if (GUILayout.Button("Vibrate " + _duration + " milliseconds"))
        {
            VibrationManager.Vibrate(_duration);
        }

        GUILayout.Space(25f);

        if (GUILayout.Button("Vibrate with pattern (no loop)"))
        {
            VibrationManager.Vibrate(Pattern, 0, 0);
        }

        GUILayout.Space(25f);

        if (GUILayout.Button("Vibrate with pattern (3 times)"))
        {
            VibrationManager.Vibrate(Pattern, 0, 2);
        }

        GUILayout.Space(25f);

        if (GUILayout.Button("Vibrate with pattern (loop)"))
        {
            VibrationManager.Vibrate(Pattern, 0);
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Stop all vibrations"))
        {
            VibrationManager.Cancel();
        }

        GUILayout.EndVertical();

        GUILayout.EndArea();
    }
Exemplo n.º 7
0
        void Start()
        {
            AudioManager.Play(GetComponent <AudioSource>(), choppingWoodSound);

            VibrationManager.Vibrate();

            DOVirtual.DelayedCall(0.5f, DestroyMethod);
        }
Exemplo n.º 8
0
    public void StartVib(VIBSTR v)
    {
        if (!GameData.Instance.m_CanVibrate || VibrationManager.HasVibrator())
        {
            return;
        }

        Vibrate(m_vStrengths[(int)v]);
    }
 // Start is called before the first frame update
 void Start()
 {
     if (manager && manager != this)
     {
         Destroy(this);
     }
     else
     {
         manager = this;
     }
 }
Exemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     if (singleton && singleton != this)
     {
         Destroy(this);
     }
     else
     {
         singleton = this;
     }
 }
Exemplo n.º 11
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            AudioManager.Play(GetComponent <AudioSource>(), choppingWoodSound);

            VibrationManager.Vibrate();

            if (other.gameObject.TryGetComponent <Rigidbody2D>(out var rigidbody2D))
            {
                rigidbody2D.AddExplosionForce(explosionForce, transform.position);
            }
        }
Exemplo n.º 12
0
 void AwakeSingleton()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Exemplo n.º 13
0
 public static void OpenLevelMenu()
 {
     foreach (PlayerController p in GameManager.players)
     {
         if (!p.IsInputDisabled())
         {
             p.DisableInput();
             disabledInputs.Add(p);
         }
     }
     Time.timeScale = 0f;
     VibrationManager.CancelAllVibrations();
     mainMenu.gameObject.SetActive(true);
 }
Exemplo n.º 14
0
    private void Fire()
    {
        // Instantiate and launch the shell.
        m_Fired = true;

        Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;

        shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward;

        m_ShootingAudio.clip = m_FireClip;
        m_ShootingAudio.Play();

        m_CurrentLaunchForce = m_MinLaunchForce;

        VibrationManager.Vibrate(100);
    }
Exemplo n.º 15
0
    public void selected(bool s)
    {
        GameObject gameObject = base.transform.Find("Selected").gameObject;

        base.transform.Find("Selected").gameObject.SetActive(s);
        if (s)
        {
            VibrationManager.Haptic(HapticTypes.LightImpact);
            base.transform.Find("Text").GetComponent <Text>().color = GameController.InGameSelectedLetterColor;
        }
        else
        {
            base.transform.Find("Text").GetComponent <Text>().color = GameController.InGameLetterColor;
        }
        base.transform.Find("Selected").GetComponent <Image>().color = GameController.SelectedLetterBGColor;
    }
Exemplo n.º 16
0
    void UpdateVibrateButton()
    {
        if (GameData.current.hasVibrate)
        {
            Vibrate_On.SetActive(true);
            Vibrate_Off.SetActive(false);
        }
        else
        {
            Vibrate_On.SetActive(false);
            Vibrate_Off.SetActive(true);
        }

        if (GameData.current.hasVibrate && VibrationManager.HasVibrator())
        {
            VibrationManager.Vibrate(Defines.V_PLACEICON);
        }
    }
Exemplo n.º 17
0
    void Init()
    {
        mGemeVersion = "1.0.0";
        mGameId      = 1;

        mFileManager      = new FileManager();
        mTextManager      = new TextManager();
        mLogManager       = new LogManager();
        mNetManager       = new NetManager();
        mResourceManager  = new ResourceManager();
        mSoundManager     = new SoundManager();
        mVibrationManager = new VibrationManager();
        mStoreManager     = new StoreManager();

        var parameters = GameObject.Find("MainObject").GetComponent <Parameters>();

        mGamePlay = new GamePlay(parameters);
    }
Exemplo n.º 18
0
    //Defined Start-Routine
    IEnumerator CheckPrestartConditions()
    {
        //Check if all Saved Data is collected
        Debug.Log(LogTime.Time() + ": Game Starter Script - Loading saved Data...");
        SaveDataManager.Load();
        while (!SaveDataManager.firstDataLoaded)
        {
            yield return(new WaitForEndOfFrame());
        }
        Debug.Log(LogTime.Time() + ": Game Starter Script - All saved Data loaded...");

        //Set Language
        Debug.Log(LogTime.Time() + ": Game Starter Script - Going to apply current Language...");
        if (SaveDataManager.getValue.languageManualySet == false)
        {
            var autoLanguage = Application.systemLanguage == SystemLanguage.German ? SettingsLanguages.German : SettingsLanguages.English;
            SaveDataManager.getValue.settingsLanguage = autoLanguage;
            SaveDataManager.Save();
        }
        LanguageScript.UpdateLanguage();
        Debug.Log(LogTime.Time() + ": Game Starter Script - Language Set...");

        //Set Vibration
        VibrationManager.Setup();

        //Setup Google Play
        GoogleLoginScript.instance.CheckAutoSetup();

        //Debug && FreeShop
        if (ConstantManager.freeShop)
        {
            SaveDataManager.getValue.coinItemLVL         = 0;
            SaveDataManager.getValue.secondChanceItemLVL = 0;
            SaveDataManager.getValue.shieldItemLVL       = 0;
            SaveDataManager.getValue.shootItemLVL        = 0;
            SaveDataManager.getValue.shrinkItemLVL       = 0;
            SaveDataManager.getValue.slideItemLVL        = 0;
            SaveDataManager.Save();
        }

        //Call SceneManager to load whatever needs to be loaded
        Debug.Log(LogTime.Time() + ": Game Starter Script - Calling Scene Manager to load first Scene...");
        SceneManager.instance.startGame();
    }
Exemplo n.º 19
0
    private void OnTriggerEnter(Collider other)
    {
        var tag = other.gameObject.tag;

        if (tag == "Particle" && other.GetType() == typeof(MeshCollider))
        {
            var particleScript = other.gameObject.GetComponent <ParticleScript>();
            if (particleScript.particleType == ParticleType.grow)
            {
                particleScript.Destroy(true);
                VibrationManager.Vibrate();
                collisionCount--;
                if (collisionCount < 1)
                {
                    DeactivateShield();
                }
            }
        }
    }
Exemplo n.º 20
0
    void UpdateAnim()
    {
        if (isStartingGame)
        {
            if (GameData.current.hasVibrate && VibrationManager.HasVibrator())
            {
                VibrationManager.Vibrate(Defines.V_STARTGAME);
            }

            blackScreen.SetActive(true);
            Color temp = blackScreen.GetComponent <Image>().color;
            temp.a += Time.deltaTime * 3.0f;
            blackScreen.GetComponent <Image>().color = temp;

            if (blackScreen.GetComponent <Image>().color.a >= 1.0f)
            {
                SceneManager.LoadScene("GameScene");
            }
        }
    }
Exemplo n.º 21
0
    void Awake()
    {
        // Only one instance of SoundManager at a time!
        if (_inited)
        {
            Destroy(gameObject);
            return;
        }
        _inited   = true;
        _instance = this;
        DontDestroyOnLoad(gameObject);

        _settings = Resources.Load <VibrationManagerSettings>("VibrationManagerSettings");
        if (_settings == null)
        {
            Debug.LogWarning("VibrationManagerSettings not founded resources. Using default settings");
            _settings = ScriptableObject.CreateInstance <VibrationManagerSettings>();
        }

        _settings.LoadSettings();
    }
Exemplo n.º 22
0
    private void OnCollisionEnter(Collision collision)
    {
        // Whether or not the ball has already collided with this rigid body
        bool collisionExists = false;

        // Loop through the list to see if the rigid body has already been collided with
        for (int i = 0; i < collisionRigidbodyList.Count; i++)
        {
            if (collisionRigidbodyList[i] == collision.rigidbody)
            {
                collisionExists = true;
                break;
            }
        }

        if (!collisionExists)
        {
            // Add the rigid body to the list
            collisionRigidbodyList.Add(collision.rigidbody);

            // Create a vibration for this collision
            VibrationManager.VibrateOnCollision(collision.relativeVelocity.magnitude);
        }
    }
Exemplo n.º 23
0
        public void TakeDamage(GameObject go, CollisionSide damageSide, int damageAmount, int hazardType)
        {
            damageAmount = ModHooks.Instance.OnTakeDamage(ref hazardType, damageAmount);
            bool spawnDamageEffect = true;

            if (damageAmount > 0)
            {
                if (BossSceneController.IsBossScene)
                {
                    int bossLevel = BossSceneController.Instance.BossLevel;
                    if (bossLevel != 1)
                    {
                        if (bossLevel == 2)
                        {
                            damageAmount = 9999;
                        }
                    }
                    else
                    {
                        damageAmount *= 2;
                    }
                }
                if (this.CanTakeDamage())
                {
                    if (this.damageMode == DamageMode.HAZARD_ONLY && hazardType == 1)
                    {
                        return;
                    }
                    if (this.cState.shadowDashing && hazardType == 1)
                    {
                        return;
                    }
                    if (this.parryInvulnTimer > 0f && hazardType == 1)
                    {
                        return;
                    }
                    VibrationMixer mixer = VibrationManager.GetMixer();
                    if (mixer != null)
                    {
                        mixer.StopAllEmissionsWithTag("heroAction");
                    }
                    bool flag = false;
                    if (this.carefreeShieldEquipped && hazardType == 1)
                    {
                        if (this.hitsSinceShielded > 7)
                        {
                            this.hitsSinceShielded = 7;
                        }
                        switch (this.hitsSinceShielded)
                        {
                        case 1:
                            if ((float)UnityEngine.Random.Range(1, 100) <= 10f)
                            {
                                flag = true;
                            }
                            break;

                        case 2:
                            if ((float)UnityEngine.Random.Range(1, 100) <= 20f)
                            {
                                flag = true;
                            }
                            break;

                        case 3:
                            if ((float)UnityEngine.Random.Range(1, 100) <= 30f)
                            {
                                flag = true;
                            }
                            break;

                        case 4:
                            if ((float)UnityEngine.Random.Range(1, 100) <= 50f)
                            {
                                flag = true;
                            }
                            break;

                        case 5:
                            if ((float)UnityEngine.Random.Range(1, 100) <= 70f)
                            {
                                flag = true;
                            }
                            break;

                        case 6:
                            if ((float)UnityEngine.Random.Range(1, 100) <= 80f)
                            {
                                flag = true;
                            }
                            break;

                        case 7:
                            if ((float)UnityEngine.Random.Range(1, 100) <= 90f)
                            {
                                flag = true;
                            }
                            break;

                        default:
                            flag = false;
                            break;
                        }
                        if (flag)
                        {
                            this.hitsSinceShielded = 0;
                            this.carefreeShield.SetActive(true);
                            damageAmount      = 0;
                            spawnDamageEffect = false;
                        }
                        else
                        {
                            this.hitsSinceShielded++;
                        }
                    }
                    damageAmount = ModHooks.Instance.AfterTakeDamage(hazardType, damageAmount);
                    if (this.playerData.equippedCharm_5 && this.playerData.blockerHits > 0 && hazardType == 1 && this.cState.focusing && !flag)
                    {
                        this.proxyFSM.SendEvent("HeroCtrl-TookBlockerHit");
                        this.audioSource.PlayOneShot(this.blockerImpact, 1f);
                        spawnDamageEffect = false;
                        damageAmount      = 0;
                    }
                    else
                    {
                        this.proxyFSM.SendEvent("HeroCtrl-HeroDamaged");
                    }
                    this.CancelAttack();
                    if (this.cState.wallSliding)
                    {
                        this.cState.wallSliding = false;
                        this.wallSlideVibrationPlayer.Stop();
                    }
                    if (this.cState.touchingWall)
                    {
                        this.cState.touchingWall = false;
                    }
                    if (this.cState.recoilingLeft || this.cState.recoilingRight)
                    {
                        this.CancelRecoilHorizontal();
                    }
                    if (this.cState.bouncing)
                    {
                        this.CancelBounce();
                        this.rb2d.velocity = new Vector2(this.rb2d.velocity.x, 0f);
                    }
                    if (this.cState.shroomBouncing)
                    {
                        this.CancelBounce();
                        this.rb2d.velocity = new Vector2(this.rb2d.velocity.x, 0f);
                    }
                    if (!flag)
                    {
                        this.audioCtrl.PlaySound(HeroSounds.TAKE_HIT);
                    }
                    if (!this.takeNoDamage && !this.playerData.invinciTest)
                    {
                        if (this.playerData.overcharmed)
                        {
                            this.playerData.TakeHealth(damageAmount * 2);
                        }
                        else
                        {
                            this.playerData.TakeHealth(damageAmount);
                        }
                    }
                    if (this.playerData.equippedCharm_3 && damageAmount > 0)
                    {
                        if (this.playerData.equippedCharm_35)
                        {
                            this.AddMPCharge(this.GRUB_SOUL_MP_COMBO);
                        }
                        else
                        {
                            this.AddMPCharge(this.GRUB_SOUL_MP);
                        }
                    }
                    if (this.joniBeam && damageAmount > 0)
                    {
                        this.joniBeam = false;
                    }
                    if (this.cState.nailCharging || this.nailChargeTimer != 0f)
                    {
                        this.cState.nailCharging = false;
                        this.nailChargeTimer     = 0f;
                    }
                    if (damageAmount > 0 && this.OnTakenDamage != null)
                    {
                        this.OnTakenDamage();
                    }
                    if (this.playerData.health == 0)
                    {
                        base.StartCoroutine(this.Die());
                    }
                    else if (hazardType == 2)
                    {
                        base.StartCoroutine(this.DieFromHazard(HazardType.SPIKES, (!(go != null)) ? 0f : go.transform.rotation.z));
                    }
                    else if (hazardType == 3)
                    {
                        base.StartCoroutine(this.DieFromHazard(HazardType.ACID, 0f));
                    }
                    else if (hazardType == 4)
                    {
                        Debug.Log("Lava death");
                    }
                    else if (hazardType == 5)
                    {
                        base.StartCoroutine(this.DieFromHazard(HazardType.PIT, 0f));
                    }
                    else
                    {
                        base.StartCoroutine(this.StartRecoil(damageSide, spawnDamageEffect, damageAmount));
                    }
                }
                else if (this.cState.invulnerable && !this.cState.hazardDeath && !this.playerData.isInvincible)
                {
                    if (hazardType == 2)
                    {
                        if (!this.takeNoDamage)
                        {
                            this.playerData.TakeHealth(damageAmount);
                        }
                        this.proxyFSM.SendEvent("HeroCtrl-HeroDamaged");
                        if (this.playerData.health == 0)
                        {
                            base.StartCoroutine(this.Die());
                        }
                        else
                        {
                            this.audioCtrl.PlaySound(HeroSounds.TAKE_HIT);
                            base.StartCoroutine(this.DieFromHazard(HazardType.SPIKES, (!(go != null)) ? 0f : go.transform.rotation.z));
                        }
                    }
                    else if (hazardType == 3)
                    {
                        this.playerData.TakeHealth(damageAmount);
                        this.proxyFSM.SendEvent("HeroCtrl-HeroDamaged");
                        if (this.playerData.health == 0)
                        {
                            base.StartCoroutine(this.Die());
                        }
                        else
                        {
                            base.StartCoroutine(this.DieFromHazard(HazardType.ACID, 0f));
                        }
                    }
                    else if (hazardType == 4)
                    {
                        Debug.Log("Lava damage");
                    }
                }
            }
        }
Exemplo n.º 24
0
    public void PlaceOnGrid(int _newState)
    {
        gridState = _newState;

        switch (gridState)
        {
        case 0:         // Nothing (Black)
            GetComponent <SpriteRenderer>().color = Defines.ICON_COLOR_GREY;
            mainIcon.SetActive(false);
            break;

        case 1:         // P1 Icon
            GetComponent <Animator>().SetTrigger("isIconPlaced");
            GetComponent <SpriteRenderer>().color           = Defines.ICON_COLOR_P1;
            mainIcon.GetComponent <SpriteRenderer>().sprite = GetTurnHandler().GetSpriteP1();
            mainIcon.SetActive(true);

            if (GameStartAnim.Instance.GameStartAnimEnded() && AudioManager.Instance)
            {
                AudioManager.Instance.PlaySoundEvent(SOUNDID.ICON_CONFIRMED);
            }

            if (GameData.current.hasVibrate && VibrationManager.HasVibrator())
            {
                VibrationManager.Vibrate(Defines.V_PLACEICON);
            }
            break;

        case 2:         // P2 Icon
            GetComponent <Animator>().SetTrigger("isIconPlaced");
            GetComponent <SpriteRenderer>().color           = Defines.ICON_COLOR_P2;
            mainIcon.GetComponent <SpriteRenderer>().sprite = GetTurnHandler().GetSpriteP2();
            mainIcon.SetActive(true);

            if (GameStartAnim.Instance.GameStartAnimEnded() && AudioManager.Instance)
            {
                AudioManager.Instance.PlaySoundEvent(SOUNDID.ICON_CONFIRMED);
            }

            if (GameData.current.hasVibrate && VibrationManager.HasVibrator())
            {
                VibrationManager.Vibrate(Defines.V_PLACEICON);
            }
            break;

        case 3:         // Highlighting (Yellow)
            GetComponent <SpriteRenderer>().color = Defines.ICON_COLOR_HIGHLIGHT;
            GetComponent <Animator>().SetTrigger("isHighlighted");
            GetGUIManagerScript().gridEffect_growStage          = 10;
            GetGUIManagerScript().gridEffect.transform.position = transform.position;
            mainIcon.SetActive(false);

            if (AudioManager.Instance)
            {
                AudioManager.Instance.PlaySoundEvent(SOUNDID.ICON_HIGHLIGHTED);
            }
            break;

        case 4:         // Invalid (Red)
            GetComponent <SpriteRenderer>().color = Defines.ICON_COLOR_INVALID;
            GetComponent <Animator>().SetTrigger("isInvalid");
            //GetBoardScript().SetCurrentHighlight(10, 10);
            mainIcon.SetActive(false);

            if (AudioManager.Instance)
            {
                AudioManager.Instance.PlaySoundEvent(SOUNDID.ICON_INVALID);
            }
            break;

        default:
            break;
        }
    }
 private void Awake()
 {
     instance = this;
 }
Exemplo n.º 26
0
    private IEnumerator delayedVibration()
    {
        yield return(new WaitForSecondsRealtime(.17f));

        VibrationManager.Vibrate();
    }
Exemplo n.º 27
0
 private void OnApplicationQuit()
 {
     VibrationManager.CancelAllVibrations();
 }
Exemplo n.º 28
0
 public static void ResetScene()
 {
     DestroyDDOL();
     SceneManager.LoadScene(GetCurrentZoneName());
     VibrationManager.CancelAllVibrations();
 }
Exemplo n.º 29
0
    public void ProcessBigGridCompleted(Defines.TURN _turn)
    {
        if (IsGridCompleted(_turn))
        {
            if (GameData.current.hasVibrate && VibrationManager.HasVibrator())
            {
                VibrationManager.Vibrate(Defines.V_WINBIGGRID);
            }

            GameObject.FindGameObjectWithTag("Board").GetComponent <BoardScript>().bigGridsCompleted++;

            if (!(TutorialScript.Instance.isTutorial && bigGridID == 7) && !(GameObject.FindGameObjectWithTag("Board").GetComponent <BoardScript>().IsBigGridCompleted()))
            {
                if (AudioManager.Instance)
                {
                    AudioManager.Instance.PlaySoundEvent(SOUNDID.WIN_BIGGRID);
                }
            }

            //add the points
            if (CanGetScore())
            {
                int _score = Defines.smallGridWin;
                if (GameObject.FindGameObjectWithTag("Board").GetComponent <BoardScript>().gameMode == Defines.GAMEMODE.LOCAL)
                {
                    _score = Defines.smallGridWin_Local;
                }
                else if (GameObject.FindGameObjectWithTag("Board").GetComponent <BoardScript>().gameMode == Defines.GAMEMODE.AI)
                {
                    _score = Defines.smallGridWin_AI;
                }

                Defines.Instance.playerScore += _score;
                GameObject tmp;

                tmp    = (GameObject)Instantiate(scrollingText);             //.gameObject.GetComponent<FloatingText>().BeginScrolling(" + " + _score + "!");
                canvas = transform.parent.parent.gameObject.GetComponent <BoardScript>().canvas;
                tmp.transform.SetParent(canvas.transform);
                tmp.transform.localScale       = new Vector3(1, 1, 1);
                tmp.transform.localPosition    = new Vector3(0, 0, 0);
                tmp.GetComponent <Text>().text = "+ " + _score + "!";

                if (AudioManager.Instance)
                {
                    AudioManager.Instance.PlaySoundEvent(SOUNDID.GETPOINTS);
                }
            }

            //begin to do the shakings
            begin = true;
            grids[pos1].GetComponent <Shaker>().StartShaking();
            //grids[pos2].GetComponent<Shaker>().StartShaking();
            //grids[pos3].GetComponent<Shaker>().StartShaking();
            // Win!

            gridWinner = (int)_turn;

            /*GetComponent<LineRenderer>().SetPosition(0,grids[pos1].transform.position+new Vector3(0,0,1));
            *  GetComponent<LineRenderer>().SetPosition(1,grids[pos3].transform.position+new Vector3(0,0,1));*/
            if (winMethod == WINMETHOD.H_TOP)
            {
                transform.Find("H1").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
            else if (winMethod == WINMETHOD.H_MID)
            {
                transform.Find("H2").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
            else if (winMethod == WINMETHOD.H_BOT)
            {
                transform.Find("H3").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
            else if (winMethod == WINMETHOD.V_LEFT)
            {
                transform.Find("V1").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
            else if (winMethod == WINMETHOD.V_MID)
            {
                transform.Find("V2").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
            else if (winMethod == WINMETHOD.V_RIGHT)
            {
                transform.Find("V3").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
            else if (winMethod == WINMETHOD.BACKSLASH)
            {
                transform.Find("LeftSlash").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
            else if (winMethod == WINMETHOD.SLASH)
            {
                transform.Find("RightSlash").GetComponent <WinLine>().startLine(grids[pos1].GetComponent <Shaker>().duration *3);
            }
        }
        else if (IsDraw())
        {
            if (GameData.current.hasVibrate && VibrationManager.HasVibrator())
            {
                VibrationManager.Vibrate(Defines.V_WINBIGGRID);
            }

            gridWinner = 3;
            sWinFrame.SetActive(true);
            sWinFrame.GetComponent <SpriteRenderer>().color =
                new Color(Defines.ICON_COLOR_DRAW.r, Defines.ICON_COLOR_DRAW.g, Defines.ICON_COLOR_DRAW.b, 0.5f);
            sWinFrame.GetComponent <Animator>().SetTrigger("isSpin");
            GameObject.FindGameObjectWithTag("Board").GetComponent <BoardScript>().ProcessBoardCompleted();
        }
    }
Exemplo n.º 30
0
    public static FeedbackCallback SendFeedback(string _eventName, Object _target, Vector3 _eventPosition, Vector3 _eventDirection, Vector3 _eventNormal, bool _onlyFX = false)
    {
        //Data initianilisation
        FeedbackCallback i_callBack = new FeedbackCallback();
        FeedbackData     i_feedback = GetFeedbackData(_eventName);

        if (i_feedback == null)
        {
            return(i_callBack);
        }
        Component target = _target as Component;

        //Shake camera
        if (i_feedback.shakeData != null && i_feedback.shakeDataInited && !_onlyFX)
        {
            CameraShaker.ShakeCamera(i_feedback.shakeData.intensity, i_feedback.shakeData.duration, i_feedback.shakeData.frequency, i_feedback.shakeData.intensityCurve);
        }

        //Vibrate gamepad
        if (i_feedback.vibrationData != null && i_feedback.vibrationDataInited && !_onlyFX)
        {
            switch (i_feedback.vibrationData.target)
            {
            case VibrationTarget.TargetedPlayer:
                if (_target == null)
                {
                    Debug.LogWarning("Can't make target vibrate"); break;
                }
                Component component;
                target.TryGetComponent(typeof(PlayerController), out component);
                PlayerController player = (PlayerController)component;
                if (player != null)
                {
                    VibrationManager.Vibrate(player.playerIndex, i_feedback.vibrationData.duration, i_feedback.vibrationData.force, i_feedback.vibrationData.forceCurve);
                }
                break;

            case VibrationTarget.BothPlayers:
                VibrationManager.Vibrate(PlayerIndex.One, i_feedback.vibrationData.duration, i_feedback.vibrationData.force, i_feedback.vibrationData.forceCurve);
                VibrationManager.Vibrate(PlayerIndex.Two, i_feedback.vibrationData.duration, i_feedback.vibrationData.force, i_feedback.vibrationData.forceCurve);
                break;
            }
        }

        //Play sound
        if (i_feedback.soundData != null && i_feedback.soundDataInited && !_onlyFX)
        {
            Component newTarget = target;
            if (newTarget == null)
            {
                newTarget = GameManager.mainCamera;
            }
            SoundData i_modifiedSoundData = new SoundData();
            i_modifiedSoundData.soundName        = i_feedback.soundData.soundName;
            i_modifiedSoundData.soundList        = i_feedback.soundData.soundList;
            i_modifiedSoundData.delay            = i_feedback.soundData.delay;
            i_modifiedSoundData.volumeMultiplier = i_feedback.soundData.volumeMultiplier * PlayerPrefs.GetFloat("REU_SFX Volume", fXVolumeSettingsMod);

            SoundManager.PlaySound(i_modifiedSoundData, newTarget.transform.position, newTarget.transform);
        }

        //Generate FX
        if (i_feedback.vfxData != null && i_feedback.vfxDataInited && i_feedback.vfxData.vfxPrefab != null)
        {
            Vector3 direction = Vector3.zero;
            switch (i_feedback.vfxData.direction)
            {
            case VFXDirection.Default:
                direction = new Vector3(0, 0, 0);
                break;

            case VFXDirection.EventDirection:
                direction = _eventDirection;
                break;

            case VFXDirection.EventNormal:
                direction = _eventNormal;
                break;

            case VFXDirection.LocalForward:
                direction = target.transform.forward;
                break;

            case VFXDirection.WorldUp:
                direction = new Vector3(0, 1, 0);
                break;
            }
            Transform newParent = null;
            Vector3   position  = _eventPosition;
            switch (i_feedback.vfxData.position)
            {
            case VFXPosition.EventObject:
                position = target.transform.position;
                break;
            }
            if (i_feedback.vfxData.attachToTarget)
            {
                newParent = target.transform;
            }
            i_callBack.vfx = FXManager.InstantiateFX(i_feedback.vfxData.vfxPrefab, position + i_feedback.vfxData.offset, false, direction, i_feedback.vfxData.scaleMultiplier, newParent);
        }
        return(i_callBack);
    }