public void SwitchPartner(bool playerInLaser) { partnerPreviewRenderer.enabled = false; previewRenderer.enabled = false; partnerLinkedPair.timesFlipped += 1; if (playerInLaser) //player is going to laser with this object, so partner should be set to real { ShaderUtility.ShaderToReal(partnerMaterial); partner.GetComponent <Transition>().SetStart(1f); StartCoroutine(flipTransitionRoutine(1, 0f, 1f, false)); partner.layer = 11; } else //player is going to real, so the pair should go to laser { ShaderUtility.ShaderToLaser(partnerMaterial); partner.GetComponent <Transition>().SetStart(0f); StartCoroutine(flipTransitionRoutine(0f, 1f, 1f, true)); partner.layer = 10; } }
} //used in flippable public virtual void LoadShader(bool real) { if (real) { ShaderUtility.ShaderToReal(_material); } else { ShaderUtility.ShaderToLaser(_material); } }
public override void Drop() { StopAllCoroutines(); wait = false; currentPositionVelocity = originalVelocity; //put the object down with the right shader if (player.GetComponent <flipScript>().space) { ShaderUtility.ShaderToReal(_renderer.material); GetComponent <Transition>().SetStart(0f); SetMaterialFloatProp("_onHover", 1); //renderer.material.SetInt("_onHold", 0); this.gameObject.layer = 11; } else { ShaderUtility.ShaderToLaser(_renderer.material); GetComponent <Transition>().SetStart(1f); OffSelect(); SetMaterialFloatProp("_onHover", 1); //renderer.material.SetInt("_onHold", 0); this.gameObject.layer = 10; } Vector3 currentVelocity = rigidbody.velocity; if (currentVelocity.magnitude > maxVelocity) { //.Log("before " + currentVelocity); rigidbody.velocity = Vector3.ClampMagnitude(currentVelocity, maxVelocity); //Debug.Log(rigidbody.velocity + ", " + rigidbody.velocity.magnitude); } FlipCore(false); _iconContainer.SetOpenHand(); selected = false; OffSelect(); rigidbody.freezeRotation = false; beenPickedUp = true; rigidbody.constraints = RigidbodyConstraints.None; rigidbody.useGravity = true; ResetWalk(); }
public void Flip(bool dir) { //quick setup for if we're changing the core shader before the core itself has done the awake if (!renderMat) { renderMat = GetComponent <Renderer>().material; } if (dir) { ShaderUtility.ShaderToLaser(renderMat); GetComponent <Transition>().SetStart(1f); } else { ShaderUtility.ShaderToReal(renderMat); GetComponent <Transition>().SetStart(0f); } }
/* * protected void SelfLayerSwitch() * { * bool goingToReal; * * if (gameObject.layer.Equals(10)) * * { * SetObjectToReal(); * goingToReal = true; * } * * else * { * SetObjectToLaser(); * * goingToReal = false; * } * * HoldableObject.ObjectType type = objectType; * * if (type == HoldableObject.ObjectType.Morph) * { * * GetComponent<MorphController>().OnFlip(goingToReal); * } * } */ protected void ForcedTransitionEffect() { Transition transition = _transition; float direction = 1f; if (gameObject.layer == 11) { if (Toolbox.Instance.PlayerInLaser()) { Debug.Log("1"); transition.SetStart(_material.GetFloat("_TransitionState")); direction = 1f; if (_core) { ShaderUtility.ShaderToLaser(_core.gameObject.GetComponent <Renderer>().material); _coreTransition.StopAllCoroutines(); _coreTransition.SetStart(0f); _coreTransition.Flip(1f, Toolbox.Instance.globalFlipSpeed); } } else { Debug.Log("2"); transition.SetStart(1f - _material.GetFloat("_TransitionState")); direction = 0f; if (_core) { ShaderUtility.ShaderToLaser(_core.gameObject.GetComponent <Renderer>().material); _coreTransition.StopAllCoroutines(); _coreTransition.SetStart(1f); _coreTransition.Flip(0f, Toolbox.Instance.globalFlipSpeed); } } Debug.Log("going to laser"); ShaderUtility.ShaderToLaser(_material); SetObjectToLaser(); } else { if (Toolbox.Instance.PlayerInLaser()) { Debug.Log("3"); transition.SetStart(_material.GetFloat("_TransitionState")); direction = 1f; if (_core) { ShaderUtility.ShaderToReal(_core.gameObject.GetComponent <Renderer>().material); _coreTransition.StopAllCoroutines(); _coreTransition.SetStart(0f); _coreTransition.Flip(1f, Toolbox.Instance.globalFlipSpeed); } } else { Debug.Log("4"); transition.SetStart(1f - _material.GetFloat("_TransitionState")); direction = 0f; if (_core) { ShaderUtility.ShaderToReal(_core.gameObject.GetComponent <Renderer>().material); _coreTransition.StopAllCoroutines(); _coreTransition.SetStart(1f); _coreTransition.Flip(0f, Toolbox.Instance.globalFlipSpeed); } } Debug.Log("going to real"); ShaderUtility.ShaderToReal(_material); SetObjectToReal(); } transition.Flip(direction, Toolbox.Instance.globalFlipSpeed); }
protected void LayerSwitch() { if (Toolbox.Instance.PlayerInReal()) { if (!AmHeldObj()) { ShaderUtility.ShaderToReal(_material); _transition.SetStart(0f); //set it fully on for laser world } SetObjectToReal(); //set object to real layer } else { if (!AmHeldObj()) { ShaderUtility.ShaderToLaser(_material); _transition.SetStart(1f); //set it fully on for laser world } SetObjectToLaser(); //set object to laser layer } /* * HoldableObject.ObjectType type = objectType; * if (Toolbox.Instance.PlayerInLaser()) * { * SetObjectToLaser(); //set object to laser layer * if (type == HoldableObject.ObjectType.Morph) * { * GetComponent<MorphController>().OnFlip(true); * } * * if (!AmHeldObj()) * { * //set the object to approperiate shader unless currently held * //if new shader - do new thing, else do old * * ShaderUtility.ShaderToLaser(material); * * _transition.SetStart(1f); //set it fully on for laser world * //_transition.SetStart(1f - (renderer.material.GetFloat("_TransitionState"))); * } * * } * else if (Toolbox.Instance.PlayerInReal()) * { * SetObjectToReal(); //set object to real layer * if (type == HoldableObject.ObjectType.Morph) * { * GetComponent<MorphController>().OnFlip(false); * } * * if (!AmHeldObj()) * { * ShaderUtility.ShaderToReal(material); * _transition.SetStart(0f); //set it fully on for real world] * //_transition.SetStart((renderer.material.GetFloat("_TransitionState"))); * } * } * * if (type == HoldableObject.ObjectType.LinkedPair) * { * //do the inverselayer switch on partner! * GetComponent<LinkedPair>().SwitchPartner(Toolbox.Instance.PlayerInLaser()); * } */ }