public override void Start() { _physics = GetComponent <CharacterPhysicsComponent>(); // Populate memory sheet. _stats = GetComponent <CharacterStats>(); _memory.Health = _stats.Health; _memory.MemoryBuffer = _memoryBuffer; _memory.VisionRange = _visionRange; _memory.VisionAngle = _visionAngle; _memory.Category = _stats.Category; _memory.Enemies = new List <GameObject>(); _memory.Facing = 1; // Create behaviour tree. _behaviourTree = new GuardTree(this); SceneInfo.AIEnteties.Add(this); // Get ability manager. _abilities = GetComponent <AbilityManager>(); if (_abilities == null) { Scheduler.Instance.AddTask(addAbilityManager()); } }
public override void Start() { // Get animation components. var anims = GetComponents <AnimationComponent>(); _animations = new Bag <AnimationComponent>(anims.Count); anims.ForEach((anim) => { anim.Sprite.AnimationFinished += animationFinished; _animations.Add(anim); }); // Get source components. _physics = GetComponent <CharacterPhysicsComponent>(); _abilities = GetComponent <AbilityManager>(); // Hook into physics events. if (_physics != null) { _physics.StateChanged += changePhysicsAnimations; } if (_abilities == null) { // Try a few frames later again. Scheduler.Instance.AddTask(getAbilityManager()); } else { _abilities.StateChanged += changeAbilityAnimations; } }
private System.Collections.IEnumerator getAbilityManager() { yield return(TimeSpan.FromSeconds(0.1f)); _abilities = GetComponent <AbilityManager>(); _abilities.StateChanged += changeAbilityAnimations; }
public override void Start() { _physics = GetComponent<CharacterPhysicsComponent>(); _manager = GetComponent<AbilityManager>(); // If not present in the current game object add it. if (_manager == null) _manager = AddComponent<AbilityManager>(); // Add ability to manager _manager.AddAbility(this, false); _timeSinceLastShot = FireRate; }
public override void Start() { _manager = GetComponent <AbilityManager>(); // If not present in the current game object add it. if (_manager == null) { _manager = AddComponent <AbilityManager>(); } // Add ability to manager _manager.AddAbility(this, true); _ownerStats = GetComponent <CharacterStats>(); }
public override void Start() { _physics = GetComponent <CharacterPhysicsComponent>(); _manager = GetComponent <AbilityManager>(); // If not present in the current game object add it. if (_manager == null) { _manager = AddComponent <AbilityManager>(); } // Add ability to manager _manager.AddAbility(this); // Hook into pre update GameObject.Scene.PreUpdate += preUpdate; }
public override void Start() { _physics = GetComponent <SpiritPhysicsComponent>(); if (_physics == null) { throw new ArgumentNullException("Spirits need a SpiritPhysicsComponent to work properly"); } _manager = GetComponent <AbilityManager>(); // If not present in the current game object add it. if (_manager == null) { _manager = AddComponent <AbilityManager>(); } // Add ability to manager _manager.AddAbility(this, true); }
System.Collections.IEnumerator addAbilityManager() { yield return(TimeSpan.FromSeconds(0.1f)); _abilities = GetComponent <AbilityManager>(); }