public void Catch(GameObject player) { CharaControl charaControl = player.GetComponent <CharaControl>(); if (charaControl.healthState != HEALTH_STATE.HEALTH) { return; } if (Input.GetAxis("ActionTrigger") > 0.9f) { if (!IsActionTrigger) { charaControl.Caught(); healthState = HEALTH_STATE.IMMUNITY; healthMark.sprite = healthSpr; IsActionTrigger = true; MaxStamina = MoveDesc.HealthStamina; MaxWalkSpeed = MoveDesc.HealthWalkSpeed; MaxRunSpeed = MoveDesc.HealthRunSpeed; IsRecover = true; count = 0f; } } }
// Chase Func void Chase() { Material mat = renderer.material; if (!chaseObj) { state = ENEMY_STATE.PATROL; return; } bool IsRun = false; if (!UnableRun) { stamina -= MoveDesc.UseStaminaPoints * Time.deltaTime; if (stamina < 0) { stamina = 0; UnableRun = true; } else { IsRun = true; } } else { stamina += MoveDesc.CureStaminaPoints * Time.deltaTime; if (stamina > MaxStamina) { stamina = MaxStamina; UnableRun = false; } } if (IsRun) { agent.speed = MaxRunSpeed; } else { agent.speed = MaxWalkSpeed; } agent.SetDestination(chaseObj.transform.position); // Catch Health Player if (agent.remainingDistance < 2.0f) { CharaControl charaControl = chaseObj.GetComponent <CharaControl>(); if (charaControl.healthState == HEALTH_STATE.HEALTH) { charaControl.Caught(); state = ENEMY_STATE.RECOVER; healthState = HEALTH_STATE.IMMUNITY; mat.color = Colors.White; MaxStamina = MoveDesc.HealthStamina; MaxWalkSpeed = MoveDesc.HealthWalkSpeed; MaxRunSpeed = MoveDesc.HealthRunSpeed; agent.speed = MaxWalkSpeed; } } // Missing Player if (agent.remainingDistance > hearingDesc.Radius) { count += Time.deltaTime; if (count > visionDesc.DetectTime) { count = 0f; state = ENEMY_STATE.PATROL; agent.SetDestination(markers[targetIndex].transform.position); chaseObj = null; agent.speed = MaxWalkSpeed; } } else { count = 0f; } }
void Game() { time -= Time.deltaTime; if (IsCycle) { if (time < 0f) { time = DeadTime; IsCycle = false; for (int i = 0; i < playerList.Count;) { CharaControl charaControl = playerList[i].GetComponent <CharaControl>(); if (charaControl.healthState == CharaControl.HEALTH_STATE.OUTBREAK) { charaControl.Dead(); playerList.RemoveAt(i); if (i == 0) { isWinner = false; tagState = TagState.FINISH; noticeText.text = "LOSE"; noticeText.color = Colors.DarkBlue; break; } if (playerList.Count == 1) { isWinner = true; tagState = TagState.FINISH; noticeText.text = "Win"; noticeText.color = Colors.Gold; break; } } i++; } } string timeStr; int timeDecimal = Mathf.FloorToInt((time - Mathf.Floor(time)) * 100f); timeStr = string.Format("{0:D2}:{1:D2}", Mathf.FloorToInt(time), timeDecimal); timerText.SetText(timeStr); if (time < 10f) { timerText.color = Color.red; } else { timerText.color = Color.white; } } else { timerText.SetText("BREAK"); timerText.color = Color.yellow; if (time < 0f) { time = CycleTime; IsCycle = true; System.Random rand = new System.Random(); CharaControl nextOutbreakChara = playerList[rand.Next(playerList.Count)].GetComponent <CharaControl>(); nextOutbreakChara.Caught(); } } if (!Debug.isDebugBuild) { return; } if (Input.GetAxis("ChangeCamera") > 0.9f && !trigger) { playerList[targetCamera].GetComponentInChildren <Camera>().depth = -1; targetCamera++; if (targetCamera >= playerList.Count) { targetCamera = 0; } playerList[targetCamera].GetComponentInChildren <Camera>().depth = 0; trigger = true; } if (Input.GetAxis("ChangeCamera") < -0.9f && !trigger) { playerList[targetCamera].GetComponentInChildren <Camera>().depth = -1; targetCamera--; if (targetCamera < 0) { targetCamera = playerList.Count - 1; } playerList[targetCamera].GetComponentInChildren <Camera>().depth = 0; trigger = true; } if (Mathf.Abs(Input.GetAxis("ChangeCamera")) < 0.9f) { trigger = false; } }