Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (_onPropagation == true)
        {
            _propagation -= Time.deltaTime;
            if (_propagation < 1)
            {
                foreach (GameObject gObject in currentCollisions)
                {
                    if (gObject)
                    {
                        if (gObject.GetComponent <ObjectState>() != null)
                        {
                            if (gameObject.GetComponentInChildren <ObjectState>()._isDestruct == true)
                            {
                                currentCollisions.Remove(gObject);
                            }
                            else
                            {
                                gObject.GetComponentInChildren <ObjectState>().SetState(gObject.GetComponentInChildren <ObjectState>().GetNewState(_state));
                            }
                        }
                    }
                }
            }
        }
        if (_onConduction == true)
        {
            _conduction -= Time.deltaTime;
            foreach (GameObject gObject in currentCollisions)
            {
                if (gObject && gObject.GetComponentInChildren <ObjectState>() != null)
                {
                    gObject.GetComponentInChildren <ObjectState>().SetState(gObject.GetComponentInChildren <ObjectState>().GetNewState(_state));
                }
            }
            if (_conduction <= 0)
            {
                _elecParticle.SetActive(false);
                _conduction   = _timeStayElec;
                _onConduction = false;
                _state       -= (short)State.ELECTRIFIED;
                if (GetComponentInParent <ObjectGeneration>())
                {
                    GetComponentInParent <ObjectGeneration>().StopElec();
                }

                PlayerKiller.LosePK(gameObject);
            }
        }
        if (_onDestruction == true)
        {
            _destruction -= Time.deltaTime;
            if (_destruction < 0 && _destruction > -1)
            {
                _isDestruct = true;
                Destroy(gameObject);
            }
        }
    }
Ejemplo n.º 2
0
 /*
  *   Return a new state depend on a water state
  */
 public short SetStateWWater()
 {
     if ((_state & (short)State.WET) == 0 && (_state & (short)State.BURNING) == 0 && _canBeWet)
     {
         _waterParticle.SetActive(true);
         return((short)(_state + (short)State.WET));
     }
     if ((_state & (short)State.BURNING) != 0)
     {
         _onDestruction = false;
         _onPropagation = false;
         _steamParticle.GetComponent <ParticleSystem>().Play();
         _fireObject.SetActive(false);
         gameObject.GetComponentInParent <ObjectSound>().playExtinguish();
         PlayerKiller.LosePK(gameObject);
         return((short)(_state - (short)State.BURNING));
     }
     return(_state);
 }