public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); shadowEvent = go.GetComponent <ShadowDetect.ShadowDetect>(); if (shadowEvent == null) { shadowEvent = go.AddComponent <ShadowDetect.ShadowDetect>(); } shadowEvent.OnExitShadow.AddListener(exitShadow); }
void OnEnable() { sd = (ShadowDetect)target; shadowtargets = serializedObject.FindProperty("_targets"); layers = serializedObject.FindProperty("_layers"); lights = serializedObject.FindProperty("_lights"); onChangeState = serializedObject.FindProperty("_onChangeState"); onEnterShadow = serializedObject.FindProperty("_onEnterShadow"); onExitShadow = serializedObject.FindProperty("_onExitShadow"); onShadow = serializedObject.FindProperty("_onShadow"); outShadow = serializedObject.FindProperty("_outShadow"); }
public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); shadowEvent = go.GetComponent <ShadowDetect.ShadowDetect>(); if (shadowEvent == null) { shadowEvent = go.AddComponent <ShadowDetect.ShadowDetect>(); } // shadowEvent.OnChangeState.AddListener((bool value); shadowEvent.OnChangeState.AddListener((value) => shadowState(value)); }
// Use this for initialization void Start() { animator = GetComponent <Animator>(); meshRenderer = GetComponentInChildren <SkinnedMeshRenderer>(); currentSpeed = speed; prevMousePos = Input.mousePosition; lightParticles = gameObject.GetComponent <ParticleSystem>(); pulseLight = GetComponentInChildren <Light>(); shadowLife = maxLife; //set HP intillay to max availableSections = maxLifeSections; //all sections are available fromt he begining lifePerSection = maxLife / maxLifeSections; //Lock mouse cursor to the middle of the screen Cursor.lockState = CursorLockMode.Confined; Cursor.visible = false; playerShadowDetect = GetComponent <ShadowDetect.ShadowDetect>(); playerDetectLights = GetComponent <DetectLights>(); //Setup shadowDetection Lights GameObject[] lights = GameObject.FindGameObjectsWithTag("Light"); for (int i = 0; i < lights.Length; i++) { playerShadowDetect.Lights.Add(lights[i].GetComponent <Light>()); //adds Sensor light to light Detection scr } InShadow(); //Set this now for instances where there are no lights, only tiles // detect if a player spawns in a safe zone // seemed wasteful to write an onTriggerStay for a use case that could only happen at the start // so this will function the same as that, only it runs once GameObject [] safeZones = GameObject.FindGameObjectsWithTag("SafeZone"); int zonesCount = safeZones.Length; for (int i = 0; i < zonesCount; i++) { if (safeZones[i].GetComponent <BoxCollider>().bounds.Contains(transform.position)) { gameObject.layer = LayerMask.NameToLayer("Ignore Raycast"); meshRenderer.material = safeMaterial; isSafe = true; } } alertMan = GameObject.FindGameObjectWithTag("Alert").GetComponent <AlertManager>(); alertMan.Restart(); }