// Start is called before the first frame update protected override void Start() { base.Start(); this.animationObject = this.gameObject.GetComponentInChildren <Animation>(); this.animationEvents = this.gameObject.GetComponentInChildren <AnimationEvents>(); if (this.animationEvents != null) { animationEvents.OnAnimationStartEvent.AddListener(this.OnAnimationStart); animationEvents.OnAnimationEndEvent.AddListener(this.OnAnimationEnd); } this.inputCollider = this.gameObject.GetComponentInChildren <BoxCollider2D>(); if (this.inputCollider != null && this.InputHeightOverride != 0.0f) { var diffY = (this.inputCollider.size.y - this.InputHeightOverride) * 0.5f; this.inputCollider.size = this.inputCollider.size.WithY(this.InputHeightOverride); this.inputCollider.offset = this.inputCollider.offset.WithY(diffY); } this.ResolveSprite(); this.ToggleInput(this.isInputEnabled); if (this.particles != null) { this.particlesRenderer = this.particles.gameObject.GetComponent <ParticleSystemRenderer>(); } }
private void castMagic() { // Change character expression. AnimationEvents animScript = GetComponentInChildren <AnimationEvents>(); animScript.SetExpression("MagicLaunchFace"); // Substract MP from UI magicControlUIScript.consumeMp(magicControlUIScript.fireballCost); freezeDueCasting = 0.5f; // We instantiate a magic fireball! GameObject fireballPrefab = availableMagics[0]; GameObject go = (GameObject)Instantiate(fireballPrefab); Fireball fireballScript = go.GetComponent <Fireball>(); fireballScript.target = targetPos; fireballScript.speed = 10f; fireballScript.startPosition = lastStaffPoint; // Call character control onCastingFinished for a pushback. GetComponentInParent <CharacterControl>().castingPushback(targetPos); GetComponentInParent <CharacterControl>().onCastingFinished(); // Assign cooldown to prevent new magic. magicCooldown = 1f; }
// Use this for initialization void Start() { transform = GetComponent <Transform>().transform; curHP = maxHP; SetUpAnimator(); animEvents = activeModel.AddComponent <AnimationEvents>(); animEvents.Init(null, this); }
void Awake() { events = GetComponent <AnimationEvents>(); marker = GetComponent <Marker>(); rotation = Root.GetChild(0).gameObject; tips = Root.GetChild(3).gameObject; text = tips.transform.GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>(); }
public virtual void HandleEvents(ExposedList <Event> eventBuffer) { if (eventBuffer == null || AnimationEvents == null) { return; } for (int i = 0, n = eventBuffer.Count; i < n; i++) { AnimationEvents.Invoke(eventBuffer.Items[i]); } }
/// <summary> /// Run by RunFionctAfterAnimation /// Assumes animation is started with "Start" trigger /// </summary> /// <param name="puniCallbackFunction"></param> /// <param name="pstrAnimationName"></param> /// <returns></returns> private IEnumerator CoroutineAnimationFunction(UnityAction puniCallbackFunction, string pstrAnimationName, int pintAnimationIndex = 0) { if (mdictAnimations[pstrAnimationName] != null) { mdictAnimations[pstrAnimationName].SetTrigger("Start" + pintAnimationIndex); } AnimationEvents animEvents = mdictAnimations[pstrAnimationName].gameObject.GetComponent <AnimationEvents>(); while (!animEvents.Complete) { yield return(null); } puniCallbackFunction.Invoke(); }
/// <summary> /// Assumes animation is started with "Start" trigger /// </summary> /// <param name="pstrAnimationName"></param> /// <returns></returns> public IEnumerator StartAndWaitForAnimation(string pstrAnimationName, int pintAnimationIndex = 0) { if (mdictAnimations[pstrAnimationName] != null) { mdictAnimations[pstrAnimationName].SetTrigger("Start" + pintAnimationIndex); } AnimationEvents animEvents = mdictAnimations[pstrAnimationName].gameObject.GetComponent <AnimationEvents>(); while (!animEvents.Complete) { yield return(null); } }
public void OnAnimationCallBack(AnimationEvents animationEvent) { switch (animationEvent) { case AnimationEvents.AttackStart: break; case AnimationEvents.WindUpDone: break; case AnimationEvents.AttackDone: break; case AnimationEvents.RecoveryDone: m_CanAttack = true; break; }; }
// Use this for initialization public void Init() { curHP = maxHP; curStamina = maxStamina; SetUpAnimator(); rigidBody = GetComponent <Rigidbody>(); rigidBody.angularDrag = 999; rigidBody.drag = 4; rigidBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; gameObject.layer = 8; ignoreLayers = ~(1 << 9); animEvents = activeModel.AddComponent <AnimationEvents>(); animEvents.Init(this, null); }
public OnStatsChange onStatsChange; // Broadcasts all stats each stat change // Start is called before the first frame update void Start() { animator = GetComponentInChildren <Animator>(); projector = GetComponentInChildren <Projector>(); stats = GetComponent <UnitStats>(); animationEvents = GetComponentInChildren <AnimationEvents>(); // setting grid position of unit and placing unit to grid center transform.position = Grid.instance.NodeFromWorldPosition(transform.position).worldPosition; OccupyGridNode(); // registring unit in manager UnitManager.instance.AddUnit(this); stats.onStatChange += delegate(Stat stat, int value) { onStatsChange?.Invoke(stats); }; }
void Awake() { AnimatorComponent = GetComponentInChildren <Animator>(); if (!AnimatorComponent) { Debug.LogError("Animation State: Animator is null."); } else { AnimatorControllerComponent = AnimatorComponent.runtimeAnimatorController as AnimatorController; if (!AnimatorControllerComponent) { Debug.LogError("Animation State: Animator Controller is null"); } } ControllerComponent = GameObject.FindGameObjectWithTag(gameObject.tag).GetComponent <PlayerController>(); if (!ControllerComponent) { Debug.LogError("Animation State: Controller is null."); } BodyComponent = GameObject.FindGameObjectWithTag(gameObject.tag).GetComponent <Rigidbody>(); if (!BodyComponent) { Debug.LogError("Animation State: Rigidbody is null."); } if (transform.childCount > 0) { PlayerObject = transform.GetChild(0).gameObject; } AnimationEventComponent = PlayerObject.GetComponent <AnimationEvents> (); if (!AnimationEventComponent) { Debug.LogError("Animation State: Animation Events is null"); } }
public void Setup(HumanSheet humanSheetIn, bool isZombie, GameObject squadDeployment = null) { this.humanSheet = humanSheetIn; this.isZombie = isZombie; animator = transform.parent.GetComponent <Animator> (); stateMachine = transform.parent.GetComponent <AnimationStateMachine> (); stateMachine.Setup(this); animationEvents = transform.parent.GetComponent <AnimationEvents> (); animationEvents.Setup(this); agent = transform.parent.GetComponent <NavMeshAgent> (); navigation = GetComponent <AINavigation> (); navigation.Setup(showAgent); senses = GetComponent <AISenses> (); senses.Setup(); vision = transform.parent.GetComponentInChildren <AIVision> (); vision.Setup(this, showVisionTargets, showNearVision, showMidVision, showFarVision); combat = GetComponent <AICombat> (); combat.Setup(this); if (isZombie) { //Debug.Log ("zombie perception : " + humanSheet.stats.perception); motor = new ZombieMotor(this, transform.parent.GetComponent <Animator> ()); behaviourTree = new BTZombie(); } else { //Debug.Log ("swat perception : " + humanSheet.stats.perception); motor = new HumanMotor(this, transform.parent.GetComponent <Animator> ()); behaviourTree = new BTSwat(); } behaviourTree.squadDeployment = squadDeployment; behaviourTree.Setup(humanSheet, this); //motor.UpdateAvatarMask (); agent.updatePosition = false; //agent.updateRotation = false; behaviourTree.StartTree(); }
private void Awake() { instance = this; }
void Start() { anim = navigationArea.GetComponent <Animator>(); events = navigationArea.GetComponent <AnimationEvents>(); }
/// <summary>The method invoked after the player loads a save.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void ReceiveSaveLoaded(object sender, EventArgs e) { // initialise animation events this.AnimationEvents = new AnimationEvents(Game1.player.FarmerSprite); this.AnimationEvents.OnNewFrame += this.ReceiveAnimationNewFrame; }