private void Start() { meshAgent = GetComponent <NavMeshAgent>(); IInvertory invertory = GetComponent <IInvertoryData>().Invertory; invertoryLogic = new InvertoryLogic(ref invertory); CharacterController characterController = GetComponent <CharacterController>(); orcAIRotator = new AIOrcRotator(this.transform, 5); orcMove = new AIOrcMove(this.transform, environment, 2f, characterController, meshAgent); AITargeter = new AITarget(this.transform); IOrcMovementInput orcMovementInput = new OrcMovementInput(ref AITargeter); orcMovementInput.DriveUpDirection = Vector3.forward; IOrcMovementLogic orcMovementLogic = new AIOrcMovementLogic(orcMovementInput, meshAgent, this.transform); IAIAttackInput orcAttackInput = new AIOrcAttackInput(AITargeter); IOrcAttackLogic orcAttackLogic = new AIOrcAttackLogic(this.transform, ref orcAttackInput, 2.0f, ref orcMovementLogic); orcAIInput = new AIOrcInput(orcMovementLogic, orcAttackLogic, meshAgent); orcAIRotator.CanRotate = true; orcControl = new OrcControl(ref orcMovementLogic, ref orcMove, ref animator, ref orcAttackLogic, ref orcAIRotator, ref invertoryLogic); commandableData = GetComponent <ICommandableData>(); if (commandableData != null) { commandableData.CommandableUnit = new CommandableUnit(AITargeter); commandableData.EnableComponent(true); } }
public OrcControl(ref IOrcMovementLogic control, ref IMove orcMove, ref Animator animator, ref IOrcAttackLogic orcAttackLogic, ref IRotateObject rotator, ref IInvertoryLogic invertoryLogic) { this.control = control; meleeLogic = orcAttackLogic; this.invertoryLogic = invertoryLogic; this.orcRotator = rotator; this.orcRotator.CanRotate = true; // Movement FSM IOrcMovementState walking = new OrcWalkState(1.2f, true, ref orcMove, EOrcMovementStates.Walking, ref this.control, ref animator); IOrcMovementState driveUpState = new OrcDrivenUpState(5, 2, false, ref orcMove, EOrcMovementStates.DrivenUp, ref this.control); IOrcMovementState fallState = new OrcFallState(2, Vector3.down, false, ref orcMove, EOrcMovementStates.Falling, ref this.control, ref animator); fSMmovement = new OrcFSMMovement(ref this.control); fSMmovement.AddState(walking); fSMmovement.AddState(driveUpState); fSMmovement.AddState(fallState); fSMmovement.SetDefaultState(walking); // Combat melee IOrcCombatState idleState = new OrcMeleeIdle(true, ref orcAttackLogic, EOrcCombatState.Idle); IOrcCombatState attackState = new OrcAttackState(false, ref orcAttackLogic, EOrcCombatState.Attacking, ref invertoryLogic, ref animator); fSMmeleeCombat = new OrcFSMCombat(ref orcAttackLogic); fSMmeleeCombat.AddState(idleState); fSMmeleeCombat.AddState(attackState); fSMmeleeCombat.SetDefaultState(idleState); if (this.invertoryLogic.HasInputModel) { this.invertoryLogic.InputInfo.SelectedWeaponIndex = 0; } }
public SpCameraFollow(Transform targetTransform, Transform cameraRoot, LayerMask collideWith, ref ISpStateView meleeView, ref ISpStateView rangedView, ref IRotateObject objectRotator) { this.cameraRoot = cameraRoot; this.pivotTransform = cameraRoot.GetChild(0); //cameras transform placed as the child of the pivot's position this.cameraTransform = pivotTransform.GetChild(0); this.targetToFollow = targetTransform; this.meleeView = meleeView; this.rangedView = rangedView; this.cameraSettings = rangedView.BasicView.CameraOption; this.cameraSensitivity = new SensitivityCamera(5f, 5f); this.cameraFollow = new CameraFollowObject(150f, targetTransform, cameraRoot); this.localStartPos = this.cameraTransform.localPosition; this.currentLocalPos = rangedView.BasicView.OnePosition.localPosition; this.toCollideWith = collideWith; this.objectRotator = objectRotator; }
// Use this for initialization void Awake() { meleeCamplaces = new SpCamPositions(meleedIdle.localPosition, meleeAim.localPosition, meleeRun.localPosition); rangedCamplaces = new SpCamPositions(rangedIdle.localPosition, rangedAim.localPosition, rangedRun.localPosition); ISpView meleeBasicView = new SpOneView(meleedIdle, transform, 5.0f, -40.0f, 30.0f, 0.1f, 5f); ISpView meleeRunView = new SpOneView(meleeRun, transform, 5.0f, -40.0f, 30.0f, 0.1f, 5f); ISpView meleeAimView = new SpOneView(meleeAim, transform, 5.0f, -40.0f, 30.0f, 0.1f, 5f); ISpView rangedBasicView = new SpOneView(rangedIdle, transform, 5.0f, -40.0f, 30.0f, 0.1f, 5f); ISpView rangedRunView = new SpOneView(rangedRun, transform, 5.0f, -40.0f, 30.0f, 0.1f, 5f); ISpView rangedAimView = new SpOneView(rangedAim, transform, 5.0f, -40.0f, 30.0f, 0.1f, 5f); meleeView = new SpStateView(meleeBasicView, meleeAimView, meleeRunView); rangedView = new SpStateView(rangedBasicView, rangedAimView, rangedRunView); objectRotator = new SpacemarineRotator(objectToRotateTransform, 5f); cameraFollow = new SpCameraFollow(target, transform, collidewith, ref meleeView, ref rangedView, ref objectRotator); }