public void Init(Unit u, GameObject mesh) { m_Unit = u; int index = u.Inventory.EquipedWeapon.WeaponMesh.WeaponIndex; m_Unit.Actions.OnTargetAction += (a, b) => { UnitAnimator.SetAimTarget(b); }; m_Unit.Actions.OnActionStarted += action => { if (action.GetType() == typeof(UnitAction_Move)) { OnMoveStart(action as UnitAction_Move); } }; m_Unit.Stats.OnDmgReceived += () => { PlayAnimation(UnitAnimationTypes.bHit); }; rush = gameObject.AddComponent <UI_AdrenalineRushBase>(); rush.Init(u.Stats); rush.OnRushGain += () => { PlayAnimation(UnitAnimationTypes.bRage); }; UnitAnimator = UnitFactory.MakeUnitAnimations(mesh, u.Inventory.EquipedWeapon.WeaponMesh, index, mesh.AddComponent <AnimationCallbackCaster>(), () => { return(rush.HasRush); }); }
/// Sets up the animations for the given action protected virtual void receiveAction(HeavyGameEventData data) { /// Will only do the setup if no animations are running from this UnitModel if (this.runningAnimation) { return; } float maxAnimationTime = -1.0f; for (int i = 0; i < this.unitActions.Length; i++) { /// Only appropriate UnitAnimations should be activated if (this.unitActions[i].TriggerActionType == data.ActionType) { maxAnimationTime = Math.Max(maxAnimationTime, this.unitActions[i].UnitAnimation.GetAnimationDuration(data)); UnitAnimation animation = Instantiate(this.unitActions[i].UnitAnimation) as UnitAnimation; animation.transform.SetParent(this.transform); animation.transform.localPosition = Vector3.zero; animation.SetupAnimation(data); this.presentAnimations.Add(animation); } } /// Only plays an animation if the time is > 0 if (maxAnimationTime > 0.0f) { StartCoroutine(this.runAnimation(maxAnimationTime)); } }
public Unit(UnitData UnitData, MapTile MapTile) { this.UnitData = UnitData; this.MapTile = MapTile; UnitAnimation = new UnitAnimation(); }
// Update is called once per frame void Update() { bool idle = false; bool combat = true; UnitAnimation CurrentAnimation = _animSync.CurrentAnimation; switch (CurrentAnimation) { case UnitAnimation.Idle: idle = true; break; case UnitAnimation.Walking: combat = false; break; case UnitAnimation.Running: combat = true; break; default: break; } _animator.SetBool("NonCombat", !combat); _animator.SetBool("Idling", idle); }
protected override void Awake() { base.Awake(); Seeker = GetComponent <Seeker>(); UnitAnimation = new UnitAnimation(animation); State = UnitState.Free; }
private void Awake() { m_gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); m_playerController = GameObject.Find("PlayerController").GetComponent <PlayerController>(); m_uiSkillCheckSystem = GameObject.Find("UISkillCheck").GetComponent <UISkillCheckSystem>(); m_unitDummy = GetComponentInParent <UnitDummy>(); m_unitAnim = GetComponentInChildren <UnitAnimation>(); }
public override bool Equals(object obj) { if (obj.GetType() == typeof(UnitAnimation)) { UnitAnimation other = obj as UnitAnimation; return(other._keyName.Equals(_keyName)); } return(false); }
private void Awake() { unitAnimation = new UnitAnimation { SpriteFaceRight = false, meleeAttackAnimation = "MeleeAttack", rangeAttackAnimation = "MeleeAttack" }; }
IEnumerator Lightning() { while (null != target && deltaTime <= data.time) { Damage(target); UnitAnimation spark = GameObject.Instantiate <UnitAnimation>(sparkPrefab); spark.transform.position = target.center; yield return(new WaitForSeconds(interval)); } }
void Awake() { motor = GetComponent <UnitMotorTarget>(); if (motor != null) { motor.SetUnit(this); } anim = GetComponent <UnitAnimation>(); if (anim != null) { anim.SetUnit(this); } }
protected override void Start() { base.Start(); unitAnimation = new UnitAnimation { SpriteFaceRight = true, meleeAttackAnimation = "MeleeAttack", rangeAttackAnimation = "MeleeAttack" }; hpText = GameObject.Find("hpText").GetComponent <Text>(); hpText.text = "HP: " + Math.Floor(unitStat.hp); apText = GameObject.Find("apText").GetComponent <Text>(); apText.text = ""; }
// .... public UnitAnimation Build() { UnitAnimation unit = new UnitAnimation( this.rightArmPosition, this.leftArmPosition, this.rightHandOrientation, this.leftHandOrientation, this.rightHandConfigration, this.leftHandConfigration, this.rightHandTransition, this.leftHandTransition, this.rightArmPositionFinal, this.leftArmPositionFinal, this.rightHandOrientationFinal, this.leftHandOrientationFinal, this.rightHandConfigrationFinal, this.leftHandConfigrationFinal); return(unit); }
protected float _lastAttackTime = -100.0f; //время, прошедшее с последней атаки public virtual void Attack(Transform target, TargetPositionPair targetPositionPair) { //поворот к цели Vector3 dirToTarget; if (target.IsBuilding()) { dirToTarget = targetPositionPair.NearestBoundaryNodePosition - transform.position; } else { dirToTarget = target.position - transform.position; } dirToTarget.y = 0;//чтобы юнит не вращался по оси Y Rotate(dirToTarget); if (ActionIsAllowed(dirToTarget)) { if (Time.time - _lastAttackTime > _attackInterval) { UnitAnimation.State = UnitAnimation.States.Attack; _lastAttackTime = Time.time; StartCoroutine("CauseDamage", target);//причинение повреждения с задержкой, чтобы урон не наносился, когда анимация удара только началась PauseAllTasks(); State = UnitState.Attack; Invoke("StartAllTasks", UnitAnimation.GetCurrentClipLength()); } else if (UnitAnimation.State != UnitAnimation.States.Attack) { UnitAnimation.State = UnitAnimation.States.IdleBattle; } } else { UnitAnimation.State = UnitAnimation.States.Run; } }
// Use this for initialization private void Start() { health = new HealthComponent(baseHealth); //NAVMESH DATA FOR PATHFINDING Unit movement towards the goal agent = GetComponent <NavMeshAgent>(); agent.destination = goal.position; agent.speed = moveSpeed; agent.acceleration = moveSpeed; agent.angularSpeed = 200f; //ANIMATION DATA(We search parent object for Model SubObject and use animation script for animating everything) model = transform.FindChild("Model").gameObject; //Debug.Log(gameObject.name +gameObject.GetHashCode() + model.name + "FOUND"); animScript = model.GetComponent <UnitAnimation>(); //WEAPON SCRIPT DATA weapon = gameObject.GetComponent <Weapon>(); damage = weapon.baseDamage; weapon.setAnimScript(animScript); //TEXTURE DATA //need to destroy material manualy when destroying object textureModel = model.transform.FindChild("UnitMesh").gameObject; skin = textureModel.GetComponent <SkinnedMeshRenderer>(); skin.material.mainTexture = normalTexture; damageThreshold = 50.0f; // Set sounds death = new[] { (AudioClip)Resources.Load("Sound/Effects/Death 1"), (AudioClip)Resources.Load("Sound/Effects/Death 2"), (AudioClip)Resources.Load("Sound/Effects/Death 3") }; source_death = GameObject.Find("Death Audio Source").GetComponent <AudioSource>(); Debug.Log("UNIT " + name + " CREATED"); }
public void Init(WeaponMesh mesh) { if (current != null) { Destroy(current.AttachmentLeft); Destroy(current.AttachmentRight); Destroy(current.gameObject); } /* * if(m_Animator != null) * { * caster.OnAbilityTrigger -= m_Animator.AbilityCallback; * caster.OnWeaponHide -= m_Animator.WeaponHide; * caster.OnWeaponShow -= m_Animator.WeaponShow; * }*/ AnimationCallbackCaster caster = TargetUnit.GetComponent <AnimationCallbackCaster>(); current = UnitFactory.SpawnWeaponMeshToUnit(TargetUnit, mesh); // UnitAnimation_IdleController idle = mesh.GetComponent<UnitAnimation_IdleController>(); m_Animator = UnitFactory.MakeUnitAnimations(TargetUnit, current, current.WeaponIndex, caster, () => { return(IsRaged); }); }
// Initialize variables protected virtual void Awake() { mAttackState = AttackState.Idle; mAttackTarget = null; mMovementState = MovementState.Idle; mDestination = new Vector3(0, 0, 0); mUnitAnimator = this.GetComponent <UnitAnimation> (); if (mUnitAnimator == null) { Debug.LogError("UnitAnimation script was not attached to this Unit!"); } if (Selector != null) { Selector.enabled = false; } if (mWarpPrefab == null) { mWarpPrefab = Resources.Load("Units/Prefabs/UnitWarpPrefab") as GameObject; } }
internal void HookOnUpdata(UnitAnimation priorUnitAnimation) { priorUnitAnimation.NextUnitAnimation = this; }
private void Awake() { m_unitMovement = this.gameObject.AddComponent <UnitMovement>(); m_unitAnimation = this.gameObject.AddComponent <UnitAnimation>(); m_unitAttack = this.gameObject.AddComponent <UnitAttack>(); }
/// <summary> /// Animate the specified type. /// </summary> /// <param name="type">The type.</param> /// <returns>The animation duration </returns> public float Animate(UnitAnimation type) { var model = (Core.Models.Entity)Model; var defView = (UnitDefinitionView)model.Definition.View; var animate = defView.GetAnimate(model.GetDiplomacy(GameAppDelegate.Account), type); Node.RunActionAsync(animate); return animate.Duration; }
/// <summary> /// Saves the unit start position. Receives the animations script. /// </summary> public void StartUp() { this.m_Position = this.transform.position; m_Animation = GetComponent <UnitAnimation>(); }
public void setAnimScript(UnitAnimation ascript) { animScript = ascript; }
/// <summary> /// Animation for the type. /// </summary> /// <param name="type">The type.</param> public void AnimateForever(UnitAnimation type) { var model = (Core.Models.Entity)Model; var defView = (UnitDefinitionView)model.Definition.View; var animate = defView.GetAnimate(model.GetDiplomacy(GameAppDelegate.Account), type); Node.RunActionAsync(new CCRepeatForever(animate)); }
public void Init(UnitAnimation anim) { m_animation = anim; }
private void Animate(UnitAnimation unit) { rightArmController.moveToTarget(unit.rightArmPosition, unit.rightArmPositionFinal, unit.rightHandTransition, lerpSpeed, slerpSpeed, waitTime); rightHandController.moveFinger(unit.rightHandConfigration, unit.rightHandConfigrationFinal, rotSpeed, waitTime); rightHandOrientationController.ReOrient(unit.rightHandOrientation, unit.rightHandOrientationFinal, rotSpeed, waitTime); }
// Initialize variables protected virtual void Awake() { mAttackState = AttackState.Idle; mAttackTarget = null; mMovementState = MovementState.Idle; mDestination = new Vector3 (0, 0, 0); mUnitAnimator = this.GetComponent<UnitAnimation> (); if (mUnitAnimator == null) Debug.LogError ("UnitAnimation script was not attached to this Unit!"); if (Selector != null) Selector.enabled = false; if (mWarpPrefab == null) mWarpPrefab = Resources.Load("Units/Prefabs/UnitWarpPrefab") as GameObject; }
public void Animate(UnitAnimation unitAnimation) { animationMap[unitAnimation](); }
/// <summary> /// Gets the animate. /// </summary> /// <returns>The animate.</returns> /// <param name="diplomacy">The diplomacy.</param> /// <param name="type">The type.</param> public CCAnimate GetAnimate(Core.Models.Diplomatic diplomacy, UnitAnimation type) { CCAnimate animate = null; m_animations[diplomacy].TryGetValue(type, out animate); return animate; }