public void EquipWeapon(GameObject WeaponObject) { GameObject = WeaponObject; Animator = GameObject.GetComponent <Animator>(); Inputs = GameObject.GetComponent <WeaponInputs>(); Common = new WeaponCommon(this); controller = new FSMController <WeaponController, eStates>(this); controller.RegisterState(eStates.Idle, new WeaponIdle()); controller.RegisterState(eStates.Shoot, new WeaponShoot()); controller.RegisterState(eStates.Reload, new WeaponReload()); controller.RegisterState(eStates.Recoil, new WeaponRecoil()); controller.AddMapping(eStates.Idle, eStates.Shoot, eStates.Reload); controller.AddMapping(eStates.Shoot, eStates.Recoil); controller.AddMapping(eStates.Reload, eStates.Idle, eStates.Shoot); controller.AddMapping(eStates.Recoil, eStates.Idle, eStates.Shoot, eStates.Reload); controller.SetLogToGUI(true, 2); controller.SetState(eStates.Idle); Common.Init(); // sanity checks QLogger.Assert(Inputs.magCapacity > 0); QLogger.Assert(Inputs.reloadTime > 0 && Inputs.recoilTime > 0 && Inputs.accuracy > 0); // if ( Inputs.shotType == eShotType.BURST ) // QLogger.Assert ( Inputs.burstBulletCount > 1 ); QLogger.Assert(Inputs.damage > 0 && Inputs.range > 0); QLogger.Assert(Inputs.muzzlePositionAndDirection != null); }
public void Init(GameObject characterObject, iPlayer player) { GameObject = characterObject; this.player = player; Animator = GameObject.GetComponent <Animator>(); Inputs = GameObject.GetComponent <CharacterInputs>(); Common = new CharacterCommon(this); controller = new FSMController <CharacterController, eStates>(this); controller.RegisterState(eStates.Idle, new CharacterIdle()); controller.RegisterState(eStates.Walk, new CharacterIdleWalk()); controller.RegisterState(eStates.Jump, new CharacterJump()); controller.RegisterState(eStates.Falling, new CharacterFalling()); controller.AddMapping(eStates.Idle, eStates.Jump, eStates.Walk, eStates.Falling); controller.AddMapping(eStates.Walk, eStates.Jump, eStates.Idle, eStates.Falling); controller.AddMapping(eStates.Jump, eStates.Idle, eStates.Walk, eStates.Falling); controller.AddMapping(eStates.Falling, eStates.Idle, eStates.Walk, eStates.Jump); controller.SetLogToGUI(true, 1); controller.SetState(eStates.Idle); }