コード例 #1
0
    /*protected void TurnPlayerPowerablesOff(bool isPowerOn)
     * {
     *  if (isPowerOn == false)
     *  {
     *      TurnPowerablePlayersOff();
     *  }
     * }*/


    protected void TogglePowerable(bool activate)
    {
        GameObject availablePowerableObject = (availablePowerable);

        if (availablePowerableObject)
        {
            PowerableObject powerable = availablePowerableObject.GetComponent <PowerableObject>();

            for (int i = 0; i < powerable.powers.Length; i++)
            {
                if (powerable.PlayerActivatesPower(powerable.powers[i].caster, gameObject))
                {
                    if (powerable.IsPowered() && !activate)
                    {
                        powerable.DeactivatePower();
                    }
                    else if (!powerable.IsPowered() && activate)
                    {
                        powerable.ActivatePower(powerable.powers[i]);
                    }
                    break;
                }
            }
        }
    }
コード例 #2
0
    protected virtual void Start()
    {
        IgnoreCollisionWithDestroyables();
        CheckVariables();

        if (hasParasite)
        {
            parasite   = (GameObject)Instantiate(Resources.Load("Prefabs/Powerables/" + parasiteName));
            pTransform = parasite.transform;
            PowerableObject pObject = gameObject.GetComponent <PowerableObject>();
            pObject.powers[0].particles[0] = parasite;
        }


        isWorking = true;

        if (dontCollideWithPlayers)
        {
            IgnoreCollisionWithPlayers(true);
        }

        if (endPoint != null)
        {
            currentTarget = endPoint;
        }
    }
コード例 #3
0
 private void Awake()
 {
     Renderer                    = GetComponent <Renderer>();
     effect                      = Camera.main.GetComponent <EdgeEffect>();
     effectOff                   = Camera.main.GetComponent <EdgeEffectOff>();
     powerAttached               = this.GetComponent <PowerExchanger>().ConnectedPowerable;
     powerAttached.OnPoweredOn  += PowerOn;
     powerAttached.OnPoweredOff += PowerOff;
 }
コード例 #4
0
    protected virtual void Awake()
    {
        // The exchanger's connected powerable must be a parent GameObject of this GameObject.
        connectedPowerable = GetComponentInParent <PowerableObject>();

        if (connectedPowerable == null)
        {
            Debug.LogError("GameObject must be a child object of the connected powerable.");
        }
    }
コード例 #5
0
    /// <summary>
    /// Initialize references to various components.
    /// </summary>
    private void InitializeReferences()
    {
        // The level transition object must be a child of a powerable.
        connectedCryochamber = GetComponentInParent <PowerableObject>();

        // The level transition panel must have a Text component as a child.
        Text levelText = levelTransitionPanel.GetComponentInChildren <Text>();

        levelText.text = levelDescription;
    }
コード例 #6
0
    private void Awake()
    {
        myRenderer  = GetComponent <MeshRenderer>();
        myPowerable = GetComponent <PowerableObject>();

        computerMaterials = new List <Material>();

        foreach (Material m in myRenderer.materials)
        {
            computerMaterials.Add(m);
        }
    }
コード例 #7
0
    private void Awake()
    {
        // There should be only one NighVision script in the hub level, and it's applied to the main camera.
        nightVision = Camera.main.GetComponent <NightVision>();

        // The main camera also has a glitch effect script.
        glitchEffect = Camera.main.GetComponent <GlitchEffect>();

        if (zoneType == ZoneType.Switch)
        {
            connectedPowerable = GetComponentInParent <PowerableObject>();
        }
    }
コード例 #8
0
    /// <summary>
    /// Initialize references to components.
    /// </summary>
    private void InitializeReferences()
    {
        myPowerable = GetComponentInParent <PowerableObject>();

        foreach (Collider c in GetComponents <Collider>())
        {
            if (c.isTrigger)
            {
                myTrigger = c;
            }
        }

        myAnimator = GetComponent <Animator>();
    }
コード例 #9
0
    private void CheckAndSetPowerableData(GameObject damagingObject, GameObject[] parasiteParticles)
    {
        if (damagingObject.GetComponent <PowerableObject>())
        {
            PowerableObject powerableObject = damagingObject.GetComponent <PowerableObject>();

            for (int i = 0; i < powerableObject.powers.Length; i++)
            {
                if (i <= 1)
                {
                    powerableObject.powers[i].particles[0] = parasiteParticles[0];
                }
                if (i <= 3 && i >= 2)
                {
                    powerableObject.powers[i].particles[0] = parasiteParticles[1];
                }
                if (i <= 5 && i >= 4)
                {
                    powerableObject.powers[i].particles[0] = parasiteParticles[2];
                }
            }
        }
    }
コード例 #10
0
 private void Awake()
 {
     connectedPowerable = transform.parent.GetComponentInChildren <PowerableObject>();
     myAnimator         = GetComponent <Animator>();
 }
コード例 #11
0
 private void Awake()
 {
     powerables = FindObjectsOfType <PowerableObject>();
     player     = GameObject.FindGameObjectWithTag("Player").GetComponent <PowerableObject>();
 }