Esempio n. 1
0
    public bool Speak()
    {
        if (isFirstTime && timer <= 0)
        {
            textPopper.MakePopup(textPosition.transform.position.x + pos.x, textPosition.transform.position.y + pos.y, oneTimer);
            timer       = cooldown;
            isFirstTime = false;
            if (givesObj)
            {
                GameObject.FindObjectOfType <PlayerController>().objectives += 1;
            }
            return(true);
        }
        else if (timer <= 0)
        {
            //check win condidition
            PlayerController pc = GameObject.FindObjectOfType <PlayerController>();
            if (pc.objectives >= 3)
            {
                pc.showEnd();
            }

            //get random index
            int index = Random.Range(0, unusedRepeats.Length);
            //poppit
            textPopper.MakePopup(textPosition.transform.position.x + pos.x, textPosition.transform.position.y + pos.y, unusedRepeats[index].array);
            timer = cooldown;

            //remove from unused
            if (unusedRepeats.Length > 1)
            {
                ArrayWrapper[] temp      = new ArrayWrapper[unusedRepeats.Length - 1]; //shorten by 1
                int            tempIndex = 0;                                          // separate index for new array;
                for (int i = 0; i < unusedRepeats.Length; ++i)
                {
                    if (index != i)                         //not the used index
                    {
                        temp[tempIndex] = unusedRepeats[i]; //copy in
                        ++tempIndex;                        //increment external index
                    }
                    //else it's the used one so ignore.
                }
                //temp set up, set it to unused array
                unusedRepeats = temp;
            }
            else //<=1 so restart
            {
                unusedRepeats = randomRepeats;
            }

            return(true);
        }
        return(false);
    }
Esempio n. 2
0
    void HandleInteract()
    {
        if (isInteracting && !justInteracted)
        {
            bool         success = false;
            bool         silence = false;
            Collider2D[] hits    = Physics2D.OverlapCircleAll(transform.position, interactionRadius, LayerMask.GetMask("Interactables"));
            foreach (Collider2D collider in hits)
            {
                DoorSwitchBehavior dsb = collider.GetComponent <DoorSwitchBehavior>();
                if (dsb != null)
                {
                    success = dsb.ToggleSwitch();
                }
                SpeakerBehavior sb = collider.GetComponent <SpeakerBehavior>();
                if (sb != null)
                {
                    success = sb.Speak();
                    silence = true;
                }
            }

            if (!silence)
            {
                if (!success)
                {
                    textPopper.MakePopup(transform.position.x, transform.position.y + .5f, new string[] { "huh?" }, gameObject);
                }
                else
                {
                    textPopper.MakePopup(transform.position.x, transform.position.y + .5f, new string[] { "yus", "diddit" }, gameObject);
                }
            }
            else
            {
                if (!success) //failure talking to someone
                {
                    textPopper.MakePopup(transform.position.x, transform.position.y + .5f, new string[] { "..." }, gameObject);
                }
            }

            if (success)
            {
                audioMan.playSFX("good", transform.position);
            }

            //don't double up.
            justInteracted = true;
        }
        else if (!isInteracting && justInteracted)
        {
            justInteracted = false;
        }
    }
Esempio n. 3
0
	// Update is called once per frame
	void Update () {
		if(started)
        {
            timer -= Time.deltaTime;

            if(timer <= 0)
            {
                if (transform.parent != null)
                {
                    popper.MakePopup(transform.position.x, transform.position.y, nextStrings, transform.parent.gameObject);
                }
                else
                {
                    popper.MakePopup(transform.position.x, transform.position.y, nextStrings, null);
                }
                GameObject.Destroy(gameObject);
            }
        }
	}