Beispiel #1
0
    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);
    }
Beispiel #2
0
    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 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();
    }