private Stone findTarget(Environment env) { Stone stoneTarget = null; List<Character> listChar = env.lookCharacter(this); List<Stone> listStone = env.lookStone(this); double minDist = maxView; Vector3 position = Vector3.ZERO; foreach (Stone c in listStone) { double dist = (c.Node.Position - this.Node.Position).Length; double distFromCastle = (c.Node.Position - castle).Length; if (minDist > dist && distFromCastle > 100) { minDist = dist; position = c.Node.Position; stoneTarget = c; carriedStoneName = c.Name; } } if (listStone.Count > stoneCastle && stoneTarget != null) { stoneCastle = listStone.Count; castle = stoneTarget.Node.Position; stoneTarget = null; } if (position != Vector3.ZERO && stoneTarget != null) { if (mWalkList.Count != 0) mWalkList.RemoveFirst(); mWalkList.AddFirst(position); } return stoneTarget; }