コード例 #1
0
    protected override void Update()
    {
        if (!isPaused)
        {
            Move(Time.unscaledDeltaTime);
            chargeClock += Time.deltaTime;

            if (action && power && !isActive)
            {
                isActive         = true;
                timeStopClock    = 0f;
                charges         -= chargesUsed;
                shouldThrowKnife = true;

                if (timeStopAction != null)
                {
                    timeStopAction.Invoke(true);
                }

                if (charges <= 0)
                {
                    power = false;
                }

                if (UpdateCharges != null)
                {
                    UpdateCharges(charges);
                }
            }
        }

        if (isActive)
        {
            timeStopClock += Time.unscaledDeltaTime;

            if (shouldThrowKnife && timeStopTime >= knifeThrowTime)
            {
                GenericProjectile knifeThrownReference = GameObject.Instantiate(knifePrefab, knifeOrigin.position, Quaternion.identity).GetComponent <GenericProjectile>();
                knifeThrownReference.InitialImpulse(transform.right);
                shouldThrowKnife = false;
                if (!isPlayer1)
                {
                    knifeThrownReference.transform.localScale = new Vector3(-knifeThrownReference.transform.localScale.x, knifeThrownReference.transform.localScale.y, knifeThrownReference.transform.localScale.z);
                }
            }

            if (timeStopClock >= timeStopTime)
            {
                power    = (charges >= chargesUsed && action);
                isActive = false;
                if (timeStopAction != null)
                {
                    timeStopAction.Invoke(false);
                }
            }
        }
    }
コード例 #2
0
    protected override void Update()
    {
        base.Update();
        if (action && power)
        {
            GenericProjectile missileScriptInstance = GameObject.Instantiate(missilePrefab, projectileOrigin.position, projectileOrigin.rotation).GetComponent <GenericProjectile>();
            missileInstance = missileScriptInstance.gameObject;

            if (!isPlayer1)
            {
                missileInstance.transform.localScale = new Vector3(-missileInstance.transform.localScale.x, missileInstance.transform.localScale.y, missileInstance.transform.localScale.z);
            }

            missileScriptInstance.InitialImpulse(this.transform.right);
            missileScriptInstance.PlatformAction += SpawnExplosion;
            missileScriptInstance.PaletteAction  += SpawnExplosion;
            missileScriptInstance.BallAction     += SpawnExplosion;
            missileScriptInstance.WallAction     += SpawnExplosion;

            canDetonateMissile = false;

            charges -= chargesRequired;
            power    = false;
            if (UpdateCharges != null)
            {
                UpdateCharges(charges);
            }
        }
        else
        {
            if (!action && missileInstance != null)
            {
                canDetonateMissile = true;
            }
        }

        if (action && !power && canDetonateMissile && missileInstance != null)
        {
            SpawnExplosion(missileInstance);
            Destroy(missileInstance);
            canDetonateMissile = false;
        }
    }
コード例 #3
0
    protected override void Update()
    {
        base.Update();
        if (action && power)
        {
            GenericProjectile smokeBombInstance = GameObject.Instantiate(smokeBombPrefab, projectileOrigin.position, projectileOrigin.rotation).GetComponent <GenericProjectile>();

            smokeBombInstance.InitialImpulse(this.transform.right);
            smokeBombInstance.PlatformAction += SpawnSmokeScreen;
            smokeBombInstance.PaletteAction  += SpawnSmokeScreenPlayer;

            animator.SetTrigger("SHOT");
            charges -= chargesRequired;
            power    = false;
            if (UpdateCharges != null)
            {
                UpdateCharges(charges);
            }
        }
    }