public void Init( KinimaticMotorController motorController, CameraController cameraController, HauntController hauntController, KeyBindingsController keyBindings, BarrierController barrierController, ActionLockController actionLockController ) { var body = GetComponentInChildren <Rigidbody>(); this.actionLockController = actionLockController; directionInput = new InputDirectionController(keyBindings); motor = motorController.GetMotor(motorConfig, body, directionInput); motorAnimator = new MotorAnimator(directionInput, GetComponentInChildren <Animator>(), walkStateName, idleStateName); cameraController.Follow(transform); haunter = new Haunter() { root = transform }; hauntController?.AddHaunter(haunter); interactKey = keyBindings.GetKey(KeyAction.Interact); dimmer = new ProximityDimmer() { root = transform, radius = dimRadius }; builder = new BarrierBuilder() { root = transform }; barrierController?.SetBuilder(builder); }
public void Init( KinimaticMotorController motorController, NodePathController nodePath, HauntController hauntController, HouseController house, FearController fearController, BarrierController barrierController, ActionLockController actionLockController, CameraController cameraController ) { this.cameraController = cameraController; this.actionLockController = actionLockController; actionLockController.OnLock += HandleActionLock; var body = GetComponent <Rigidbody>(); pather = new PathDirectionController(transform, nodePath.GetRoute, finalOffset); motor = motorController.GetMotor(motorConfig, body, pather); animator = modelRoot.GetComponentInChildren <Animator>(); motorAnimator = new MotorAnimator(pather, animator, walkStateName, idleStateName); var hauntResponder = new HauntResponder() { root = transform }; hauntResponder.onRespond += HandleHaunt; hauntController?.AddResponder(hauntResponder); this.house = house; foreach (var reaction in reactions) { reactionMap[reaction.haunt] = reaction; } fearActor = new FearActor() { house = house, root = transform, maxFear = maxFear }; fearActor.OnScared += HandleScared; fearActor.OnPanic += HandlePanic; fearActor.OnCuriouse += HandleCuriouse; fearController?.AddActor(fearActor); blockable = new BarrierBlockable() { root = transform }; blockable.OnBlock += HandleBlock; blockable.OnUnblock += HandleUnblock; barrierController?.AddBlockable(blockable); currentBlockAnim = breakDownAnim; ui.Init(reactions, fearActor, hauntController); entrance = house.GetEntrance(); }
public void Init( KinimaticMotorController motorController, NodePathController pathController, HauntController hauntController, BarrierController barrierController ) { this.barrierController = barrierController; this.motorController = motorController; this.pathController = pathController; this.hauntController = hauntController; hauntController.SetPositionTranslator(this); this.halfUnitWorldSize = unitWorldSize / 2.0f; }
public void Init(List <HauntReaction> reactions, FearActor actor, HauntController hauntController) { this.actor = actor; currentPercent = minFearShow; Dictionary <FearReaction, IconReactionConfig> reactMap = new Dictionary <FearReaction, IconReactionConfig>(); foreach (var config in reactionConfigs) { reactMap[config.reaction] = config; } List <HauntReaction> displayReactions = new List <HauntReaction>(); foreach (var item in reactions) { if (item.reaction == FearReaction.Ignore) { continue; } displayReactions.Add(item); } if (displayReactions.Count == 0) { return; } var reactionIncrement = 1.0f / (displayReactions.Count); for (var index = 0; index < displayReactions.Count; index++) { var reaction = displayReactions[index]; var icon = GameObject.Instantiate(iconPrefab); icon.rectTransform.parent = iconRow; icon.rectTransform.localPosition = Vector3.zero; icon.rectTransform.localScale = Vector3.one; icon.rectTransform.anchorMin = new Vector2(index * reactionIncrement, 0); icon.rectTransform.anchorMax = new Vector2((index + 1) * reactionIncrement, 1); icon.rectTransform.anchoredPosition = Vector2.zero; icon.rectTransform.sizeDelta = Vector2.zero; icon.rectTransform.localRotation = Quaternion.identity; icon.rectTransform.pivot = Vector2.one * .05f; icon.sprite = hauntController.GetIcon(reaction.haunt); icon.color = reactMap[reaction.reaction].color; } }
public void Start() { actionLock = new ActionLockController(); barrierController = GetComponent <BarrierController>(); fearController = GetComponent <FearController>(); keyBindings = GetComponent <KeyBindingsController>(); cameraController = GetComponent <CameraController>(); motorController = GetComponent <KinimaticMotorController>(); houseController = GetComponent <HouseController>(); hauntController = GetComponent <HauntController>(); pathController = GetComponent <NodePathController>(); barrierController.Init(actionLock); fearController.Init(); keyBindings.Init(); cameraController.Init(actionLock); motorController.Init(); hauntController.Init(actionLock); houseController.Init(motorController, pathController, hauntController, barrierController); ui = GameObject.Instantiate(uiPrefab, transform); ui.OnEndOfNight += HandleEndOfNight; ui.Init(fearController, fearTarget, actionLock); houseController.Generate(); var invShuffle = new ShuffleSet <GameObject>(investigatorModels); var roomShuffle = new ShuffleSet <Vector2Int>(houseController.GetNonStartingRooms()); var rotationIncrement = 360.0f / investigatorCount; for (int i = 0; i < investigatorCount; i++) { var rotation = i * rotationIncrement; var offset = Quaternion.Euler(0, rotation, 0) * (Vector3.right * offsetDistance); SpawnInvestigator(invShuffle, offset); } SpawnPlayer(); }