Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        var q = HSRandom.Next(10);

        if (q == 0)
        {
            on = !on;
            if (on)
            {
                a.Play(0);
            }
            else
            {
                a.Stop();
            }
        }

        if (on)
        {
            GetComponent <Light>().intensity = 7;
        }
        else
        {
            GetComponent <Light>().intensity = 0;
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        speed = player.GetComponent <PlayerBread>().HowManyBreadsHaveYouEatenInYourLife;
        if (!isActive)
        {
            if (player.GetComponent <PlayerBread>().HowManyBreadsHaveYouEatenInYourLife > 0)
            {
                isActive = true;
            }
        }
        if (isActive)
        {
            if (!isDone)
            {
                // Move our position a step closer to the target.
                float step = speed * Time.deltaTime;  // calculate distance to move
                transform.position = Vector3.MoveTowards(transform.position, player.transform.position, step);

                // Make birb look at the player
                transform.LookAt(player.transform);
            }

            // Layer for the line cast
            int layermask = 1 << 8;
            layermask = ~layermask;

            // Check dist between birb and player
            var dist = Vector3.Distance(transform.position, player.transform.position);

            // Draw the sightline debug
            Debug.DrawLine(transform.position, player.transform.position, Color.red, 0.0f);

            // Teleport the birb if conditions are met
            if (dist > 15f && Physics.Linecast(transform.position, player.transform.position, layermask))
            {
                int q = HSRandom.Next(10);
                if (q == 0)
                {
                    transform.position = player.transform.position + (player.transform.forward * 7f);
                }
                else
                {
                    transform.position = player.transform.position - (player.transform.forward * 7);
                }
                teleportSound.Play(0);
            }

            if (dist < 7)
            {
                this.GetComponentInChildren <Animator>().runtimeAnimatorController = animEat as RuntimeAnimatorController;
            }
            else
            {
                this.GetComponentInChildren <Animator>().runtimeAnimatorController = animWalk as RuntimeAnimatorController;
            }
        }
    }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     for (int j = 0; j < 7; j++)
     {
         int i = HSRandom.Next(20 - j);
         var c = transform.GetChild(i);
         Instantiate(p, c.position, c.rotation);
         Destroy(c.gameObject);
     }
 }
Ejemplo n.º 4
0
    /// <summary>
    /// Shuffles the Deck of Cards
    /// </summary>
    public void Shuffle()
    {
        List <Card> tempDeck = new List <Card>(deck);

        deck.Clear();

        while (tempDeck.Count > 0)
        {
            int card = HSRandom.Next(tempDeck.Count);
            deck.Add(tempDeck[card]);
            tempDeck.RemoveAt(card);
        }
        return;
    }