Exemplo n.º 1
0
    public void Play()
    {
        curIndex = Random.Range(0, clips.Length);
        src.clip = clips[curIndex];
        src.Play();

        if (fadeTimer != null)
        {
            fadeTimer.Set();
        }
    }
Exemplo n.º 2
0
    protected override void StateEnter_Voting()
    {
        voteExpiration.Set();
        timerStart  = TimeMilliseconds();
        timerLength = (int)(voteExpiration.expiration * 1000);

        connectedPlayers[curJudge].iconObject.Express();
        shockSound.Play();

        foreach (var c in connectedPlayers)
        {
            if (c.receivedInsult != null && c.receivedInsult.Length > 0)
            {
                var t  = Instantiate(insultViewPrefab).GetComponent <RectTransform>();
                var t2 = t.GetComponentInChildren <Text>();
                t2.text = c.receivedInsult;

                if (t2.text.Length > 300)
                {
                    t2.text = t2.text.Substring(0, 300) + "...";
                }

                InsultStacc.inst.Push(t);
                c.insultViewObject = t.gameObject;
            }
        }
    }
Exemplo n.º 3
0
 void FixedUpdate()
 {
     if (Random.value < threshold)
     {
         flickerExpiration.Set();
     }
 }
Exemplo n.º 4
0
 public void Reload()
 {
     if (remainingShots < clipSize)
     {
         remainingShots = clipSize;
         reload.Set();
     }
 }
Exemplo n.º 5
0
    // Update is called once per frame
    public override void TakeInput()
    {
        //Will is the direction your input WANTS you to go
        Vector3 will = channels.movement2;

        will = Vector3.ClampMagnitude(will, 1);

        //The angle between the will and the direction of the vehicle
        float inputDisparityAngle = Vector3.Cross(Quaternion.Euler(0, 0, 0) * will, aestheticTarget.forward).y;

        //The desired rotation in 2D
        Quaternion targetTilt     = aestheticTarget.rotation;
        Quaternion targetRotation = (will.magnitude > 0.01f) ? Quaternion.LookRotation(will, Vector3.up) : transform.rotation;

        //X rotation determines wheelieing, pretty much
        float newX = (Input.GetButton("Fire2")) ? -45f * (motor.velocity.magnitude / motor.walkSpeed) : 0;

        //The desired rotation, now accounting for wheelies and tilt
        targetTilt = Quaternion.Euler(newX, 0, (will.magnitude > 0 ? maxTilt * inputDisparityAngle : 0));

        float f = turnSpeed;

        if (Input.GetButton("Fire2"))
        {
            f *= 2;
        }

        if (channels.dash && dashTimer.Use())
        {
            dashInvulnTimer.Set();
            dashExpTimer.Set();
            dashing    = true;
            preDashVel = motor.velocity;
            src.Play();
        }

        if (!dashExpTimer.expired)
        {
            motor.velocity = aestheticTarget.forward * dashDist / dashDuration;
        }
        else if (dashing)
        {
            dashing        = false;
            motor.velocity = preDashVel;
        }


        hitbox.enabled = dashInvulnTimer.expired;

        //Apply the rotation to the aesthetic target
        transform.rotation            = Quaternion.RotateTowards(transform.rotation, targetRotation, f * Time.deltaTime);
        aestheticTarget.localRotation = Quaternion.RotateTowards(aestheticTarget.localRotation, targetTilt, f * Time.deltaTime);

        //Move forwards, always, but the previous code can change the rotation
        channels.movement += transform.forward * will.magnitude;
    }
Exemplo n.º 6
0
    public void SetDamaging(float duration)
    {
        if (curAttack == "Spin")
        {
            Util.PlayClipAtPoint(attackSound, transform.position, 1, 0, false, transform);
        }

        damageTimer.expiration = duration;
        damageTimer.Set();
    }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (changeTimer.expired)
        {
            changeTimer.Set();

            text.text = lines[lineNum];
            lineNum   = (lineNum + 1) % lines.Count;
        }
    }
Exemplo n.º 8
0
    public override void Fire(Vector3 direction, bool align = true)
    {
        base.Fire(direction, align);

        this.direction = direction;
        this.align     = align;

        delayTimer = new ExpirationTimer(delay);
        delayTimer.Set();

        targetPoint = transform.position + direction;
    }
Exemplo n.º 9
0
        public static Game CreateGame()
        {
            string          code  = GetRoomCode();
            ExpirationTimer timer = new ExpirationTimer(serverExpiration);

            timer.Set();
            GameManager manager = new GameManager();
            int         id      = GetId();

            games[code] = Tuple.Create(code, id, timer, manager);
            return(games[code]);
        }
Exemplo n.º 10
0
 public void SetLeaping(int isLeaping)
 {
     if (isLeaping == 1)
     {
         leapTimer.Set();
         Util.PlayClipAtPoint(attackSound, transform.position, 1, 0, false, transform);
     }
     else
     {
         motor.velocity = Vector3.zero;
     }
     this.isLeaping = isLeaping == 1;
 }
Exemplo n.º 11
0
    protected override void StateEnter_PostGame()
    {
        endExpiration.Set();
        timerStart  = TimeMilliseconds();
        timerLength = (int)(endExpiration.expiration * 1000);

        if (winner != null)
        {
            winner.iconObject.Win();
            winSound.Play();

            if (winner.insultViewObject != null)
            {
                winner.insultViewObject.GetComponent <Image>().color = Color.green;
            }
        }
    }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        if (activateFlap.Use)
        {
            deactivateFlap.Set();
        }


        if (!lr.enabled && (!deactivateFlap.Expired || draggable.held || !GetComponent <PenguinStand>().grounded))
        {
            wingLeft.localEulerAngles  = new Vector3(Mathf.Sin(Time.time * timescale) * 20 - 20, -90, 90);
            wingRight.localEulerAngles = new Vector3(-Mathf.Sin(Time.time * timescale) * 20 + 20, -90, -90);
        }
        else
        {
            wingLeft.localEulerAngles  = new Vector3(0, -90, 90);
            wingRight.localEulerAngles = new Vector3(0, -90, -90);
        }
    }
Exemplo n.º 13
0
        protected override void StateEnter_Insulting()
        {
            foreach (var c in connectedPlayers)
            {
                c.receivedInsult = null;
            }

            winner = null;
            insultExpiration.Set();
            timerStart  = Time.rawMillis;
            timerLength = (int)(insultExpiration.expiration * 1000);

            if (connectedPlayers.Count > 0)
            {
                curJudge = (curJudge + 1) % connectedPlayers.Count;
            }
            else
            {
                curJudge = 0;
            }
        }
Exemplo n.º 14
0
    public override void TakeInput()
    {
        LineRenderer   beam   = GetComponentInChildren <LineRenderer> ();
        SpriteRenderer sprite = GetComponent <SpriteRenderer> ();

        if (channels.attack && shootCooldownTimer.Use())
        {
            shootDurTimer.Set();
        }

        if (!shootDurTimer.expired)
        {
            RaycastHit2D obj  = Physics2D.Raycast(transform.position, sprite.flipX ? new Vector2(-1, 0) : new Vector2(1, 0));
            float        True = 9999.9f;
            if (obj)
            {
                True = obj.distance;
                var health = obj.collider.GetComponent <Health>();

                if (health)
                {
                    health.ApplyDamage(new Damage(dps * Time.deltaTime, obj.point, obj.normal));
                }
            }

            if (sprite.flipX)
            {
                beam.SetPosition(1, new Vector3(-True, 0, 0));
            }
            else
            {
                beam.SetPosition(1, new Vector3(True, 0, 0));
            }
        }
        else
        {
            beam.SetPosition(1, new Vector3(1, 0, 0));
        }
    }
Exemplo n.º 15
0
    void DamageNotify(Damage dmg)
    {
        flashTimer.Set();

        if (dmg.amount < 100)
        {
            damageSound.Play();

            penaltyTimer.Set();
            damaged = true;

            startPos  = flippydoo.localPosition;
            startRot  = flippydoo.localRotation;
            rotAxis   = Random.insideUnitCircle.normalized;
            rotAxis.z = rotAxis.y;
            rotAxis.y = 0;

            foreach (var mot in affectedMotors)
            {
                mot.enableInput = false;
            }
        }
    }
Exemplo n.º 16
0
        public bool Use()
        {
            if (reloading && reloadTimer.expired)
            {
                remaining = capacity;
            }

            if (remaining > 0)
            {
                remaining--;

                if (remaining == 0)
                {
                    reloading = true;
                    reloadTimer.Set();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 17
0
 public void Express()
 {
     expressionExpiration.Set();
 }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     timer = new ExpirationTimer(splitTime);
     timer.Set();
 }
 private void OnEnable()
 {
     timer = new ExpirationTimer(time);
     timer.Set();
     select.Select();
 }
Exemplo n.º 20
0
 public void SetFiring(float duration)
 {
     shootTimer.expiration = duration;
     shootTimer.Set();
 }
Exemplo n.º 21
0
 protected override void StateEnter_PostGame()
 {
     endExpiration.Set();
     timerStart  = Time.rawMillis;
     timerLength = (int)(endExpiration.expiration * 1000);
 }
Exemplo n.º 22
0
 protected override void StateEnter_Voting()
 {
     voteExpiration.Set();
     timerStart  = Time.rawMillis;
     timerLength = (int)(voteExpiration.expiration * 1000);
 }