Example #1
0
    void Awake()
    {
        // check for duplicate singleton
        if (me && me != this)
        {
            Debug.LogWarning("duplicate Domination");
            enabled = false;
            return;
        }
        me = this;

        // get bar normal sizes/colors
        barSize = new Vector2[barIm.Length];
        barCol  = new Color[barIm.Length];
        for (int i = 0; i < barTr.Length; i++)
        {
            barSize[i]         = barTr[i].sizeDelta;
            barTr[i].sizeDelta = new Vector2(0, barSize[i].y);
            barCol[i]          = barIm[i].color;
        }
    }
Example #2
0
    /// <summary>
    /// trigger match begin (used by button)
    /// </summary>
    public void MatchBegin()
    {
        playing = true;

        // enable/disable objects
        foreach (var go in ingameObjects)
        {
            MenuSetActive(go, true);
        }
        foreach (var go in menuObjects)
        {
            MenuSetActive(go, false);
        }
        playerObject.SetActive(true);

        // start music
        Options.me.music.volume = Options.musicVol;
        if (Options.me.music.volume > 0 && !Options.me.music.isPlaying)
        {
            Options.me.music.Play();
        }
        // reset point-related stuff
        Domination.ResetMe();
        Multipliers.ResetMe();

        // trigger respawn of all existing bots
        foreach (var ss in SSTeam.list)
        {
            var   death = ss.GetComponent <SSDeathAndSpawn>();
            float v     = Random.value;
            if (ss.GetComponent <SSControlPlayer>())
            {
                v = .75f + .25f * v;
            }
            death.Die(true, v);
        }
    }
Example #3
0
    /// <summary>
    /// Die/reset this spaceship.
    /// </summary>
    /// <param name="asReset">whether this was a reset (no explosion, no points)</param>
    /// <param name="delayMultiplier">factor to multiply respawn delay with</param>
    public void Die(bool asReset = false, float delayMultiplier = 1f)
    {
        if (!gameObject.activeSelf)
        {
            // cancel previous respawn timer
            CancelInvoke();
            // respawn after given time
            if (delayMultiplier <= 0)
            {
                BeginSpawn();
            }
            else
            {
                Invoke(nameof(BeginSpawn), respawnDelay * delayMultiplier);
            }
            return;
        }

        // reset health
        health = StartHealth;

        if (!asReset)
        {
            // explode and add points and multiplier kill
            MakeExplosion();
            int mul = 1;
            if (Multipliers.me)
            {
                mul = Multipliers.me.muls[1 - team.team];
            }
            if (Domination.me)
            {
                Domination.Score(1 - team.team, mul);
            }
            if (Multipliers.me)
            {
                Multipliers.AddKill(1 - team.team);
            }
        }

        // reset relevant objects
        if (shield)
        {
            shield.ResetMe();
        }
        foreach (var go in toggles)
        {
            go.SetActive(false);
        }

        // respawn after given time
        if (delayMultiplier <= 0)
        {
            BeginSpawn();
        }
        else
        {
            Invoke(nameof(BeginSpawn), respawnDelay * delayMultiplier);
        }

        // hide object (Invoke will still run)
        gameObject.SetActive(false);
    }