// Use this for initialization
    void Start()
    {
        scoreCounter = GameObject.Find("subScoreCounter").GetComponent <scoreCounter>();
        PlayerPrefs.SetInt("boost3timesAch", 0);
        boostLane          = GameObject.Find("BoostLane");
        btnShield          = GameObject.Find("btnShield").GetComponent <Button>();
        btnAttack          = GameObject.Find("btnAttack").GetComponent <Button>();
        btnBoost           = GameObject.Find("btnBoost").GetComponent <Button>();
        btnPause           = GameObject.Find("Pause");
        maincam            = GameObject.Find("Main Camera");
        swipeScript        = maincam.gameObject.GetComponent <SwipeMovement>();
        boostPropScript    = GameObject.FindGameObjectWithTag("Player").GetComponent <boostProp>();
        cDownAttack        = GameObject.Find("cooldownAttack").GetComponent <cooldownAttack>();
        cDownShield        = GameObject.Find("cooldownShield").GetComponent <cooldownShield>();
        pauseScript        = GameObject.Find("onPause").GetComponent <pauseScale>();
        achPowerTripScript = GameObject.Find("btnBoost").GetComponent <achPowerTripper>();

        if (PlayerPrefs.HasKey("boostSkillLvl"))
        {
            boostSkillLvl = PlayerPrefs.GetInt("boostSkillLvl");
        }
        else
        {
            boostSkillLvl = 0;
        }

        if (boostbarSlider.value <= 0f && boostSkillLvl >= 1)
        {
            if (!isRunning)
            {
                regenBoost();
            }
        }

        coroutine = WaitAndUpdate(1.0f);
        StartCoroutine(coroutine);
    }
Esempio n. 2
0
    void FixedUpdate()
    {
        character = GameObject.FindGameObjectWithTag("character");
        anim      = character.GetComponent <Animation>();
        protag    = GameObject.FindGameObjectWithTag("Player");


        if (character.name == "Ruth2")
        {
            GameObject tornadoSide  = GameObject.Find("bag tornado side moveLeft");
            GameObject tornadoSide2 = GameObject.Find("bag tornado side moveRight");
            tornadoSpriteLeft  = tornadoSide.GetComponent <SpriteRenderer>();
            tornadoSpriteRight = tornadoSide2.GetComponent <SpriteRenderer>();
        }
        else if (character.name == "Char")
        {
            PropScript         = protag.GetComponent <boostProp>();
            garySwipeLeftProp  = PropScript.swipeLeftProp;
            garySwipeRightProp = PropScript.swipeRightProp;
        }
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
        {
            // Get movement of the finger since last frame

            Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;

            // Move object across XY plane

            if (touchDeltaPosition.x > 1 && swipeCap >= 1 && Time.timeScale == 1f && protag.GetComponent <Rigidbody>().velocity == Vector3.zero)
            {
                if (character.name == "Ruth2")
                {
                    anim["shopper_moveright_anim"].speed = 2.0f;
                }
                //SwipeRight
                if (currentLane == "Lane2" && garySwiped == false)
                {
                    targetPosition = target3.transform.position;
                    playSwipeRightAnimations();
                }
                else if (currentLane == "Lane1" && garySwiped == false)
                {
                    targetPosition = target2.transform.position;
                    playSwipeRightAnimations();
                }
            }
            else if (touchDeltaPosition.x < -1 && swipeCap >= 1 && Time.timeScale == 1f && protag.GetComponent <Rigidbody>().velocity == Vector3.zero)
            {
                if (character.name == "Ruth2")
                {
                    anim["shopper_moveleft_anim"].speed = 2.0f;
                }
                //SwipeLeft
                if (currentLane == "Lane2" && garySwiped == false)
                {
                    targetPosition = target1.transform.position;
                    playSwipeLeftAnimations();
                }
                else if (currentLane == "Lane3" && garySwiped == false)
                {
                    targetPosition = target2.transform.position;
                    playSwipeLeftAnimations();
                }
            }
            else
            {
                AudioSource insufficientSwipe = GameObject.Find("sfxInsufficientSwipe").GetComponent <AudioSource>();
                insufficientSwipe.Play();
            }
            if (character.name == "Ruth2")
            {
                Invoke("disableTornadoSprite", 0.5f);
            }
        }

        if (isGameOver == false)
        {
            MovePlayer();
        }
    }