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);
        }
    }
Exemple #2
0
    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;
        }
    }
Exemple #3
0
 public LaydownState(bool conCurrentCanRun, ref IRangedCombatLogic control, ERangedAttackID currentID, ref IInvertoryLogic invertoryLogic)
 {
     this.conCurrentCanRun = conCurrentCanRun;
     this.control          = control;
     this.currenStateID    = currentID;
     this.invertoryLogic   = invertoryLogic;
 }
Exemple #4
0
 public AttackState(bool concurrentCanRun, EMeleeAttackID currentID, ref IMovementAndMeleeCombatLogic control, ref IInvertoryLogic invertory, ref Animator animator)
 {
     this.concurrentCanRun = concurrentCanRun;
     this.currentID        = currentID;
     this.control          = control;
     this.animator         = animator;
     this.invertoryLogic   = invertory;
 }
Exemple #5
0
 public OrcAttackState(bool conCurrentCanRun, ref IOrcAttackLogic control,
                       EOrcCombatState stateID, ref IInvertoryLogic invertoryLogic, ref Animator animator)
 {
     this.conCurrentCanRun = conCurrentCanRun;
     this.control          = control;
     this.currentID        = stateID;
     this.invertoryLogic   = invertoryLogic;
     this.animator         = animator;
 }
Exemple #6
0
 public ShootState(bool canConcurentRun, ERangedAttackID currentStateID, ref IRangedCombatLogic control,
                   ref Animator animator, ref IInvertoryLogic invertoryLogic)
 {
     this.canConcurentRun = canConcurentRun;
     this.currentStateID  = currentStateID;
     this.control         = control;
     this.animator        = animator;
     this.invertoryLogic  = invertoryLogic;
 }
Exemple #7
0
 // TODO: weapon Invertory current weapon ref InvertoryWeapons
 public ReloadState(bool conCurrentCanRun, ref IRangedCombatLogic control, ERangedAttackID currentID,
                    ref IInvertoryLogic invertoryLogic, ref Animator animator)
 {
     this.conCurrentCanRun = conCurrentCanRun;
     this.control          = control;
     this.currentID        = currentID;
     this.invertoryLogic   = invertoryLogic;
     this.animator         = animator;
 }
Exemple #8
0
 public HoldState(bool canConcurrentRun, ref IRangedCombatLogic control, ERangedAttackID currentID,
                  ref IHoldWeapon holdWeaponInfo, ref Animator animator, ref IInvertoryLogic invertoryLogic)
 {
     this.canConcurrentRun = canConcurrentRun;
     this.control          = control;
     this.currentID        = currentID;
     this.animator         = animator;
     this.holdWeaponInfo   = holdWeaponInfo;
     this.invertoryLogic   = invertoryLogic;
 }
Exemple #9
0
 private void Start()
 {
     IWeaponData[] weaponsData = GetComponentsInChildren <IWeaponData>();
     if (weaponsData.Length != 0)
     {
         List <IEquippedWeapon> invertoryItems = CreateInvertory(invertoryStructure.StashStructure, weaponsData.ToList());
         invertory      = new Invertory(invertoryItems);
         invertoryLogic = new InvertoryLogic(ref invertory);
     }
     else
     {
         invertoryLogic = new InvertoryLogic();
     }
 }
    // Use this for initialization
    void Start()
    {
        ICameraData camData = userCamera.GetComponent <ICameraData>();

        spCamera = camData.SpCamera;

        invertoryLogic = GetComponent <IInvertoryData>().InvertoryLogic;

        Transform           follow = transform;
        CharacterController characterController = GetComponent <CharacterController>();

        characterControl = new SpacemarineMove(ref characterController, ref follow, collideWith);

        movementInput = new SpMovementAndMeleeCombat(ref rayCastFrom, collideWith, ref characterController);
        movementLogic = new SpMovementAndMeleeLogic(movementInput);

        rangedInput = new RangedCombatInput();
        rangedLogic = new RangedCombatLogic(ref rangedInput, spCamera.CameraTransform);

        spaceMove = new ControlSpMovement(ref movementLogic, ref characterControl,
                                          ref characterAnimator, ref rangedLogic,
                                          ref invertoryLogic, ref spCamera);
    }
Exemple #11
0
 public InvertorySwitch(bool conCurrentCanRun, ref IInvertoryLogic control, ref Animator animator)
 {
     this.conCurrentCanRun = conCurrentCanRun;
     this.control          = control;
     this.animator         = animator;
 }
Exemple #12
0
 public InvertoryIdle(bool conCurrentCanRun, ref IInvertoryLogic control)
 {
     this.control          = control;
     this.conCurrentCanRun = conCurrentCanRun;
 }
Exemple #13
0
    public ControlSpMovement(ref IMovementAndMeleeCombatLogic input, ref IMove characterController
                             , ref Animator animator, ref IRangedCombatLogic rangedLogic, ref IInvertoryLogic invertoryLogic, ref ISpCameraFollow camera)
    {
        this.rangedInput = rangedLogic;
        this.rangedInput.InputChanged += RangedInput_InputChanged;
        this.invertoryInput            = invertoryLogic;
        this.spCamera = camera;

        // Movement FSM setup
        this.movementAndMeleeControl = input;
        this.fSMSpMovement           = new FSMachineSpacemarineMove(EMovementID.Walking, ref this.movementAndMeleeControl, true);

        WalkState  walkState  = new WalkState(true, 2.0f, ref characterController, ref this.movementAndMeleeControl, EMovementID.Walking, ref animator);
        RunState   runState   = new RunState(false, 5.0f, ref characterController, ref this.movementAndMeleeControl, EMovementID.Running, ref animator);
        SmashState smashState = new SmashState(false, 6.0f, 1.25f, ref characterController, ref this.movementAndMeleeControl, EMovementID.Smashing, ref animator);
        FallState  fallState  = new FallState(2.0f, -Physics.gravity.y * Vector3.down, true, ref characterController, ref this.movementAndMeleeControl, EMovementID.Falling, ref animator);
        LandState  landState  = new LandState(0.75f, false, ref input, ref characterController, EMovementID.Landing);

        this.fSMSpMovement.AddState(walkState);
        this.fSMSpMovement.AddState(runState);
        this.fSMSpMovement.AddState(smashState);
        this.fSMSpMovement.AddState(fallState);
        this.fSMSpMovement.AddState(landState);
        this.fSMSpMovement.SetDefaultState(walkState);

        this.fSMSpMovement.StateChanged += FSMSpMovement_StateChanged;

        // Melee FSM machine setup
        AttackState attackState = new AttackState(false, EMeleeAttackID.Attacking, ref this.movementAndMeleeControl, ref invertoryLogic, ref animator);
        MeleeIdle   meleeIdle   = new MeleeIdle(true, EMeleeAttackID.Idle, ref this.movementAndMeleeControl);

        this.fSMSpCombat = new FSMCombatSpacemarine(true, EMeleeAttackID.Idle, ref this.movementAndMeleeControl, ref invertoryLogic);

        this.fSMSpCombat.AddState(attackState);
        this.fSMSpCombat.AddState(meleeIdle);
        this.fSMSpCombat.SetDefaultState(meleeIdle);

        //Ranged FSM setup
        IHoldWeapon       holdWeaponInfo = new HoldPistol(5.0f);
        IRangedState      holdState      = new HoldState(true, ref rangedLogic, ERangedAttackID.Hold, ref holdWeaponInfo, ref animator, ref invertoryInput);
        IRangedShootState shootState     = new ShootState(true, ERangedAttackID.Shoot, ref rangedLogic, ref animator, ref invertoryLogic);
        IRangedState      reloadState    = new ReloadState(true, ref rangedLogic, ERangedAttackID.Reload, ref invertoryLogic, ref animator);
        IRangedState      laydownState   = new LaydownState(true, ref rangedLogic, ERangedAttackID.LayDown, ref invertoryLogic);

        this.fSMSpRangedCombat = new FSMRangedSpacemarine(true, ERangedAttackID.LayDown, ref rangedLogic, ref invertoryLogic);

        this.fSMSpRangedCombat.AddState(holdState);
        this.fSMSpRangedCombat.AddState(reloadState);
        this.fSMSpRangedCombat.AddState(shootState);
        this.fSMSpRangedCombat.AddState(laydownState);
        this.fSMSpRangedCombat.SetDefaultState(laydownState);

        this.fSMSpRangedCombat.StateChanged += FSMSpRangedCombat_StateChanged;

        // Invertory Setup
        InvertoryIdle   invertoryIdleState   = new InvertoryIdle(true, ref invertoryLogic);
        InvertorySwitch invertorySwitchState = new InvertorySwitch(true, ref invertoryLogic, ref animator);

        this.fSMInvertory = new FSMInvertory(EInvertoryStateID.None, ref invertoryLogic);

        this.fSMInvertory.AddState(invertoryIdleState);
        this.fSMInvertory.AddState(invertorySwitchState);
        this.fSMInvertory.SetDefaultState(invertoryIdleState);

        this.fSMInvertory.StateChanged += FSMInvertory_StateChanged;

        if (invertoryLogic.HasInputModel)
        {
            this.spCamera.ObjectRotator.CanRotate = !invertoryLogic.InputInfo.CurrentWeapons.IsMeleeEquipment;
            this.spCamera.IsMeleeViewEnabled      = !invertoryLogic.InputInfo.CurrentWeapons.IsMeleeEquipment;
        }
        else
        {
            this.spCamera.IsMeleeViewEnabled = false;
        }
    }
 public FSMRangedSpacemarine(bool concurrentMachineCanRun, ERangedAttackID defaultID,
                             ref IRangedCombatLogic control, ref IInvertoryLogic invertoryLogic) : base(concurrentMachineCanRun, defaultID, ref control)
 {
     this.invertoryLogic = invertoryLogic;
 }
Exemple #15
0
 public FSMInvertory(EInvertoryStateID defaultStateID, ref IInvertoryLogic control)
 {
     this.defaultStateID = defaultStateID;
     this.states         = new List <IState <IInvertoryLogic, EInvertoryStateID> >();
     this.control        = control;
 }
Exemple #16
0
 public FSMCombatSpacemarine(bool concurrentMachineCanRun, EMeleeAttackID defaultStateID,
                             ref IMovementAndMeleeCombatLogic control, ref IInvertoryLogic invertoryLogic) : base(concurrentMachineCanRun, defaultStateID, ref control)
 {
     this.invertoryLogic = invertoryLogic;
 }