public void ProcessNodeTest() { var basis = new FlowAIBasis(); var proc1 = new ProcessNode(); var proc2 = new ProcessNode(); var proc3 = new ProcessNode(); var terminal = new ProcessNode(); var branch = new RandomBranchNode(); proc1.Initialize(0.3f, branch, () => Debug.Log("completed process1")); branch.nextNode1 = proc2; branch.nextNode2 = proc3; proc2.Initialize(0.1f, terminal, () => Debug.Log("completed process2")); proc3.Initialize(0.2f, terminal, () => Debug.Log("completerd process3")); terminal.Initialize(0.0f, null); basis.AddNode(proc1, proc2, proc3, terminal, branch); basis.entryPointNode.nextNode = proc1; basis.Entry(); for(int f1=0;f1<50;f1++) { Debug.LogFormat("---{0}sec---", (f1 + 1) * 0.1f); basis.Update(0.1f); } }
public void BranchNodeTest() { float elapsed = 0f; var basis = new FlowAIBasis(); var branch = new BranchNode(); var proc1 = new ProcessNode(); var proc2 = new ProcessNode(); branch.Initialize( proc1, 0.2f, proc2, 0.2f, () => { return elapsed < 0.5f; }); proc1.Initialize(0.2f, branch, () => Debug.Log("プロセス1完了")); proc2.Initialize(0.2f, branch, () => Debug.Log("プロセス2完了")); basis.entryPointNode.nextNode = branch; basis.AddNode(branch, proc1, proc2); basis.Entry(); for(int f1=0;f1<50;f1++) { elapsed += 0.1f; Debug.LogFormat("---{0:0.0}sec---", elapsed); basis.Update(0.1f); } }
// Update is called once per frame void Update() { fireTimer = Mathf.Max(0.0f, fireTimer - Time.deltaTime); // プレイヤーの情報が何も入ってない場合 if (Player == null) { GameplayChannel.GetInstance().SendRequestPlayerEvent(); return; } //更新処理 Update. _flowAI.Update(Time.deltaTime); time += Time.deltaTime; bool canSeePlayer = UpdatePlayerLastKnownPosition(); _visionCone.CreateVisionConeMesh(); // 敵を見ているかの判定 //if (_visionCone.IsTargetInVisionCone(gameObject, Player)) if (CanSeePlayer()) { _isFound = true; //Debug.Log("Can see target! 主人公を見ています!"); } else { _isFound = false; //Debug.Log("Cannot see target! 主人公を見ていません!"); } //Any process... if (_isRot) { //head.transform.Rotate(new Vector3(0,0, 60f * Time.deltaTime)); this.transform.Rotate(new Vector3(0, 60f * Time.deltaTime)); head.transform.Rotate(new Vector3(0, (((-1) * 60f) * Time.deltaTime))); } if (_isBullet) { Shoot(); } canSeePlayerPrevious = canSeePlayer; TFDebug.ClearMonitor("enemy"); TFDebug.Write("enemy", "isRot:{0}\n", _isRot.ToString()); TFDebug.Write("enemy", "isFound:{0}\n", _isFound.ToString()); }
// Update is called once per frame void Update() { //更新処理 Update. _flowAI.Update(Time.deltaTime); //Any process... if (_isRot) { this.transform.Rotate(new Vector3(0f, 60f * Time.deltaTime)); } TFDebug.ClearMonitor("enemy"); TFDebug.Write("enemy", "isRot:{0}\n", _isRot.ToString()); TFDebug.Write("enemy", "isFound:{0}\n", _isFound.ToString()); }
public void BasisTest() { Debug.Log("---initial---"); var basis = new FlowAIBasis(); var dummy1 = new DummyNode(); var dummy2 = new DummyNode(); var dummy3 = new DummyNode(); var branch = new RandomBranchNode(); dummy1.duration = 0.5f; dummy1.nextNode = branch; branch.duration = 0.2f; branch.nextNode1 = dummy2; branch.nextNode2 = dummy3; dummy2.duration = 0.5f; dummy2.nextNode = dummy1; dummy3.duration = 0.5f; dummy3.nextNode = dummy1; basis.AddNode(dummy1); basis.AddNode(branch); basis.AddNode(dummy2); basis.AddNode(dummy3); basis.entryPointNode.nextNode = dummy1; basis.Entry(); for(int f1=0;f1<30;f1++) { Debug.Log("\n"); Debug.LogFormat("---{0}[sec]---", (f1+1) * 0.1f); basis.Update(0.1f); } }
// Update is called once per frame void Update() { _flowAI.Update(Time.deltaTime); }
// Update is called once per frame void Update() { fireTimer = Mathf.Max(0.0f, fireTimer - Time.deltaTime); //Check if we know who the player is. if (player == null) { //Debug.Log("EnemyControl_Patrol::Update - No Player!"); GameplayChannel.GetInstance().SendRequestPlayerEvent(); //主人公は誰ですか。 return; // Skip this frame. } // 現のフレーム主人公おみましたか? bool canSeePlayer = UpdatePlayerLastKnownPosition(); flowAI.Update(Time.deltaTime); switch (currentState) { case AIState.AIState_Patrol: Patrol(); //Debug.Log(gameObject.name + "'s current state is PATROL."); break; case AIState.AIState_Chase: //Debug.Log(gameObject.name + "'s current state is CHASE."); Chase(canSeePlayer); break; case AIState.AIState_Explode: //Debug.Log(gameObject.name + "'s current state is EXPLODE."); エクスプロージョン(); break; case AIState.AIState_Shoot: Shoot(); break; default: // Do nothing. break; } if (canSeePlayer != canSeePlayerPrevious || previousState != currentState) { if (canSeePlayer) { visionCone.SetMaterial(canSeePlayerMaterial, true); } else { if (currentState == AIState.AIState_Chase) { visionCone.SetMaterial(chaseCannotSeePlayerMaterial, true); } else { visionCone.SetMaterial(patrolCannotSeePlayerMaterial, true); } } } // 更新 // Update previousState = currentState; canSeePlayerPrevious = canSeePlayer; }