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; } } }
private void createChara(string _strName, int _iCost) { CharaControl charaControl = PrefabManager.Instance.AddGameObject <CharaControl>(m_goHomeMine); charaControl.gameObject.transform.parent = Root.transform; charaControl.Init(0, _strName, m_goHomeEnemy, m_goRootLifeGauge); }
public bool Remove(int _iTeamId, CharaControl _chara) { bool bRet = false; List <CharaControl> chara_list = null; if (member.TryGetValue(_iTeamId, out chara_list)) { bRet = chara_list.Remove(_chara); } return(bRet); }
public void Start() { mControl = GetComponent <CharaControl>(); mKillInfo = Instantiate(mKillInfo); mKillInfo.transform.SetParent(mControl.transform); mDirector = mKillInfo.GetComponent <PlayableDirector>(); foreach (var at in mDirector.playableAsset.outputs) { if (!bindingDict.ContainsKey(at.streamName)) { bindingDict.Add(at.streamName, at); } } }
private void OnTriggerStay(Collider other) { if (transform.parent.gameObject == other.gameObject) { return; } CharaControl chara = transform.parent.GetComponent <CharaControl>(); if (chara.healthState != CharaControl.HEALTH_STATE.OUTBREAK) { return; } if (other.tag == "Player") { triggerEvent.Invoke(other.gameObject); } }
void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.tag == "Chara") { // エントリーなので、履いた処理とかいらんでしょ // 親です CharaControl chara = collider.gameObject.transform.parent.gameObject.GetComponent <CharaControl>(); /* * Debug.Log(chara); * Debug.Log(m_dataEnemy); * Debug.Log(m_dataEnemy.attack); */ if (0 < DataManager.Instance.dataChara.hp) { chara.Damage(m_dataEnemy.attack, m_dataEnemy.attribute); } } }
// Discovering Player Func public void DiscoverPlayer(GameObject player) { MeshCollider col = visionDesc.Field.GetComponent <MeshCollider>(); Vector3 rayDir = player.GetComponent <CapsuleCollider>().center + player.transform.position - col.transform.position; rayDir.Normalize(); Ray ray = new Ray(col.transform.position, rayDir); RaycastHit hit; Physics.Raycast(ray, out hit, Mathf.Infinity, mask); Debug.DrawRay(col.transform.position, rayDir * hit.distance, Color.red); CharaControl charaScript = hit.collider.GetComponent <CharaControl>(); if (!charaScript) { return; } if (healthState == HEALTH_STATE.OUTBREAK && state != ENEMY_STATE.CHARGE) { if (charaScript.healthState == HEALTH_STATE.HEALTH) { chaseObj = hit.collider.gameObject; state = ENEMY_STATE.CHASE; count = 0f; } } else if (healthState == HEALTH_STATE.HEALTH || healthState == HEALTH_STATE.IMMUNITY) { if (charaScript.healthState == HEALTH_STATE.OUTBREAK) { chaseObj = hit.collider.gameObject; state = ENEMY_STATE.RUN; count = 0f; SearchEscapeMarker(); } } }
public bool Add(int _iTeamId, CharaControl _chara) { bool bRet = true; List <CharaControl> chara_list = null; if (member.TryGetValue(_iTeamId, out chara_list)) { if (chara_list.Contains(_chara)) { bRet = false; } else { chara_list.Add(_chara); } } else { member.Add(_iTeamId, new List <CharaControl> { _chara }); } foreach (int teamId in member.Keys) { if (member.TryGetValue(teamId, out chara_list)) { foreach (CharaControl chara in chara_list) { //Debug.Log(string.Format("teamId:{0} chara:{1}",teamId,chara.param.name)); } } } return(bRet); }
private void createChara(string _strName, int _iCost) { CharaControl charaControl = PrefabManager.Instance.AddGameObject <CharaControl>(m_goHome); //string prefabName = string.Format("prefab/chara/{0}", _strName); charaControl.gameObject.transform.parent = m_goRoot.transform; charaControl.Init(1, _strName, m_goTarget, m_goRootLifeGauge); /* * * //Debug.LogError(string.Format("name:{0} const:{1}", _strName, _iCost)); * string prefabName = string.Format("prefab/chara/{0}", _strName); * //Debug.Log(string.Format("prefabname:{0}", prefabName)); * * CharaControl charaControl = PrefabManager.Instance.MakeScript<CharaControl>(prefabName, m_goHome); * //Debug.Log(charaControl); * charaControl.gameObject.transform.localPosition = Vector3.zero; * charaControl.gameObject.transform.localRotation = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f); * * charaControl.gameObject.transform.parent = m_goRoot.transform; * charaControl.Init(_strName, m_goTarget); */ }
public override void OnEnter() { base.OnEnter(); charaControl = Owner.GetComponent <CharaControl>(); }
// 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; } }