public void onNotify(IGameActor actor, Event ev) { switch (ev) { case Event.EVENT_ACTOR_MOVE: isMoving = true; break; case Event.EVENT_ACTOR_STOP: isMoving = false; break; case Event.EVENT_ACTOR_ATTACK: animator_.SetTrigger("attack"); isAttacking = true; break; case Event.EVENT_ACTOR_HEAL_BUFF: animator_.SetTrigger("heal"); isHealing = true; break; case Event.EVENT_ACTOR_TAKE_DAMAGE: animator_.SetTrigger("hurt"); isHurting = true; break; } }
public void attack() { int lookingSide = facingRight_ ? 1 : -1; Vector2 correctedOffset = attackColliderOffset_; correctedOffset.x *= lookingSide; Vector2 origin = (Vector2)transform.position + correctedOffset; var hit = Physics2D.BoxCast(origin, attackColliderSize_, 0f, Vector2.zero, Mathf.Infinity, attackMask_); if (hit.collider == null) { return; } GameObject player = hit.collider.gameObject; IGameActor playerActor = player.GetComponent <IGameActor>(); #if UNITY_EDITOR if (playerActor == null) { Error.ShowError("Object with \"Player\" tag does not have a IGameActor script"); } #endif playerActor.takeDamage(1); notify(this, Event.EVENT_ACTOR_ATTACK); }
void Start() { playerActions_ = GetComponent <PlayerActions>(); zKey_ = new AttackCommand(playerActions_); xKey_ = new BuffCommand(playerActions_, Buff.BUFF_HEAL); spaceKey_ = new InteractCommand(playerActions_); }
public void useBuff(IGameActor actor, Buff buff) { if (!canAct) { return; } notify(null, Event.EVENT_ACTOR_HEAL_BUFF); canAct = false; }
public void onNotify(IGameActor actor, Event ev) { switch (ev) { case Event.EVENT_ACTOR_TAKE_DAMAGE_ANIM_ENDED: isHurting = false; break; } }
private IGameActor GetGameActor(RaycastHit2D hit) { IGameActor enemy = hit.collider.gameObject.GetComponent <IGameActor>(); #if UNITY_EDITOR if (enemy == null) { Error.ShowError("Object with \"Enemy\" tag does not have a IGameActor script"); } #endif return(enemy); }
public void AddHitToActor(IGameActor touchedActor) { if (touchedActor != null) { if (!actorsHitbyProjectile.ContainsKey(MyId)) { actorsHitbyProjectile[MyId] = new List <IGameActor>(); } if (!actorsHitbyProjectile[MyId].Contains(touchedActor)) { actorsHitbyProjectile[MyId].Add(touchedActor); } RemainingHits--; } }
public void AddActor(IGameActor Actor) { lock (this.myActors) this.myActors.Add(Actor.ActorId, Actor); // on affecte la cell Actor.CellId = this.Id; if (Actor.ActorType == GameActorTypeEnum.TYPE_CHARACTER) { foreach (var Action in this.myActions) { Action.Apply(Actor as Player); } } }
public void onNotify(IGameActor actor, Event ev) { switch (ev) { case Event.EVENT_ACTOR_ANIM_PLAYING: canAct_ = false; break; case Event.EVENT_ACTOR_ANIM_ENDED: canAct_ = true; break; case Event.EVENT_ACTOR_LOW_HEALTH: lowHealth_ = true; break; } }
void Start() { slimeActor_ = GetComponent <IGameActor>(); SlimeActions actions = GetComponent <SlimeActions>(); actions.addObserver(this); SlimeAnimation anim = GetComponent <SlimeAnimation>(); anim.addObserver(this); player_ = GameObject.FindGameObjectWithTag("Player").transform; stateScore_ = new Dictionary <SlimeState, int>(); foreach (SlimeState state in Enum.GetValues(typeof(SlimeState))) { stateScore_.Add(state, 0); } }
public bool CanHitActor(IGameActor touchedActor) { bool canHitActor = true; if (touchedActor == null) { canHitActor = false; } else if (touchedActor.IsDodging()) { canHitActor = false; } else if (MyOwner != null && touchedActor.GetTribe() == MyOwner.GetTribe()) { canHitActor = false; } else if (actorsHitbyProjectile.TryGetValue(MyId, out List <IGameActor> actors) && actors.Contains(touchedActor)) { // Don't let a bullet hit the same character multiple times. canHitActor = false; } return(canHitActor); }
private void Initialize(WeaponDefinition weapon, IGameActor owner, uint projectileId) { MyWeaponData = weapon; MyOwner = owner; RemainingLifetime = weapon.lifetime; RemainingHits = weapon.maximumEnemiesHit; MyId = projectileId; if (weapon.projectileLockedEffect != null) { spawnedEffect = CosmeticEffect.Spawn(weapon.projectileLockedEffect, weapon.lifetime, transform.position, transform.rotation, this.transform); dummyRenderer.SetActive(false); } else { dummyRenderer.SetActive(!weapon.hiddenAttack); } // Don't spawn the actorsHitByProjectile array until it actually hits something. if (weapon.reflectsOtherAttacks) { reflectionCollider.gameObject.SetActive(true); reflectionCollider.radius = weapon.radius; reflectingColliders[reflectionCollider] = MyOwner; } }
public GameActorShowMessage(GameActorShowEnum ShowType, IGameActor Actor) { this.Actor = Actor; this.ShowType = ShowType; }