void UpdatePaths(CommandUnit unit) { if (unit.Paths.Count > 0 && unit.Paths.CurrentPath.Traversed) { unit.Paths.PopPath(); } if (unit.Paths.Count == 0) { return; } var sqrOffset = unit.Paths.CurrentPath.NextNode - unit.Unit.Position; sqrOffset = Vector3.Scale(sqrOffset, sqrOffset); var samePosXZ = sqrOffset.x < 0.01f && sqrOffset.z < 0.01f; var sameAltitude = sqrOffset.y < 1.0; // TODO: Exchange 1.0 with unit height variable var sqrStepSize = Mathf.Pow(unit.Unit.Speed * Time.fixedDeltaTime, 2); // Is this the actual step size? var sqrDistXZ = new Vector3(sqrOffset.x, 0, sqrOffset.z).sqrMagnitude; var reachedNextNode = samePosXZ && sameAltitude || sqrDistXZ < sqrStepSize; var lastNode = unit.Paths.CurrentPath.NextNodeIndex == unit.Paths.CurrentPath.Nodes.Length - 1; var lastPath = unit.Paths.Count == 1; if (!(lastNode && lastPath)) { reachedNextNode |= sqrDistXZ < _sqrAllowedDistanceFromNode; } if (reachedNextNode) { unit.Paths.CurrentPath.Increment(); } }
public override void UnInit() { systemFunctionTypePriorityArray = null; function2SystemTypeDict.Clear(); commandUnit = null; executeSystemUnit = null; }
public override void Init() { InitSystemFunctionTypePriority(); InitFunction2SystemTypeDict(); executeSystemUnit = GlobalUnion.GetUnit <ExecuteSystemUnit>(); commandUnit = GlobalUnion.GetUnit <CommandUnit>(); }
/// <summary> /// 执行Sql,返回物件 /// </summary> /// <param name="sSql">SQL</param> /// <returns></returns> protected object ExecuteScalar(string Sql, IDbTransaction Atran) { // 实例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(Sql, Atran.Connection, Atran); // 加入参数 NewCommand.AddParameters(this.Parameter); return(NewCommand.ExeScalar()); }
/// <summary> /// 执行Sql,返回影响行数 /// </summary> /// <param name="Sql">Sql</param> /// <param name="ATans">事务</param> /// <returns></returns> protected int ExeNonQuery(string Sql, IDbTransaction ATans) { // 实例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(Sql, ATans.Connection, ATans); // 加入参数 NewCommand.AddParameters(this.Parameter); // 返回结果 return(NewCommand.ExeNonQuery()); }
/// <summary> /// 查询结果集 /// </summary> /// <param name="sSql">SQL</param> /// <param name="tran">tran事务</param> /// <returns></returns> /// <remarks></remarks> protected DataSet SearchDataSet(string Sql, IDbTransaction tran) { // 实例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(Sql, tran.Connection, tran); // 加入参数 NewCommand.AddParameters(this.Parameter); // 返回结果集 return(NewCommand.SearchDataSet()); }
/// <summary> /// 执行Sql,返回影响行数 /// </summary> /// <param name="sSql">SQL</param> /// <returns></returns> protected int ExecuteNonQueryByAtt(string Sql) { using (IDbConnection AConnection = this.OpenConnection()) { IDbCommand NewCommand = CommandUnit.NewCommand(Sql, AConnection); NewCommand.AddParameters(this.Parameter); return(NewCommand.ExeNonQuery()); } }
//public int tanknumber;SB // Use this for initialization void Start() { rb = GetComponent <Rigidbody>(); initialMaterial = tankMaterial.material; GameObject pGameObj = GameObject.FindGameObjectWithTag("PlayGameObj"); pgame = pGameObj.GetComponent <PlayGame>(); GameObject commandMenuObj = GameObject.FindGameObjectWithTag("CommandUnitCanvas"); commandMenu = commandMenuObj.GetComponent <Canvas>(); commandUnit = commandMenu.GetComponent <CommandUnit>(); }
void EnsureNextNodeIsReachable(CommandUnit unit) { var navMeshMask = 1 << NavMesh.GetAreaFromName("Walkable"); var foundNearbyPos = false; var preNextIndex = unit.Paths.CurrentPath.NextNodeIndex; while (!unit.Paths.CurrentPath.Traversed && !foundNearbyPos) { NavMeshHit navMeshHit; foundNearbyPos = NavMesh.SamplePosition(unit.Paths.CurrentPath.NextNode, out navMeshHit, 1f, navMeshMask); // is 1f good enough?? if (foundNearbyPos) { unit.Paths.CurrentPath.NextNode = navMeshHit.position; } else { unit.Paths.CurrentPath.Increment(); } } if (unit.Paths.CurrentPath.Traversed) { return; } var invalidNextNode = preNextIndex != unit.Paths.CurrentPath.NextNodeIndex; var blockedPath = false; if (!invalidNextNode) { var mask = RBTConfig.WalkableMask | RBTConfig.UnitMask; mask = ~mask; var posOffset = unit.Paths.CurrentPath.NextNode - unit.Unit.Position; blockedPath = Physics.Raycast(unit.Unit.Position, posOffset.normalized, posOffset.magnitude, mask); } if (blockedPath || invalidNextNode) { var path = new NavMeshPath(); NavMesh.CalculatePath(unit.Unit.Position, unit.Paths.CurrentPath.NextNode, NavMesh.AllAreas, path); if (path.status == NavMeshPathStatus.PathComplete) { unit.Paths.CurrentPath.Increment(); var nodes = new Vector3[path.corners.Length - 1]; Array.Copy(path.corners, 1, nodes, 0, nodes.Length); unit.Paths.PushPath(nodes); } } }
public override void UnInit() { SynchroValueRepOperation.UnInit(); SynchroValueRspOperation.UnInit(); systemFunctionTypePriorityArray = null; function2SystemTypeDict.Clear(); commandUnit = null; executeSystemUnit = null; _ecsUnit = null; }
// Use this for initialization void Start() { CommandUnit piece = new CommandUnit(this); piece.x = System.Convert.ToInt32(transform.position.x + 3.5); piece.y = System.Convert.ToInt32(transform.position.z + 3.5); Game.instance.pieces[piece.x, piece.y] = piece; Transform healthBar = transform.Find("HealthBar"); healtBarManager = healthBar.GetComponent <HealtBarManager>(); }
/// <summary> /// 执行Sql,返回物件 /// </summary> /// <param name="Sql">Sql</param> /// <param name="bPrepare">是否要预编译</param> /// <returns></returns> protected object ExecuteScalar(string Sql, bool bPrepare) { using (IDbConnection AConnection = this.OpenConnection()) { // 實例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(Sql, AConnection); // 加入參數 NewCommand.AddParameters(this.Parameter); // 返回結果物件 return(NewCommand.ExeScalar()); } }
/// <summary> /// 查询结果集 /// </summary> /// <param name="Sql">SQL</param> /// <returns></returns> protected DataSet SearchDataSet(string Sql) { using (IDbConnection AConnection = this.OpenConnection()) { // 实例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(Sql, AConnection); // 加入参数 NewCommand.AddParameters(this.Parameter); // 返回结果集 return(NewCommand.SearchDataSet()); } }
/// <summary> /// 执行Sql,返回影响行数 /// </summary> /// <param name="Sql">Sql</param> /// <param name="bPrepare">是否要预编译</param> /// <returns></returns> protected int ExeNonQuery(string Sql, bool bPrepare) { using (IDbConnection AConnection = this.OpenConnection()) { // 实例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(Sql, AConnection); // 加入参数 NewCommand.AddParameters(this.Parameter); // 返回结果 return(NewCommand.ExeNonQuery()); } }
/// <summary> /// 执行Sql,返回Reader物件 /// </summary> /// <param name="sSql">Sql</param> /// <param name="bPrepare">是否要预编译</param> /// <returns></returns> protected IDataReader ExecuteReader(string Sql, bool bPrepare) { // 实例化并开启连接 using (IDbConnection AConnection = this.OpenConnection()) { // 实例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(Sql, AConnection); // 加入参数 NewCommand.AddParameters(this.Parameter); // 返回Reader return(NewCommand.ExeReader(CommandBehavior.CloseConnection)); } }
/// <summary> /// 使用StoredProcedure查询结果集 /// </summary> /// <param name="spName">SP名称</param> /// <returns></returns> protected DataTable ExecuteSP(string spName) { using (IDbConnection AConnection = this.OpenConnection()) { // 实例化命令 IDbCommand NewCommand = CommandUnit.NewCommand(AConnection); // 存储过程命令类型 NewCommand.CommandType = CommandType.StoredProcedure; // 命令文本 NewCommand.CommandText = spName; // 加入参数 NewCommand.AddParameters(this.Parameter); // 返回结果集 return(NewCommand.Search()); } }
public override void Init() { SynchroValueRepOperation = new Operation(); SynchroValueRepOperation.Init(); SynchroValueRepOperation.SetName("SynchroValueRep"); SynchroValueRspOperation = new Operation(); SynchroValueRspOperation.Init(); SynchroValueRspOperation.SetName("SynchroValueRsp"); synchroValueIdDistributionChunk = new IdDistributionChunk(); synchroValueIdDistributionChunk.Init(); synchroValueIdDistributionChunk.SetInterval(2); InitSystemFunctionTypePriority(); InitFunction2SystemTypeDict(); executeSystemUnit = GlobalUnion.GetUnit <ExecuteSystemUnit>(); commandUnit = GlobalUnion.GetUnit <CommandUnit>(); }
/// <summary> /// 使用StoredProcedure查询结果集 /// </summary> /// <param name="spName">SP名称</param> /// <returns></returns> protected int ExecuteNonQuerySP(string spName) { using (IDbConnection AConnection = this.OpenConnection()) { // 实例化命令 IDbCommand newCommand = CommandUnit.NewCommand(AConnection); // 存储过程类型 newCommand.CommandType = CommandType.StoredProcedure; // 存储过程名称 newCommand.CommandText = spName; // 加入参数 newCommand.AddParameters(this.Parameter); // 返回结果 return(newCommand.ExeNonQuery());; } }
public MoveCommandUnitAnimation(CommandUnit commandUnit, Vector2Int position) { this.commandUnit = commandUnit; this.position = position; commandUnit.Move(position.x, position.y); }
public MoveCommandUnit(CommandUnit commandUnit, List <Tile> moves) { this.commandUnit = commandUnit; this.moves = moves; }