Exemplo n.º 1
0
    void onPurchasing(SuppliesUIObject item, GameObject tag)
    {
        if (tag.tag == "GoldButton")
        {
            Debug.Log(tag.name);

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("Gold Buy Attempt");
            }

            if (tag.name == "Gold")
            {
                tweenIn();
            }
            else if (tag.name == "GoldButtonBG")
            {
                tweenOut();
            }
            else if (tag.name == "Coins_L1")
            {
#if UNITY_ANDROID || UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
                tweenOut();
#elif UNITY_IPHONE
                EtceteraBinding.showBezelActivityViewWithLabel("Connecting to iTunes Store...");
                StoreKitBinding.purchaseProduct(MainMenuController.GOLD_200, 1);
#endif
            }
            else if (tag.name == "Coins_L2")
            {
#if UNITY_ANDROID || UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
                tweenOut();
#elif UNITY_IPHONE
                EtceteraBinding.showBezelActivityViewWithLabel("Connecting to iTunes Store...");
                StoreKitBinding.purchaseProduct(MainMenuController.GOLD_500, 1);
#endif
            }
            else if (tag.name == "Coins_L3")
            {
#if UNITY_ANDROID || UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
                tweenOut();
#elif UNITY_IPHONE
                EtceteraBinding.showBezelActivityViewWithLabel("Connecting to iTunes Store...");
                StoreKitBinding.purchaseProduct(MainMenuController.GOLD_4000, 1);
#endif
            }
        }
    }
Exemplo n.º 2
0
    void onUIUpdate(Gun gun, PlayerController._GameState state, GameObject clicked, EnemyStats stats)
    {
        if (clicked == gameObject && state != PlayerController._GameState.None)
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("Health Pack Use");
            }

            switch (name)
            {
            case "HPackTiny":
                DBAccess.instance.userPrefs.useHealthPack(0);
                tweenScale();
                break;

            case "HPackSmall":
                DBAccess.instance.userPrefs.useHealthPack(1);
                tweenScale();
                break;

            case "HPackMedium":
                DBAccess.instance.userPrefs.useHealthPack(2);
                tweenScale();
                break;

            case "HPackLarge":
                DBAccess.instance.userPrefs.useHealthPack(3);
                tweenScale();
                break;

            case "HPackHuge":
                DBAccess.instance.userPrefs.useHealthPack(4);
                tweenScale();
                break;

            default:
                break;
            }
        }
    }
Exemplo n.º 3
0
    void onUIUpdate(Gun gun, PlayerController._GameState state, GameObject clicked, EnemyStats stats)
    {
        if (clicked == gameObject)
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("Quit Button Event");
                UnityEngine.Debug.Log("QuitSprite.cs: onUIUpdate: Quit Button Event");
            }

            DBAccess.instance.userPrefs.playCount++;

            if (onQuit != null)
            {
                onQuit();
            }
        }

        /*if( state == PlayerController._GameState.Reload )
         * {
         *      iTween.MoveTo( PARENT, iTween.Hash(
         *              "y", TWEEN_POS,
         *              "islocal", true,
         *              "time", 0.4f,
         *              "easetype", iTween.EaseType.easeOutBack
         *              )
         *      );
         * }
         * if( state == PlayerController._GameState.Active || state == PlayerController._GameState.IsReloading )
         * {
         *      iTween.MoveTo( PARENT, iTween.Hash(
         *              "y", RESET_POS,
         *              "islocal", true,
         *              "time", 0.4f,
         *              "easetype", iTween.EaseType.easeInBack
         *              )
         *      );
         * }*/
    }
Exemplo n.º 4
0
    void onPause()
    {
        // Disable Pause in Reload Mode
        // Bugfix hack: Pause does not release in Reload Menu.
        if (GameState == _GameState.Reload)
        {
            UnityEngine.Debug.Log("PlayerController.cs: Bypass Pause in Reload Menu");
            return;
        }

        if (Time.timeScale == 1)
        {
            _cachedAxes      = axes;
            _cachedGameState = GameState;

            axes      = RotationAxes.None;
            GameState = _GameState.Paused;

            audioSources[10].mute = true;
            audioSources[11].mute = true;

            Time.timeScale = 0;

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("On Pause Event");
            }
        }
        else
        {
            axes      = _cachedAxes;
            GameState = _cachedGameState;

            audioSources[10].mute = false;
            audioSources[11].mute = false;

            Time.timeScale = 1;
        }
    }
Exemplo n.º 5
0
    void Update()
    {
        // Raycast checking for where to route information and what events / SendMessages to use.
        if (Input.GetMouseButtonDown(0))
        {
            if (instance.menuState != MenuState.InTransition)
            {
                Ray        ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                //Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow, 3f);
                if (Physics.Raycast(ray, out hit, 100f))
                {
                    if (hit.collider.tag == "MainUI")
                    {
                        hit.collider.gameObject.SendMessage("onMenuClick", instance, SendMessageOptions.DontRequireReceiver);
                    }
                    else if (hit.collider.gameObject.layer == 11 && instance.menuState == MainMenuController.MenuState.Character)
                    {
                        DBAccess.instance.userPrefs.enemyName = findTaggedParent(hit.collider.transform).tag;
                        DBAccess.instance.enemyStats          = findTaggedParent(hit.collider.transform).GetComponent <EnemySelectStats>().stats;

                        if (DBAccess.instance.userPrefs.playCount == 0)
                        {
                            StartCoroutine(loadNextLevel(1));                                           //Tutorial Scene
                        }
                        else
                        {
                            StartCoroutine(loadNextLevel(2));                                   //Demo Scene
                        }
                    }

                    else if (hit.collider.tag == "StoreUI")
                    {
                        onStoreClick(hit.collider.GetComponent <SuppliesUIObject>(), instance.menuState, hit.collider.gameObject);
                    }
                    else if (hit.collider.tag == "BuyButton")
                    {
                        onPurchasableClick(hit.collider.gameObject);

                        if (Application.platform == RuntimePlatform.IPhonePlayer)
                        {
                            ChartBoostBinding.trackEvent("Buy Item Attempt");
                        }
                    }
                    else if (hit.collider.tag == "GoldButton")
                    {
                        onPurchasableClick(hit.collider.gameObject);
                    }
                    else if (hit.collider.tag == "StashUI")
                    {
                        onStashClick(hit.collider.GetComponent <SuppliesUIObject>(), instance.menuState, hit.collider.gameObject);
                    }
                    else if (hit.collider.tag == "OptionsUI")
                    {
                        GameObject clicked = hit.collider.gameObject;

                        if (clicked.name.Contains("Sound"))
                        {
                            clicked.SendMessage("hitByRayCast", SendMessageOptions.DontRequireReceiver);
                        }
                        else if (clicked.name.Contains("Music"))
                        {
                            clicked.SendMessage("hitByRayCast", SendMessageOptions.DontRequireReceiver);
                        }
                        else if (clicked.name.Contains("Control"))
                        {
                            clicked.SendMessage("hitByRayCast", SendMessageOptions.DontRequireReceiver);
                        }
                        else if (clicked.name.Contains("GameCenter"))
                        {
                            clicked.SendMessage("hitByRayCast", SendMessageOptions.DontRequireReceiver);
                        }
                        else if (clicked.name.Contains("Play"))
                        {
                            StartCoroutine(loadNextLevel(1));
                        }
                        else if (clicked.name.Contains("Background More Apps"))
                        {
                            Debug.Log("Options More Apps");
                            if (Application.platform == RuntimePlatform.IPhonePlayer)
                            {
                                ChartBoostBinding.showMoreApps();
                                ChartBoostBinding.trackEvent("Options More Apps Click");
                            }
                        }
                    }
                    else if (hit.collider.tag == "CharacterUI")
                    {
                        EnemySelectPopulator e = GameObject.Find("EnemyGroupingParent").GetComponent <EnemySelectPopulator>();

                        if (hit.collider.name == "Arrow Right" && e.characterIndex < 4)
                        {
                            instance.menuState = MainMenuController.MenuState.InTransition;

                            hit.collider.SendMessage("hitByRayCast", hit.collider.gameObject, SendMessageOptions.DontRequireReceiver);

                            if (onCharacterArrow != null)
                            {
                                onCharacterArrow(true);
                            }
                        }
                        if (hit.collider.name == "Arrow Left" && e.characterIndex > 0)
                        {
                            instance.menuState = MainMenuController.MenuState.InTransition;

                            hit.collider.SendMessage("hitByRayCast", hit.collider.gameObject, SendMessageOptions.DontRequireReceiver);

                            if (onCharacterArrow != null)
                            {
                                onCharacterArrow(false);
                            }
                        }
                        if (hit.collider.name.Contains("Background More Apps"))
                        {
                            Debug.Log("Character More Apps");

                            if (Application.platform == RuntimePlatform.IPhonePlayer)
                            {
                                ChartBoostBinding.showMoreApps();
                                ChartBoostBinding.trackEvent("Character Select More Apps Click");
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
    void onMenuClick(MainMenuController mmc)
    {
        mmc.setOffset();

        if (mmc.menuState == MainMenuController.MenuState.Main)
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("On Options Click");
            }

            mmc.menuIsInTransition();

            StartCoroutine
            (
                mmc.thisGO.animation.PlayWithOptions("MainOptions",
                                                     () => { mmc.applyOffset(); },
                                                     () =>
            {
                StartCoroutine
                (
                    mmc.thisGO.animation.PlayWithOptions("OptionsStart",
                                                         () =>
                {
                    mmc.menuState = MainMenuController.MenuState.Options;
                    mmc.thisGO.animation.Play("OptionsIdle");
                }
                                                         )
                );
            }
                                                     ));
        }
        else if (mmc.menuState == MainMenuController.MenuState.Options)
        {
            mmc.menuIsInTransition();

            StartCoroutine
            (
                mmc.thisGO.animation.PlayWithOptions("OptionsBack",
                                                     () => { mmc.applyOffset(); },
                                                     () => { mmc.playMenuStart(); }
                                                     )
            );
        }
        else if (mmc.menuState == MainMenuController.MenuState.Character)
        {
            mmc.menuIsInTransition();

            StartCoroutine
            (
                mmc.thisGO.animation.PlayWithOptions("EnemySelBack",
                                                     () => { mmc.applyOffset(); },
                                                     () => { mmc.playMenuStart(); }
                                                     )
            );

            if (onOptionsBack != null)
            {
                onOptionsBack();
            }
        }
        else if (mmc.menuState == MainMenuController.MenuState.Store)
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("On Store Enter");
            }

            mmc.menuIsInTransition();

            StartCoroutine
            (
                mmc.thisGO.animation.PlayWithOptions("SuppliesBack",
                                                     () => { mmc.applyOffset(); },
                                                     () => { mmc.playMenuStart(); }
                                                     )
            );
        }
    }
Exemplo n.º 7
0
    // Method for when hit by Enemy bullet or projectile
    private void hitByEnemy(EnemyStats stats)
    {
        //Debug.Log("Player: OUCH, I GOT HIT");

        iTween.ShakePosition(gameObject, iTween.Hash(
                                 "amount", new Vector3(0.4f, 0.4f, 0.4f),
                                 "time", 0.5f,
                                 "oncompletetarget", gameObject,
                                 "oncomplete", "resetPos"
                                 ));

        DBAccess.instance.userPrefs.health -= stats.damage;

        audioSources[Random.Range(3, 5)].Play();

        if (DBAccess.instance.userPrefs.health > 0)
        {
            if (onHitByEnemy != null)
            {
                onHitByEnemy(DBAccess.instance.userPrefs.health);
            }
        }
        else
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("Player Loss");
            }

            if (onHitByEnemy != null)
            {
                onHitByEnemy(DBAccess.instance.userPrefs.health);
            }

            GameState = _GameState.Dead;

            cameraAnimNode.animation.Play("CameraDeath");

            // Death Sound
            audioSources[7].Play();

            // Stop Heartbeat
            audioSources[9].Stop();

            // Fade Music
            if (audioSources[10].isPlaying)
            {
                iTween.AudioTo(gameObject, iTween.Hash(
                                   "audiosource", audioSources[10],
                                   "volume", 0f,
                                   "time", 1f,
                                   "easetype", iTween.EaseType.linear
                                   )
                               );
            }

            if (audioSources[11].isPlaying)
            {
                iTween.AudioTo(gameObject, iTween.Hash(
                                   "audiosource", audioSources[11],
                                   "volume", 0,
                                   "time", 1f,
                                   "easetype", iTween.EaseType.linear
                                   )
                               );
            }

            GameObject.Find("Crosshair").GetComponent <UISprite>().enabled = false;

            StartCoroutine(deathRoutine());

            onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, stats);
        }

        int randRange = Random.Range(0, 101);

        if (randRange < 33)
        {
            splatCam.onHitByRayCast();
        }
    }
Exemplo n.º 8
0
    void Update()
    {
        if (isCalibrating)
        {
            if (Input.GetMouseButtonUp(0))
            {
                Ray        ray = UICam2D.camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 100f))
                {
                    if (hit.collider.name == "WindowBG(Calibrate)")
                    {
                        hit.collider.SendMessage("onHitByRayCast", this, SendMessageOptions.DontRequireReceiver);
                        CalibrateAccelerometer();
                    }
                }
            }
        }
        if (!isCalibrating)
        {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
            if (GameState != _GameState.Dead && GameState != _GameState.Results && GameState != _GameState.None && GameState != _GameState.Paused)
            {
                if (axes == RotationAxes.MouseXAndY)
                {
                    // Read the mouse input axis
                    rotationX += Input.GetAxis("Mouse X") * sensitivityX;
                    rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

                    rotationX = ClampAngle(rotationX, ROTATION_MIN_Y, ROTATION_MAX_Y);
                    rotationY = ClampAngle(rotationY, ROTATION_MIN_X, ROTATION_MAX_X);

                    Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
                    Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, -Vector3.right);

                    transform.localRotation = originalRotation * xQuaternion * yQuaternion;
                }
                else if (axes == RotationAxes.MouseX)
                {
                    rotationX += Input.GetAxis("Mouse X") * sensitivityX;
                    rotationX  = ClampAngle(rotationX, ROTATION_MIN_Y, ROTATION_MAX_Y);

                    Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
                    transform.localRotation = originalRotation * xQuaternion;
                }
                else
                {
                    rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                    rotationY  = ClampAngle(rotationY, ROTATION_MIN_X, ROTATION_MAX_X);

                    Quaternion yQuaternion = Quaternion.AngleAxis(-rotationY, Vector3.right);
                    transform.localRotation = originalRotation * yQuaternion;
                }
                if (rotationY < -25f && GameState != _GameState.Reload && GameState != _GameState.IsReloading)
                {
                    GameState = _GameState.Reload;

                    lastAmmoHit = null;

                    if (onUIUpdate != null)
                    {
                        onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, null);
                    }

                    gunModel.animation.Stop();
                    gunModel.animation.Play("ReloadStart");
                }
                if (rotationY > -25f && (GameState == _GameState.Reload || GameState == _GameState.IsReloading))
                {
                    if (!DBAccess.instance.userPrefs.userGun.isReloading)
                    {
                        GameState = _GameState.Active;

                        if (onUIUpdate != null)
                        {
                            onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, null);
                        }

                        if (lastAmmoHit == null)
                        {
                            gunModel.animation.Play("ReloadEnd");
                        }
                        else if (lastAmmoHit != null && lastAmmoHit.name != "ActiveAmmo")
                        {
                            gunModel.animation.Play("ReloadEnd");
                        }
                    }
                    else
                    {
                        if (onUIUpdate != null)
                        {
                            onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, null);
                        }
                    }
                }
            }
#elif UNITY_IPHONE || UNITY_ANDROID
            if (GameState != _GameState.Dead && GameState != _GameState.Results && GameState != _GameState.None && GameState != _GameState.Paused)
            {
                if (axes == RotationAxes.MouseXAndY)
                {
                    // Store movement into temporary Vector3 to be applied to transform
                    localRotation.y -= Input.acceleration.y * speed;
                    localRotation.x += FixAcceleration(Input.acceleration).x *speed;

                    // Clamp rotation within set field of view
                    localRotation.y = ClampAngle(localRotation.y, ROTATION_MIN_Y, ROTATION_MAX_Y);
                    localRotation.x = ClampAngle(localRotation.x, ROTATION_MIN_X, ROTATION_MAX_X);

                    //Debug.Log( "Y : " + localRotation.y );
                    //Debug.Log( "X : " + localRotation.x );

                    // Apply new cached rotation to transform rotation
                    transform.localEulerAngles = localRotation;
                }
                else if (axes == RotationAxes.MouseX)
                {
                    localRotation.y -= Input.acceleration.y * speed;
                    localRotation.y  = ClampAngle(localRotation.y, ROTATION_MIN_Y, ROTATION_MAX_Y);

                    transform.localEulerAngles = localRotation;
                }
                else if (axes == RotationAxes.MouseY)
                {
                    localRotation.x += FixAcceleration(Input.acceleration).x *speed;
                    localRotation.x  = ClampAngle(localRotation.x, ROTATION_MIN_X, ROTATION_MAX_X);

                    transform.localEulerAngles = localRotation;
                }
                if (localRotation.x > 25f && GameState != _GameState.Reload && GameState != _GameState.IsReloading)
                {
                    GameState = _GameState.Reload;

                    lastAmmoHit = null;

                    if (onUIUpdate != null)
                    {
                        onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, null);
                    }

                    gunModel.animation.Play("ReloadStart");
                }
                if (localRotation.x < 25f && (GameState == _GameState.Reload || GameState == _GameState.IsReloading))
                {
                    if (!DBAccess.instance.userPrefs.userGun.isReloading)
                    {
                        GameState = _GameState.Active;

                        if (onUIUpdate != null)
                        {
                            onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, null);
                        }

                        if (lastAmmoHit == null)
                        {
                            gunModel.animation.Play("ReloadEnd");
                        }
                        else if (lastAmmoHit != null && lastAmmoHit.name != "ActiveAmmo")
                        {
                            gunModel.animation.Play("ReloadEnd");
                        }
                    }
                    else
                    {
                        if (onUIUpdate != null)
                        {
                            onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, null);
                        }
                    }
                }
            }
#endif
            if (Input.GetMouseButtonUp(0))
            {
                if (GameState == _GameState.Active || GameState == _GameState.Paused)
                {
                    // If user hits ammo sprite, reload instead of shooting
                    Ray        ray = UICam.camera.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;

                    if (Physics.Raycast(ray, out hit, 100f, UIMask3D))
                    {
                        onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, hit.collider.gameObject, null);
                        lastAmmoHit = hit.collider.gameObject;
                    }
                    else if (DBAccess.instance.userPrefs.userGun.capacity > 0 && GameState == _GameState.Active)
                    {
                        // If not in reload or pause, shoot gun.  Gun will take care of bullets remaining logic.
                        if (DBAccess.instance.userPrefs.userGun.model == "Winchester_1912")
                        {
                            DBAccess.instance.userPrefs.userGun.ShootShotgun(transform, capsulCastMask, gunModel);
                        }
                        else
                        {
                            DBAccess.instance.userPrefs.userGun.Shoot(transform, rayCastmask, gunModel);
                        }

                        onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, null, null);

                        BroadcastMessage("applyRecoil");

                        if (DBAccess.instance.userPrefs.userGun.gunID == 1)
                        {
                            audioSources[0].Play();
                        }
                        if (DBAccess.instance.userPrefs.userGun.gunID == 2)
                        {
                            audioSources[1].Play();
                        }
                        if (DBAccess.instance.userPrefs.userGun.gunID == 3)
                        {
                            audioSources[2].Play();
                        }
                    }
                    else if (GameState == _GameState.Active)
                    {
                        audioSources[6].Play();
                    }
                }
                if (GameState == _GameState.Reload || GameState == _GameState.Results || GameState == _GameState.Dead || GameState == _GameState.None)
                {
                    if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        ChartBoostBinding.trackEvent("Secondary Reload Screen Use");
                    }

                    Ray        ray = UICam.camera.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;

                    if (Physics.Raycast(ray, out hit, 100f, UIMask3D))
                    {
                        onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, hit.collider.gameObject, null);
                        lastAmmoHit = hit.collider.gameObject;
                    }
                }
                if (GameState == _GameState.Dead || GameState == _GameState.Results)
                {
                    Ray        ray = UICam2D.camera.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;

                    if (Physics.Raycast(ray, out hit, 100f))
                    {
                        onUIUpdate(DBAccess.instance.userPrefs.userGun, GameState, hit.collider.gameObject, null);
                    }
                }
            }
        }
    }
Exemplo n.º 9
0
    void onUIUpdate(Gun gun, PlayerController._GameState state, GameObject clicked, EnemyStats stats)
    {
        if (clicked == gameObject && !gun.isReloading && state != PlayerController._GameState.None)
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                ChartBoostBinding.trackEvent("Secondary Ammo Reload Use");
            }

            switch (name)
            {
            case "Ammo_L0":
                gun.Reload(gun.compatibleAmmo[0]);
                tweenScale();
                break;

            case "Ammo_L1":
                if (gun.compatibleAmmo[1].amountOwned > 0)
                {
                    gun.Reload(gun.compatibleAmmo[1]);
                }
                else
                {
                    thisSprite.collider.enabled = false;
                    thisSprite.alpha            = 0.5f;
                }
                tweenScale();
                break;

            case "Ammo_L2":
                if (gun.compatibleAmmo[2].amountOwned > 0)
                {
                    gun.Reload(gun.compatibleAmmo[2]);
                }
                else
                {
                    thisSprite.collider.enabled = false;
                    thisSprite.alpha            = 0.5f;
                }
                tweenScale();
                break;

            case "Ammo_L3":
                if (gun.compatibleAmmo[3].amountOwned > 0)
                {
                    gun.Reload(gun.compatibleAmmo[3]);
                }
                else
                {
                    thisSprite.collider.enabled = false;
                    thisSprite.alpha            = 0.5f;
                }
                tweenScale();
                break;

            default:
                switch (thisSprite.spriteName)
                {
                case "Ammo_L0":
                    gun.Reload(gun.compatibleAmmo[0]);
                    tweenScale();
                    break;

                case "Ammo_L1":
                    if (gun.compatibleAmmo[1].amountOwned > 0)
                    {
                        gun.Reload(gun.compatibleAmmo[1]);
                    }
                    else
                    {
                        thisSprite.collider.enabled = false;
                        thisSprite.alpha            = 0.5f;
                    }
                    tweenScale();
                    break;

                case "Ammo_L2":
                    if (gun.compatibleAmmo[2].amountOwned > 0)
                    {
                        gun.Reload(gun.compatibleAmmo[2]);
                    }
                    else
                    {
                        thisSprite.collider.enabled = false;
                        thisSprite.alpha            = 0.5f;
                    }
                    tweenScale();
                    break;

                case "Ammo_L3":
                    if (gun.compatibleAmmo[3].amountOwned > 0)
                    {
                        gun.Reload(gun.compatibleAmmo[3]);
                    }
                    else
                    {
                        thisSprite.collider.enabled = false;
                        thisSprite.alpha            = 0.5f;
                    }
                    tweenScale();
                    break;
                }
                break;
            }
        }
    }
Exemplo n.º 10
0
    void hitByRayCast(GameObject hit)
    {
        //Debug.Log("hitByRayCast");

        if (hit.layer == gameObject.layer)
        {
            StartCoroutine(damagedAnim());

            if (Application.loadedLevel == 2)
            {
                stats.health -= DBAccess.instance.userPrefs.userGun.modifiedPower;
            }

            if (stats.health > 0)
            {
                if (onEnemyStatsChange != null)
                {
                    onEnemyStatsChange(stats, EnemyState);
                }
            }
            else
            {
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    ChartBoostBinding.trackEvent("Player Win");
                }

                EnemyState = _EnemyState.Dead;

                StopAllCoroutines();

                mat.color = Color.white;

                iTween.Stop(gameObject);
                iTween.Stop(enemyActual);

                enemyActual.animation.Stop();
                enemyActual.animation.Play("Character_Death");

                if (onEnemyStatsChange != null)
                {
                    onEnemyStatsChange(stats, EnemyState);
                }

                GameObject.Find("Crosshair").GetComponent <UISprite>().enabled = false;
            }

            // If in Tutorial Level
            if (Application.loadedLevel == 1)
            {
                // Reset state of tutorial to progress forward
                Tutorial t = GameObject.Find("Player").GetComponent <Tutorial>();

                if (hitCount < 4 && (int)t.TutorialState < (int)Tutorial._TutorialState.MissionFour)
                {
                    hitCount++;
                }
                else if (t.TutorialState == Tutorial._TutorialState.MissionFour)
                {
                    hitCount++;

                    stats.health -= 10;

                    if (stats.health > 0)
                    {
                        if (onEnemyStatsChange != null)
                        {
                            onEnemyStatsChange(stats, EnemyState);
                        }
                    }
                    else
                    {
                        EnemyState = _EnemyState.Dead;

                        StopAllCoroutines();

                        mat.color = Color.white;

                        iTween.Stop(gameObject);
                        iTween.Stop(enemyActual);

                        enemyActual.animation.Stop();
                        enemyActual.animation.Play("Character_Death");

                        TutorialGrid tg = GameObject.FindObjectOfType(typeof(TutorialGrid)) as TutorialGrid;
                        tg.moveGrid(Tutorial._TutorialState.None);

                        if (onEnemyStatsChange != null)
                        {
                            onEnemyStatsChange(stats, EnemyState);
                        }
                    }
                }
                else
                {
                    // Reset hitCount for reuse through tutorial
                    hitCount = 0;

                    t.axes = Tutorial.RotationAxes.None;
                    t.grid.moveGrid(Tutorial._TutorialState.None);

                    // Stop AI pathing
                    GetComponent <AStarEnemy>().StopAllCoroutines();
                }
            }
        }
    }
Exemplo n.º 11
0
    void OnGUI()
    {
        float yPos       = 5.0f;
        float xPos       = 5.0f;
        float width      = (Screen.width >= 960 || Screen.height >= 960) ? 320 : 160;
        float height     = (Screen.width >= 960 || Screen.height >= 960) ? 80 : 40;
        float heightPlus = height + 10.0f;


        if (GUI.Button(new Rect(xPos, yPos, width, height), "Init"))
        {
            ChartBoostBinding.init("YOUR_APP_ID", "YOUR_APP_SIGNATURE");
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Cache Interstitial"))
        {
            ChartBoostBinding.cacheInterstitial("default");
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Is Interstitial Cached?"))
        {
            Debug.Log("is cached: " + ChartBoostBinding.hasCachedInterstitial("default"));
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Show Interstitial"))
        {
            ChartBoostBinding.showInterstitial("default");
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Cache More Apps"))
        {
            ChartBoostBinding.cacheMoreApps();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Show More Apps"))
        {
            ChartBoostBinding.showMoreApps();
        }


        xPos = Screen.width - width - 5.0f;
        yPos = 5.0f;

        if (GUI.Button(new Rect(xPos, yPos, width, height), "Track Event"))
        {
            ChartBoostBinding.trackEvent("some_event");
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Track Event with Metadata"))
        {
            var dict = new Dictionary <string, string>();
            dict.Add("key", "theValue");
            ChartBoostBinding.trackEventWithMetadata("some_event_with_data", dict);
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Track Event with Value"))
        {
            ChartBoostBinding.trackEventWithValue("event_with_value", 123);
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Track Event with Value and Metadata"))
        {
            var dict = new Dictionary <string, string>();
            dict.Add("key", "theValue");
            ChartBoostBinding.trackEventWithValueAndMetadata("event_with_value_and_data", 9809823, dict);
        }
    }