public bool TakeDamage(ChampionComponent player, int damage) { // Debug.Log("EnemyComponent.TakeDamage(" + damage.ToString() + ")"); pm.uiManager.MakeCanvasMessageHud(gameObject.transform, "-" + damage.ToString(), canvasHudOffset, Color.red, Color.white); hp -= damage; if (hp <= 0) { if (!string.IsNullOrEmpty(deadSfx)) { SoundManager.Instance.Play(deadSfx); } hp = 0; isDead = true; return(false); } else { if (!string.IsNullOrEmpty(damageSfx)) { SoundManager.Instance.Play(damageSfx); } Attack(player); return(true); } }
public void PushpadAction(ChampionComponent champion, Node currentNode, Node beforeNode) { animator.SetTrigger("invoke"); Node targetNode = currentNode; if (direction == Direction.up) { targetNode += new Node(0, 1); } else if (direction == Direction.right) { targetNode += new Node(1, 0); } else if (direction == Direction.down) { targetNode += new Node(0, -1); } else if (direction == Direction.left) { targetNode += new Node(-1, 0); } TrapComponent trapComponent = pm.pathManager.GetTrapComponent(targetNode); if (trapComponent == null || !trapComponent.isObstacle) { champion.MoveChampion(currentNode, targetNode, GameManager.championMoveDuration, MoveType.walk, false); } else { champion.MoveChampion(currentNode, beforeNode, GameManager.championMoveDuration, MoveType.walk, false); } }
public void Attack(ChampionComponent champion) { if (!string.IsNullOrEmpty(attackSfx)) { SoundManager.Instance.Play(attackSfx); } champion.TakeDamage(attack, DamageType.enemy); }
public void ResetGame() { playSceneState = PlaySceneState.main; pathManager.InitPath(); distance = 0; kill = 0; addCoin = 0; combo = 0; totalCombo = 0; score = 0; uiManager.UpdateKill(this.kill); uiManager.UpdateDistance(this.distance); uiManager.UpdateCoin(false); uiManager.UpdateScoreUI(this.score, 0); isClear = false; isContinued = false; pausePanel.isPaused = false; pausePanel.button_pause.gameObject.SetActive(true); isHpDecreasing = false; isSpIncreasing = false; if (gameOverCoroutine != null) { StopCoroutine(gameOverCoroutine); } if (hpDecreasingCoroutine != null) { StopCoroutine(hpDecreasingCoroutine); } if (spIncreasingCoroutine != null) { StopCoroutine(spIncreasingCoroutine); } if (autoMoveCoroutine != null) { StopCoroutine(autoMoveCoroutine); } if (this.champion != null) { Destroy(this.champion.gameObject); } GameObject championPrefab = PrefabManager.Instance.GetChampionPrefab(GameManager.Instance.GetLastPlayChampion()); GameObject championInstance = Instantiate(championPrefab) as GameObject; ChampionComponent championComponent = championInstance.GetComponent <ChampionComponent>(); Node startNode = new Node(1, 1); championComponent.InitChampionComponent(startNode, Direction.right); this.champion = championComponent; cameraController.SetPosition(startNode); cameraController.SetTarget(championComponent); cameraController.SetInitialRotation(startNode); // cameraController.SetPivotAngle(Direction.right); uiManager.InitUIManager(); }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Champion")) { ChampionComponent championComponent = other.GetComponent <ChampionComponent>(); championComponent.TakeDamage(attack, DamageType.projectile); Destroy(gameObject); } else if (other.CompareTag("Trap") || other.CompareTag("Obstacle")) { Destroy(gameObject); } }
Node GetNextNode(ChampionComponent player, PlayerInput input) { Node targetNode = player.origin; if (player.direction == Direction.right) { if (input == PlayerInput.left) { targetNode += new Node(1, 1); } else if (input == PlayerInput.forward) { targetNode += new Node(1, 0); } else if (input == PlayerInput.right) { targetNode += new Node(1, -1); } } else if (player.direction == Direction.up) { if (input == PlayerInput.left) { targetNode += new Node(-1, 1); } else if (input == PlayerInput.forward) { targetNode += new Node(0, 1); } else if (input == PlayerInput.right) { targetNode += new Node(1, 1); } } else if (player.direction == Direction.down) { if (input == PlayerInput.left) { targetNode += new Node(1, -1); } else if (input == PlayerInput.forward) { targetNode += new Node(0, -1); } else if (input == PlayerInput.right) { targetNode += new Node(-1, -1); } } return(targetNode); }
public void SetTarget(ChampionComponent target) { this.champion = target; }