void Start() { MoveFSM = GetComponent<MovementFSM>(); agent = GetComponent<NavMeshAgent>(); controller = GetComponent<CharacterController>(); agent.acceleration = 100f; agent.updateRotation = false; }
void Awake() { Group = transform.parent.GetComponent<AIGroupController>(); Aggro = GetComponentInChildren<AggroRadius>(); MoveFSM = GetComponent<MovementFSM>(); EntityObject = GetComponent<Entity>(); _animationController = GetComponent<AnimationController>(); SetupMachine(AIStates.idle); HashSet<Enum> idleTransitions = new HashSet<Enum>(); idleTransitions.Add(AIStates.pursuit); idleTransitions.Add(AIStates.wander); HashSet<Enum> pursuitTransitions = new HashSet<Enum>(); pursuitTransitions.Add(AIStates.dead); pursuitTransitions.Add(AIStates.reset); HashSet<Enum> resetTransitions = new HashSet<Enum>(); resetTransitions.Add(AIStates.idle); HashSet<Enum> wanderTransitions = new HashSet<Enum>(); wanderTransitions.Add(AIStates.idle); AddTransitionsFrom(AIStates.idle, idleTransitions); AddTransitionsFrom(AIStates.pursuit, pursuitTransitions); AddTransitionsFrom(AIStates.reset, resetTransitions); AddTransitionsFrom(AIStates.wander, wanderTransitions); StartMachine(AIStates.idle); _soundManager = GetComponent<EntitySoundManager>(); }
void Awake() { SetupMachine(PursuitStates.inactive); HashSet<Enum> inactiveTransitions = new HashSet<Enum>(); inactiveTransitions.Add(PursuitStates.approach); AddTransitionsFrom(PursuitStates.inactive, inactiveTransitions); AddAllTransitionsTo(PursuitStates.inactive); HashSet<Enum> approachTransitions = new HashSet<Enum>(); approachTransitions.Add(PursuitStates.seek); approachTransitions.Add(PursuitStates.flee); AddTransitionsFrom(PursuitStates.approach, approachTransitions); AddAllTransitionsFrom(PursuitStates.seek); HashSet<Enum> attackTransitions = new HashSet<Enum>(); attackTransitions.Add(PursuitStates.seek); attackTransitions.Add(PursuitStates.flee); AddTransitionsFrom(PursuitStates.attack, attackTransitions); HashSet<Enum> fleeTransitions = new HashSet<Enum>(); fleeTransitions.Add(PursuitStates.approach); fleeTransitions.Add(PursuitStates.inactive); fleeTransitions.Add(PursuitStates.flee); AddTransitionsFrom(PursuitStates.flee, fleeTransitions); StartMachine(PursuitStates.inactive); hasFled = false; doesFlee = true; _swinging = false; entity = GetComponent<Entity>(); MoveFSM = GetComponent<MovementFSM>(); combatFSM = GetComponent<CombatFSM>(); _abilityManager = GetComponent<AbilityManager>(); _animationController = GetComponent<AnimationController>(); _soundManager = GetComponent<EntitySoundManager>(); _collider = GetComponent<CapsuleCollider>(); }
// Use this for initialization void Start() { targetPosition = Vector3.zero; agent = GetComponent<NavMeshAgent>(); entity = GetComponent<PlayerEntity>(); moveFSM = GetComponent<MovementFSM>(); combatFSM = GetComponent<CombatFSM>(); }
public void InjectData(RPGActorData data) { actorData = data; name = actorData.actorName; battleStats = new Dictionary <ActorStatType, ActorStat>(); battleStats[ActorStatType.HP] = ActorStat.CreateBattleStat(ActorStatType.HP, "HP", data.hp); battleStats[ActorStatType.MP] = ActorStat.CreateBattleStat(ActorStatType.MP, "MP", data.mp); battleStats[ActorStatType.SPD] = ActorStat.CreateBattleStat(ActorStatType.SPD, "SPD", data.speed); battleStats[ActorStatType.STAM] = ActorStat.CreateBattleStat(ActorStatType.STAM, "STM", data.stamina); battleStats[ActorStatType.ABP] = ActorStat.CreateBattleStat(ActorStatType.ABP, "ABP", 100); battleStats[ActorStatType.ABP].currentScore = 0; statList = new List <ActorStat>(); statList.AddRange(battleStats.Values); // @TODO add BattleActorCommands to battleCommandHolder foreach (string commandName in data.commands) { if (string.IsNullOrEmpty(commandName)) { continue; } CommandData commandData = MasterCommandList.GetCommandData(this, commandName); regularCommands.Add(commandData); } movementFSM = new MovementFSM <BattleActor>(this, actorAnimator); movementFSM.AddState(MovementStateType.GroundMovement, new GroundMovementState(this)); actionFSM = new ActionFSM <BattleActor>(this, actorAnimator); actionFSM.AddState(ActionType.Stand, new NeutralAction(this)); actionFSM.AddState(ActionType.Fight, new FightCommandAction(this)); actorAnimator = GetComponent <ActorAnimator>(); actorAnimator.SetAnimatorController(data); //if (data.isPlayerCharacter) { gameObject.tag = Tags.PC; actorAnimator.AddAnimations(ActionAnimationState.Neutral, false); actorAnimator.AddAnimations(ActionAnimationState.Walk, false); actorAnimator.AddAnimations(ActionAnimationState.MainAttack, false); actorAnimator.AddAnimations(ActionAnimationState.OffHandAttack, false); actorAnimator.AddAnimations(ActionAnimationState.SpellCharge, false); actorAnimator.AddAnimations(ActionAnimationState.SpellCast, false); actorAnimator.AddAnimations(ActionAnimationState.Guard, false); } //else //{ // battleManager.battleHUD.AddNPCToPanel(name); // gameObject.tag = Tags.NPC; //} actorAnimator.SetAnimationState(ActionAnimationState.Neutral, currentFacing); var sprite = GetComponent <SpriteRenderer>(); var collider = GetComponent <CapsuleCollider2D>(); collider.offset = new Vector2(0, 0); collider.size = new Vector3(sprite.bounds.size.x / transform.lossyScale.x, sprite.bounds.size.y / transform.lossyScale.y, sprite.bounds.size.z / transform.lossyScale.z); }
// Start is called before the first frame update void Start() { StateMachine = new MovementFSM(HeroAnimator); }
void Awake() { if (!animation) { gameObject.AddComponent<Animation>(); } animation.playAutomatically = true; animation.AddClip(_idle, "Idle"); animation["Idle"].layer = 1; animation.AddClip(_walk, "Walk"); animation["Walk"].layer = 1; animation["Walk"].wrapMode = WrapMode.Loop; animation.AddClip(_run, "Run"); animation["Run"].layer = 1; animation["Run"].wrapMode = WrapMode.Loop; animation.AddClip(_death, "Death"); animation["Death"].layer = 1; animation["Death"].wrapMode = WrapMode.Once; if (_sleep != null) { animation.AddClip(_sleep, "Sleep"); animation["Sleep"].layer = 1; } else { animation.AddClip(_idle, "Sleep"); animation["Sleep"].layer = 1; } _movementAnimation = "Run"; foreach (AnimationClip clip in _attackAnimations) { animation.AddClip(clip, clip.name); animation[clip.name].layer = 2; animation[clip.name].wrapMode = WrapMode.Once; if (clip.name == "attack 6") { animation[clip.name].wrapMode = WrapMode.Loop; animation[clip.name].layer = 1; } if (_attackTransform != null) { animation[clip.name].AddMixingTransform(_attackTransform, true); } } _movementFSM = GetComponent<MovementFSM>(); _entity = GetComponent<Entity>(); }
void Awake() { if (!animation) { gameObject.AddComponent<Animation>(); } animation.playAutomatically = true; animation.AddClip(_idle, "Idle"); animation["Idle"].layer = 1; animation.AddClip(_walk, "Walk"); animation["Walk"].layer = 1; animation["Walk"].wrapMode = WrapMode.Loop; animation.AddClip(_run, "Run"); animation["Run"].layer = 1; animation["Run"].wrapMode = WrapMode.Loop; animation.AddClip(_death, "Death"); animation["Death"].layer = 1; animation["Death"].wrapMode = WrapMode.Once; if (_sleep != null) { animation.AddClip(_sleep, "Sleep"); animation["Sleep"].layer = 1; } else { animation.AddClip(_idle, "Sleep"); animation["Sleep"].layer = 1; } ProcessCombatAnimations(_meleeAnimations); ProcessCombatAnimations(_spellAnimations); ProcessCombatAnimations(_miscAnimations); _movementAnimation = "Run"; if (tag == "Player") { animation["cast spell"].speed = 3f; animation["attack 1"].speed = 2f; animation["attack 2"].speed = 2f; animation["attack 3"].speed = 2f; animation["attack 4"].speed = 2f; animation["attack 5"].speed = 2f; animation["attack 6"].speed = 2f; } _movementFSM = GetComponent<MovementFSM>(); _entity = GetComponent<Entity>(); }