void OnTriggerEnter2D(Collider2D col) { if (col.tag == "Enemy") { CreatureBehavior striked = col.gameObject.GetComponent <CreatureBehavior>(); striked.TakeDamage(pStats.damage); Destroy(this.gameObject); } }
void Start() { creatureMotor = GetComponent <CreatureMotor>(); creatureAI = GetComponent <CreatureAI>(); behavior = creatureAI.creature.creatureBehavior; creatureHealth = creatureAI.creature.creatureHealth; }
/// <summary> /// Resolves the pending actions /// </summary> private void ResolvePendingActions() { var playerController = PlayerController.LocalPlayer; // Go through the action stack while (this.ActionStack.Count > 0) { var curIntent = this.ActionStack.Pop(); CreatureBehavior curCreature = null; // Grab the current target creature if applicable if (curIntent.TargetId >= Settings.MaxPlayerCount && ((curIntent.TargetId - Settings.MaxPlayerCount) < CreatureBehavior.Creatures.Count)) { curCreature = CreatureBehavior.Creatures[curIntent.TargetId]; } // Grab the corresponding playerState switch (curIntent.Intent) { case IntentEnum.PassTurn: continue; case IntentEnum.Counter: this.ActionStack.Pop(); continue; case IntentEnum.BuffCreatureAttack: // Search through creatures and buff attack if (curCreature == null) { Debug.Log("Error: Null creature when trying to buff attack!"); continue; } var creatures = PlayerStateManager.CurrentInstance.PlayerStates[curCreature.TargetCreature.OwnerUserId].Creatures; for (int i = 0; i < creatures.Count; i++) { if (creatures[i].CreatureId == curCreature.TargetCreature.CreatureId) { var newCreature = creatures[i]; newCreature.BuffAttack(curIntent.Card); creatures.RemoveAt(i); creatures.Insert(i, newCreature); // Discard PlayerStateManager.CurrentInstance.PlayerStates[curIntent.IssuingPlayerId].PlayerHand.Remove(curIntent.Card); } } break; case IntentEnum.BuffCreatureDefense: // Search through creatures and buff defense if (curCreature == null) { Debug.Log("Error: Null creature when trying to buff defense!"); continue; } creatures = PlayerStateManager.CurrentInstance.PlayerStates[curCreature.TargetCreature.OwnerUserId].Creatures; for (int i = 0; i < creatures.Count; i++) { if (creatures[i].CreatureId == curCreature.TargetCreature.CreatureId) { var newCreature = creatures[i]; newCreature.BuffDefense(curIntent.Card); creatures.RemoveAt(i); creatures.Insert(i, newCreature); // Discard PlayerStateManager.CurrentInstance.PlayerStates[curIntent.IssuingPlayerId].PlayerHand.Remove(curIntent.Card); } } break; } } // Re-render creature area TurnManager.CurrentInstance.Render(); this.Render(); playerController.MyPlayerState.Displayer.RenderAll(); playerController.EnemyPlayerState.Displayer.RenderAll(); }