public static GoPatrolAction GetSSAction(Vector3 location) { GoPatrolAction action = CreateInstance <GoPatrolAction>(); action.pos_x = location.x; action.pos_z = location.z; //设定移动矩形的边长 action.move_length = Random.Range(4, 7); return(action); }
void createPatrol() { GameObject patrol = Instantiate(Resources.Load <GameObject>("prefabs/patrol")); float minX = 0, minY = 0, maxX = 0, maxY = 0; if (max_id == 0)//左上角区域 { minX = -1.7f; maxX = -0.5f; minY = 0.2f; maxY = 1.8f; } else if (max_id == 1)//右上角区域 { minX = 0.1f; maxX = 1.1f; minY = 0.3f; maxY = 1.8f; } else if (max_id == 2)//左下角区域 { minX = -3.0f; maxX = -2.6f; minY = -2.4f; maxY = -0.47f; } else//右下角区域 { minX = -0.11f; maxX = 1.1f; minY = -2.4f; maxY = -0.47f; } float randX = Random.Range(minX, maxX); float randY = Random.Range(minY, maxY); patrol.transform.position = new Vector2(randX, randY); patrol.GetComponent <PatrolData>().Area_min_x = minX; patrol.GetComponent <PatrolData>().Area_max_x = maxX; patrol.GetComponent <PatrolData>().Area_min_y = minY; patrol.GetComponent <PatrolData>().Area_max_y = maxY; patrol.GetComponent <PatrolData>().ID = max_id; patrol.GetComponent <PatrolData>().active = false; GoPatrolAction action = GoPatrolAction.GetAction(0.3f); action_manager.RunAction(patrol, action, this.action_manager); patrols[max_id] = patrol; max_id += 1; }
public void SSActionEvent(SSAction source, int intParam = 0, GameObject objectParam = null) { if (intParam == 0) { PatrolFollowAction follow = PatrolFollowAction.GetSSAction(objectParam.gameObject.GetComponent <PatrolData>().player); this.RunAction(objectParam, follow, this); } else { GoPatrolAction move = GoPatrolAction.GetSSAction(objectParam.gameObject.GetComponent <PatrolData>().start_position); this.RunAction(objectParam, move, this); Singleton <GameEventManager> .Instance.PlayerEscape(); } }
//针对这次游戏新增的一个方法,用于增加不同的动作 public void SSActionEvent(SSAction source, bool catching = false, GameObject objectParam = null) { //不捉玩家时,自由移动 if (!catching) { GoPatrolAction goPatrolAction = GoPatrolAction.GetSSAction(objectParam.gameObject.GetComponent <PatrolData>().start_position); RunAction(objectParam, goPatrolAction, this); Singleton <GameEventManager> .Instance.PlayerEscape(); } //捕捉玩家时,跟着玩家走 else { PatrolFollowAction patrolFollowAction = PatrolFollowAction.GetSSAction(objectParam.gameObject.GetComponent <PatrolData>().player); RunAction(objectParam, patrolFollowAction, this); } }
public void SSActionEvent(SSAction source, int intParam = 0, GameObject objectParam = null) { if (intParam == 0) { //侦查兵跟随玩家 Debug.Log("follow"); PatrolFollowAction follow = PatrolFollowAction.GetSSAction(objectParam.gameObject.GetComponent <PatrolData>().player); this.RunAction(objectParam, follow, this); } else { //侦察兵按照初始位置开始继续巡逻 GoPatrolAction move = GoPatrolAction.GetSSAction(objectParam.gameObject.GetComponent <PatrolData>().start_position); this.RunAction(objectParam, move, this); //玩家逃脱 Singleton <GameEventManager> .Instance.PlayerEscape(); } }
public void GoPatrol(GameObject patrol) { go_patrol = GoPatrolAction.GetSSAction(patrol.transform.position); this.RunAction(patrol, go_patrol, this); }